awful.rules.execute: Make for loop easier to read
Signed-off-by: Uli Schlachter <uli.schlachter@informatik.uni-oldenburg.de>
This commit is contained in:
parent
fb8c70b07d
commit
79e16cf950
|
@ -211,7 +211,9 @@ end
|
||||||
-- @tab props Properties to apply.
|
-- @tab props Properties to apply.
|
||||||
-- @tab[opt] callbacks Callbacks to apply.
|
-- @tab[opt] callbacks Callbacks to apply.
|
||||||
function rules.execute(c, props, callbacks)
|
function rules.execute(c, props, callbacks)
|
||||||
|
local handle_later = { focus = true, switchtotag = true }
|
||||||
local switchtotag = props.switchtotag
|
local switchtotag = props.switchtotag
|
||||||
|
|
||||||
for property, value in pairs(props) do
|
for property, value in pairs(props) do
|
||||||
if property ~= "focus" and type(value) == "function" then
|
if property ~= "focus" and type(value) == "function" then
|
||||||
value = value(c)
|
value = value(c)
|
||||||
|
@ -231,15 +233,14 @@ function rules.execute(c, props, callbacks)
|
||||||
local geo = c:geometry();
|
local geo = c:geometry();
|
||||||
geo[property] = value
|
geo[property] = value
|
||||||
c:geometry(geo);
|
c:geometry(geo);
|
||||||
elseif property == "focus" or property == "switchtotag" then
|
elseif not handle_later[property] then
|
||||||
-- This will be handled below
|
if type(c[property]) == "function" then
|
||||||
(function() end)() -- I haven't found a nice way to silence luacheck here
|
|
||||||
elseif type(c[property]) == "function" then
|
|
||||||
c[property](c, value)
|
c[property](c, value)
|
||||||
else
|
else
|
||||||
c[property] = value
|
c[property] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Only do this after the tag has been (possibly) set
|
-- Only do this after the tag has been (possibly) set
|
||||||
if switchtotag and c.first_tag then
|
if switchtotag and c.first_tag then
|
||||||
|
|
Loading…
Reference in New Issue