From: Bastien Dejean Date: Sat, 29 May 2021 08:57:37 +0000 (+0200) Subject: Properly update the sticky count in `transfer_*` X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=a827412f1de9eb409584d3891f91803794d8d61c;p=bspwm.git Properly update the sticky count in `transfer_*` 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. --- diff --git a/src/desktop.c b/src/desktop.c index 421804d..6738ea0 100644 --- a/src/desktop.c +++ b/src/desktop.c @@ -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); } } diff --git a/src/tree.c b/src/tree.c index a1fd906..97dce28 100644 --- a/src/tree.c +++ b/src/tree.c @@ -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) {