]> git.lizzy.rs Git - bspwm.git/commitdiff
New message: `biggest`
authorBastien Dejean <nihilhill@gmail.com>
Thu, 30 May 2013 10:14:22 +0000 (12:14 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 30 May 2013 10:14:22 +0000 (12:14 +0200)
README.md
bash_completion
bspwm.1
messages.c
messages.h
tree.c
tree.h
types.h

index 8bc1533e199dfa75668f1358eebe628dfb8ca6c6..3ca8ae2d67fa8a3237832224043540c294dae288 100644 (file)
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ The following messages are handled:
 
 - `shift left|right|up|down` — Exchange the current window with the given neighbor.
 
-- `swap [biggest|smallest]` — Swap the focused window with the biggest/smallest window or with the last focused window if no arguments are given.
+- `swap` — Swap the focused window the last focused window.
 
 - `push left|right|up|down` — Push the fence located in the given direction.
 
@@ -111,6 +111,8 @@ The following messages are handled:
 
 - `nearest older|newer [--skip-floating|--skip-tiled|--skip-class-equal|--skip-class-differ]` — Focus the nearest window matching the given constraints.
 
+- `biggest` — Return the ID of the biggest tiled window.
+
 - `circulate forward|backward` — Circulate the leaves in the given direction.
 
 - `grab_pointer focus|move|resize_side|resize_corner` — Begin the specified pointer action.
index c7a894583ee34c1f16e4d188749aedba94da5cba..59332440fedf325df77d470520caef9354af5a7d 100644 (file)
@@ -1,6 +1,6 @@
 _bspc()
 {
-    local messages='get set list list_desktops list_monitors list_windows list_rules list_history presel cancel ratio pad focus shift swap push pull cycle nearest circulate grab_pointer track_pointer ungrab_pointer toggle_fullscreen toggle_floating toggle_locked toggle_visibility close kill send_to drop_to send_to_monitor drop_to_monitor use use_monitor alternate alternate_desktop alternate_monitor add add_in rename_monitor rename cycle_monitor cycle_desktop layout cycle_layout rotate flip balance rule remove_rule put_status adopt_orphans restore_layout restore_history quit'
+    local messages='get set list list_desktops list_monitors list_windows list_rules list_history presel cancel ratio pad focus shift swap push pull cycle nearest biggest circulate grab_pointer track_pointer ungrab_pointer toggle_fullscreen toggle_floating toggle_locked toggle_visibility close kill send_to drop_to send_to_monitor drop_to_monitor use use_monitor alternate alternate_desktop alternate_monitor add add_in rename_monitor rename cycle_monitor cycle_desktop layout cycle_layout rotate flip balance rule remove_rule put_status adopt_orphans restore_layout restore_history quit'
 
     local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color urgent_border_color border_width window_gap split_ratio top_padding right_padding bottom_padding left_padding wm_name borderless_monocle gapless_monocle focus_follows_pointer adaptative_raise apply_shadow_property auto_alternate focus_by_distance'
 
diff --git a/bspwm.1 b/bspwm.1
index f5a0b1e9a547867ffe6dff75e413c0aaa87ef61e..7204efe556044f70dbee1b5d17c00a54e93649d1 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -133,8 +133,8 @@ Focus the neighbor window situated in the given direction.
 .BI shift " left|right|up|down"
 Exchange the current window with the given neighbor.
 .TP
-.BI swap " [biggest|smallest]"
-Swap the focused window with the biggest/smallest window or with the last focused window if no arguments are given.
+.BI swap
+Swap the focused window with the last focused window.
 .TP
 .BI push " left|right|up|down"
 Push the fence located in the given direction.
@@ -148,6 +148,9 @@ Focus the next or previous window matching the given constraints.
 .BI nearest " older|newer [--skip-floating|--skip-tiled|--skip-class-equal|--skip-class-differ]"
 Focus the nearest window matching the given constraints.
 .TP
+.BI biggest
+Return the ID of the biggest tiled window.
+.TP
 .BI circulate " forward|backward"
 Circulate the leaves in the given direction.
 .TP
index 2a6ee5de6bf7da9351216546839396a57f03056c..b363190a77a2ade725a31ce4fb91a3ae45988480 100644 (file)
@@ -350,6 +350,10 @@ void process_message(char *msg, char *rsp)
             }
         }
         return;
