From 72936ccb3ebef166b5c50c871fb83f1a01d1ec4f Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:22:23 +0200 Subject: [PATCH] src/ssd: fix tiling via keybind when maximized 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 | 1 + src/ssd/ssd.c | 13 +++++++++++++ src/view.c | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/include/ssd.h b/include/ssd.h index d63c74bc..a539a4a3 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -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); diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index f2f37c12..54d6070b 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -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); diff --git a/src/view.c b/src/view.c index 4d1e5490..8628c7ee 100644 --- a/src/view.c +++ b/src/view.c @@ -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); } /*