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:
Bastien Dejean 2012-12-20 11:14:38 +01:00
parent 2e5099848c
commit 43f76714aa
3 changed files with 5 additions and 1 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}
}