]> git.lizzy.rs Git - bspwm.git/commitdiff
New argument for the `rule` message: `follow`
authorBastien Dejean <nihilhill@gmail.com>
Tue, 12 Mar 2013 09:56:45 +0000 (10:56 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Tue, 12 Mar 2013 09:56:45 +0000 (10:56 +0100)
README.md
bspwm.1
messages.c
rules.c
rules.h
types.c
types.h
window.c

index 7574a9ac6f7df24689dc539cfc24b8aec9e45e31..ee8e26ea84670ad20f6fe6a61ebbebd57294dead 100644 (file)
--- a/README.md
+++ b/README.md
@@ -173,7 +173,7 @@ The following messages are handled:
 
 - `balance` — Adjust the split ratios so that all windows occupy the same area.
 
-- `rule PATTERN [DESKTOP_NAME] [floating]` — Create a new rule (`PATTERN` must match the class or instance name).
+- `rule PATTERN [DESKTOP_NAME] [floating] [follow]` — Create a new rule (`PATTERN` must match the class or instance name).
 
 - `remove_rule UID ...` — Remove the rules with the given UIDs.
 
diff --git a/bspwm.1 b/bspwm.1
index 1af0f379336f5792af757372e6d9b17af7c930d2..69633947e3ab920fa8d5e80ead7eefbc13149707 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -248,7 +248,7 @@ Flip the window tree.
 .B balance
 Adjust the split ratios so that all windows occupy the same area.
 .TP
-.BI rule " PATTERN [DESKTOP_NAME] [floating]"
+.BI rule " PATTERN [DESKTOP_NAME] [floating] [follow]"
 Create a new rule (PATTERN must match the class or instance name).
 .TP
 .BI remove_rule " UID ..."
index 285702dd6f1ab93fe9a7d6a969bc2eaa843e824b..7f3bd8c00930cbd66d7603fe0c2e367e2225fe58 100644 (file)
@@ -367,6 +367,8 @@ void process_message(char *msg, char *rsp)
             while (arg != NULL) {
                 if (strcmp(arg, "floating") == 0) {
                     rule->effect.floating = true;
+                } else if (strcmp(arg, "follow") == 0) {
+                    rule->effect.follow = true;
                 } else {
                     desktop_location_t loc;
                     if (locate_desktop(arg, &loc)) {
diff --git a/rules.c b/rules.c
index f53ea3fcfaebce9a81de98a2ad8cd3ad9097f145..2762f29628b6ee1a6abe7e12955aacacb3fe439e 100644 (file)
--- a/rules.c
+++ b/rules.c
@@ -60,7 +60,7 @@ bool is_match(rule_t *r, xcb_window_t win)
     return false;
 }
 
-void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, 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 *follow, bool *transient, bool *fullscreen, bool *takes_focus, bool *manage)
 {
     xcb_ewmh_get_atoms_reply_t win_type;
 
@@ -113,6 +113,8 @@ void handle_rules(xcb_window_t win, monitor_t **m, desktop_t **d, bool *floating
             rule_effect_t efc = rule->effect;
             if (efc.floating)
                 *floating = true;
+            if (efc.follow)
+                *follow = true;
             if (efc.monitor != NULL && efc.desktop != NULL) {
                 *m = efc.monitor;
                 *d = efc.desktop;
@@ -127,7 +129,7 @@ void list_rules(char *rsp)
     char line[MAXLEN];
 
     for (rule_t *r = rule_head; r != NULL; r = r->next) {
-        snprintf(line, sizeof(line), "%02X %s %s %s\n", r->uid, r->cause.name, (r->effect.desktop != NULL ? r->effect.desktop->name : "\b"), (r->effect.floating ? "floating" : "\b"));
+        snprintf(line, sizeof(line), "%2X %s %s %s %s\n", r->uid, r->cause.name, (r->effect.desktop != NULL ? r->effect.desktop->name : "\b"), (r->effect.floating ? "floating" : "\b"), (r->effect.follow ? "follow" : "\b"));
         strncat(rsp, line, REMLEN(rsp));
     }
 }
diff --git a/rules.h b/rules.h
index 682d625c1e7df10cd0be7f59cf6fd64307f8e6d1..a003ecd0117dc1a1e35bcd5447a623a0ef9a07da 100644 (file)
--- a/rules.h
+++ b/rules.h
@@ -6,7 +6,7 @@ void remove_rule(rule_t *);
 void remove_rule_by_uid(unsigned int);
 rule_t *find_rule(unsigned int);
 bool is_match(rule_t *, xcb_window_t);
-void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *);
+void handle_rules(xcb_window_t, monitor_t **, desktop_t **, bool *, bool *, bool *, bool *, bool *, bool *);
 void list_rules(char *);
 
 #endif
diff --git a/types.c b/types.c
index 9d5eafefd2c59b4f2cb0d6389e1b876c796819cd..250785dc09c552da8e3f2e9510f77fc0c60f1fda 100644 (file)
--- a/types.c
+++ b/types.c
@@ -144,6 +144,7 @@ rule_t *make_rule(void)
     rule_t *r = malloc(sizeof(rule_t));
     r->uid = ++rule_uid;
     r->effect.floating = false;
+    r->effect.follow = false;
     r->effect.monitor = NULL;
     r->effect.desktop = NULL;
     r->prev = NULL;
diff --git a/types.h b/types.h
index 6e00d7d4f8dbf3013137e6e88af2fd43db5164b3..7b59f1c3108c4258229ec9a02721ade3b3d81d6a 100644 (file)
--- a/types.h
+++ b/types.h
@@ -175,6 +175,7 @@ typedef struct {
 
 typedef struct {
     bool floating;
+    bool follow;
     monitor_t *monitor;
     desktop_t *desktop;
 } rule_effect_t;
index c2fc838b32407ccd962f42aa7f1334160b437334..0734b63ea7ee58f297681fe0e3507b1b98dc3109 100644 (file)
--- a/window.c
+++ b/window.c
@@ -96,9 +96,9 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
     if (override_redirect || locate_window(win, &loc))
         return;
 
-    bool floating = false, transient = false, fullscreen = false, takes_focus = true, manage = true;
+    bool floating = false, follow = false, transient = false, fullscreen = false, takes_focus = true, manage = true;
 
-    handle_rules(win, &m, &d, &floating, &transient, &fullscreen, &takes_focus, &manage);
+    handle_rules(win, &m, &d, &floating, &follow, &transient, &fullscreen, &takes_focus, &manage);
 
     if (!manage) {
         disable_shadow(win);
@@ -162,6 +162,11 @@ void manage_window(monitor_t *m, desktop_t *d, xcb_window_t win)
     uint32_t values[] = {(focus_follows_pointer ? CLIENT_EVENT_MASK_FFP : CLIENT_EVENT_MASK)};
     xcb_change_window_attributes(dpy, c->window, XCB_CW_EVENT_MASK, values);
 
+    if (follow) {
+        select_monitor(m);
+        select_desktop(d);
+    }
+
     num_clients++;
     ewmh_set_wm_desktop(birth, d);
     ewmh_update_client_list();