]> git.mdlowis.com Git - proto/labwc.git/commitdiff
SnapToRegion: Respect core.gap setting
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 16 Sep 2022 04:08:28 +0000 (06:08 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Wed, 11 Jan 2023 17:52:24 +0000 (18:52 +0100)
src/view.c

index d8364ab66909a874113e0094a2ecc3bf39b6f6d5..0208ec5888b02a79aa76f1daa0efdf7a896e477a 100644 (file)
@@ -375,6 +375,38 @@ view_apply_region_geometry(struct view *view)
        /* Create a copy of the original region geometry */
        struct wlr_box geo = view->tiled_region->geo;
 
+       /* Adjust for rc.gap */
+       struct output *output = view_output(view);
+       if (rc.gap && output) {
+               double half_gap = rc.gap / 2.0;
+               struct wlr_fbox offset = {
+                       .x = half_gap,
+                       .y = half_gap,
+                       .width = -rc.gap,
+                       .height = -rc.gap
+               };
+               struct wlr_box usable =
+                       output_usable_area_in_layout_coords(output);
+               if (geo.x == usable.x) {
+                       offset.x += half_gap;
+                       offset.width -= half_gap;
+               }
+               if (geo.y == usable.y) {
+                       offset.y += half_gap;
+                       offset.height -= half_gap;
+               }
+               if (geo.x + geo.width == usable.x + usable.width) {
+                       offset.width -= half_gap;
+               }
+               if (geo.y + geo.height == usable.y + usable.height) {
+                       offset.height -= half_gap;
+               }
+               geo.x += offset.x;
+               geo.y += offset.y;
+               geo.width += offset.width;
+               geo.height += offset.height;
+       }
+
        /* And adjust for current view */
        struct border margin = ssd_get_margin(view->ssd);
        geo.x += margin.left;