At 1257599734 time_t, Thomas Brunko wrote:
> +
> +--- This table contains the methods to set individual properties.
> +-- <p>The order of properties in the table defines the order in which
> +-- they're set on the client.
> +-- All 'method = nil' properties will be set by using 'client[...] = value'.
> +-- The method for 'focus' will always be called as the last method.
> +-- <br/>
> +-- <code>
> +-- methods = {<br/>
> +-- ...<br/>
> +-- { property = "sticky", method = nil },<br/>
> +-- { property = "tag", method = function(client,value)
> awful.client.movetotag(value, client) end},<br/>
> +-- ...<br/>
> +-- }
> +-- </code>
> +--
> +-- @name methods_default
> +-- @class table
> +
> +methods_default = {
> + { property = "visible", method = nil },
> + { property = "floating", method = function(c,v)
> aclient.floating.set(c,v) end},
> + { property = "size_hints_honor", method = nil },
> + { property = "maximized", method = function(c,v)
> c.maximized_horizontal = v ; c.maximized_vertical = v ; end},
> + { property = "fullscreen", method = nil },
> + { property = "height", method = function(c,v) local geo =
> c:geometry(); geo["height"] = v ; c:geometry(geo); end},
> + { property = "width", method = function(c,v) local geo =
> c:geometry(); geo["width"] = v ; c:geometry(geo); end},
> + { property = "x", method = function(c,v) local geo =
> c:geometry(); geo["x"] = v ; c:geometry(geo); end},
> + { property = "y", method = function(c,v) local geo =
> c:geometry(); geo["y"] = v ; c:geometry(geo); end},
> + { property = "ontop", method = nil },
> + { property = "above", method = nil },
> + { property = "below", method = nil },
> + { property = "normal", method = nil },
> + { property = "desktop", method = nil },
> + { property = "ignore", method = nil },
> + { property = "sticky", method = nil },
> + { property = "tag", method = function(c,v)
> aclient.movetotag(v, c) end},
> + { property = "slave", method = function(c,v)
> aclient.setslave(c) end},
> + { property = "screen", method = nil },
> + { property = "switchtotag", method = function(c,v)
> atag.viewonly(props.tag) end},
> + { property = "focus", method = function(c,v) if v then
> client.focus = c end end},
> +}
Setting method = nil is useless.
And then listing client property a second time (ontop, above…,) for
nothing seems like a bad idea to me.
> +
> +--- This is the user defined set of methods.
> +-- <p>A user can create his own methods by copying the variable
> +-- 'awful.rules.methods_default' into 'awful.rules.methods' and append/insert
> +-- his own methods.
> +--
> +-- @class table
> +-- @name methods
> +
> +methods = nil
> +
You don't need 2 differents tables, If you expose methods_default to the
user, like you did, then it can modify it so methods is kinda useless.
> --- This is the global rules table.
> -- <p>You should fill this table with your rule and properties to apply.
> -- For example, if you want to set xterm maximized at startup, you can add:
> @@ -53,10 +106,12 @@ module("awful.rules")
> -- 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>
> --
> --- @class table
> -- @name rules
> +-- @class table
> +
> rules = {}
>
> +
Garbage change?
> --- Check if a client match a rule.
> -- @param c The client.
> -- @param rule The rule to check.
> @@ -90,28 +145,42 @@ function apply(c)
> end
> end
>
> - for property, value in pairs(props) do
> - if property == "floating" then
> - aclient.floating.set(c, value)
> - elseif property == "tag" then
> - aclient.movetotag(value, c)
> - elseif property == "switchtotag" and value and props.tag then
> - atag.viewonly(props.tag)
> - elseif property == "height" or property == "width" or
> - property == "x" or property == "y" then
> - local geo = c:geometry();
> - geo[property] = value
> - c:geometry(geo);
> - elseif type(c[property]) == "function" then
> - c[property](c, value)
> + local methods = methods or methods_default
> + local focus
> +
> + -- iterate over all methods and remove the
> + -- processed ones from 'props'.
> + for i, a in pairs(methods) do
> + if a.property ~= "focus" then
Please chose more obvious variable name.
for _, method in pairs(methods) do
seems more likely to be helpful. :)
> + if props[a.property] ~= nil then
> + if a.method then
> + a.method(c, props[a.property])
> + else
> + c[a.property] = props[a.property]
You set value...
> + end
> + props[a.property] = nil
> + end
> else
> - c[property] = value
> + focus = a.method
> end
> end
> +
> + -- iterate over all methods from 'props' not
> + -- found in our property list
> + for property, value in pairs(props) do
> + if property ~= "focus" then
> + if type(c[property]) == "function" then
> + c[property](c, value)
> + else
> + c[property] = value
And you set value again here? Or do I miss something? (can happen, it's
Sunday).
Cheers,
--
Julien Danjou
// ᐰ <[email protected]> http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD
// Anna Molly! Anna Molly! Anna Molly!
signature.asc
Description: Digital signature
