]> git.mdlowis.com Git - proto/labwc.git/commitdiff
view/ssd: Move view->margin to view->ssd.margin
authorJohn Lindgren <john@jlindgren.net>
Mon, 21 Nov 2022 20:13:43 +0000 (15:13 -0500)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Tue, 22 Nov 2022 08:17:33 +0000 (09:17 +0100)
include/ssd.h
include/view.h
src/resistance.c
src/ssd/ssd.c
src/view.c
src/xdg.c

index e412ea80938b0386d633e5e45f47eee4db037609..ca3edb3c5f07dd9da10a57f99ee71d42167aa7bf 100644 (file)
@@ -117,6 +117,13 @@ struct ssd {
                struct ssd_sub_tree active;
                struct ssd_sub_tree inactive;
        } border;
+
+       /*
+        * Space between the extremities of the view's wlr_surface
+        * and the max extents of the server-side decorations.
+        * For xdg-shell views with CSD, this margin is zero.
+        */
+       struct border margin;
 };
 
 struct ssd_part {
index f94e76dac85d40abcc3952d9c5a7adfed10fd248..f317dd2b87979cd1c4f2eb17e02162baf683e3b2 100644 (file)
@@ -59,13 +59,6 @@ struct view {
        /* user defined geometry before maximize / tiling / fullscreen */
        struct wlr_box natural_geometry;
 
-       /*
-        * 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;
-
        struct view_pending_move_resize {
                bool update_x, update_y;
                int x, y;
index 55a9713f0c809787d46967cdb4920e6a72df8002..9a09097421dd9ba92e1c7da94465d34a9c55123a 100644 (file)
@@ -41,7 +41,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->margin;
+       struct border border = view->ssd.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 */
@@ -112,7 +112,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->margin;
+       struct border border = view->ssd.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 a1706a58759c267aac80c8a727628cc0cd2c7028..9ea1c3b85d95c9a8438a8113e7ba833dfab57c73 100644 (file)
@@ -161,7 +161,7 @@ ssd_create(struct view *view)
        ssd_extents_create(view);
        ssd_border_create(view);
        ssd_titlebar_create(view);
-       view->margin = ssd_thickness(view);
+       view->ssd.margin = ssd_thickness(view);
        ssd_set_active(view, is_active);
 }
 
@@ -175,14 +175,14 @@ ssd_update_geometry(struct view *view)
        if (!view->ssd.enabled) {
                if (view->ssd.tree && view->ssd.tree->node.enabled) {
                        wlr_scene_node_set_enabled(&view->ssd.tree->node, false);
-                       view->margin = ssd_thickness(view);
+                       view->ssd.margin = ssd_thickness(view);
                }
                return;
        } else if (!view->ssd.tree) {
                ssd_create(view);
        } else if (!view->ssd.tree->node.enabled) {
                wlr_scene_node_set_enabled(&view->ssd.tree->node, true);
-               view->margin = ssd_thickness(view);
+               view->ssd.margin = ssd_thickness(view);
        }
 
        int width = view->w;
index 6f53cbc0c030fdcaec9539a2e35096dc8418e35d..8b76334af79737c8afbf8e186bc407ee2dcaf3d4 100644 (file)
@@ -88,10 +88,10 @@ view_get_edge_snap_box(struct view *view, struct output *output,
                break;
        }
        struct wlr_box dst = {
-               .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,
+               .x = x_offset + usable.x + view->ssd.margin.left,
+               .y = y_offset + usable.y + view->ssd.margin.top,
+               .width = base_width - view->ssd.margin.left - view->ssd.margin.right,
+               .height = base_height - view->ssd.margin.top - view->ssd.margin.bottom,
        };
 
        return dst;
@@ -276,8 +276,8 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y)
        }
 
        struct wlr_box usable = output_usable_area_in_layout_coords(output);
-       int width = w + view->margin.left + view->margin.right;
-       int height = h + view->margin.top + view->margin.bottom;
+       int width = w + view->ssd.margin.left + view->ssd.margin.right;
+       int height = h + view->ssd.margin.top + view->ssd.margin.bottom;
        *x = usable.x + (usable.width - width) / 2;
        *y = usable.y + (usable.height - height) / 2;
 
@@ -292,8 +292,8 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y)
 #if HAVE_XWAYLAND
        /* TODO: refactor xwayland.c functions to get rid of this */
        if (view->type == LAB_XWAYLAND_VIEW) {
-               *x += view->margin.left;
-               *y += view->margin.top;
+               *x += view->ssd.margin.left;
+               *y += view->ssd.margin.top;
        }
 #endif
 
@@ -725,18 +725,18 @@ view_move_to_edge(struct view *view, const char *direction)
 
        int x = 0, y = 0;
        if (!strcasecmp(direction, "left")) {
-               x = usable.x + view->margin.left + rc.gap;
+               x = usable.x + view->ssd.margin.left + rc.gap;
                y = view->y;
        } else if (!strcasecmp(direction, "up")) {
                x = view->x;
-               y = usable.y + view->margin.top + rc.gap;
+               y = usable.y + view->ssd.margin.top + rc.gap;
        } else if (!strcasecmp(direction, "right")) {
-               x = usable.x + usable.width - view->w - view->margin.right
+               x = usable.x + usable.width - view->w - view->ssd.margin.right
                        - rc.gap;
                y = view->y;
        } else if (!strcasecmp(direction, "down")) {
                x = view->x;
-               y = usable.y + usable.height - view->h - view->margin.bottom
+               y = usable.y + usable.height - view->h - view->ssd.margin.bottom
                        - rc.gap;
        } else {
                wlr_log(WLR_ERROR, "invalid edge");
index f09de3b2ed801320e304228b7295e354a25eb982..48c80115734a31a06c3a235c69a0e7595595ed34 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -276,8 +276,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->y += view->margin.top;
+       view->x += view->ssd.margin.left;
+       view->y += view->ssd.margin.top;
 }
 
 static const char *