+    } else if (strcmp(cmd, "biggest") == 0) {
+        node_t *n = find_biggest(mon->desk);
+        if (n != NULL)
+            snprintf(rsp, BUFSIZ, "0x%X", n->client->window);
     } else if (strcmp(cmd, "circulate") == 0) {
         if (mon->desk->layout == LAYOUT_MONOCLE
                 || (mon->desk->focus != NULL && !is_tiled(mon->desk->focus->client)))
@@ -391,16 +395,7 @@ void process_message(char *msg, char *rsp)
                 remove_rule_by_uid(uid);
         return;
     } else if (strcmp(cmd, "swap") == 0) {
-        char *arg;
-        swap_arg_t a;
-        if ((arg = strtok(NULL, TOK_SEP)) != NULL) {
-            if (parse_swap_argument(arg, &a)) {
-                node_t *n = find_by_area(mon->desk, a);
-                swap_nodes(mon->desk->focus, n);
-            }
-        } else {
-            swap_nodes(mon->desk->focus, history_get(mon->desk->history, 1));
-        }
+        swap_nodes(mon->desk->focus, history_get(mon->desk->history, 1));
     } else if (strcmp(cmd, "alternate") == 0) {
         focus_node(mon, mon->desk, history_get(mon->desk->history, 1));
         return;
@@ -674,18 +669,6 @@ bool parse_nearest_argument(char *s, nearest_arg_t *a)
     return false;
 }
 
-bool parse_swap_argument(char *s, swap_arg_t *a)
-{
-    if (strcmp(s, "biggest") == 0) {
-        *a = SWAP_BIGGEST;
-        return true;
-    } else if (strcmp(s, "smallest") == 0) {
-        *a = SWAP_SMALLEST;
-        return true;
-    }
-    return false;
-}
-
 bool parse_cycle_direction(char *s, cycle_dir_t *d)
 {
     if (strcmp(s, "prev") == 0) {
index 7e5c3f6f37635c015eb6f311efd12d65b6fbf7ed..8f7d5d6d7296c32e161526e7a0656c6c4156f9c0 100644 (file)
@@ -12,7 +12,6 @@ bool parse_bool(char *, bool *);
 bool parse_layout(char *, layout_t *);
 bool parse_direction(char *, direction_t *);
 bool parse_nearest_argument(char *, nearest_arg_t *);
-bool parse_swap_argument(char *, swap_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 *);
diff --git a/tree.c b/tree.c
index ea23060d1d6515797500bd13983d7ea93ebb992b..7a8e9ca7e6a2bf091dd0e12ea39aeea25b4a2bc1 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -128,20 +128,20 @@ node_t *find_neighbor(node_t *n, direction_t dir)
     return NULL;
 }
 
-void get_opposite(direction_t dir, direction_t* val)
+void get_opposite(direction_t src, direction_t* dst)
 {
-    switch (dir) {
+    switch (src) {
         case DIR_RIGHT:
-            *val = DIR_LEFT;
+            *dst = DIR_LEFT;
             break;
         case DIR_DOWN:
-            *val = DIR_UP;
+            *dst = DIR_UP;
             break;
         case DIR_LEFT:
-            *val = DIR_RIGHT;
+            *dst = DIR_RIGHT;
             break;
         case DIR_UP:
-            *val = DIR_DOWN;
+            *dst = DIR_DOWN;
             break;
     }
 }
@@ -192,7 +192,7 @@ int tiled_area(node_t *n)
     return rect.width * rect.height;
 }
 
-node_t *find_by_area(desktop_t *d, swap_arg_t a)
+node_t *find_biggest(desktop_t *d)
 {
     if (d == NULL)
         return NULL;
@@ -205,8 +205,7 @@ node_t *find_by_area(desktop_t *d, swap_arg_t a)
         if (r == NULL) {
             r = f;
             r_area = f_area;
-        } else if ((a == SWAP_BIGGEST && f_area > r_area)
-                || (a == SWAP_SMALLEST && f_area < r_area)) {
+        } else if (f_area > r_area) {
             r = f;
             r_area = f_area;
         }
diff --git a/tree.h b/tree.h
index fee10ac9618c2880c0dc2ccdfd3a7d61d2737c61..e6750d752502a6277688fd8d2416709ffef21d3a 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -19,7 +19,7 @@ node_t *find_neighbor(node_t *, direction_t);
 void get_opposite(direction_t, direction_t*);
 node_t *nearest_neighbor(desktop_t *, node_t *, direction_t);
 int tiled_area(node_t *);
-node_t *find_by_area(desktop_t *, swap_arg_t);
+node_t *find_biggest(desktop_t *);
 void move_fence(node_t *, direction_t, fence_move_t);
 void rotate_tree(node_t *, rotate_t);
 void rotate_brother(node_t *);
diff --git a/types.h b/types.h
index 4dd959cc7bcca0cbcdab84b3b13d96d82b4281f6..c8fbeb68367908b7f8df38dfd9838e1d6920ace6 100644 (file)
--- a/types.h
+++ b/types.h
@@ -70,11 +70,6 @@ typedef enum {
     NEAREST_NEWER
 } nearest_arg_t;
 
-typedef enum {
-    SWAP_BIGGEST,
-    SWAP_SMALLEST
-} swap_arg_t;
-
 typedef enum {
     CIRCULATE_FORWARD,
     CIRCULATE_BACKWARD