diff --git a/client.c b/client.c index babddda9..243da82f 100644 --- a/client.c +++ b/client.c @@ -445,6 +445,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW + | XCB_EVENT_MASK_LEAVE_WINDOW }; diff --git a/event.c b/event.c index 6c580422..17ce7a7b 100644 --- a/event.c +++ b/event.c @@ -459,17 +459,29 @@ event_handle_leavenotify(void *data __attribute__ ((unused)), xcb_connection_t *connection, xcb_leave_notify_event_t *ev) { - wibox_t *wibox = wibox_getbywin(ev->event); + wibox_t *wibox; + client_t *c = client_getbywin(ev->event); - if(wibox && wibox->mouse_over) + if(c) { - if(wibox->mouse_over->mouse_leave != LUA_REFNIL) + if(globalconf.hooks.mouse_leave != LUA_REFNIL) { - /* call mouse leave function on widget the mouse was over */ - luaA_wibox_userdata_new(globalconf.L, wibox); - luaA_dofunction(globalconf.L, wibox->mouse_over->mouse_leave, 1, 0); + luaA_client_userdata_new(globalconf.L, c); + luaA_dofunction(globalconf.L, globalconf.hooks.mouse_leave, 1, 0); + } + } + else if((wibox = wibox_getbywin(ev->event))) + { + if(wibox->mouse_over) + { + if(wibox->mouse_over->mouse_leave != LUA_REFNIL) + { + /* call mouse leave function on widget the mouse was over */ + luaA_wibox_userdata_new(globalconf.L, wibox); + luaA_dofunction(globalconf.L, wibox->mouse_over->mouse_leave, 1, 0); + } + wibox->mouse_over = NULL; } - wibox->mouse_over = NULL; } return 0; diff --git a/hooks.c b/hooks.c index 42611013..f3826c1f 100644 --- a/hooks.c +++ b/hooks.c @@ -83,7 +83,7 @@ luaA_hooks_unmanage(lua_State *L) HANDLE_HOOK(L, globalconf.hooks.unmanage); } -/** Set the function called each time the mouse enter a new window. This +/** Set the function called each time the mouse enter a window. This * function is called with the client object as argument. * \param L The Lua VM state. * \return The number of elements pushed on stack. @@ -96,6 +96,19 @@ luaA_hooks_mouse_enter(lua_State *L) HANDLE_HOOK(L, globalconf.hooks.mouse_enter); } +/** Set the function called each time the mouse leave a window. This + * function is called with the client object as argument. + * \param L The Lua VM state. + * \return The number of elements pushed on stack. + * \luastack + * \lparam A function to call each time a client gets mouse over it. + */ +static int +luaA_hooks_mouse_leave(lua_State *L) +{ + HANDLE_HOOK(L, globalconf.hooks.mouse_leave); +} + /** Set the function called on each client list change. * This function is called without any argument. * \param L The Lua VM state. @@ -215,6 +228,7 @@ const struct luaL_reg awesome_hooks_lib[] = { "manage", luaA_hooks_manage }, { "unmanage", luaA_hooks_unmanage }, { "mouse_enter", luaA_hooks_mouse_enter }, + { "mouse_leave", luaA_hooks_mouse_leave }, { "property", luaA_hooks_property }, { "arrange", luaA_hooks_arrange }, { "clients", luaA_hooks_clients }, diff --git a/luaa.c b/luaa.c index 6022a335..23cdb43b 100644 --- a/luaa.c +++ b/luaa.c @@ -820,6 +820,7 @@ luaA_init(void) globalconf.hooks.focus = LUA_REFNIL; globalconf.hooks.unfocus = LUA_REFNIL; globalconf.hooks.mouse_enter = LUA_REFNIL; + globalconf.hooks.mouse_leave = LUA_REFNIL; globalconf.hooks.arrange = LUA_REFNIL; globalconf.hooks.clients = LUA_REFNIL; globalconf.hooks.tags = LUA_REFNIL; diff --git a/structs.h b/structs.h index 92ab082e..f23b7872 100644 --- a/structs.h +++ b/structs.h @@ -350,6 +350,8 @@ struct awesome_t luaA_ref unfocus; /** Command to run when mouse enter a client */ luaA_ref mouse_enter; + /** Command to run when mouse leave a client */ + luaA_ref mouse_leave; /** Command to run on arrange */ luaA_ref arrange; /** Command to run when client list changes */