diff --git a/awesomerc.lua.in b/awesomerc.lua.in index d0c3c27b..e39b2b1c 100644 --- a/awesomerc.lua.in +++ b/awesomerc.lua.in @@ -406,9 +406,8 @@ awful.hooks.manage.register(function (c, startup) -- c.size_hints_honor = false end) --- Hook function to execute when arranging the screen. --- (tag switch, new client, etc) -awful.hooks.arrange.register(function (screen) +-- Hook function to execute when switching tag selection. +awful.hooks.tags.register(function (screen, tag, view) local layout = awful.layout.getname(awful.layout.get(screen)) if layout and beautiful["layout_" ..layout] then 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 -- 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) if c then client.focus = c end end diff --git a/hooks.c b/hooks.c index af8e51a3..7ca241f8 100644 --- a/hooks.c +++ b/hooks.c @@ -123,7 +123,8 @@ luaA_hooks_clients(lua_State *L) /** Set the function called on each screen tag list change. * 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. * \return The number of elements pushed on stack. * \luastack diff --git a/tag.c b/tag.c index 96589d5e..8b779d46 100644 --- a/tag.c +++ b/tag.c @@ -54,10 +54,22 @@ luaA_tag_gc(lua_State *L) static void tag_view(tag_t *tag, bool view) { + int screen_index = screen_array_indexof(&globalconf.screens, tag->screen); + tag->selected = view; - ewmh_update_net_current_desktop(screen_virttophys(screen_array_indexof(&globalconf.screens, - tag->screen))); 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.