Merge pull request #2617 from psychon/more_enterleave_events

Honor *some* Enter/Leave events with detail==Inferior
This commit is contained in:
mergify[bot] 2019-01-27 17:48:09 +00:00 committed by GitHub
commit febbbb69a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 22 deletions

58
event.c
View File

@ -586,24 +586,38 @@ event_handle_leavenotify(xcb_leave_notify_event_t *ev)
* Ignore events with non-normal modes. Those are because a grab
* activated/deactivated. Everything will be "back to normal" after the
* grab.
*
* Also ignore events with detail "inferior". This means that the window was
* left for a child window, i.e. the pointer is basically still inside of
* our window.
*/
if(ev->mode != XCB_NOTIFY_MODE_NORMAL || ev->detail == XCB_NOTIFY_DETAIL_INFERIOR)
if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
return;
if((c = client_getbyframewin(ev->event)))
{
/* The window was left in some way, so definitely no titlebar has the
* mouse cursor.
*/
lua_pushnil(L);
event_drawable_under_mouse(L, -1);
lua_pop(L, 1);
/* If detail is inferior, it means that the cursor is now in some child
* window of our window. Thus, the titlebar was left, but now the cursor
* is in the actual child window. Thus, ignore detail=Inferior for
* leaving client windows.
*/
if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
luaA_object_push(L, c);
luaA_object_emit_signal(L, -1, "mouse::leave", 0);
lua_pop(L, 1);
}
} else if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
/* Some window was left. This must be a drawin. Ignore detail=Inferior,
* because this means that some child window now contains the mouse
* cursor, i.e. a systray window. Everything else is a real 'leave'.
*/
lua_pushnil(L);
event_drawable_under_mouse(L, -1);
lua_pop(L, 1);
}
}
/** The enter notify event handler.
@ -622,15 +636,20 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev)
* Ignore events with non-normal modes. Those are because a grab
* activated/deactivated. Everything will be "back to normal" after the
* grab.
*
* Also ignore events with detail "inferior". This means that the cursor was
* previously inside of a child window and now left that child window. For
* our purposes, the cursor was already inside our window before.
*/
if(ev->mode != XCB_NOTIFY_MODE_NORMAL || ev->detail == XCB_NOTIFY_DETAIL_INFERIOR)
if(ev->mode != XCB_NOTIFY_MODE_NORMAL)
return;
if((drawin = drawin_getbywin(ev->event)))
/*
* We ignore events with detail "inferior". This detail means that the
* cursor was previously inside of a child window and now left that child
* window. For our purposes, the cursor was already inside our window
* before.
* One exception are titlebars: They are not their own window, but are
* "outside of the actual client window".
*/
if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR && (drawin = drawin_getbywin(ev->event)))
{
luaA_object_push(L, drawin);
luaA_object_push_item(L, -1, drawin->drawable);
@ -641,18 +660,25 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev)
if((c = client_getbyframewin(ev->event)))
{
luaA_object_push(L, c);
/* Detail=Inferior means that a child of the frame window now contains
* the mouse cursor, i.e. the actual client now has the cursor. All
* other details mean that the client itself was really left.
*/
if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
luaA_object_emit_signal(L, -1, "mouse::enter", 0);
}
drawable_t *d = client_get_drawable(c, ev->event_x, ev->event_y);
if (d)
{
luaA_object_push_item(L, -1, d);
} else {
lua_pushnil(L);
}
event_drawable_under_mouse(L, -1);
lua_pop(L, 1);
lua_pop(L, 2);
}
lua_pop(L, 1);
}
else if (ev->event == globalconf.screen->root) {
else if (ev->detail != XCB_NOTIFY_DETAIL_INFERIOR && ev->event == globalconf.screen->root) {
/* When there are multiple X screens with awesome running separate
* instances, reset focus.
*/