]> git.lizzy.rs Git - bspwm.git/commitdiff
Select focused desktop when selecting monitor
authorBastien Dejean <nihilhill@gmail.com>
Wed, 29 May 2013 08:00:25 +0000 (10:00 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 29 May 2013 08:00:25 +0000 (10:00 +0200)
Also:
- Observe `auto_alternate` with `use_monitor`.
- Update `last_mon` when a monitor is removed.

messages.c
types.c

index 43801cc8e0d27c521a86e926c985e2e76b6d6902..c28019a383dca1647aa1cce1302460d791e70623 100644 (file)
@@ -288,8 +288,15 @@ void process_message(char *msg, char *rsp)
         char *name = strtok(NULL, TOK_SEP);
         if (name != NULL) {
             monitor_t *m = find_monitor(name);
-            if (m != NULL)
-                select_monitor(m);
+            if (m != NULL) {
+                if (auto_alternate && m == mon && last_mon != NULL) {
+                    select_monitor(last_mon);
+                    select_desktop(last_mon->desk);
+                } else {
+                    select_monitor(m);
+                    select_desktop(m->desk);
+                }
+            }
         }
     } else if (strcmp(cmd, "use") == 0) {
         char *name = strtok(NULL, TOK_SEP);
diff --git a/types.c b/types.c
index cc9786fab80fc1bf9414c532c95cb0211a805ab4..e0b3bbcf1b94a5f6484c4e7c6323612f0fab8f7d 100644 (file)
--- a/types.c
+++ b/types.c
@@ -81,6 +81,8 @@ void remove_monitor(monitor_t *m)
         mon_head = next;
     if (m == mon_tail)
         mon_tail = prev;
+    if (m == last_mon)
+        last_mon = NULL;
     free(m);
     num_monitors--;
 }