tag: add a hook for tag on select/unselect
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
87c56359bc
commit
71c0ded940
|
@ -406,9 +406,8 @@ awful.hooks.manage.register(function (c, startup)
|
||||||
-- c.size_hints_honor = false
|
-- c.size_hints_honor = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Hook function to execute when arranging the screen.
|
-- Hook function to execute when switching tag selection.
|
||||||
-- (tag switch, new client, etc)
|
awful.hooks.tags.register(function (screen, tag, view)
|
||||||
awful.hooks.arrange.register(function (screen)
|
|
||||||
local layout = awful.layout.getname(awful.layout.get(screen))
|
local layout = awful.layout.getname(awful.layout.get(screen))
|
||||||
if layout and beautiful["layout_" ..layout] then
|
if layout and beautiful["layout_" ..layout] then
|
||||||
mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
|
mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
|
||||||
|
@ -418,7 +417,7 @@ awful.hooks.arrange.register(function (screen)
|
||||||
|
|
||||||
-- Give focus to the latest client in history if no window has focus
|
-- Give focus to the latest client in history if no window has focus
|
||||||
-- or if the current window is a desktop or a dock one.
|
-- or if the current window is a desktop or a dock one.
|
||||||
if not client.focus then
|
if not client.focus or not client.focus:isvisible() then
|
||||||
local c = awful.client.focus.history.get(screen, 0)
|
local c = awful.client.focus.history.get(screen, 0)
|
||||||
if c then client.focus = c end
|
if c then client.focus = c end
|
||||||
end
|
end
|
||||||
|
|
3
hooks.c
3
hooks.c
|
@ -123,7 +123,8 @@ luaA_hooks_clients(lua_State *L)
|
||||||
|
|
||||||
/** Set the function called on each screen tag list change.
|
/** Set the function called on each screen tag list change.
|
||||||
* This function is called with a screen number as first argument,
|
* This function is called with a screen number as first argument,
|
||||||
* the tag object as second and the action (add or remove) as third.
|
* the tag object as second and the action (add, remove, select or unselect)
|
||||||
|
* as third.
|
||||||
* \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.
|
||||||
* \luastack
|
* \luastack
|
||||||
|
|
16
tag.c
16
tag.c
|
@ -54,10 +54,22 @@ luaA_tag_gc(lua_State *L)
|
||||||
static void
|
static void
|
||||||
tag_view(tag_t *tag, bool view)
|
tag_view(tag_t *tag, bool view)
|
||||||
{
|
{
|
||||||
|
int screen_index = screen_array_indexof(&globalconf.screens, tag->screen);
|
||||||
|
|
||||||
tag->selected = view;
|
tag->selected = view;
|
||||||
ewmh_update_net_current_desktop(screen_virttophys(screen_array_indexof(&globalconf.screens,
|
|
||||||
tag->screen)));
|
|
||||||
tag->screen->need_arrange = true;
|
tag->screen->need_arrange = true;
|
||||||
|
ewmh_update_net_current_desktop(screen_virttophys(screen_index));
|
||||||
|
|
||||||
|
if(globalconf.hooks.tags != LUA_REFNIL)
|
||||||
|
{
|
||||||
|
lua_pushnumber(globalconf.L, screen_index + 1);
|
||||||
|
tag_push(globalconf.L, tag);
|
||||||
|
if(view)
|
||||||
|
lua_pushliteral(globalconf.L, "select");
|
||||||
|
else
|
||||||
|
lua_pushliteral(globalconf.L, "unselect");
|
||||||
|
luaA_dofunction(globalconf.L, globalconf.hooks.tags, 3, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Append a tag which on top of the stack to a screen.
|
/** Append a tag which on top of the stack to a screen.
|
||||||
|
|
Loading…
Reference in New Issue