]> git.lizzy.rs Git - bspwm.git/commitdiff
Properly update the sticky count in `transfer_*`
authorBastien Dejean <nihilhill@gmail.com>
Sat, 29 May 2021 08:57:37 +0000 (10:57 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Sat, 29 May 2021 08:57:37 +0000 (10:57 +0200)
I think the initial regression came from
875defe46997b983bbb3102567bdd68866c202bb (the removed lines at the end)
which led to #1098.

This issue was fixed by 5df311b12c06dca86f8e5a56ee522bd48d2178bc. This
commit brought another regression which led to #1199.

Fixes #1199.

src/desktop.c
src/tree.c

index 421804d9d0cef9a482accccee1bce97dd43d0ed0..6738ea042a7900dbba24d890c90022b2743ea9b5 100644 (file)
@@ -172,8 +172,10 @@ bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
 
        bool d_was_active = (d == ms->desk);
        bool ms_was_focused = (ms == mon);
+       unsigned int sc = (ms->sticky_count > 0 && d_was_active) ? sticky_count(d->root) : 0;
 
        unlink_desktop(ms, d);
+       ms->sticky_count -= sc;
 
        if ((!follow || !d_was_active || !ms_was_focused) && md->desk != NULL) {
                hide_sticky = false;
@@ -182,6 +184,7 @@ bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
        }
 
        insert_desktop(md, d);
+       md->sticky_count += sc;
        history_remove(d, NULL, false);
 
        if (d_was_active) {
@@ -201,15 +204,11 @@ bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
                }
        }
 
-       if (ms->sticky_count > 0 && d_was_active) {
+       if (sc > 0) {
                if (ms->desk != NULL) {
                        transfer_sticky_nodes(md, d, ms, ms->desk, d->root);
-               } else {
-                       ms->sticky_count -= sticky_count(d->root);
-                       md->sticky_count += sticky_count(d->root);
-                       if (d != md->desk) {
-                               transfer_sticky_nodes(md, d, md, md->desk, d->root);
-                       }
+               } else if (d != md->desk) {
+                       transfer_sticky_nodes(md, d, md, md->desk, d->root);
                }
        }
 
index a1fd906696d44e3edd724d68b0fde9e9c9713cdd..97dce282ded10866c07c22c0504b73abe3dfe608 100644 (file)
@@ -433,8 +433,6 @@ node_t *insert_node(monitor_t *m, desktop_t *d, node_t *n, node_t *f)
                }
        }
 
-       m->sticky_count += sticky_count(n);
-
        propagate_flags_upward(m, d, n);
 
        if (d->focus == NULL && is_focusable(n)) {
@@ -1312,10 +1310,6 @@ void unlink_node(monitor_t *m, desktop_t *d, node_t *n)
 
        node_t *p = n->parent;
 
-       if (m->sticky_count > 0) {
-               m->sticky_count -= sticky_count(n);
-       }
-
        if (p == NULL) {
                d->root = NULL;
                d->focus = NULL;
@@ -1418,6 +1412,9 @@ void remove_node(monitor_t *m, desktop_t *d, node_t *n)
        history_remove(d, n, true);
        remove_stack_node(n);
        cancel_presel_in(m, d, n);
+       if (m->sticky_count > 0 && d == m->desk) {
+               m->sticky_count -= sticky_count(n);
+       }
        clients_count -= clients_count_in(n);
        if (is_descendant(grabbed_node, n)) {
                grabbed_node = NULL;
@@ -1599,7 +1596,8 @@ bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desk
                return false;
        }
 
-       if (sticky_still && ms->sticky_count > 0 && sticky_count(ns) > 0 && dd != md->desk) {
+       unsigned int sc = (ms->sticky_count > 0 && ds == ms->desk) ? sticky_count(ns) : 0;
+       if (sticky_still && sc > 0 && dd != md->desk) {
                return false;
        }
 
@@ -1621,6 +1619,8 @@ bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desk
                if (ns->client == NULL || monitor_from_client(ns->client) != md) {
                        adapt_geometry(&ms->rectangle, &md->rectangle, ns);
                }
+               ms->sticky_count -= sc;
+               md->sticky_count += sc;
        }
 
        if (ds != dd) {