_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=()
_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
.\" 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
.\" -----------------------------------------------------------------
\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
'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.
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'
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;
}
}
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);
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;
}
}
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
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)
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)
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) {
!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;
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;
#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
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;
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;
!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;
}
}
}
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);