From d96c4d61a9a50b205f8b2e01635775cd4bc90fb5 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 17 Sep 2015 17:03:36 +0200 Subject: [PATCH] Handle enter/leave events with detail=Inferior correctly There is a client window C. Around this window, awesome adds a frame window F. When the pointer is inside of C and then moves inside of F, we get a LeaveNotify with detail=Inferior, but from our point of view, the pointer is still inside of C, because F is contained in C. Similarly, if the pointer is in F and moves to C, we get an EnterNotify with detail=Inferior that we should ignore. However, for an EnterNotify the pointer can now be inside of a titlebar, so this case has to be handled now. The above explains the enter/leave behavior for clients. Let's now think about titlebars: When the pointer moves from C to F, it cannot be in any titlebar any more, so we must generate a leave event on that titlebar. Similar when the pointer moves from F to C, but in this case we also have to figure out which titlebar now contains the pointer. This patch makes the code handle these events with detail=Inferior correctly. Closes https://github.com/awesomeWM/awesome/pull/461. Signed-off-by: Uli Schlachter --- event.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/event.c b/event.c index b9b0b751e..d91f6e207 100644 --- a/event.c +++ b/event.c @@ -512,7 +512,10 @@ event_handle_leavenotify(xcb_leave_notify_event_t *ev) if(ev->mode != XCB_NOTIFY_MODE_NORMAL) return; - if((c = client_getbyframewin(ev->event))) + /* Ignore leave with detail inferior (we were left for a window contained in + * our window, so technically the pointer is still inside of this window). + */ + if(ev->detail != XCB_NOTIFY_DETAIL_INFERIOR && (c = client_getbyframewin(ev->event))) { luaA_object_push(L, c); luaA_object_emit_signal(L, -1, "mouse::leave", 0); @@ -549,7 +552,12 @@ event_handle_enternotify(xcb_enter_notify_event_t *ev) if((c = client_getbyframewin(ev->event))) { luaA_object_push(L, c); - luaA_object_emit_signal(L, -1, "mouse::enter", 0); + /* Ignore enter with detail inferior: The pointer was previously inside + * of a child window, so technically this isn't a 'real' enter. + */ + 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) {