From 430f4fab15bb101b4af9fadbebb9a9bfa47ba9de Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 10 Jan 2016 19:27:55 +0100 Subject: [PATCH] Leave titlebars early When a client is unmanaged, we know emit mouse::leave on its titlebar before the client object is invalidated, so that Lua can still work with it. Before, this event was emitted only when we got a LeaveNotify from the X11 server. Fixes: #620 Signed-off-by: Uli Schlachter --- event.c | 2 +- event.h | 3 ++- objects/client.c | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/event.c b/event.c index 8bea60ca8..570f37c81 100644 --- a/event.c +++ b/event.c @@ -426,7 +426,7 @@ event_handle_destroynotify(xcb_destroy_notify_event_t *ev) /** Record that the given drawable contains the pointer. */ -static void +void event_drawable_under_mouse(lua_State *L, int ud) { void *d; diff --git a/event.h b/event.h index e1ce8fe84..61c60884a 100644 --- a/event.h +++ b/event.h @@ -48,7 +48,8 @@ awesome_refresh(void) return xcb_flush(globalconf.connection); } -void event_handle(xcb_generic_event_t *event); +void event_handle(xcb_generic_event_t *); +void event_drawable_under_mouse(lua_State *, int); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/objects/client.c b/objects/client.c index 244c5b098..5ce84f3fd 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1335,6 +1335,13 @@ client_unmanage(client_t *c, bool window_valid) if (c->titlebar[bar].drawable == NULL) continue; + if (globalconf.drawable_under_mouse == c->titlebar[bar].drawable) { + /* Leave drawable before we invalidate the client */ + lua_pushnil(L); + event_drawable_under_mouse(L, -1); + lua_pop(L, 1); + } + /* Forget about the drawable */ luaA_object_push(L, c); luaA_object_unref_item(L, -1, c->titlebar[bar].drawable);