]> git.lizzy.rs Git - bspwm.git/commitdiff
Reinstate `focus_by_distance` setting
authorBastien Dejean <nihilhill@gmail.com>
Fri, 18 Jul 2014 17:21:58 +0000 (19:21 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Fri, 18 Jul 2014 17:21:58 +0000 (19:21 +0200)
contrib/bash_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.txt
examples/bspwmrc
messages.c
settings.h
tree.c
tree.h

index 2b87851307d321daeb459e05c3c309865e7fa761..2d487a5c8cd881bedf043244b93b999e0361c329 100644 (file)
@@ -1,7 +1,7 @@
 _bspc() {
        local commands='window desktop monitor query pointer rule restore control config quit'
 
-       local settings='external_rules_command status_prefix focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus ignore_ewmh_focus remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
+       local settings='external_rules_command status_prefix focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color focused_sticky_border_color normal_sticky_border_color focused_private_border_color active_private_border_color normal_private_border_color urgent_border_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor apply_floating_atom auto_alternate auto_cancel history_aware_focus focus_by_distance ignore_ewmh_focus remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
 
        COMPREPLY=()
 
index 53881b3ef43844496ce90be31f560f5b11e434b0..2b50b5f465764390fa7fe0392a93f9f0c3f17611 100644 (file)
@@ -3,7 +3,7 @@
 _bspc() {
        local -a commands settings
        commands=('window' 'desktop' 'monitor' 'query' 'pointer' 'rule' 'restore' 'control' 'config' 'quit')
-       settings=('external_rules_command' 'status_prefix' 'focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'ignore_ewmh_focus' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
+       settings=('external_rules_command' 'status_prefix' 'focused_border_color' 'active_border_color' 'normal_border_color' 'presel_border_color' 'focused_locked_border_color' 'active_locked_border_color' 'normal_locked_border_color' 'focused_sticky_border_color' 'normal_sticky_border_color' 'focused_private_border_color' 'active_private_border_color' 'normal_private_border_color' 'urgent_border_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'borderless_monocle' 'gapless_monocle' 'focus_follows_pointer' 'pointer_follows_monitor' 'apply_floating_atom' 'auto_alternate' 'auto_cancel' 'history_aware_focus' 'focus_by_distance' 'ignore_ewmh_focus' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
        if (( CURRENT == 2 )) ; then
                _values 'command' "$commands[@]"
        elif (( CURRENT == 3 )) ; then
index 71613a9bf13dcb281472351d6ccca47ff6774ff8..fab196a8cbc40e49da18dd822f69111e902ed309 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      Date: 06/21/2014
+.\"      Date: 07/18/2014
 .\"    Manual: Bspwm Manual
 .\"    Source: Bspwm 0.8.9
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "06/21/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
+.TH "BSPWM" "1" "07/18/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1061,6 +1061,11 @@ command)\&.
 Give priority to the focus history when focusing nodes\&.
 .RE
 .PP
+\fIfocus_by_distance\fR
+.RS 4
+Base focusing on distances between windows\&.
+.RE
+.PP
 \fIborderless_monocle\fR
 .RS 4
 Remove borders for tiled windows in monocle mode\&.
index f550ad6aca8e9d7a7976b2f1afa19e6ac2166a70..0139404e070d327eebd35b7587a7a222ddee9381 100644 (file)
@@ -652,6 +652,9 @@ Global Settings
 'history_aware_focus'::
        Give priority to the focus history when focusing nodes.
 
+'focus_by_distance'::
+       Base focusing on distances between windows.
+
 'borderless_monocle'::
        Remove borders for tiled windows in monocle mode.
 
index ab98df73acf4477657a4c80cc34bf87139054046..f54e04dca7f3b515c201bace55427f4227572776 100755 (executable)
@@ -6,6 +6,7 @@ bspc config window_gap         12
 bspc config split_ratio         0.52
 bspc config borderless_monocle  true
 bspc config gapless_monocle     true
+bspc config focus_by_distance   true
 
 bspc monitor -d I II III IV V VI VII VIII IX X
 
index e891618cf4e81793b27568bcc4093eca678b587c..74f45ad2aaf85d91cbb3c493ab9e1fdf86bd5beb 100644 (file)
@@ -996,6 +996,7 @@ int set_setting(coordinates_t loc, char *name, char *value)
                SETBOOL(auto_alternate)
                SETBOOL(auto_cancel)
                SETBOOL(history_aware_focus)
+               SETBOOL(focus_by_distance)
                SETBOOL(ignore_ewmh_focus)
                SETBOOL(remove_disabled_monitors)
                SETBOOL(remove_unplugged_monitors)
@@ -1071,6 +1072,7 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
        GETBOOL(auto_alternate)
        GETBOOL(auto_cancel)
        GETBOOL(history_aware_focus)
+       GETBOOL(focus_by_distance)
        GETBOOL(ignore_ewmh_focus)
        GETBOOL(remove_disabled_monitors)
        GETBOOL(remove_unplugged_monitors)
index 0a85b51844806d1bd76a8402114619fc49f44c34..66b17d2ee5061d1c383ca7a477a4f90bd3d7bd2d 100644 (file)
@@ -57,6 +57,7 @@
 #define BORDER_WIDTH   1
 
 #define HISTORY_AWARE_FOCUS        false
+#define FOCUS_BY_DISTANCE          false
 #define BORDERLESS_MONOCLE         false
 #define GAPLESS_MONOCLE            false
 #define FOCUS_FOLLOWS_POINTER      false
@@ -99,6 +100,7 @@ bool apply_floating_atom;
 bool auto_alternate;
 bool auto_cancel;
 bool history_aware_focus;
+bool focus_by_distance;
 bool ignore_ewmh_focus;
 bool remove_disabled_monitors;
 bool remove_unplugged_monitors;
diff --git a/tree.c b/tree.c
index 075654761c1bf3ed11b3cdf3b81939942f3eedf7..c653b97229b287e13627abdcd7966700510f7df7 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -604,8 +604,33 @@ node_t *nearest_neighbor(monitor_t *m, desktop_t *d, node_t *n, direction_t dir,
        node_t *nearest = NULL;
        if (history_aware_focus)
                nearest = nearest_from_history(m, d, n, dir, sel);
-       if (nearest == NULL)
-               nearest = nearest_from_distance(m, d, n, dir, sel);
+    if (nearest == NULL) {
+        if (focus_by_distance) {
+            nearest = nearest_from_distance(m, d, n, dir, sel);
+        } else {
+            nearest = nearest_from_tree(n, dir);
+        }
+    }
+    return nearest;
+}
+
+node_t *nearest_from_tree(node_t *n, direction_t dir)
+{
+    if (n == NULL)
+        return NULL;
+
+    node_t *fence = find_fence(n, dir);
+
+    if (fence == NULL)
+        return NULL;
+
+    node_t *nearest = NULL;
+
+    if (dir == DIR_UP || dir == DIR_LEFT)
+        nearest = second_extrema(fence->first_child);
+    else if (dir == DIR_DOWN || dir == DIR_RIGHT)
+        nearest = first_extrema(fence->second_child);
+
        return nearest;
 }
 
diff --git a/tree.h b/tree.h
index 3f0ee5d90a75b699d432e0a3a985ab84fe2e4a97..5563be5144e371cb7ad6c0611fd7e3f89d091353 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -54,6 +54,7 @@ node_t *prev_tiled_leaf(desktop_t *d, node_t *n, node_t *r);
 bool is_adjacent(node_t *a, node_t *b, direction_t dir);
 node_t *find_fence(node_t *n, direction_t dir);
 node_t *nearest_neighbor(monitor_t *m, desktop_t *d, node_t *n, direction_t dir, client_select_t sel);
+node_t *nearest_from_tree(node_t *n, direction_t dir);
 node_t *nearest_from_history(monitor_t *m, desktop_t *d, node_t *n, direction_t dir, client_select_t sel);
 node_t *nearest_from_distance(monitor_t *m, desktop_t *d, node_t *n, direction_t dir, client_select_t sel);
 void get_opposite(direction_t src, direction_t *dst);