]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Simplify view margin/padding related code
authorJohan Malm <jgm323@gmail.com>
Sat, 27 Feb 2021 16:55:10 +0000 (16:55 +0000)
committerJohan Malm <jgm323@gmail.com>
Sat, 27 Feb 2021 16:55:10 +0000 (16:55 +0000)
Fix xdg-shell CSD resize bug

include/labwc.h
src/cursor.c
src/xdg.c

index 26754a21ec94ba07bd534e17dd1f936f24e8460e..f703b595ecdb417dd473e835dc07284a4c0f4833 100644 (file)
@@ -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;
index 899a13b75e3db53a9aebc1f60fe1fe70e061f240..da331964fb9519d7a4738587d620515ce7cfa004 100644 (file)
@@ -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);
 }
 
index 91fb7b2296c0d977cb9e37d8910c5be8369d49ab..6078ab427deb336cde87be3b86ac2eb3667f7627 100644 (file)
--- 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;