]> git.lizzy.rs Git - bspwm.git/commitdiff
New rule effect: move to the given desktop
authorBastien Dejean <nihilhill@gmail.com>
Sun, 11 Nov 2012 17:40:55 +0000 (18:40 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 11 Nov 2012 17:40:55 +0000 (18:40 +0100)
README.md
bspwm.1
messages.c
rules.c
rules.h
types.c
types.h
window.c

index b40dac488c011b3b6b61325d60feb2b1c8745749..2486770c991d4acfbc91e68253297647d8ff4bf0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -182,8 +182,8 @@ The following messages are handled:
     rotate clockwise|counter_clockwise|full_cycle
         Rotate the tree of the current desktop.
 
-    rule PATTERN floating
-        Make a new rule that will float the windows whose class name or instance name equals PATTERN.
+    rule PATTERN [DESKTOP_NAME] [floating]
+        Create a new rule (PATTERN must match the class or instance name).
 
     adopt_orphans
         Manage all the unmanaged windows remaining from a previous session.
diff --git a/bspwm.1 b/bspwm.1
index 5927844ff506e87fad161a83a410f03f0a2982a2..2e3114cd727935873ca08ed67c8d70e015293251 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -211,8 +211,8 @@ Cycle the layout of the current desktop.
 .BI rotate " clockwise|counter_clockwise|full_cycle"
 Rotate the tree of the current desktop.
 .TP
-.BI rule " PATTERN floating "
-Make a new rule that will float the windows whose class name or instance name equals PATTERN.
+.BI rule " PATTERN [DESKTOP_NAME] [floating] "
+Create a new rule (PATTERN must match the class or instance name).
 .TP
 .BI adopt_orphans
 Manage all the unmanaged windows remaining from a previous session.
index 3e445c8c89fdfa24fb8c94209225bca09c3b6a02..84a30efe078c52155ba366cf588038fbda53d285 100644 (file)
@@ -248,8 +248,15 @@ void process_message(char *msg, char *rsp)
             strncpy(rule->cause.name, name, sizeof(rule->cause.name));
             char *arg = strtok(NULL, TOKEN_SEP);
             while (arg != NULL) {
-                if (strcmp(arg, "floating") == 0)
+                if (strcmp(arg, "floating") == 0) {
                     rule->effect.floating = true;
+                } else {
+                    desktop_location_t loc;
+                    if (locate_desktop(arg, &loc)) {
+                        rule->effect.monitor = loc.monitor;
+                        rule->effect.desktop = loc.desktop;
+                    }
+                }
                 arg = strtok(NULL, TOKEN_SEP);
             }
             rule->next = rule_head;
diff --git a/rules.c b/rules.c
index fe8f3e50fa2b018985583015149a8741af3a5afc..0834560dd211e48e5faa53a292d5a9d97eed0f90 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -19,7 +19,7 @@ bool is_match(rule_t *r, xcb_window_t win)
     return false;
 }
 
-void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
+void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, bool *floating, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
 {
     xcb_ewmh_get_atoms_reply_t win_type;
 
@@ -60,8 +60,13 @@ void handle_rules(xcb_window_t win, bool *floating, bool *transient, bool *fulls
 
     while (rule != NULL) {
         if (is_match(rule, win)) {
-            if (rule->effect.floating)
+            rule_effect_t efc = rule->effect;
+            if (efc.floating)
                 *floating = true;
+            if (efc.monitor != NULL && efc.desktop != NULL) {
+                *m = efc.monitor;
+                *d = efc.desktop;
+            }
         }
         rule = rule->next;
     }
diff --git a/rules.h b/rules.h
index 47976988a9b7d5d07647eb35a3007f9f4acca15e..f09d21bc8962c19cbf4735e98ffe5c6da8a45909 100644 (file)
--- a/rules.h
+++ b/rules.h
@@ -2,6 +2,6 @@
 #define _RULES_H
 
 bool is_match(rule_t *, xcb_window_t);
-void handle_rules(xcb_window_t, bool *, bool *, bool *, bool *, bool *);
+void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *);
 
 #endif
diff --git a/types.c b/types.c
index feb13d6c4e890e4b9e3bb14134e65a3be97298b3..659c1bbeeed1baa99b79347dcb3f1f0c84457f40 100644 (file)
--- a/types.c
+++ b/types.c
@@ -58,6 +58,8 @@ rule_t *make_rule(void)
 {
     rule_t *r = malloc(sizeof(rule_t));
     r->effect.floating = false;
+    r->effect.monitor = NULL;
+    r->effect.desktop = NULL;
     r->next = NULL;
     return r;
 }
diff --git a/types.h b/types.h
index 5f02f352edfc7f864a16fcd2b46452b98ed8c753..9458b7738020067606b89598f11454372b40c657 100644 (file)
--- a/types.h
+++ b/types.h
@@ -146,6 +146,8 @@ typedef struct {
 
 typedef struct {
     bool floating;
+    monitor_t *monitor;
+    desktop_t *desktop;
 } rule_effect_t;
 
 typedef struct rule_t rule_t;
index 7b0748c5e070a6c63df9ad0e3adcd3c272598704..8d567b3778886810572955b95fd3759ac22a8f10 100644 (file)
--- a/window.c
+++ b/window.c
@@ -71,7 +71,7 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
 
     bool floating = false, transient = false, fullscreen = false, takes_focus = true, manage = true;
 
-    handle_rules(win, &floating, &transient, &fullscreen, &takes_focus, &manage);
+    handle_rules(win, &m, &d, &floating, &transient, &fullscreen, &takes_focus, &manage);
 
     if (!manage) {
         window_show(win);