[hooks] Rename newclient to `manage', add unmanage hook
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
77fc1cb503
commit
4573147196
|
@ -203,7 +203,7 @@ function hook_mouseover(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hook function to execute when a new client appears.
|
-- Hook function to execute when a new client appears.
|
||||||
function hook_newclient(c)
|
function hook_manage(c)
|
||||||
-- New client may not receive focus
|
-- New client may not receive focus
|
||||||
-- if they're not focusable, so set border anyway.
|
-- if they're not focusable, so set border anyway.
|
||||||
c:border_set({ width = 1, color = "black" })
|
c:border_set({ width = 1, color = "black" })
|
||||||
|
@ -231,7 +231,7 @@ end
|
||||||
-- Set up some hooks
|
-- Set up some hooks
|
||||||
awful.hooks.focus(hook_focus)
|
awful.hooks.focus(hook_focus)
|
||||||
awful.hooks.unfocus(hook_unfocus)
|
awful.hooks.unfocus(hook_unfocus)
|
||||||
awful.hooks.newclient(hook_newclient)
|
awful.hooks.manage(hook_manage)
|
||||||
awful.hooks.mouseover(hook_mouseover)
|
awful.hooks.mouseover(hook_mouseover)
|
||||||
awful.hooks.arrange(hook_arrange)
|
awful.hooks.arrange(hook_arrange)
|
||||||
awful.hooks.timer(1, hook_timer)
|
awful.hooks.timer(1, hook_timer)
|
||||||
|
|
6
client.c
6
client.c
|
@ -414,7 +414,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int screen)
|
||||||
|
|
||||||
/* call hook */
|
/* call hook */
|
||||||
luaA_client_userdata_new(c);
|
luaA_client_userdata_new(c);
|
||||||
luaA_dofunction(globalconf.L, globalconf.hooks.newclient, 1);
|
luaA_dofunction(globalconf.L, globalconf.hooks.manage, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static area_t
|
static area_t
|
||||||
|
@ -629,6 +629,10 @@ client_unmanage(client_t *c)
|
||||||
{
|
{
|
||||||
tag_t *tag;
|
tag_t *tag;
|
||||||
|
|
||||||
|
/* call hook */
|
||||||
|
luaA_client_userdata_new(c);
|
||||||
|
luaA_dofunction(globalconf.L, globalconf.hooks.unmanage, 1);
|
||||||
|
|
||||||
/* The server grab construct avoids race conditions. */
|
/* The server grab construct avoids race conditions. */
|
||||||
xcb_grab_server(globalconf.connection);
|
xcb_grab_server(globalconf.connection);
|
||||||
|
|
||||||
|
|
37
lua.c
37
lua.c
|
@ -251,16 +251,38 @@ luaA_hooks_unfocus(lua_State *L)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the function called each time a new client appears. This function is
|
/** Set the function called each time a new client appears. This function is
|
||||||
* called with the client object as argument
|
* called with the client object as argument.
|
||||||
* \param A function to call on each new client.
|
* \param L The Lua VM state.
|
||||||
|
*
|
||||||
|
* \luastack
|
||||||
|
*
|
||||||
|
* \lparam A function to call on each new client.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_hooks_newclient(lua_State *L)
|
luaA_hooks_manage(lua_State *L)
|
||||||
{
|
{
|
||||||
luaA_checkfunction(L, 1);
|
luaA_checkfunction(L, 1);
|
||||||
if(globalconf.hooks.newclient)
|
if(globalconf.hooks.manage)
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.newclient);
|
luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.manage);
|
||||||
globalconf.hooks.newclient = luaL_ref(L, LUA_REGISTRYINDEX);
|
globalconf.hooks.manage = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set the function called each time a client goes away. This function is
|
||||||
|
* called with the client object as argument.
|
||||||
|
* \param L The Lua VM state.
|
||||||
|
*
|
||||||
|
* \luastack
|
||||||
|
*
|
||||||
|
* \lparam A function to call on each new client.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
luaA_hooks_unmanage(lua_State *L)
|
||||||
|
{
|
||||||
|
luaA_checkfunction(L, 1);
|
||||||
|
if(globalconf.hooks.unmanage)
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.unmanage);
|
||||||
|
globalconf.hooks.unmanage = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,7 +456,8 @@ luaA_init(void)
|
||||||
{
|
{
|
||||||
{ "focus", luaA_hooks_focus },
|
{ "focus", luaA_hooks_focus },
|
||||||
{ "unfocus", luaA_hooks_unfocus },
|
{ "unfocus", luaA_hooks_unfocus },
|
||||||
{ "newclient", luaA_hooks_newclient },
|
{ "manage", luaA_hooks_manage },
|
||||||
|
{ "unmanage", luaA_hooks_unmanage },
|
||||||
{ "mouseover", luaA_hooks_mouseover },
|
{ "mouseover", luaA_hooks_mouseover },
|
||||||
{ "arrange", luaA_hooks_arrange },
|
{ "arrange", luaA_hooks_arrange },
|
||||||
{ "titleupdate", luaA_hooks_titleupdate },
|
{ "titleupdate", luaA_hooks_titleupdate },
|
||||||
|
|
|
@ -426,7 +426,9 @@ struct awesome_t
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/** Command to execute when spawning a new client */
|
/** Command to execute when spawning a new client */
|
||||||
luaA_function newclient;
|
luaA_function manage;
|
||||||
|
/** Command to execute when unmanaging client */
|
||||||
|
luaA_function unmanage;
|
||||||
/** Command to execute when giving focus to a client */
|
/** Command to execute when giving focus to a client */
|
||||||
luaA_function focus;
|
luaA_function focus;
|
||||||
/** Command to execute when removing focus to a client */
|
/** Command to execute when removing focus to a client */
|
||||||
|
|
Loading…
Reference in New Issue