]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src/ssd: use view->ssd_titlebar_hidden for ssd_thickness calculations
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Sun, 17 Sep 2023 20:41:46 +0000 (22:41 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Thu, 21 Sep 2023 21:21:19 +0000 (22:21 +0100)
Before this patch we were using the internal .enabled flag of the titlebar
tree node. This failed due to ssd_thickness() not having view->ssd assigned
when initially called. Instead of assigning view->ssd within ssd_create()
we just always use the view boolean flag directly. This fixes an issue
where a border-only view that has been snapped to an edge or region would
have a gap in the size of the titlebar on top after a Reconfigure.

Fixes #1083

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

index a539a4a364c306b6d65aa00fa2eb4904a872ad97..f1b275168bddd67f525f084949bca7293f8013ea 100644 (file)
@@ -65,7 +65,6 @@ void ssd_set_active(struct ssd *ssd, bool active);
 void ssd_update_title(struct ssd *ssd);
 void ssd_update_geometry(struct ssd *ssd);
 void ssd_destroy(struct ssd *ssd);
-bool ssd_titlebar_is_hidden(struct ssd *ssd);
 void ssd_titlebar_hide(struct ssd *ssd);
 
 void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
index 54d6070bc349ae1cfaabf84ba6c90820dc39ba80..ef821b86a029f1c84d9b58abe45d1ec4856491c9 100644 (file)
@@ -21,6 +21,13 @@ ssd_thickness(struct view *view)
        /*
         * Check preconditions for displaying SSD. Note that this
         * needs to work even before ssd_create() has been called.
+        *
+        * For that reason we are not using the .enabled state of
+        * the titlebar node here but rather check for the view
+        * boolean. If we were to use the .enabled state this would
+        * cause issues on Reconfigure events with views which were
+        * in border-only deco mode as view->ssd would only be set
+        * after ssd_create() returns.
         */
        if (!view->ssd_enabled || view->fullscreen) {
                return (struct border){ 0 };
@@ -30,7 +37,7 @@ ssd_thickness(struct view *view)
 
        if (view->maximized) {
                struct border thickness = { 0 };
-               if (!ssd_titlebar_is_hidden(view->ssd)) {
+               if (!view->ssd_titlebar_hidden) {
                        thickness.top += theme->title_height;
                }
                return thickness;
@@ -43,7 +50,7 @@ ssd_thickness(struct view *view)
                .right = theme->border_width,
        };
 
-       if (ssd_titlebar_is_hidden(view->ssd)) {
+       if (view->ssd_titlebar_hidden) {
                thickness.top -= theme->title_height;
        }
        return thickness;
@@ -177,8 +184,8 @@ ssd_create(struct view *view, bool active)
        ssd_extents_create(ssd);
        ssd_border_create(ssd);
        ssd_titlebar_create(ssd);
-       if (rc.ssd_keep_border && view->ssd_titlebar_hidden) {
-               /* Ensure we keep the old state when exiting fullscreen */
+       if (view->ssd_titlebar_hidden) {
+               /* Ensure we keep the old state on Reconfigure or when exiting fullscreen */
                ssd_titlebar_hide(ssd);
        }
        ssd->margin = ssd_thickness(view);
@@ -231,12 +238,6 @@ ssd_update_geometry(struct ssd *ssd)
        ssd->state.geometry = current;
 }
 
-bool
-ssd_titlebar_is_hidden(struct ssd *ssd)
-{
-       return ssd && !ssd->titlebar.tree->node.enabled;
-}
-
 void
 ssd_titlebar_hide(struct ssd *ssd)
 {
index 8628c7ee4dd5f9f6ed149de13d4b11a25fdb66d1..51798e949176c8576cdb40445e5567293a7fb9dd 100644 (file)
@@ -740,9 +740,13 @@ view_toggle_decorations(struct view *view)
 {
        assert(view);
        if (rc.ssd_keep_border && view->ssd_enabled && view->ssd
-                       && !ssd_titlebar_is_hidden(view->ssd)) {
-               ssd_titlebar_hide(view->ssd);
+                       && !view->ssd_titlebar_hidden) {
+               /*
+                * ssd_titlebar_hidden has to be set before calling
+                * ssd_titlebar_hide() to make ssd_thickness() happy.
+                */
                view->ssd_titlebar_hidden = true;
+               ssd_titlebar_hide(view->ssd);
                if (!view_is_floating(view)) {
                        view_apply_special_geometry(view);
                }