]> git.lizzy.rs Git - bspwm.git/commitdiff
Add '--follow' option to 'send_to*' messages
authorBastien Dejean <nihilhill@gmail.com>
Sun, 23 Dec 2012 12:14:33 +0000 (13:14 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 23 Dec 2012 12:14:33 +0000 (13:14 +0100)
README.md
bspwm.1
messages.c
messages.h
types.h

index 8c85f8480db13cd615b8b7a634bf326b3fdc2b52..7c24b143e15ebc0013e62b5b902465a87ed29377 100644 (file)
--- a/README.md
+++ b/README.md
@@ -146,10 +146,10 @@ The following messages are handled:
     kill
         Kill the focused window.
 
-    send_to DESKTOP_NAME
+    send_to DESKTOP_NAME [--follow]
         Send the focused window to the given desktop.
 
-    send_to_monitor MONITOR_NAME
+    send_to_monitor MONITOR_NAME [--follow]
         Send the focused window to the given monitor.
 
     use DESKTOP_NAME
diff --git a/bspwm.1 b/bspwm.1
index 354493fd362df799e061a6ef5163e841a84a0a11..f91e886f6cf0b097d142483fcddf6990cd626652 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -169,10 +169,10 @@ Close the focused window.
 .BI kill
 Kill the focused window.
 .TP
-.BI send_to " DESKTOP_NAME"
+.BI send_to " DESKTOP_NAME [--follow]"
 Send the focused window to the given desktop.
 .TP
-.BI send_to_monitor " MONITOR_NAME"
+.BI send_to_monitor " MONITOR_NAME [--follow]"
 Send the focused window to the given monitor.
 .TP
 .BI use " DESKTOP_NAME"
index f15b5ebdf38f91999a3782fd7b2c7e296aeb4a55..1a413cc6576edc19f295f9d1459dc58f8a9e6504 100644 (file)
@@ -167,6 +167,10 @@ void process_message(char *msg, char *rsp)
             if (m != NULL && m != mon) {
                 transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
                 arrange(m, m->desk);
+                char *arg = strtok(NULL, TOK_SEP);
+                send_option_t opt;
+                if (parse_send_option(arg, &opt) && opt == SEND_OPTION_FOLLOW)
+                    select_monitor(m);
             }
         }
     } else if (strcmp(cmd, "send_to") == 0) {
@@ -177,6 +181,12 @@ void process_message(char *msg, char *rsp)
                 transfer_node(mon, mon->desk, loc.monitor, loc.desktop, mon->desk->focus);
                 if (mon != loc.monitor && loc.monitor->desk == loc.desktop)
                     arrange(loc.monitor, loc.desktop);
+                char *arg = strtok(NULL, TOK_SEP);
+                send_option_t opt;
+                if (parse_send_option(arg, &opt) && opt == SEND_OPTION_FOLLOW) {
+                    select_monitor(loc.monitor);
+                    select_desktop(loc.desktop);
+                }
             }
         }
     } else if (strcmp(cmd, "rename_monitor") == 0) {
@@ -646,6 +656,18 @@ bool parse_list_option(char *s, list_option_t *o)
     return false;
 }
 
+bool parse_send_option(char *s, send_option_t *o)
+{
+    if (s == NULL) {
+        *o = SEND_OPTION_DONT_FOLLOW;
+        return true;
+    } else if (strcmp(s, "--follow") == 0) {
+        *o = SEND_OPTION_FOLLOW;
+        return true;
+    }
+    return false;
+}
+
 bool parse_rotate(char *s, rotate_t *r)
 {
     if (strcmp(s, "clockwise") == 0) {
index 29f25159156115dce18fdc3c9a599ea0c98ccf93..9c4717e373dc8a6573499cc81f9f562f16a13606 100644 (file)
@@ -15,6 +15,7 @@ bool parse_nearest_argument(char *, nearest_arg_t *);
 bool parse_cycle_direction(char *, cycle_dir_t *);
 bool parse_circulate_direction(char *, circulate_dir_t *);
 bool parse_list_option(char *, list_option_t *);
+bool parse_send_option(char *, send_option_t *);
 bool parse_skip_client(char *, skip_client_t *);
 bool parse_skip_desktop(char *, skip_desktop_t *);
 bool parse_rotate(char *, rotate_t *);
diff --git a/types.h b/types.h
index b50c438a8fd539d5c8d89bee84eb00371505fddc..fb9a22043e35cdab67fa8a669ee292f8f497374b 100644 (file)
--- a/types.h
+++ b/types.h
@@ -41,6 +41,11 @@ typedef enum {
     LIST_OPTION_QUIET
 } list_option_t;
 
+typedef enum {
+    SEND_OPTION_FOLLOW,
+    SEND_OPTION_DONT_FOLLOW
+} send_option_t;
+
 typedef enum {
     CLIENT_SKIP_NONE,
     CLIENT_SKIP_FLOATING,