]> git.lizzy.rs Git - bspwm.git/commitdiff
Properly handle sticky nodes in transfer_desktop
authorBastien Dejean <nihilhill@gmail.com>
Sun, 18 Nov 2018 21:04:55 +0000 (22:04 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 18 Nov 2018 21:04:55 +0000 (22:04 +0100)
Fixes #865.
Closes #852.

src/bspwm.c
src/bspwm.h
src/desktop.c
src/tree.c
src/tree.h

index 3bd82e655838d2fd5c99470f3e99eecbd3eb7baf..33acc81ac9aa483c756fd720de4bc808c6815e9c 100644 (file)
@@ -215,7 +215,7 @@ void init(void)
        stack_head = stack_tail = NULL;
        subscribe_head = subscribe_tail = NULL;
        pending_rule_head = pending_rule_tail = NULL;
-       auto_raise = sticky_still = record_history = true;
+       auto_raise = sticky_still = hide_sticky = record_history = true;
        auto_split_type = false;
        randr_base = 0;
        exit_status = 0;
index ca33dd9e2e8c18fbdf52350ab9776cb7bd62f3a7..746e851bf50af77c98d2955bc7d9b616da3d9337 100644 (file)
@@ -79,6 +79,7 @@ int exit_status;
 bool auto_raise;
 bool auto_split_type;
 bool sticky_still;
+bool hide_sticky;
 bool record_history;
 bool running;
 bool randr;
index 19f0cb152a1e003b13054e0cc045f04c4b5316ec..a2c040877a7fb27995c1107bfaa40575c376aa67 100644 (file)
@@ -74,8 +74,8 @@ bool activate_desktop(monitor_t *m, desktop_t *d)
                return false;
        }
 
-       if (m->sticky_count > 0) {
-               transfer_sticky_nodes(m, m->desk, d, m->desk->root);
+       if (m->sticky_count > 0 && m->desk != NULL) {
+               transfer_sticky_nodes(m, m->desk, m, d, m->desk->root);
        }
 
        show_desktop(d);
@@ -180,7 +180,9 @@ bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
        unlink_desktop(ms, d);
 
        if ((!follow || !d_was_active || !ms_was_focused) && md->desk != NULL) {
+               hide_sticky = false;
                hide_desktop(d);
+               hide_sticky = true;
        }
 
        insert_desktop(md, d);
@@ -204,7 +206,15 @@ bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
        }
 
        if (ms->sticky_count > 0 && d_was_active) {
-               transfer_sticky_nodes(ms, d, ms->desk, d->root);
+               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);
+                       }
+               }
        }
 
        adapt_geometry(&ms->rectangle, &md->rectangle, d->root);
@@ -359,6 +369,7 @@ void merge_desktops(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd)
        if (ds == NULL || dd == NULL || ds == dd) {
                return;
        }
+       /* TODO: Handle sticky nodes. */
        transfer_node(ms, ds, ds->root, md, dd, dd->focus, false);
 }
 
index 14ee95cae68dbba4ea4eb83ecee29afacf0b5f48..5f27ed98d32e1744ae92747d47a20a348669d3c9 100644 (file)
@@ -493,21 +493,21 @@ bool activate_node(monitor_t *m, desktop_t *d, node_t *n)
        return true;
 }
 
-void transfer_sticky_nodes(monitor_t *m, desktop_t *ds, desktop_t *dd, node_t *n)
+void transfer_sticky_nodes(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n)
 {
        if (n == NULL) {
                return;
        } else if (n->sticky) {
                sticky_still = false;
-               transfer_node(m, ds, n, m, dd, dd->focus, false);
+               transfer_node(ms, ds, n, md, dd, dd->focus, false);
                sticky_still = true;
        } else {
                /* we need references to the children because n might be freed after
                 * the first recursive call */
                node_t *first_child = n->first_child;
                node_t *second_child = n->second_child;
-               transfer_sticky_nodes(m, ds, dd, first_child);
-               transfer_sticky_nodes(m, ds, dd, second_child);
+               transfer_sticky_nodes(ms, ds, md, dd, first_child);
+               transfer_sticky_nodes(ms, ds, md, dd, second_child);
        }
 }
 
@@ -561,12 +561,12 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
                clear_input_focus();
        }
 
-       if (m->sticky_count > 0 && d != m->desk) {
+       if (m->sticky_count > 0 && m->desk != NULL && d != m->desk) {
                if (guess && m->desk->focus != NULL && m->desk->focus->sticky) {
                        n = m->desk->focus;
                }
 
-               transfer_sticky_nodes(m, m->desk, d, m->desk->root);
+               transfer_sticky_nodes(m, m->desk, m, d, m->desk->root);
 
                if (n == NULL && d->focus != NULL) {
                        n = d->focus;
@@ -636,7 +636,7 @@ bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
 
 void hide_node(desktop_t *d, node_t *n)
 {
-       if (n == NULL) {
+       if (n == NULL || (!hide_sticky && n->sticky)) {
                return;
        } else {
                if (!n->hidden) {
@@ -1446,11 +1446,6 @@ 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);
                }
-
-               if (ms->sticky_count > 0 && sticky_count(ns) > 0) {
-                       ms->sticky_count -= sticky_count(ns);
-                       md->sticky_count += sticky_count(ns);
-               }
        }
 
        if (ds != dd) {
index 0609d52785ed3ca023908fbb433a4e03744ae1d1..11fd280fea56c6b1112e431d6aab5e93e81c268f 100644 (file)
@@ -40,7 +40,7 @@ node_t *find_public(desktop_t *d);
 node_t *insert_node(monitor_t *m, desktop_t *d, node_t *n, node_t *f);
 void insert_receptacle(monitor_t *m, desktop_t *d, node_t *n);
 bool activate_node(monitor_t *m, desktop_t *d, node_t *n);
-void transfer_sticky_nodes(monitor_t *m, desktop_t *ds, desktop_t *dd, node_t *n);
+void transfer_sticky_nodes(monitor_t *ms, desktop_t *ds, monitor_t *md, desktop_t *dd, node_t *n);
 bool focus_node(monitor_t *m, desktop_t *d, node_t *n);
 void hide_node(desktop_t *d, node_t *n);
 void show_node(desktop_t *d, node_t *n);