client: Simplify screen selection decision tree.
This commit remove the `awful.tag` "manage" hook. The relevant code has been moved to ewmh.lua request::tag handler. The handler is called either by a volontary screen change or by a forced one. It also require the awful.rules to be executed. This is done by default and the user would have to explicitly disable that behavior. From now on, disabling the rules require the user to handle tag selection. Fixes #1028 #1052
This commit is contained in:
parent
abb36c3697
commit
21787444e4
|
@ -122,20 +122,41 @@ function ewmh.activate(c, context, hints) -- luacheck: no unused args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get tags that are on the same screen as the client. This should _almost_
|
||||||
|
-- always return the same content as c:tags().
|
||||||
|
local function get_valid_tags(c, s)
|
||||||
|
local tags, new_tags = c:tags(), {}
|
||||||
|
|
||||||
|
for _, t in ipairs(tags) do
|
||||||
|
if screen[s] == t.screen then
|
||||||
|
table.insert(new_tags, t)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return new_tags
|
||||||
|
end
|
||||||
|
|
||||||
--- Tag a window with its requested tag.
|
--- Tag a window with its requested tag.
|
||||||
--
|
--
|
||||||
-- It is the default signal handler for `request::tag` on a `client`.
|
-- It is the default signal handler for `request::tag` on a `client`.
|
||||||
--
|
--
|
||||||
-- @signalhandler awful.ewmh.tag
|
-- @signalhandler awful.ewmh.tag
|
||||||
-- @client c A client to tag
|
-- @client c A client to tag
|
||||||
-- @tag[opt] t A tag to use. If omitted, then the client is made sticky.
|
-- @tparam[opt] tag|boolean t A tag to use. If true, then the client is made sticky.
|
||||||
-- @tparam[opt={}] table hints Extra information
|
-- @tparam[opt={}] table hints Extra information
|
||||||
function ewmh.tag(c, t, hints) --luacheck: no unused
|
function ewmh.tag(c, t, hints) --luacheck: no unused
|
||||||
-- There is nothing to do
|
-- There is nothing to do
|
||||||
if not t and #c:tags() > 0 then return end
|
if not t and #get_valid_tags(c, c.screen) > 0 then return end
|
||||||
|
|
||||||
if not t then
|
if not t then
|
||||||
|
if c.transient_for then
|
||||||
|
c.screen = c.transient_for.screen
|
||||||
|
if not c.sticky then
|
||||||
|
c:tags(c.transient_for:tags())
|
||||||
|
end
|
||||||
|
else
|
||||||
c:to_selected_tags()
|
c:to_selected_tags()
|
||||||
|
end
|
||||||
elseif type(t) == "boolean" and t then
|
elseif type(t) == "boolean" and t then
|
||||||
c.sticky = true
|
c.sticky = true
|
||||||
else
|
else
|
||||||
|
|
|
@ -12,6 +12,7 @@ local util = require("awful.util")
|
||||||
local ascreen = require("awful.screen")
|
local ascreen = require("awful.screen")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
|
local timer = require("gears.timer")
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local table = table
|
local table = table
|
||||||
|
@ -1277,21 +1278,25 @@ function tag.attached_connect_signal(screen, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register standard signals.
|
-- Register standard signals.
|
||||||
capi.client.connect_signal("manage", function(c)
|
capi.client.connect_signal("property::screen", function(c)
|
||||||
-- If we are not managing this application at startup,
|
-- First, the delayed timer is necessary to avoid a race condition with
|
||||||
-- move it to the screen where the mouse is.
|
-- awful.rules. It is also messing up the tags before the user have a chance
|
||||||
-- We only do it for "normal" windows (i.e. no dock, etc).
|
-- to set them manually.
|
||||||
if not awesome.startup and c.type ~= "desktop" and c.type ~= "dock" then
|
timer.delayed_call(function()
|
||||||
if c.transient_for then
|
local tags, new_tags = c:tags(), {}
|
||||||
c.screen = c.transient_for.screen
|
|
||||||
if not c.sticky then
|
for _, t in ipairs(tags) do
|
||||||
c:tags(c.transient_for:tags())
|
if t.screen == c.screen then
|
||||||
end
|
table.insert(new_tags, t)
|
||||||
else
|
|
||||||
c.screen = ascreen.focused()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
c:connect_signal("property::screen", function() c:to_selected_tags() end)
|
|
||||||
|
if #new_tags == 0 then
|
||||||
|
c:emit_signal("request::tag", nil, {reason="screen"})
|
||||||
|
elseif #new_tags < #tags then
|
||||||
|
c:tags(new_tags)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Keep track of the number of urgent clients.
|
-- Keep track of the number of urgent clients.
|
||||||
|
|
Loading…
Reference in New Issue