mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	Merge pull request #3141 from tslocum/resize-set-floating-ppt
resize set: convert ppt to px for floating containers
This commit is contained in:
		
						commit
						b67baf5108
					
				
					 1 changed files with 33 additions and 9 deletions
				
			
		| 
						 | 
					@ -511,16 +511,40 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static struct cmd_results *resize_set_floating(struct sway_container *con,
 | 
					static struct cmd_results *resize_set_floating(struct sway_container *con,
 | 
				
			||||||
		struct resize_amount *width, struct resize_amount *height) {
 | 
							struct resize_amount *width, struct resize_amount *height) {
 | 
				
			||||||
	int min_width, max_width, min_height, max_height;
 | 
						int min_width, max_width, min_height, max_height, grow_width, grow_height;
 | 
				
			||||||
	calculate_constraints(&min_width, &max_width, &min_height, &max_height);
 | 
						calculate_constraints(&min_width, &max_width, &min_height, &max_height);
 | 
				
			||||||
	width->amount = fmax(min_width, fmin(width->amount, max_width));
 | 
					
 | 
				
			||||||
	height->amount = fmax(min_height, fmin(height->amount, max_height));
 | 
						if (width->amount) {
 | 
				
			||||||
	int grow_width = width->amount - con->width;
 | 
							if (width->unit == RESIZE_UNIT_PPT ||
 | 
				
			||||||
	int grow_height = height->amount - con->height;
 | 
									width->unit == RESIZE_UNIT_DEFAULT) {
 | 
				
			||||||
	con->x -= grow_width / 2;
 | 
								// Convert to px
 | 
				
			||||||
	con->y -= grow_height / 2;
 | 
								width->amount = con->workspace->width * width->amount / 100;
 | 
				
			||||||
	con->width = width->amount;
 | 
								width->unit = RESIZE_UNIT_PX;
 | 
				
			||||||
	con->height = height->amount;
 | 
							}
 | 
				
			||||||
 | 
							if (width->unit == RESIZE_UNIT_PX) {
 | 
				
			||||||
 | 
								width->amount = fmax(min_width, fmin(width->amount, max_width));
 | 
				
			||||||
 | 
								grow_width = width->amount - con->width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								con->x -= grow_width / 2;
 | 
				
			||||||
 | 
								con->width = width->amount;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (height->amount) {
 | 
				
			||||||
 | 
							if (height->unit == RESIZE_UNIT_PPT ||
 | 
				
			||||||
 | 
									height->unit == RESIZE_UNIT_DEFAULT) {
 | 
				
			||||||
 | 
								// Convert to px
 | 
				
			||||||
 | 
								height->amount = con->workspace->height * height->amount / 100;
 | 
				
			||||||
 | 
								height->unit = RESIZE_UNIT_PX;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (height->unit == RESIZE_UNIT_PX) {
 | 
				
			||||||
 | 
								height->amount = fmax(min_height, fmin(height->amount, max_height));
 | 
				
			||||||
 | 
								grow_height = height->amount - con->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								con->y -= grow_height / 2;
 | 
				
			||||||
 | 
								con->height = height->amount;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (con->view) {
 | 
						if (con->view) {
 | 
				
			||||||
		struct sway_view *view = con->view;
 | 
							struct sway_view *view = con->view;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue