]> git.lizzy.rs Git - bspwm.git/commitdiff
Add desktop selector: MONITOR_SEL:^<n>
authorBastien Dejean <nihilhill@gmail.com>
Sun, 9 Feb 2014 09:23:01 +0000 (10:23 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 9 Feb 2014 09:23:01 +0000 (10:23 +0100)
doc/bspwm.1
doc/bspwm.1.txt
query.c
query.h

index 7fd061502408110ded20cfc754947a90fcabd616..e88d8279d6a9ad725f9195d318b0aadea71a473f 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 02/06/2014
+.\"      Date: 02/09/2014
 .\"    Manual: Bspwm Manual
 .\"    Source: Bspwm 0.8.8
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "02/06/2014" "Bspwm 0\&.8\&.8" "Bspwm Manual"
+.TH "BSPWM" "1" "02/09/2014" "Bspwm 0\&.8\&.8" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -274,8 +274,8 @@ Select a desktop\&.
 .\}
 .nf
 DESKTOP_SEL := <desktop_name>
-             | ^<n>
-             | (CYCLE_DIR|last|focused[:MONITOR_SEL]|older|newer)[\&.occupied|\&.free][\&.urgent][\&.local]
+             | [MONITOR_SEL:]^<n>
+             | (CYCLE_DIR|last|[MONITOR_SEL:]focused|older|newer)[\&.occupied|\&.free][\&.urgent][\&.local]
 .fi
 .if n \{\
 .RE
index 000fea24e758df176b569a429c8c282b0a52184a..ee0a0408c1898e1eb4fd968e9624b79b103617ef 100644 (file)
@@ -195,8 +195,8 @@ Select a desktop.
 
 ----
 DESKTOP_SEL := <desktop_name>
-             | ^<n>
-             | (CYCLE_DIR|last|focused[:MONITOR_SEL]|older|newer)[.occupied|.free][.urgent][.local]
+             | [MONITOR_SEL:]^<n>
+             | (CYCLE_DIR|last|[MONITOR_SEL:]focused|older|newer)[.occupied|.free][.urgent][.local]
 ----
 
 Primary Selectors
diff --git a/query.c b/query.c
index f139d6f7d21468aaa7fa20f88e740d5092036605..56ce2d01affdfd9f2a62403a367d8abcd1747951 100644 (file)
--- a/query.c
+++ b/query.c
@@ -267,11 +267,15 @@ bool desktop_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                }
        } else if ((colon = index(desc, ':')) != NULL) {
                *colon = '\0';
-               if (streq("focused", desc))
-                       if (monitor_from_desc(colon + 1, ref, dst))
+               if (monitor_from_desc(desc, ref, dst)) {
+                       if (streq("focused", colon + 1)) {
                                dst->desktop = dst->monitor->desk;
+                       } else if (parse_index(colon + 1, &idx)) {
+                               desktop_from_index(idx, dst, dst->monitor);
+                       }
+               }
        } else if (parse_index(desc, &idx)) {
-               desktop_from_index(idx, dst);
+               desktop_from_index(idx, dst, NULL);
        } else {
                locate_desktop(desc, dst);
        }
@@ -362,9 +366,11 @@ bool locate_monitor(char *name, coordinates_t *loc)
        return false;
 }
 
-bool desktop_from_index(int i, coordinates_t *loc)
+bool desktop_from_index(int i, coordinates_t *loc, monitor_t *mm)
 {
-       for (monitor_t *m = mon_head; m != NULL; m = m->next)
+       for (monitor_t *m = mon_head; m != NULL; m = m->next) {
+               if (mm != NULL && m != mm)
+                       continue;
                for (desktop_t *d = m->desk_head; d != NULL; d = d->next, i--)
                        if (i == 1) {
                                loc->monitor = m;
@@ -372,6 +378,7 @@ bool desktop_from_index(int i, coordinates_t *loc)
                                loc->node = NULL;
                                return true;
                        }
+       }
        return false;
 }
 
diff --git a/query.h b/query.h
index 4c78a5b4a6db3b4de274526238d025e9af243884..145dcdb2ab9f4e2d5fe595c5726d519428b50807 100644 (file)
--- a/query.h
+++ b/query.h
@@ -50,7 +50,7 @@ bool monitor_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst);
 bool locate_window(xcb_window_t win, coordinates_t *loc);
 bool locate_desktop(char *name, coordinates_t *loc);
 bool locate_monitor(char *name, coordinates_t *loc);
-bool desktop_from_index(int i, coordinates_t *loc);
+bool desktop_from_index(int i, coordinates_t *loc, monitor_t *mm);
 bool monitor_from_index(int i, coordinates_t *loc);
 bool node_matches(coordinates_t *loc, coordinates_t *ref, client_select_t sel);
 bool desktop_matches(coordinates_t *loc, coordinates_t *ref, desktop_select_t sel);