From 133ea96f64fa6fc99b04ecb8ce2c53dbb3806204 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Sat, 27 Feb 2021 16:55:10 +0000 Subject: [PATCH] Simplify view margin/padding related code Fix xdg-shell CSD resize bug --- include/labwc.h | 17 ++++++++++++----- src/cursor.c | 2 -- src/xdg.c | 8 +++++--- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/labwc.h b/include/labwc.h index 26754a21..f703b595 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -193,12 +193,21 @@ struct view { int x, y, w, h; /* - * margin refers to the space between the extremities of the view and - * wlr_surface - typically made up of decoration. - * For xdg-shell views, the margin is typically negative. + * margin refers to the space between the extremities of the + * wlr_surface and the max extents of the server-side decorations. + * For xdg-shell views with CSD, this margin is zero. */ 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 { bool update_x, update_y; double x, y; @@ -206,8 +215,6 @@ struct view { uint32_t configure_serial; } pending_move_resize; - int xdg_grab_offset; - bool server_side_deco; struct wl_listener map; diff --git a/src/cursor.c b/src/cursor.c index 899a13b7..da331964 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -108,8 +108,6 @@ process_cursor_resize(struct server *server, uint32_t time) 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); } diff --git a/src/xdg.c b/src/xdg.c index 91fb7b22..6078ab42 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -279,8 +279,9 @@ xdg_toplevel_view_for_each_surface(struct view *view, wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, data); } +/* Return area between surface extremities and window */ static struct border -xdg_shell_border(struct view *view) +xdg_shell_padding(struct view *view) { struct wlr_box 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) { view->margin = deco_thickness(view); } else { - view->margin = xdg_shell_border(view); - view->xdg_grab_offset = -view->margin.left; + view->padding = xdg_shell_padding(view); } if (istopmost(view)) { /* align to edge of screen */ view->x += view->margin.left; view->y += view->margin.top; + view->x += view->padding.left; + view->y += view->padding.top; } } view->been_mapped = true;