]> git.lizzy.rs Git - bspwm.git/commitdiff
New messages: 'drop_to{,monitor}'
authorBastien Dejean <nihilhill@gmail.com>
Sun, 13 Jan 2013 10:10:15 +0000 (11:10 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Sun, 13 Jan 2013 10:10:15 +0000 (11:10 +0100)
'send_to' was broken, '--next' and '--prev' can't be options, and I
don't want to restrain the name of the desktops with 'send_to
DESKTOP_NAME|next|prev [--follow]' or handle multiple options: 'send_to
(DESKTOP_NAME|(next|prev --relative)) [--follow]' so I just created new
messages.

README.md
bspwm.1
messages.c
types.h

index a97b9a4719ade632e15d8596d7350f37df75184c..a99e74c46885db7eb737628c74c0465d68d2b439 100644 (file)
--- a/README.md
+++ b/README.md
@@ -164,9 +164,15 @@ The following messages are handled:
     send_to DESKTOP_NAME [--follow]
         Send the focused window to the given desktop.
 
+    drop_to next|prev [--follow]
+        Send the focused window to the next or previous desktop.
+
     send_to_monitor MONITOR_NAME [--follow]
         Send the focused window to the given monitor.
 
+    drop_to_monitor next|prev [--follow]
+        Send the focused window to the next or previous monitor.
+
     use DESKTOP_NAME
         Select the given desktop.
 
diff --git a/bspwm.1 b/bspwm.1
index 2c01e11246422f1026556a0b38054db0615f9944..167bbd78f2dcaccdd1f212c9bf74d331d9a0672c 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -191,9 +191,15 @@ Kill the focused window.
 .BI send_to " DESKTOP_NAME [--follow]"
 Send the focused window to the given desktop.
 .TP
+.BI drop_to " next|prev [--follow]"
+Send the focused window to the next or previous desktop.
+.TP
 .BI send_to_monitor " MONITOR_NAME [--follow]"
 Send the focused window to the given monitor.
 .TP
+.BI drop_to_monitor " next|prev [--follow]"
+Send the focused window to the next or previous monitor.
+.TP
 .BI use " DESKTOP_NAME"
 Select the given desktop.
 .TP
index 94483b9454c5201a12d3c2031004f83b970b1774..9105a315c54d81a62ac63f21cfbf1cc9970c6967 100644 (file)
@@ -185,25 +185,53 @@ void process_message(char *msg, char *rsp)
                 move_fence(mon->desk->focus, d, m);
             }
         }
-    } else if (strcmp(cmd, "send_to_monitor") == 0) {
-        char *arg = strtok(NULL, TOK_SEP);
-        if (arg != NULL) {
-            send_option_t opt;
-            if (parse_send_option(arg, &opt)) {
+    } else if (strcmp(cmd, "drop_to_monitor") == 0) {
+        char *dir = strtok(NULL, TOK_SEP);
+        if (dir != NULL) {
+            cycle_dir_t d;
+            if (parse_cycle_direction(dir, &d)) {
                 monitor_t *m;
-                if (opt == SEND_OPTION_NEXT)
+                if (d == CYCLE_NEXT)
                     m = ((mon->next == NULL ? mon_head : mon->next));
-                else if (opt == SEND_OPTION_PREV)
+                else
                     m = ((mon->prev == NULL ? mon_tail : mon->prev));
+                transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
+                arrange(m, m->desk);
+                char *opt = strtok(NULL, TOK_SEP);
+                send_option_t o;
+                if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
+                    select_monitor(m);
+            }
+        }
+    } else if (strcmp(cmd, "send_to_monitor") == 0) {
+        char *name = strtok(NULL, TOK_SEP);
+        if (name != NULL) {
+            monitor_t *m = find_monitor(name);
+            if (m != NULL && m != mon) {
+                transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
+                arrange(m, m->desk);
+                char *opt = strtok(NULL, TOK_SEP);
+                send_option_t o;
+                if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
+                    select_monitor(m);
+            }
+        } 
+    } else if (strcmp(cmd, "drop_to") == 0) {
+        char *dir = strtok(NULL, TOK_SEP);
+        if (dir != NULL) {
+            cycle_dir_t c;
+            if (parse_cycle_direction(dir, &c)) {
+                desktop_t *d;
+                if (c == CYCLE_NEXT)
+                    d = ((mon->desk->next == NULL ? mon->desk_head : mon->desk->next));
                 else
-                    m = find_monitor(arg);
-                if (m != NULL && m != mon) {
-                    transfer_node(mon, mon->desk, m, m->desk, mon->desk->focus);
-                    arrange(m, m->desk);
-                    if (opt == SEND_OPTION_FOLLOW)
-                        select_monitor(m);
-                }
-            } 
+                    d = ((mon->desk->prev == NULL ? mon->desk_tail : mon->desk->prev));
+                transfer_node(mon, mon->desk, mon, d, mon->desk->focus);
+                char *opt = strtok(NULL, TOK_SEP);
+                send_option_t o;
+                if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW)
+                    select_desktop(d);
+            }
         }
     } else if (strcmp(cmd, "send_to") == 0) {
         char *name = strtok(NULL, TOK_SEP);
@@ -213,9 +241,9 @@ 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) {
+                char *opt = strtok(NULL, TOK_SEP);
+                send_option_t o;
+                if (parse_send_option(opt, &o) && o == SEND_OPTION_FOLLOW) {
                     select_monitor(loc.monitor);
                     select_desktop(loc.desktop);
                 }
@@ -686,12 +714,6 @@ bool parse_send_option(char *s, send_option_t *o)
     } else if (strcmp(s, "--follow") == 0) {
         *o = SEND_OPTION_FOLLOW;
         return true;
-    } else if (strcmp(s, "--next") == 0) {
-        *o = SEND_OPTION_NEXT;
-        return true;
-    } else if (strcmp(s, "--prev") == 0) {
-        *o = SEND_OPTION_PREV;
-        return true;
     }
     return false;
 }
diff --git a/types.h b/types.h
index 23d58d78da46b021b57ccfaf05ecbc4980bd5855..199ef727267fca90b135e67330a03072c99db887 100644 (file)
--- a/types.h
+++ b/types.h
@@ -43,9 +43,7 @@ typedef enum {
 
 typedef enum {
     SEND_OPTION_FOLLOW,
-    SEND_OPTION_DONT_FOLLOW,
-    SEND_OPTION_NEXT,
-    SEND_OPTION_PREV
+    SEND_OPTION_DONT_FOLLOW
 } send_option_t;
 
 typedef enum {