Add setting: pointer_follows_focus

This commit is contained in:
Bastien Dejean 2014-10-22 11:24:51 +02:00
parent 9f8f115534
commit b7fa492602
11 changed files with 30 additions and 9 deletions

View 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 focus_by_distance 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_focus 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=()

View 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' 'focus_by_distance' '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_focus' '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

View file

@ -2,12 +2,12 @@
.\" Title: bspwm
.\" Author: [see the "Author" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 08/16/2014
.\" Date: 10/22/2014
.\" Manual: Bspwm Manual
.\" Source: Bspwm 0.8.9
.\" Language: English
.\"
.TH "BSPWM" "1" "08/16/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.TH "BSPWM" "1" "10/22/2014" "Bspwm 0\&.8\&.9" "Bspwm Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -1081,6 +1081,11 @@ Remove gaps for tiled windows in monocle mode\&.
Focus the window under the pointer\&.
.RE
.PP
\fIpointer_follows_focus\fR
.RS 4
When focusing a window, put the pointer at its center\&.
.RE
.PP
\fIpointer_follows_monitor\fR
.RS 4
When focusing a monitor, put the pointer at its center\&.

View file

@ -664,6 +664,9 @@ Global Settings
'focus_follows_pointer'::
Focus the window under the pointer.
'pointer_follows_focus'::
When focusing a window, put the pointer at its center.
'pointer_follows_monitor'::
When focusing a monitor, put the pointer at its center.

View file

@ -991,6 +991,7 @@ int set_setting(coordinates_t loc, char *name, char *value)
return MSG_FAILURE;
SETBOOL(borderless_monocle)
SETBOOL(gapless_monocle)
SETBOOL(pointer_follows_focus)
SETBOOL(pointer_follows_monitor)
SETBOOL(apply_floating_atom)
SETBOOL(auto_alternate)
@ -1074,6 +1075,7 @@ int get_setting(coordinates_t loc, char *name, FILE* rsp)
GETBOOL(borderless_monocle)
GETBOOL(gapless_monocle)
GETBOOL(focus_follows_pointer)
GETBOOL(pointer_follows_focus)
GETBOOL(pointer_follows_monitor)
GETBOOL(apply_floating_atom)
GETBOOL(auto_alternate)

View file

@ -139,7 +139,7 @@ void focus_monitor(monitor_t *m)
mon = m;
if (pointer_follows_monitor)
center_pointer(m);
center_pointer(m->rectangle);
ewmh_update_current_desktop();
put_status();

View file

@ -68,6 +68,7 @@ void load_settings(void)
borderless_monocle = BORDERLESS_MONOCLE;
gapless_monocle = GAPLESS_MONOCLE;
focus_follows_pointer = FOCUS_FOLLOWS_POINTER;
pointer_follows_focus = POINTER_FOLLOWS_FOCUS;
pointer_follows_monitor = POINTER_FOLLOWS_MONITOR;
apply_floating_atom = APPLY_FLOATING_ATOM;
auto_alternate = AUTO_ALTERNATE;

View file

@ -61,6 +61,7 @@
#define BORDERLESS_MONOCLE false
#define GAPLESS_MONOCLE false
#define FOCUS_FOLLOWS_POINTER false
#define POINTER_FOLLOWS_FOCUS false
#define POINTER_FOLLOWS_MONITOR false
#define AUTO_ALTERNATE false
#define AUTO_CANCEL false
@ -95,6 +96,7 @@ unsigned int border_width;
bool borderless_monocle;
bool gapless_monocle;
bool focus_follows_pointer;
bool pointer_follows_focus;
bool pointer_follows_monitor;
bool apply_floating_atom;
bool auto_alternate;

8
tree.c
View file

@ -103,6 +103,10 @@ void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, x
window_border_width(n->client->window, bw);
window_draw_border(n, d->focus == n, m == mon);
if (pointer_follows_focus && mon->desk->focus == n && frozen_pointer->action == ACTION_NONE) {
center_pointer(r);
}
} else {
xcb_rectangle_t first_rect;
xcb_rectangle_t second_rect;
@ -353,6 +357,10 @@ void focus_node(monitor_t *m, desktop_t *d, node_t *n)
disable_motion_recorder();
}
if (pointer_follows_focus) {
center_pointer(get_rectangle(n->client));
}
ewmh_update_active_window();
}

View file

@ -762,10 +762,10 @@ void clear_input_focus(void)
xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
}
void center_pointer(monitor_t *m)
void center_pointer(xcb_rectangle_t r)
{
int16_t cx = m->rectangle.x + m->rectangle.width / 2;
int16_t cy = m->rectangle.y + m->rectangle.height / 2;
int16_t cx = r.x + r.width / 2;
int16_t cy = r.y + r.height / 2;
window_lower(motion_recorder);
xcb_warp_pointer(dpy, XCB_NONE, root, 0, 0, 0, 0, cx, cy);
window_raise(motion_recorder);

View file

@ -83,7 +83,7 @@ void update_motion_recorder(void);
void update_input_focus(void);
void set_input_focus(node_t *n);
void clear_input_focus(void);
void center_pointer(monitor_t *m);
void center_pointer(xcb_rectangle_t r);
void get_atom(char *name, xcb_atom_t *atom);
void set_atom(xcb_window_t win, xcb_atom_t atom, uint32_t value);
bool has_proto(xcb_atom_t atom, xcb_icccm_get_wm_protocols_reply_t *protocols);