]> git.mdlowis.com Git - proto/labwc.git/commitdiff
overlay: take into account <core><gap> for region overlay
authortokyo4j <hrak1529@gmail.com>
Sat, 5 Jul 2025 07:07:04 +0000 (16:07 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 2 Aug 2025 11:31:16 +0000 (12:31 +0100)
include/view.h
src/overlay.c
src/view.c

index 04ed7d64ad7b973999a620af81ce32d6fcf6e969..a7aa1af057f4aaaa259b3a724081ba7a6ea4b8f6 100644 (file)
@@ -504,6 +504,7 @@ enum view_edge view_edge_invert(enum view_edge edge);
 /* If view is NULL, the size of SSD is not considered */
 struct wlr_box view_get_edge_snap_box(struct view *view, struct output *output,
        enum view_edge edge);
+struct wlr_box view_get_region_snap_box(struct view *view, struct region *region);
 
 /**
  * view_is_focusable() - Check whether or not a view can be focused
index 3424f160bb1f45c2022ee4f52b7b35320f879d80..2aecf0075ca4a2b6150fd3764eed3bfbced12f3a 100644 (file)
@@ -111,7 +111,8 @@ show_region_overlay(struct seat *seat, struct region *region)
        inactivate_overlay(&seat->overlay);
        seat->overlay.active.region = region;
 
-       show_overlay(seat, &seat->overlay.region_rect, &region->geo);
+       struct wlr_box geo = view_get_region_snap_box(NULL, region);
+       show_overlay(seat, &seat->overlay.region_rect, &geo);
 }
 
 static struct wlr_box get_edge_snap_box(enum view_edge edge, struct output *output)
index 2f6e62771da53b4e79082b8a9191a52ec85e7562..99a597ccd7d6e4d0ebd6978cb889b80d768d660a 100644 (file)
@@ -1195,33 +1195,10 @@ view_apply_natural_geometry(struct view *view)
        view_move_resize(view, geometry);
 }
 
-static void
-view_apply_region_geometry(struct view *view)
+struct wlr_box
+view_get_region_snap_box(struct view *view, struct region *region)
 {
-       assert(view);
-       assert(view->tiled_region || view->tiled_region_evacuate);
-       struct output *output = view->output;
-       assert(output_is_usable(output));
-
-       if (view->tiled_region_evacuate) {
-               /* View was evacuated from a destroying output */
-               /* Get new output local region, may be NULL */
-               view->tiled_region = regions_from_name(
-                       view->tiled_region_evacuate, output);
-
-               /* Get rid of the evacuate instruction */
-               zfree(view->tiled_region_evacuate);
-
-               if (!view->tiled_region) {
-                       /* Existing region name doesn't exist in rc.xml anymore */
-                       view_set_untiled(view);
-                       view_apply_natural_geometry(view);
-                       return;
-               }
-       }
-
-       /* Create a copy of the original region geometry */
-       struct wlr_box geo = view->tiled_region->geo;
+       struct wlr_box geo = region->geo;
 
        /* Adjust for rc.gap */
        if (rc.gap) {
@@ -1233,7 +1210,7 @@ view_apply_region_geometry(struct view *view)
                        .height = -rc.gap
                };
                struct wlr_box usable =
-                       output_usable_area_in_layout_coords(output);
+                       output_usable_area_in_layout_coords(region->output);
                if (geo.x == usable.x) {
                        offset.x += half_gap;
                        offset.width -= half_gap;
@@ -1255,12 +1232,43 @@ view_apply_region_geometry(struct view *view)
        }
 
        /* And adjust for current view */
-       struct border margin = ssd_get_margin(view->ssd);
-       geo.x += margin.left;
-       geo.y += margin.top;
-       geo.width -= margin.left + margin.right;
-       geo.height -= margin.top + margin.bottom;
+       if (view) {
+               struct border margin = ssd_get_margin(view->ssd);
+               geo.x += margin.left;
+               geo.y += margin.top;
+               geo.width -= margin.left + margin.right;
+               geo.height -= margin.top + margin.bottom;
+       }
+
+       return geo;
+}
+
+static void
+view_apply_region_geometry(struct view *view)
+{
+       assert(view);
+       assert(view->tiled_region || view->tiled_region_evacuate);
+       struct output *output = view->output;
+       assert(output_is_usable(output));
+
+       if (view->tiled_region_evacuate) {
+               /* View was evacuated from a destroying output */
+               /* Get new output local region, may be NULL */
+               view->tiled_region = regions_from_name(
+                       view->tiled_region_evacuate, output);
+
+               /* Get rid of the evacuate instruction */
+               zfree(view->tiled_region_evacuate);
+
+               if (!view->tiled_region) {
+                       /* Existing region name doesn't exist in rc.xml anymore */
+                       view_set_untiled(view);
+                       view_apply_natural_geometry(view);
+                       return;
+               }
+       }
 
+       struct wlr_box geo = view_get_region_snap_box(view, view->tiled_region);
        view_move_resize(view, geo);
 }