]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/ssd: fix tiling via keybind when maximized
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 25 Aug 2023 11:22:23 +0000 (13:22 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 25 Aug 2023 13:54:22 +0000 (15:54 +0200)
The previous PR introduced an issue with tiling based actions
like SnapToEdge and SnapToRegion using outdated SSD margin
values when called via keybind while maximized. That resulted
in wrong offsets for the tiled windows.

This commit restores the functionality by forcing a re-calculation
of the SSD margin when changing the maximized state.

Thanks to @Flrian for reporting the issue via IRC.

include/ssd.h
src/ssd/ssd.c
src/view.c

index d63c74bcab662fc460d760c814d9e8f9b77556cd..a539a4a364c306b6d65aa00fa2eb4904a872ad97 100644 (file)
@@ -60,6 +60,7 @@ struct wlr_scene_node;
  */
 struct ssd *ssd_create(struct view *view, bool active);
 struct border ssd_get_margin(const struct ssd *ssd);
+void ssd_update_margin(struct ssd *ssd);
 void ssd_set_active(struct ssd *ssd, bool active);
 void ssd_update_title(struct ssd *ssd);
 void ssd_update_geometry(struct ssd *ssd);
index f2f37c12cb834a53e6ac7cb3c9a3de2587d0e692..54d6070bc349ae1cfaabf84ba6c90820dc39ba80 100644 (file)
@@ -195,6 +195,15 @@ ssd_get_margin(const struct ssd *ssd)
        return ssd ? ssd->margin : (struct border){ 0 };
 }
 
+void
+ssd_update_margin(struct ssd *ssd)
+{
+       if (!ssd) {
+               return;
+       }
+       ssd->margin = ssd_thickness(ssd->view);
+}
+
 void
 ssd_update_geometry(struct ssd *ssd)
 {
@@ -210,6 +219,10 @@ ssd_update_geometry(struct ssd *ssd)
                        ssd_extents_update(ssd);
                        ssd->state.geometry = current;
                }
+               if (ssd->state.squared_corners != ssd->view->maximized) {
+                       ssd_border_update(ssd);
+                       ssd_titlebar_update(ssd);
+               }
                return;
        }
        ssd_extents_update(ssd);
index 4d1e5490a34036aafa87a3d26a595cbcbff71bb7..8628c7ee4dd5f9f6ed149de13d4b11a25fdb66d1 100644 (file)
@@ -648,6 +648,13 @@ set_maximized(struct view *view, bool maximized)
                        view->toplevel.handle, maximized);
        }
        view->maximized = maximized;
+
+       /*
+        * Ensure that follow-up actions like SnapToEdge / SnapToRegion
+        * use up-to-date SSD margin information. Otherwise we will end
+        * up using an outdated ssd->margin to calculate offsets.
+        */
+       ssd_update_margin(view->ssd);
 }
 
 /*