hooks: add clients hook
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1f4df91c30
commit
ba66ae8035
26
client.c
26
client.c
|
@ -456,8 +456,8 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
|||
}
|
||||
|
||||
/* Push client in client list */
|
||||
client_list_push(&globalconf.clients, c);
|
||||
client_ref(&c);
|
||||
client_list_push(&globalconf.clients, client_ref(&c));
|
||||
|
||||
/* Push client in stack */
|
||||
client_raise(c);
|
||||
|
||||
|
@ -470,6 +470,9 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
|||
ewmh_update_net_client_list(c->phys_screen);
|
||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||
|
||||
/* Call hook to notify list change */
|
||||
luaA_dofunction(globalconf.L, globalconf.hooks.clients, 0, 0);
|
||||
|
||||
/* call hook */
|
||||
luaA_client_userdata_new(globalconf.L, c);
|
||||
luaA_dofunction(globalconf.L, globalconf.hooks.manage, 1, 0);
|
||||
|
@ -815,10 +818,19 @@ client_unmanage(client_t *c)
|
|||
if(globalconf.screens[c->phys_screen].client_focus == c)
|
||||
client_unfocus(c);
|
||||
|
||||
/* remove client everywhere */
|
||||
client_list_detach(&globalconf.clients, c);
|
||||
stack_client_delete(c);
|
||||
for(int i = 0; i < tags->len; i++)
|
||||
untag_client(c, tags->tab[i]);
|
||||
|
||||
/* call hook */
|
||||
luaA_client_userdata_new(globalconf.L, c);
|
||||
luaA_dofunction(globalconf.L, globalconf.hooks.unmanage, 1, 0);
|
||||
|
||||
/* Call hook to notify list change */
|
||||
luaA_dofunction(globalconf.L, globalconf.hooks.clients, 0, 0);
|
||||
|
||||
/* The server grab construct avoids race conditions. */
|
||||
xcb_grab_server(globalconf.connection);
|
||||
|
||||
|
@ -833,12 +845,6 @@ client_unmanage(client_t *c)
|
|||
xcb_flush(globalconf.connection);
|
||||
xcb_ungrab_server(globalconf.connection);
|
||||
|
||||
/* remove client everywhere */
|
||||
client_list_detach(&globalconf.clients, c);
|
||||
stack_client_delete(c);
|
||||
for(int i = 0; i < tags->len; i++)
|
||||
untag_client(c, tags->tab[i]);
|
||||
|
||||
titlebar_client_detach(c);
|
||||
|
||||
ewmh_update_net_client_list(c->phys_screen);
|
||||
|
@ -1035,6 +1041,10 @@ luaA_client_swap(lua_State *L)
|
|||
client_need_arrange(*swap);
|
||||
widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS);
|
||||
widget_invalidate_cache((*swap)->screen, WIDGET_CACHE_CLIENTS);
|
||||
|
||||
/* Call hook to notify list change */
|
||||
luaA_dofunction(L, globalconf.hooks.clients, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
15
luaa.c
15
luaa.c
|
@ -218,6 +218,19 @@ luaA_hooks_mouse_over(lua_State *L)
|
|||
return luaA_hooks_mouse_enter(L);
|
||||
}
|
||||
|
||||
/** Set the function called on each client list change.
|
||||
* This function is called without any argument.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
* \lparam A function to call on each client list change.
|
||||
*/
|
||||
static int
|
||||
luaA_hooks_clients(lua_State *L)
|
||||
{
|
||||
return luaA_registerfct(L, 1, &globalconf.hooks.clients);
|
||||
}
|
||||
|
||||
/** Set the function called on each screen arrange. This function is called
|
||||
* with the screen number as argument.
|
||||
* \param L The Lua VM state.
|
||||
|
@ -611,6 +624,7 @@ luaA_init(void)
|
|||
{ "mouse_enter", luaA_hooks_mouse_enter },
|
||||
{ "property", luaA_hooks_property },
|
||||
{ "arrange", luaA_hooks_arrange },
|
||||
{ "clients", luaA_hooks_clients },
|
||||
{ "timer", luaA_hooks_timer },
|
||||
/* deprecated */
|
||||
{ "mouse_over", luaA_hooks_mouse_over },
|
||||
|
@ -686,6 +700,7 @@ luaA_init(void)
|
|||
globalconf.hooks.unfocus = LUA_REFNIL;
|
||||
globalconf.hooks.mouse_enter = LUA_REFNIL;
|
||||
globalconf.hooks.arrange = LUA_REFNIL;
|
||||
globalconf.hooks.clients = LUA_REFNIL;
|
||||
globalconf.hooks.property = LUA_REFNIL;
|
||||
globalconf.hooks.timer = LUA_REFNIL;
|
||||
}
|
||||
|
|
1
mouse.c
1
mouse.c
|
@ -551,6 +551,7 @@ mouse_client_move(client_t *c, int snap, bool infobox)
|
|||
{
|
||||
client_list_swap(&globalconf.clients, c, target);
|
||||
globalconf.screens[c->screen].need_arrange = true;
|
||||
luaA_dofunction(globalconf.L, globalconf.hooks.clients, 0, 0);
|
||||
layout_refresh();
|
||||
wibox_refresh();
|
||||
xcb_flush(globalconf.connection);
|
||||
|
|
Loading…
Reference in New Issue