Skip to content

Commit

Permalink
Remove setting: history_aware_focus
Browse files Browse the repository at this point in the history
The new implementation of the DIR descriptor is based on
[right-window](https://github.com/ntrrgc/right-window).

Fixes baskerville#467.
  • Loading branch information
baskerville committed Apr 28, 2016
1 parent 8f86e93 commit c32f30a
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 76 deletions.
2 changes: 1 addition & 1 deletion contrib/bash_completion
Original file line number Diff line number Diff line change
@@ -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=()

Expand Down
2 changes: 1 addition & 1 deletion contrib/zsh_completion
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions doc/bspwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
.\" -----------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions doc/bspwm.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 0 additions & 1 deletion examples/bspwmrc
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 19 additions & 6 deletions geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions history.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion history.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 5 additions & 40 deletions tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c32f30a

Please sign in to comment.