awful.rules: Implement callbacks for individual properties
When a property is now set to a function, the function's return value will be used for the value of the property. The function gets the new client as its only argument. There is no property which accepts a function as its value and thus this change can't break anything (yeah, famous last words...). This should fix half of FS#1011. Panels now don't get focused by awful.rules. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
29b09cf7da
commit
48c6c11d17
|
@ -334,7 +334,7 @@ awful.rules.rules = {
|
||||||
{ rule = { },
|
{ rule = { },
|
||||||
properties = { border_width = beautiful.border_width,
|
properties = { border_width = beautiful.border_width,
|
||||||
border_color = beautiful.border_normal,
|
border_color = beautiful.border_normal,
|
||||||
focus = true,
|
focus = awful.client.focus.filter,
|
||||||
keys = clientkeys,
|
keys = clientkeys,
|
||||||
buttons = clientbuttons } },
|
buttons = clientbuttons } },
|
||||||
{ rule = { class = "MPlayer" },
|
{ rule = { class = "MPlayer" },
|
||||||
|
|
|
@ -65,6 +65,8 @@ local rules = {}
|
||||||
-- <p>If a client matches multiple rules, their applied in the order they are
|
-- <p>If a client matches multiple rules, their applied in the order they are
|
||||||
-- put in this global rules table. If the value of a rule is a string, then the
|
-- put in this global rules table. If the value of a rule is a string, then the
|
||||||
-- match function is used to determine if the client matches the rule.</p>
|
-- match function is used to determine if the client matches the rule.</p>
|
||||||
|
-- <p>If the value of a property is a function, that function gets called and
|
||||||
|
-- function's return value is used for the property.</p>
|
||||||
--
|
--
|
||||||
-- <p> To match multiple clients to a rule one need to use slightly different
|
-- <p> To match multiple clients to a rule one need to use slightly different
|
||||||
-- syntax:
|
-- syntax:
|
||||||
|
@ -165,6 +167,9 @@ function rules.apply(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
for property, value in pairs(props) do
|
for property, value in pairs(props) do
|
||||||
|
if property ~= "focus" and type(value) == "function" then
|
||||||
|
value = value(c)
|
||||||
|
end
|
||||||
if property == "floating" then
|
if property == "floating" then
|
||||||
aclient.floating.set(c, value)
|
aclient.floating.set(c, value)
|
||||||
elseif property == "tag" then
|
elseif property == "tag" then
|
||||||
|
@ -198,7 +203,7 @@ function rules.apply(c)
|
||||||
|
|
||||||
-- Do this at last so we do not erase things done by the focus
|
-- Do this at last so we do not erase things done by the focus
|
||||||
-- signal.
|
-- signal.
|
||||||
if props.focus then
|
if props.focus and (type(props.focus) ~= "function" or props.focus(c)) then
|
||||||
client.focus = c
|
client.focus = c
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue