mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	regions: perform rounding more carefully
Add percentages (x + width, y + height) before scaling so that there is no gap between regions due to rounding variations
This commit is contained in:
		
							parent
							
								
									47e80a488e
								
							
						
					
					
						commit
						921c30c1fa
					
				
					 1 changed files with 13 additions and 4 deletions
				
			
		| 
						 | 
					@ -208,10 +208,19 @@ regions_update_geometry(struct output *output)
 | 
				
			||||||
	wl_list_for_each(region, &output->regions, link) {
 | 
						wl_list_for_each(region, &output->regions, link) {
 | 
				
			||||||
		geo = ®ion->geo;
 | 
							geo = ®ion->geo;
 | 
				
			||||||
		perc = ®ion->percentage;
 | 
							perc = ®ion->percentage;
 | 
				
			||||||
		geo->x = usable.x + usable.width * perc->x / 100;
 | 
							/*
 | 
				
			||||||
		geo->y = usable.y + usable.height * perc->y / 100;
 | 
							 * Add percentages (x + width, y + height) before scaling
 | 
				
			||||||
		geo->width = usable.width * perc->width / 100;
 | 
							 * so that there is no gap between regions due to rounding
 | 
				
			||||||
		geo->height = usable.height * perc->height / 100;
 | 
							 * variations
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							int left = usable.width * perc->x / 100;
 | 
				
			||||||
 | 
							int right = usable.width * (perc->x + perc->width) / 100;
 | 
				
			||||||
 | 
							int top = usable.height * perc->y / 100;
 | 
				
			||||||
 | 
							int bottom = usable.height * (perc->y + perc->height) / 100;
 | 
				
			||||||
 | 
							geo->x = usable.x + left;
 | 
				
			||||||
 | 
							geo->y = usable.y + top;
 | 
				
			||||||
 | 
							geo->width = right - left;
 | 
				
			||||||
 | 
							geo->height = bottom - top;
 | 
				
			||||||
		region->center.x = geo->x + geo->width / 2;
 | 
							region->center.x = geo->x + geo->width / 2;
 | 
				
			||||||
		region->center.y = geo->y + geo->height / 2;
 | 
							region->center.y = geo->y + geo->height / 2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue