client: add mouse_leave hook
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2037a053a9
commit
26de388c4c
1
client.c
1
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_STRUCTURE_NOTIFY
|
||||||
| XCB_EVENT_MASK_PROPERTY_CHANGE
|
| XCB_EVENT_MASK_PROPERTY_CHANGE
|
||||||
| XCB_EVENT_MASK_ENTER_WINDOW
|
| XCB_EVENT_MASK_ENTER_WINDOW
|
||||||
|
| XCB_EVENT_MASK_LEAVE_WINDOW
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
26
event.c
26
event.c
|
@ -459,17 +459,29 @@ event_handle_leavenotify(void *data __attribute__ ((unused)),
|
||||||
xcb_connection_t *connection,
|
xcb_connection_t *connection,
|
||||||
xcb_leave_notify_event_t *ev)
|
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_client_userdata_new(globalconf.L, c);
|
||||||
luaA_wibox_userdata_new(globalconf.L, wibox);
|
luaA_dofunction(globalconf.L, globalconf.hooks.mouse_leave, 1, 0);
|
||||||
luaA_dofunction(globalconf.L, wibox->mouse_over->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;
|
return 0;
|
||||||
|
|
16
hooks.c
16
hooks.c
|
@ -83,7 +83,7 @@ luaA_hooks_unmanage(lua_State *L)
|
||||||
HANDLE_HOOK(L, globalconf.hooks.unmanage);
|
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.
|
* function is called with the client object as argument.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \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);
|
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.
|
/** Set the function called on each client list change.
|
||||||
* This function is called without any argument.
|
* This function is called without any argument.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
|
@ -215,6 +228,7 @@ const struct luaL_reg awesome_hooks_lib[] =
|
||||||
{ "manage", luaA_hooks_manage },
|
{ "manage", luaA_hooks_manage },
|
||||||
{ "unmanage", luaA_hooks_unmanage },
|
{ "unmanage", luaA_hooks_unmanage },
|
||||||
{ "mouse_enter", luaA_hooks_mouse_enter },
|
{ "mouse_enter", luaA_hooks_mouse_enter },
|
||||||
|
{ "mouse_leave", luaA_hooks_mouse_leave },
|
||||||
{ "property", luaA_hooks_property },
|
{ "property", luaA_hooks_property },
|
||||||
{ "arrange", luaA_hooks_arrange },
|
{ "arrange", luaA_hooks_arrange },
|
||||||
{ "clients", luaA_hooks_clients },
|
{ "clients", luaA_hooks_clients },
|
||||||
|
|
1
luaa.c
1
luaa.c
|
@ -820,6 +820,7 @@ luaA_init(void)
|
||||||
globalconf.hooks.focus = LUA_REFNIL;
|
globalconf.hooks.focus = LUA_REFNIL;
|
||||||
globalconf.hooks.unfocus = LUA_REFNIL;
|
globalconf.hooks.unfocus = LUA_REFNIL;
|
||||||
globalconf.hooks.mouse_enter = LUA_REFNIL;
|
globalconf.hooks.mouse_enter = LUA_REFNIL;
|
||||||
|
globalconf.hooks.mouse_leave = LUA_REFNIL;
|
||||||
globalconf.hooks.arrange = LUA_REFNIL;
|
globalconf.hooks.arrange = LUA_REFNIL;
|
||||||
globalconf.hooks.clients = LUA_REFNIL;
|
globalconf.hooks.clients = LUA_REFNIL;
|
||||||
globalconf.hooks.tags = LUA_REFNIL;
|
globalconf.hooks.tags = LUA_REFNIL;
|
||||||
|
|
|
@ -350,6 +350,8 @@ struct awesome_t
|
||||||
luaA_ref unfocus;
|
luaA_ref unfocus;
|
||||||
/** Command to run when mouse enter a client */
|
/** Command to run when mouse enter a client */
|
||||||
luaA_ref mouse_enter;
|
luaA_ref mouse_enter;
|
||||||
|
/** Command to run when mouse leave a client */
|
||||||
|
luaA_ref mouse_leave;
|
||||||
/** Command to run on arrange */
|
/** Command to run on arrange */
|
||||||
luaA_ref arrange;
|
luaA_ref arrange;
|
||||||
/** Command to run when client list changes */
|
/** Command to run when client list changes */
|
||||||
|
|
Loading…
Reference in New Issue