[client] Add a hook on urgent flag

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-05-28 11:08:48 +02:00
parent 83470a99e8
commit ebb56ce6b1
3 changed files with 21 additions and 2 deletions

View File

@ -666,11 +666,13 @@ client_updatewmhints(client_t *c)
if((wmh = xcb_get_wm_hints(globalconf.connection, c->win))) if((wmh = xcb_get_wm_hints(globalconf.connection, c->win)))
{ {
const uint32_t wm_hints_flags = xcb_wm_hints_get_flags(wmh); const uint32_t wm_hints_flags = xcb_wm_hints_get_flags(wmh);
if((c->isurgent = ((wm_hints_flags & XCB_WM_X_URGENCY_HINT) && if((c->isurgent = (wm_hints_flags & XCB_WM_X_URGENCY_HINT)))
globalconf.focus->client != c)))
{ {
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
titlebar_draw(c); titlebar_draw(c);
/* execute hook */
luaA_client_userdata_new(c);
luaA_dofunction(globalconf.L, globalconf.hooks.urgent, 1);
} }
if((wm_hints_flags & XCB_WM_STATE_HINT) && if((wm_hints_flags & XCB_WM_STATE_HINT) &&
(xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE)) (xcb_wm_hints_get_initial_state(wmh) == XCB_WM_WITHDRAWN_STATE))

15
lua.c
View File

@ -360,6 +360,20 @@ luaA_hooks_titleupdate(lua_State *L)
return 0; return 0;
} }
/** Set the function called when a client get urgency flag. This function is called with
* the client object as argument.
* \param A function to call when a client get the urgent flag.
*/
static int
luaA_hooks_urgent(lua_State *L)
{
luaA_checkfunction(L, 1);
if(globalconf.hooks.urgent)
luaL_unref(L, LUA_REGISTRYINDEX, globalconf.hooks.urgent);
globalconf.hooks.urgent = luaL_ref(L, LUA_REGISTRYINDEX);
return 0;
}
/** Set default font. /** Set default font.
* \param A string with a font name in Pango format. * \param A string with a font name in Pango format.
*/ */
@ -439,6 +453,7 @@ luaA_parserc(const char *rcfile)
{ "mouseover", luaA_hooks_mouseover }, { "mouseover", luaA_hooks_mouseover },
{ "arrange", luaA_hooks_arrange }, { "arrange", luaA_hooks_arrange },
{ "titleupdate", luaA_hooks_titleupdate }, { "titleupdate", luaA_hooks_titleupdate },
{ "urgent", luaA_hooks_urgent },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -429,6 +429,8 @@ struct awesome_t
luaA_function arrange; luaA_function arrange;
/** Command to run on title change */ /** Command to run on title change */
luaA_function titleupdate; luaA_function titleupdate;
/** Command to run on urgent flag */
luaA_function urgent;
} hooks; } hooks;
}; };