mirror of
https://github.com/vale981/bspwm
synced 2025-03-06 02:01:42 -05:00
Prevent focus stealing for 'focus_follows_mouse'
When 'focus_follows_mouse' was enabled, and the focus was given (through the 'focus' message) to another window, it was possible for the previous window to generate an enter notify event and, hence, stole the focus.
This commit is contained in:
parent
2e5099848c
commit
43f76714aa
3 changed files with 5 additions and 1 deletions
1
bspwm.c
1
bspwm.c
|
@ -136,6 +136,7 @@ void setup(void)
|
|||
rule_head = make_rule();
|
||||
frozen_pointer = make_pointer_state();
|
||||
get_pointer_position(&pointer_position);
|
||||
last_entered = XCB_NONE;
|
||||
split_mode = MODE_AUTOMATIC;
|
||||
}
|
||||
|
||||
|
|
1
bspwm.h
1
bspwm.h
|
@ -27,6 +27,7 @@ monitor_t *mon_tail;
|
|||
rule_t *rule_head;
|
||||
pointer_state_t *frozen_pointer;
|
||||
xcb_point_t pointer_position;
|
||||
xcb_window_t last_entered;
|
||||
|
||||
bool running;
|
||||
|
||||
|
|
4
events.c
4
events.c
|
@ -207,7 +207,8 @@ void enter_notify(xcb_generic_event_t *evt)
|
|||
|
||||
if (!focus_follows_mouse
|
||||
|| (e->mode != XCB_NOTIFY_MODE_NORMAL && e->detail == XCB_NOTIFY_DETAIL_INFERIOR)
|
||||
|| (pointer_position.x == e->root_x && pointer_position.y == e->root_y))
|
||||
|| (pointer_position.x == e->root_x && pointer_position.y == e->root_y)
|
||||
|| last_entered == e->event)
|
||||
return;
|
||||
|
||||
window_location_t loc;
|
||||
|
@ -215,6 +216,7 @@ void enter_notify(xcb_generic_event_t *evt)
|
|||
select_monitor(loc.monitor);
|
||||
focus_node(loc.monitor, loc.desktop, loc.node, true);
|
||||
pointer_position = (xcb_point_t) {e->root_x, e->root_y};
|
||||
last_entered = e->event;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue