mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	container_at_stacked: skip titles when zero pixels
It is possible to make the title bars have a zero pixel height while stacked, by using a blank font and no padding. This causes a division by zero when attempting to calculate the child index in container_at_stacked, which then results in a segfault when attempting to access the child at that bad index (INT_MIN). This just skips the check to see if the cursor is over a title bar of a child of a stacked container when the title bar height is zero since there will be no title bars.
This commit is contained in:
		
							parent
							
								
									f5190d1f79
								
							
						
					
					
						commit
						995b6edab6
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		| 
						 | 
					@ -251,10 +251,12 @@ static struct sway_container *container_at_stacked(struct sway_node *parent,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Title bars
 | 
						// Title bars
 | 
				
			||||||
	int title_height = container_titlebar_height();
 | 
						int title_height = container_titlebar_height();
 | 
				
			||||||
	int child_index = (ly - box.y) / title_height;
 | 
						if (title_height > 0) {
 | 
				
			||||||
	if (child_index < children->length) {
 | 
							int child_index = (ly - box.y) / title_height;
 | 
				
			||||||
		struct sway_container *child = children->items[child_index];
 | 
							if (child_index < children->length) {
 | 
				
			||||||
		return child;
 | 
								struct sway_container *child = children->items[child_index];
 | 
				
			||||||
 | 
								return child;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Surfaces
 | 
						// Surfaces
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue