mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	menu: correctly center menu opened with <position {x,y}="center">
Prior to this commit, a menu opened with:
  <action name="ShowMenu">
    <position x="center" y="center" />
  </action>
was not correctly centered when menu.items.padding.x is non-zero.
			
			
This commit is contained in:
		
							parent
							
								
									3c39ed38b5
								
							
						
					
					
						commit
						0aaa2e0102
					
				
					 1 changed files with 1 additions and 11 deletions
				
			
		
							
								
								
									
										12
									
								
								src/action.c
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/action.c
									
										
									
									
									
								
							| 
						 | 
					@ -688,19 +688,9 @@ show_menu(struct server *server, struct view *view, struct cursor_context *ctx,
 | 
				
			||||||
	if (pos_x && pos_y) {
 | 
						if (pos_x && pos_y) {
 | 
				
			||||||
		struct output *output = output_nearest_to(server,
 | 
							struct output *output = output_nearest_to(server,
 | 
				
			||||||
				server->seat.cursor->x, server->seat.cursor->y);
 | 
									server->seat.cursor->x, server->seat.cursor->y);
 | 
				
			||||||
		struct menuitem *item;
 | 
					 | 
				
			||||||
		struct theme *theme = server->theme;
 | 
					 | 
				
			||||||
		int max_width = theme->menu_min_width;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		wl_list_for_each(item, &menu->menuitems, link) {
 | 
					 | 
				
			||||||
			if (item->native_width > max_width) {
 | 
					 | 
				
			||||||
				max_width = item->native_width < theme->menu_max_width
 | 
					 | 
				
			||||||
					? item->native_width : theme->menu_max_width;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!strcasecmp(pos_x, "center")) {
 | 
							if (!strcasecmp(pos_x, "center")) {
 | 
				
			||||||
			x = (output->usable_area.width / 2) - (max_width / 2);
 | 
								x = (output->usable_area.width - menu->size.width) / 2;
 | 
				
			||||||
		} else if (strchr(pos_x, '%')) {
 | 
							} else if (strchr(pos_x, '%')) {
 | 
				
			||||||
			x = (output->usable_area.width * atoi(pos_x)) / 100;
 | 
								x = (output->usable_area.width * atoi(pos_x)) / 100;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue