]> git.lizzy.rs Git - bspwm.git/commitdiff
Remove setting: history_aware_focus
authorBastien Dejean <nihilhill@gmail.com>
Thu, 28 Apr 2016 08:33:30 +0000 (10:33 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Thu, 28 Apr 2016 08:33:30 +0000 (10:33 +0200)
The new implementation of the DIR descriptor is based on
[right-window](https://github.com/ntrrgc/right-window).

Fixes #467.

15 files changed:
contrib/bash_completion
contrib/zsh_completion
doc/bspwm.1
doc/bspwm.1.asciidoc
examples/bspwmrc
geometry.c
geometry.h
history.c
history.h
messages.c
monitor.c
settings.c
settings.h
tree.c
tree.h

index 342c663595acc8cecfc4d3df563852e7a4dec482..0654f1f61af87a27fbf357e038b5fe59114a1228 100644 (file)
@@ -1,7 +1,7 @@
 _bspc() {
        local commands='node desktop monitor query rule restore wm subscribe config quit'
 
-       local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle single_monocle pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus focus_follows_pointer pointer_follows_focus pointer_follows_monitor history_aware_focus ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
+       local settings='external_rules_command status_prefix normal_border_color active_border_color focused_border_color presel_feedback_color border_width window_gap top_padding right_padding bottom_padding left_padding split_ratio initial_polarity borderless_monocle gapless_monocle single_monocle pointer_modifier pointer_action1 pointer_action2 pointer_action3 click_to_focus focus_follows_pointer pointer_follows_focus pointer_follows_monitor ignore_ewmh_focus center_pseudo_tiled honor_size_hints remove_disabled_monitors remove_unplugged_monitors merge_overlapping_monitors'
 
        COMPREPLY=()
 
index 96e38346e2af6bdfcc3b7f5360c3b2ade0969987..c8eaee8d29d79118035ce16ae80457d5c929482e 100644 (file)
@@ -3,7 +3,7 @@
 _bspc() {
        local -a commands settings
        commands=('node' 'desktop' 'monitor' 'query' 'rule' 'restore' 'wm' 'subscribe' 'config' 'quit')
-       settings=('external_rules_command' 'status_prefix' 'normal_border_color' 'active_border_color' 'focused_border_color' 'presel_feedback_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'single_monocle' 'pointer_modifier' 'pointer_action1' 'pointer_action2' 'pointer_action3' 'click_to_focus' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'history_aware_focus' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'honor_size_hints' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
+       settings=('external_rules_command' 'status_prefix' 'normal_border_color' 'active_border_color' 'focused_border_color' 'presel_feedback_color' 'border_width' 'window_gap' 'top_padding' 'right_padding' 'bottom_padding' 'left_padding' 'split_ratio' 'initial_polarity' 'borderless_monocle' 'gapless_monocle' 'single_monocle' 'pointer_modifier' 'pointer_action1' 'pointer_action2' 'pointer_action3' 'click_to_focus' 'focus_follows_pointer' 'pointer_follows_focus' 'pointer_follows_monitor' 'ignore_ewmh_focus' 'center_pseudo_tiled' 'honor_size_hints' 'remove_disabled_monitors' 'remove_unplugged_monitors' 'merge_overlapping_monitors')
        if (( CURRENT == 2 )) ; then
                _values 'command' "$commands[@]"
        elif (( CURRENT == 3 )) ; then
index ca1adfa08644ae18a935aa09ab524e18fd0c33bd..96e25bb9b698c7a3a8a6af6a70b0f4dcb2bd37b2 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: 04/21/2016
+.\"      Date: 04/28/2016
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.1-45-g09e3d72
+.\"    Source: Bspwm 0.9.1-50-g8f86e93
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "04/21/2016" "Bspwm 0\&.9\&.1\-45\-g09e3d72" "Bspwm Manual"
+.TH "BSPWM" "1" "04/28/2016" "Bspwm 0\&.9\&.1\-50\-g8f86e93" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1017,11 +1017,6 @@ On which child should a new window be attached when adding a window on a single
 \fBsecond_child\fR\&.
 .RE
 .PP
-\fIhistory_aware_focus\fR
-.RS 4
-Give priority to the focus history when focusing nodes\&.
-.RE
-.PP
 \fIborderless_monocle\fR
 .RS 4
 Remove borders of tiled windows for the
index 5633716d3581bd917026a4dc12c1b3ac12c96ae9..efa5ba17492802e5080581794f8604f45b7bb1a6 100644 (file)
@@ -600,9 +600,6 @@ Global Settings
 'initial_polarity'::
        On which child should a new window be attached when adding a window on a single window tree in automatic mode. Accept the following values: *first_child*, *second_child*.
 
-'history_aware_focus'::
-       Give priority to the focus history when focusing nodes.
-
 'borderless_monocle'::
        Remove borders of tiled windows for the *monocle* desktop layout.
 
index 39e7f6400726aadd075ce6d156d593dacde3566e..279c79d39e131eef9c4e840f182e8f12115c5602 100755 (executable)
@@ -10,7 +10,6 @@ bspc config window_gap          12
 bspc config split_ratio          0.52
 bspc config borderless_monocle   true
 bspc config gapless_monocle      true
-bspc config history_aware_focus  true
 
 bspc rule -a Gimp desktop='^8' state=floating follow=on
 bspc rule -a Chromium desktop='^2'
index 047b18ae6482df84644990bdd9773be70adc5a3b..f0af29b595bbe3aa6b59d8bf835845585f9ab961 100644 (file)
@@ -48,25 +48,38 @@ xcb_point_t center(xcb_rectangle_t r)
        return (xcb_point_t) {r.x + r.width/2, r.y + r.height/2};
 }
 
-double rdistance(xcb_rectangle_t r1, xcb_rectangle_t r2)
+uint32_t rect_dir_dist(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t dir)
 {
-       return distance(center(r1), center(r2));
+       switch (dir) {
+               case DIR_NORTH:
+                       return r1.y - (r2.y + r2.height);
+                       break;
+               case DIR_WEST:
+                       return r1.x - (r2.x + r2.width);
+                       break;
+               case DIR_SOUTH:
+                       return r2.y - (r1.y + r1.height);
+                       break;
+               case DIR_EAST:
+                       return r2.x - (r1.x + r1.width);
+                       break;
+       }
 }
 
 bool on_dir_side(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t dir)
 {
        switch (dir) {
                case DIR_NORTH:
-                       return (r2.y + r2.height) <= r1.y;
+                       return (r2.y + r2.height) <= r1.y && r2.x < (r1.x + r1.width) && (r2.x + r2.width) >= r1.x;
                        break;
                case DIR_WEST:
-                       return (r2.x + r2.width) <= r1.x;
+                       return (r2.x + r2.width) <= r1.x && r2.y < (r1.y + r1.height) && (r2.y + r2.height) >= r1.y;
                        break;
                case DIR_SOUTH:
-                       return r2.y >= (r1.y + r1.height);
+                       return r2.y >= (r1.y + r1.height) && r2.x < (r1.x + r1.width) && (r2.x + r2.width) >= r1.x;
                        break;
                case DIR_EAST:
-                       return r2.x >= (r1.x + r1.width);
+                       return r2.x >= (r1.x + r1.width) && r2.y < (r1.y + r1.height) && (r2.y + r2.height) >= r1.y;
                        break;
        }
 }
index b4a6f7f42b1c138847a4cafe8c3fcfd9d7c2d320..09c414035c1f59d0d6f474aed3fc4ed42f951013 100644 (file)
@@ -32,7 +32,7 @@ double distance(xcb_point_t a, xcb_point_t b);
 bool is_inside(xcb_point_t p, xcb_rectangle_t r);
 unsigned int area(xcb_rectangle_t r);
 xcb_point_t center(xcb_rectangle_t r);
-double rdistance(xcb_rectangle_t r1, xcb_rectangle_t r2);
+uint32_t rect_dir_dist(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t dir);
 bool on_dir_side(xcb_rectangle_t r1, xcb_rectangle_t r2, direction_t dir);
 bool rect_eq(xcb_rectangle_t a, xcb_rectangle_t b);
 int rect_cmp(xcb_rectangle_t r1, xcb_rectangle_t r2);
index 11f68000855954ae850afd42553bd94fbc56f7b6..4cb8572b05268a3b5f8d3d0e72ed90b91447752c 100644 (file)
--- a/history.c
+++ b/history.c
@@ -261,17 +261,17 @@ bool history_find_monitor(history_dir_t hdi, coordinates_t *ref, coordinates_t *
        return false;
 }
 
-int history_rank(node_t *n)
+uint32_t history_rank(node_t *n)
 {
-       int i = 0;
+       uint32_t r = 0;
        history_t *h = history_tail;
        while (h != NULL && (!h->latest || h->loc.node != n)) {
                h = h->prev;
-               i++;
+               r++;
        }
        if (h == NULL) {
-               return -1;
+               return UINT32_MAX;
        } else {
-               return i;
+               return r;
        }
 }
index 64dfb7c7544ebaa90e7c2c43b7018f21d4ceb35b..5df4629fe3324207c7952dc1fc093e199ce9d109 100644 (file)
--- a/history.h
+++ b/history.h
@@ -41,6 +41,6 @@ monitor_t *history_last_monitor(monitor_t *m);
 bool history_find_node(history_dir_t hdi, coordinates_t *ref, coordinates_t *dst, node_select_t sel);
 bool history_find_desktop(history_dir_t hdi, coordinates_t *ref, coordinates_t *dst, desktop_select_t sel);
 bool history_find_monitor(history_dir_t hdi, coordinates_t *ref, coordinates_t *dst, monitor_select_t sel);
-int history_rank(node_t *n);
+uint32_t history_rank(node_t *n);
 
 #endif
index ba781b244e51e11f38c331539f84c485405098d9..6ce744c6c5143e5497eaded89bf8bbb520eab776 100644 (file)
@@ -1451,7 +1451,6 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
                SET_BOOL(single_monocle)
                SET_BOOL(pointer_follows_focus)
                SET_BOOL(pointer_follows_monitor)
-               SET_BOOL(history_aware_focus)
                SET_BOOL(ignore_ewmh_focus)
                SET_BOOL(center_pseudo_tiled)
                SET_BOOL(honor_size_hints)
@@ -1555,7 +1554,6 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
        GET_BOOL(focus_follows_pointer)
        GET_BOOL(pointer_follows_focus)
        GET_BOOL(pointer_follows_monitor)
-       GET_BOOL(history_aware_focus)
        GET_BOOL(ignore_ewmh_focus)
        GET_BOOL(center_pseudo_tiled)
        GET_BOOL(honor_size_hints)
index a547ed5e87251055533eb231bdca9c0af05c565c..4005ea264b4f702c50271a62f0a02f59b0f10779 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -397,7 +397,7 @@ monitor_t *monitor_from_client(client_t *c)
 
 monitor_t *nearest_monitor(monitor_t *m, direction_t dir, monitor_select_t sel)
 {
-       double dmin = DBL_MAX;
+       uint32_t dmin = UINT32_MAX;
        monitor_t *nearest = NULL;
        xcb_rectangle_t rect = m->rectangle;
        for (monitor_t *f = mon_head; f != NULL; f = f->next) {
@@ -408,7 +408,7 @@ monitor_t *nearest_monitor(monitor_t *m, direction_t dir, monitor_select_t sel)
                    !on_dir_side(rect, r, dir)) {
                        continue;
                }
-               double d = rdistance(rect, r);
+               uint32_t d = rect_dir_dist(rect, r, dir);
                if (d < dmin) {
                        dmin = d;
                        nearest = f;
index 3d40075beee23999f4f1d4e737b0807268bc2139..7e509dd11a5af34996da7c6c338e5250b38c3dea 100644 (file)
@@ -68,7 +68,6 @@ void load_settings(void)
        focus_follows_pointer = FOCUS_FOLLOWS_POINTER;
        pointer_follows_focus = POINTER_FOLLOWS_FOCUS;
        pointer_follows_monitor = POINTER_FOLLOWS_MONITOR;
-       history_aware_focus = HISTORY_AWARE_FOCUS;
        ignore_ewmh_focus = IGNORE_EWMH_FOCUS;
        center_pseudo_tiled = CENTER_PSEUDO_TILED;
        click_to_focus = CLICK_TO_FOCUS;
index 0fc5519221afb39e663c873df58405636543fee5..c4075d90b23bde98648e8ef916e264e59507bf55 100644 (file)
@@ -44,7 +44,6 @@
 #define BORDER_WIDTH         1
 #define SPLIT_RATIO          0.5
 
-#define HISTORY_AWARE_FOCUS         false
 #define BORDERLESS_MONOCLE          false
 #define GAPLESS_MONOCLE             false
 #define PADDINGLESS_MONOCLE         false
@@ -84,7 +83,6 @@ bool single_monocle;
 bool focus_follows_pointer;
 bool pointer_follows_focus;
 bool pointer_follows_monitor;
-bool history_aware_focus;
 bool ignore_ewmh_focus;
 bool center_pseudo_tiled;
 bool click_to_focus;
diff --git a/tree.c b/tree.c
index 92e9bc44f4a56790a45ae85e905261c25f7f51d5..5d14968f9b7b8db3364e0f7f287643767c0d1da5 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -920,19 +920,8 @@ void find_nearest_neighbor(coordinates_t *ref, coordinates_t *dst, direction_t d
                return;
        }
 
-       if (history_aware_focus) {
-               nearest_from_history(ref, dst, dir, sel);
-       }
-
-       if (dst->node == NULL) {
-               nearest_from_distance(ref, dst, dir, sel);
-       }
-}
-
-void nearest_from_distance(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t sel)
-{
        xcb_rectangle_t rect = get_rectangle(ref->desktop, ref->node);
-       double md = DBL_MAX;
+       uint32_t md = UINT32_MAX, mr = UINT32_MAX;
 
        for (monitor_t *m = mon_head; m != NULL; m = m->next) {
                desktop_t *d = m->desk;
@@ -946,36 +935,12 @@ void nearest_from_distance(coordinates_t *ref, coordinates_t *dst, direction_t d
                            !on_dir_side(rect, r, dir)) {
                                continue;
                        }
-                       double fd = rdistance(rect, r);
-                       if (fd < md) {
+                       uint32_t fd = rect_dir_dist(rect, r, dir);
+                       uint32_t fr = history_rank(f);
+                       if (fd < md || (fd == md && fr < mr)) {
                                md = fd;
-                               *dst = loc;
-                       }
-               }
-       }
-}
-
-void nearest_from_history(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t sel)
-{
-       xcb_rectangle_t rect = get_rectangle(ref->desktop, ref->node);
-       int mr = INT_MAX;
-
-       for (monitor_t *m = mon_head; m != NULL; m = m->next) {
-               desktop_t *d = m->desk;
-               for (node_t *f = first_extrema(d->root); f != NULL; f = next_leaf(f, d->root)) {
-                       coordinates_t loc = {m, d, f};
-                       xcb_rectangle_t r = get_rectangle(d, f);
-                       if (f == ref->node ||
-                           f->client == NULL ||
-                           f->hidden ||
-                           !node_matches(&loc, ref, sel) ||
-                           !on_dir_side(rect, r, dir)) {
-                               continue;
-                       }
-                       int fr = history_rank(f);
-                       if (fr >= 0 && fr < mr) {
-                               *dst = loc;
                                mr = fr;
+                               *dst = loc;
                        }
                }
        }
diff --git a/tree.h b/tree.h
index b9087f0a54b6c93ffb4600050d74877b11ef7da0..78ae47ffc5682cf92fb36c0499db4b249bf02279 100644 (file)
--- a/tree.h
+++ b/tree.h
@@ -64,8 +64,6 @@ bool is_descendant(node_t *a, node_t *b);
 bool find_by_id(uint32_t id, coordinates_t *loc);
 node_t *find_by_id_in(node_t *r, uint32_t id);
 void find_nearest_neighbor(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t sel);
-void nearest_from_distance(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t sel);
-void nearest_from_history(coordinates_t *ref, coordinates_t *dst, direction_t dir, node_select_t sel);
 unsigned int node_area(desktop_t *d, node_t *n);
 int tiled_count(node_t *n);
 node_t *find_biggest(monitor_t *m, desktop_t *d, node_t *n, node_select_t sel);