activate: Add `switch_tag_tag` and `switch_to_tags`.

Also bring some consistency with `awful.rules` naming. A future commit
will add a `TODO v5` to resolve this naming issue.
This commit is contained in:
Emmanuel Lepage Vallee 2018-10-01 16:09:47 -04:00
parent 9e45e016e9
commit 9250610a77
1 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@ local aplace = require("awful.placement")
local asuit = require("awful.layout.suit") local asuit = require("awful.layout.suit")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local alayout = require("awful.layout") local alayout = require("awful.layout")
local atag = require("awful.tag")
local ewmh = { local ewmh = {
generic_activate_filters = {}, generic_activate_filters = {},
@ -83,6 +84,10 @@ end
-- @tparam string context The context where this signal was used. -- @tparam string context The context where this signal was used.
-- @tparam[opt] table hints A table with additional hints: -- @tparam[opt] table hints A table with additional hints:
-- @tparam[opt=false] boolean hints.raise should the client be raised? -- @tparam[opt=false] boolean hints.raise should the client be raised?
-- @tparam[opt=false] boolean hints.switch_to_tag should the client's first tag
-- be selected if none of the client's tags are selected?
-- @tparam[opt=false] boolean hints.switch_to_tags Select all tags associated
-- with the client.
function ewmh.activate(c, context, hints) -- luacheck: no unused args function ewmh.activate(c, context, hints) -- luacheck: no unused args
hints = hints or {} hints = hints or {}
@ -121,12 +126,18 @@ function ewmh.activate(c, context, hints) -- luacheck: no unused args
return return
end end
if hints and hints.raise then if hints.raise then
c:raise() c:raise()
if not awesome.startup and not c:isvisible() then if not awesome.startup and not c:isvisible() then
c.urgent = true c.urgent = true
end end
end end
-- The rules use `switchtotag`. For consistency and code re-use, support it,
-- but keep undocumented.
if hints.switchtotag or hints.switch_to_tag or hints.switch_to_tags then
atag.viewmore(c:tags(), c.screen, (not hints.switch_to_tags) and 0 or nil)
end
end end
--- Add an activate (focus stealing) filter function. --- Add an activate (focus stealing) filter function.