]> git.mdlowis.com Git - proto/labwc.git/commitdiff
xdg-shell: remove view->padding
authorJohan Malm <jgm323@gmail.com>
Wed, 20 Apr 2022 16:00:43 +0000 (17:00 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 21 Apr 2022 19:21:36 +0000 (20:21 +0100)
With the wlroots scene-graph API, the padding variable is no longer
needed for windows with Client Side Decoration (CSD).

include/labwc.h
src/resistance.c
src/view.c
src/xdg.c

index 55c40b4ff2da7e954f44e545e7fcfd0f5682576c..eaa84c6c5ba7cc796d84a29bbff70ce74f7b2e5f 100644 (file)
@@ -296,15 +296,6 @@ struct view {
         */
        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 view_pending_move_resize {
                bool update_x, update_y;
                double x, y;
@@ -379,7 +370,6 @@ void xwayland_unmanaged_create(struct server *server,
 
 void view_set_activated(struct view *view, bool activated);
 void view_close(struct view *view);
-struct border view_border(struct view *view);
 
 /**
  * view_move_resize - resize and move view
index e4c8bb88e5ae6db71d2a723a9ee4f5b809aba537..4a3d99bac1690ad881c974ec98e042fc78ef1ab7 100644 (file)
@@ -40,7 +40,7 @@ resistance_move_apply(struct view *view, double *x, double *y)
        struct wlr_box tgeom = {.x = *x, .y = *y, .width = view->w,
                .height = view->h};
        struct output *output;
-       struct border border = view_border(view);
+       struct border border = view->margin;
        struct edges view_edges; /* The edges of the current view */
        struct edges target_edges; /* The desired edges */
        struct edges other_edges; /* The edges of the monitor/other view */
@@ -107,7 +107,7 @@ resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo)
                .height = view->h};
        struct wlr_box tgeom = {.x = new_view_geo->x, .y = new_view_geo->y,
                .width = new_view_geo->width, .height = new_view_geo->height};
-       struct border border = view_border(view);
+       struct border border = view->margin;
        struct edges view_edges; /* The edges of the current view */
        struct edges target_edges; /* The desired edges */
        struct edges other_edges; /* The edges of the monitor/other view */
index ead0dc985753959600fc48165f50232cdff7c983..d2933d19bba17ab5417caa0d58c009a255ca836c 100644 (file)
@@ -385,18 +385,6 @@ view_adjust_for_layout_change(struct view *view)
        }
 }
 
-struct border
-view_border(struct view *view)
-{
-       struct border border = {
-               .left = view->margin.left - view->padding.left,
-               .top = view->margin.top - view->padding.top,
-               .right = view->margin.right + view->padding.right,
-               .bottom = view->margin.bottom + view->padding.bottom,
-       };
-       return border;
-}
-
 static void
 view_output_enter(struct view *view, struct wlr_output *wlr_output)
 {
@@ -446,7 +434,6 @@ view_move_to_edge(struct view *view, const char *direction)
                wlr_log(WLR_ERROR, "no output");
                return;
        }
-       struct border border = view_border(view);
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
        if (usable.height == output->wlr_output->height
                        && output->wlr_output->scale != 1) {
@@ -459,17 +446,19 @@ view_move_to_edge(struct view *view, const char *direction)
 
        int x = 0, y = 0;
        if (!strcasecmp(direction, "left")) {
-               x = usable.x + border.left + rc.gap;
+               x = usable.x + view->margin.left + rc.gap;
                y = view->y;
        } else if (!strcasecmp(direction, "up")) {
                x = view->x;
-               y = usable.y + border.top + rc.gap;
+               y = usable.y + view->margin.top + rc.gap;
        } else if (!strcasecmp(direction, "right")) {
-               x = usable.x + usable.width - view->w - border.right - rc.gap;
+               x = usable.x + usable.width - view->w - view->margin.right
+                       - rc.gap;
                y = view->y;
        } else if (!strcasecmp(direction, "down")) {
                x = view->x;
-               y = usable.y + usable.height - view->h - border.bottom - rc.gap;
+               y = usable.y + usable.height - view->h - view->margin.bottom
+                       - rc.gap;
        }
        view_move(view, x, y);
 }
@@ -525,7 +514,6 @@ static struct wlr_box
 view_get_edge_snap_box(struct view *view, struct output *output,
                enum view_edge edge)
 {
-       struct border border = view_border(view);
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
        if (usable.height == output->wlr_output->height
                        && output->wlr_output->scale != 1) {
@@ -560,10 +548,10 @@ view_get_edge_snap_box(struct view *view, struct output *output,
                break;
        }
        struct wlr_box dst = {
-               .x = x_offset + usable.x + border.left,
-               .y = y_offset + usable.y + border.top,
-               .width = base_width - border.left - border.right,
-               .height = base_height - border.top - border.bottom,
+               .x = x_offset + usable.x + view->margin.left,
+               .y = y_offset + usable.y + view->margin.top,
+               .width = base_width - view->margin.left - view->margin.right,
+               .height = base_height - view->margin.top - view->margin.bottom,
        };
 
        return dst;
index b8c0b4a5c47e82490e19c30fb9ffb73ed2afa900..0f11ec3e612b414b3475d2d35856a44372e870cc 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -42,12 +42,6 @@ handle_commit(struct wl_listener *listener, void *data)
        view->w = size.width;
        view->h = size.height;
 
-       /* padding changes with maximize/unmaximize */
-       view->padding.top = size.y;
-       view->padding.bottom = size.y;
-       view->padding.left = size.x;
-       view->padding.right = size.x;
-
        uint32_t serial = view->pending_move_resize.configure_serial;
        if (serial > 0 && serial >= view->xdg_surface->current.configure_serial) {
                if (view->pending_move_resize.update_x) {
@@ -211,17 +205,6 @@ xdg_toplevel_view_close(struct view *view)
        wlr_xdg_toplevel_send_close(view->xdg_surface->toplevel);
 }
 
-static void
-update_padding(struct view *view)
-{
-       struct wlr_box padding;
-       wlr_xdg_surface_get_geometry(view->xdg_surface, &padding);
-       view->padding.top = padding.y;
-       view->padding.bottom = padding.y;
-       view->padding.left = padding.x;
-       view->padding.right = padding.x;
-}
-
 static void
 xdg_toplevel_view_maximize(struct view *view, bool maximized)
 {
@@ -287,8 +270,8 @@ position_xdg_toplevel_view(struct view *view)
                view->x = center_x - view->xdg_surface->current.geometry.width / 2;
                view->y = center_y - view->xdg_surface->current.geometry.height / 2;
        }
-       view->x += view->margin.left - view->padding.left;
-       view->y += view->margin.top - view->padding.top;
+       view->x += view->margin.left;
+       view->y += view->margin.top;
 }
 
 static const char *
@@ -323,7 +306,6 @@ xdg_toplevel_view_map(struct view *view)
                        ssd_create(view);
                }
 
-               update_padding(view);
                if (!view->fullscreen && requested->fullscreen) {
                        view_set_fullscreen(view, true,
                                requested->fullscreen_output);