mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Simplify view margin/padding related code
Fix xdg-shell CSD resize bug
This commit is contained in:
		
							parent
							
								
									b5677992f3
								
							
						
					
					
						commit
						133ea96f64
					
				
					 3 changed files with 17 additions and 10 deletions
				
			
		| 
						 | 
					@ -193,12 +193,21 @@ struct view {
 | 
				
			||||||
	int x, y, w, h;
 | 
						int x, y, w, h;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * margin refers to the space between the extremities of the view and
 | 
						 * margin refers to the space between the extremities of the
 | 
				
			||||||
	 * wlr_surface - typically made up of decoration.
 | 
						 * wlr_surface and the max extents of the server-side decorations.
 | 
				
			||||||
	 * For xdg-shell views, the margin is typically negative.
 | 
						 * For xdg-shell views with CSD, this margin is zero.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	struct border margin;
 | 
						struct border margin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * padding refers to the space between the extremities of the
 | 
				
			||||||
 | 
						 * wlr_surface and the parts of the surface that is considered the
 | 
				
			||||||
 | 
						 * window.
 | 
				
			||||||
 | 
						 * This is only used for xdg-shell views with CSD where the padding
 | 
				
			||||||
 | 
						 * area is typically invisible except for client-side drop-shawdows.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						struct border padding;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		bool update_x, update_y;
 | 
							bool update_x, update_y;
 | 
				
			||||||
		double x, y;
 | 
							double x, y;
 | 
				
			||||||
| 
						 | 
					@ -206,8 +215,6 @@ struct view {
 | 
				
			||||||
		uint32_t configure_serial;
 | 
							uint32_t configure_serial;
 | 
				
			||||||
	} pending_move_resize;
 | 
						} pending_move_resize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int xdg_grab_offset;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bool server_side_deco;
 | 
						bool server_side_deco;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_listener map;
 | 
						struct wl_listener map;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,8 +108,6 @@ process_cursor_resize(struct server *server, uint32_t time)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new_view_geo.width -= 2 * view->xdg_grab_offset;
 | 
					 | 
				
			||||||
	new_view_geo.height -= 2 * view->xdg_grab_offset;
 | 
					 | 
				
			||||||
	view_move_resize(view, new_view_geo);
 | 
						view_move_resize(view, new_view_geo);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,8 +279,9 @@ xdg_toplevel_view_for_each_surface(struct view *view,
 | 
				
			||||||
	wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, data);
 | 
						wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, data);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Return area between surface extremities and window */
 | 
				
			||||||
static struct border
 | 
					static struct border
 | 
				
			||||||
xdg_shell_border(struct view *view)
 | 
					xdg_shell_padding(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_box box;
 | 
						struct wlr_box box;
 | 
				
			||||||
	wlr_xdg_surface_get_geometry(view->xdg_surface, &box);
 | 
						wlr_xdg_surface_get_geometry(view->xdg_surface, &box);
 | 
				
			||||||
| 
						 | 
					@ -309,13 +310,14 @@ xdg_toplevel_view_map(struct view *view)
 | 
				
			||||||
		if (view->server_side_deco) {
 | 
							if (view->server_side_deco) {
 | 
				
			||||||
			view->margin = deco_thickness(view);
 | 
								view->margin = deco_thickness(view);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			view->margin = xdg_shell_border(view);
 | 
								view->padding = xdg_shell_padding(view);
 | 
				
			||||||
			view->xdg_grab_offset = -view->margin.left;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (istopmost(view)) {
 | 
							if (istopmost(view)) {
 | 
				
			||||||
			/* align to edge of screen */
 | 
								/* align to edge of screen */
 | 
				
			||||||
			view->x += view->margin.left;
 | 
								view->x += view->margin.left;
 | 
				
			||||||
			view->y += view->margin.top;
 | 
								view->y += view->margin.top;
 | 
				
			||||||
 | 
								view->x += view->padding.left;
 | 
				
			||||||
 | 
								view->y += view->padding.top;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view->been_mapped = true;
 | 
						view->been_mapped = true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue