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;
}
insert_desktop(md, d);
+ md->sticky_count += sc;
history_remove(d, NULL, false);
if (d_was_active) {
}
}
- 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);
}
}
}
}
- m->sticky_count += sticky_count(n);
-
propagate_flags_upward(m, d, n);
if (d->focus == NULL && is_focusable(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;
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;
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;
}
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) {