diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 9bf775ae..ae74a9f4 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1296,7 +1296,7 @@ end -- @staticfct awful.client.iterate -- @usage -- un-minimize all urxvt instances -- local urxvt = function (c) --- return awful.rules.match(c, {class = "URxvt"}) +-- return ruled.client.match(c, {class = "URxvt"}) -- end -- -- for c in awful.client.iterate(urxvt) do @@ -1326,7 +1326,7 @@ end -- @usage -- run or raise urxvt (perhaps, with tabs) on modkey + semicolon -- awful.key({ modkey, }, 'semicolon', function () -- local matcher = function (c) --- return awful.rules.match(c, {class = 'URxvt'}) +-- return ruled.client.match(c, {class = 'URxvt'}) -- end -- awful.client.run_or_raise('urxvt', matcher) -- end); diff --git a/lib/awful/spawn.lua b/lib/awful/spawn.lua index 2899636f..ff41e0ea 100644 --- a/lib/awful/spawn.lua +++ b/lib/awful/spawn.lua @@ -185,7 +185,7 @@ -- -- This should (if the program correctly implements the protocol) result in -- `c.startup_id` to at least match `something`. --- This identifier can then be used in `awful.rules` to configure the client. +-- This identifier can then be used in `ruled.client` to configure the client. -- -- Awesome can automatically set the `DESKTOP_STARTUP_ID` variable. This is used -- by `awful.spawn` to specify additional rules for the startup. For example: @@ -206,7 +206,7 @@ -- })' -- -- This table contains the client properties that are valid when used the --- `sn_rules` or `prop` function argument. They are the same as in `awful.rules`. +-- `sn_rules` or `prop` function argument. They are the same as in `ruled.client`. -- --@DOC_rules_index_COMMON@ -- @@ -334,7 +334,7 @@ end -- Applying properties or running a callback requires the program/client to -- support startup notifications. -- --- See `awful.rules.execute` for more details about the format of `sn_rules`. +-- See `ruled.client.execute` for more details about the format of `sn_rules`. -- -- @tparam string|table cmd The command. -- @tparam[opt=true] table|boolean sn_rules A table of properties to be applied @@ -636,7 +636,7 @@ end -- command and rules, you need to specify an UID or only the first one will be -- executed. -- --- The `rules` are standard `awful.rules`. +-- The `rules` are standard `ruled.client`. -- -- This function depends on the startup notification protocol to be correctly -- implemented by the command. See `client.startup_id` for more information. @@ -649,7 +649,7 @@ end -- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- multiple time. -- @tparam[opt] function callback A callback function when the client is created. --- @see awful.rules +-- @see ruled.client -- @staticfct awful.spawn.once function spawn.once(cmd, rules, matcher, unique_id, callback) local hash = unique_id or hash_command(cmd, rules) @@ -666,7 +666,7 @@ end -- This is like `awful.spawn.once`, but will spawn new instances if the previous -- has finished. -- --- The `rules` are standard `awful.rules`. +-- The `rules` are standard `ruled.client`. -- -- This function depends on the startup notification protocol to be correctly -- implemented by the command. See `client.startup_id` for more information. @@ -682,7 +682,7 @@ end -- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- multiple time. -- @tparam[opt] function callback A callback function when the client is created. --- @see awful.rules +-- @see ruled.client -- @staticfct awful.spawn.single_instance function spawn.single_instance(cmd, rules, matcher, unique_id, callback) local hash = unique_id or hash_command(cmd, rules) @@ -709,7 +709,7 @@ local raise_rules = {focus = true, switch_to_tags = true, raise = true} -- @tparam[opt] string unique_id A string to identify the client so it isn't executed -- multiple time. -- @tparam[opt] function callback A callback function when the client is created. --- @see awful.rules +-- @see ruled.client -- @treturn client The client if it already exists. -- @staticfct awful.spawn.raise_or_spawn -- @request client activate spawn.raise_or_spawn granted Activate a client when diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index fe831453..05f199f2 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -1684,8 +1684,8 @@ end -- Register standard signals. capi.client.connect_signal("property::screen", function(c) -- First, the delayed timer is necessary to avoid a race condition with - -- awful.rules. It is also messing up the tags before the user have a chance - -- to set them manually. + -- `ruled.client`. It is also messing up the tags before the user have a + -- chance to set them manually. timer.delayed_call(function() if not c.valid then return diff --git a/lib/gears/matcher.lua b/lib/gears/matcher.lua index 8bc9feac..a0ad4bb4 100644 --- a/lib/gears/matcher.lua +++ b/lib/gears/matcher.lua @@ -3,7 +3,7 @@ -- Sources -- ======= -- --- This module holds the business logic used by `awful.rules`. It provides an +-- This module holds the business logic used by `ruled.client`. It provides an -- object on which one can add sets of rules or, alternatively, functions. -- In this module, the sets of rules or custom functions are called sources. -- @@ -29,11 +29,11 @@ -- -- @DOC_text_gears_matcher_types_EXAMPLE@ -- --- More examples are available in `awful.rules`. +-- More examples are available in `ruled.client`. -- -- @author Julien Danjou <julien@danjou.info> -- @copyright 2009 Julien Danjou --- @see awful.rules +-- @see ruled.client -- @module gears.matcher local gtable = require("gears.table") @@ -445,7 +445,7 @@ function matcher:remove_matching_source(name) return false end ---- Apply awful.rules.rules to an object. +--- Apply ruled.client.rules to an object. -- -- Calling this will apply all properties provided by the matching functions -- and rules. diff --git a/objects/client.c b/objects/client.c index 4178235b..7856eb63 100644 --- a/objects/client.c +++ b/objects/client.c @@ -255,7 +255,7 @@ * (from `awful.client.focus.history.previous`). * * *menu.clients*: When using the builtin client menu * (from `awful.menu.clients`). - * * *rules*: When a new client is focused from a rule (from `awful.rules`). + * * *rules*: When a new client is focused from a rule (from `ruled.client`). * * *screen.focus*: When a screen is focused (from `awful.screen.focus`). * * Default implementation: `awful.ewmh.activate`. @@ -596,7 +596,7 @@ * multiple of the character size. Honoring size hints will cause the terminal * window to have a small gap at the bottom. * - * This is enabled by default. To disable it by default, see `awful.rules`. + * This is enabled by default. To disable it by default, see `ruled.client`. * * **Signal:** * @@ -946,8 +946,8 @@ * blacklisted_snid[snid] = c * end * - * awful.rules.add_rule_source( - * "snid", fix_startup_id, {}, {"awful.spawn", "awful.rules"} + * ruled.client.add_rule_source( + * "snid", fix_startup_id, {}, {"awful.spawn", "ruled.client"} * ) * * **Signal:** diff --git a/tests/_client.lua b/tests/_client.lua index f2b6eac1..31b9c618 100644 --- a/tests/_client.lua +++ b/tests/_client.lua @@ -1,7 +1,7 @@ local spawn = require("awful.spawn") -- This file provide a simple, yet flexible, test client. --- It is used to test the `awful.rules` +-- It is used to test the `ruled.client` local test_client_source = [[ pcall(require, 'luarocks.loader') diff --git a/tests/_runner.lua b/tests/_runner.lua index 5b357773..193348d7 100644 --- a/tests/_runner.lua +++ b/tests/_runner.lua @@ -1,7 +1,5 @@ local timer = require("gears.timer") -local awful = require("awful") local gtable = require("gears.table") -local gdebug = require("gears.debug") local runner = { quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1', @@ -9,21 +7,6 @@ local runner = { local verbose = os.getenv('VERBOSE') == '1' --- Helpers. - ---- Add some rules to awful.rules.rules, after the defaults. -local dep = gdebug.deprecate -gdebug.deprecate = function() end -local default_rules = gtable.clone(awful.rules.rules) -gdebug.deprecate = dep - -runner.add_to_default_rules = function(r) - gdebug.deprecate = function() end - awful.rules.rules = gtable.clone(default_rules) - table.insert(awful.rules.rules, r) - gdebug.deprecate = dep -end - -- Was the runner started already? local running = false diff --git a/tests/examples/awful/titlebar/default.lua b/tests/examples/awful/titlebar/default.lua index eaffd68c..f1347713 100644 --- a/tests/examples/awful/titlebar/default.lua +++ b/tests/examples/awful/titlebar/default.lua @@ -11,7 +11,7 @@ local c = client.gen_fake {hide_first=true} --DOC_HIDE place.maximize(c, {honor_padding=true, honor_workarea=true}) --DOC_HIDE -- Create a titlebar for the client. - -- By default, `awful.rules` will create one, but all it does is to call this + -- By default, `ruled.client` will create one, but all it does is to call this -- function. local top_titlebar = awful.titlebar(c, { diff --git a/tests/test-awful-client.lua b/tests/test-awful-client.lua index e69a7ca0..7c7c80da 100644 --- a/tests/test-awful-client.lua +++ b/tests/test-awful-client.lua @@ -1,5 +1,7 @@ local awful = require("awful") local test_client = require("_client") +local cruled = require("ruled.client") +local gdebug = require("gears.debug") local has_spawned = false local steps = { @@ -177,7 +179,10 @@ end) local has_error -- Disable awful.screen.preferred(c) -awful.rules.rules[1].properties.screen = nil +local dep = gdebug.deprecate +gdebug.deprecate = function() end +cruled.rules[1].properties.screen = nil +gdebug.deprecate = dep table.insert(steps, function() -- Make sure there is no extra callbacks that causes double screen changes diff --git a/tests/test-awful-placement.lua b/tests/test-awful-placement.lua index 6aedf95c..007766de 100644 --- a/tests/test-awful-placement.lua +++ b/tests/test-awful-placement.lua @@ -1,6 +1,7 @@ local awful = require("awful") local test_client = require("_client") local runner = require("_runner") +local cruled = require("ruled.client") -- This test makes some assumptions about the no_overlap behavior which may not -- be correct if the screen is in the portrait orientation. @@ -27,7 +28,8 @@ local rule = { placement = awful.placement.no_overlap + awful.placement.no_offscreen } } -table.insert(awful.rules.rules, rule) + +cruled.append_rule(rule) local function check_geometry(c, x, y, width, height) local g = c:geometry() diff --git a/tests/test-awful-rules.lua b/tests/test-awful-rules.lua index 2482363d..fbf783b4 100644 --- a/tests/test-awful-rules.lua +++ b/tests/test-awful-rules.lua @@ -1,4 +1,5 @@ local awful = require("awful") +local ruledc = require("ruled.client") local gears = require("gears") local test_client = require("_client") local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1) @@ -12,8 +13,8 @@ local tests = {} -- local border_width = beautiful.border_width -- Detect "request::manage" race conditions -local real_apply = awful.rules.apply -function awful.rules.apply(c) +local real_apply = ruledc.apply +function ruledc.apply(c) assert(#c:tags() == 0) return real_apply(c) end @@ -33,7 +34,7 @@ local function test_rule(rule) rule.test = nil end - table.insert(awful.rules.rules, rule) + ruledc.append_rule(rule) end -- Helper function to search clients @@ -263,20 +264,20 @@ test_rule { } -- Test the custom sources -assert(awful.rules.add_rule_source("high_priority", function(c, props, _) +assert(ruledc.add_rule_source("high_priority", function(c, props, _) assert(type(c) == "client") assert(props.random2) props.random1 = true end, {"awful.spawn"}, {"awful.rules", "low_priority"})) -assert(awful.rules.add_rule_source("before2", function() +assert(ruledc.add_rule_source("before2", function() error("This function should not be called") end, {"awful.spawn"}, {"awful.rules"})) -assert(awful.rules.remove_rule_source("before2")) +assert(ruledc.remove_rule_source("before2")) -assert(awful.rules.add_rule_source("low_priority", function(c, props, _) +assert(ruledc.add_rule_source("low_priority", function(c, props, _) assert(type(c) == "client") assert(not props.random1) @@ -285,7 +286,7 @@ end, {"awful.spawn", "high_priority"}, {"void", "awful.rules"})) local temp = gears.debug.print_warning gears.debug.print_warning = function() end -assert(not awful.rules.add_rule_source("invalid_source", function() +assert(not ruledc.add_rule_source("invalid_source", function() assert(false, "This cannot happen") end, {"awful.rules"}, {"awful.spawn"})) gears.debug.print_warning = temp diff --git a/tests/test-geometry.lua b/tests/test-geometry.lua index a97491a8..b9ed5ea5 100644 --- a/tests/test-geometry.lua +++ b/tests/test-geometry.lua @@ -4,21 +4,38 @@ local runner = require( "_runner" ) local awful = require( "awful" ) local wibox = require( "wibox" ) local beautiful = require( "beautiful" ) +local cruled = require("ruled.client") +local gdebug = require("gears.debug") local w = nil local w1_draw, w2_draw +-- Replacing the rules is not supported anymore. +local dep = gdebug.deprecate + +local function set_rules(new_rules) + gdebug.deprecate = function() end + + cruled.rules = {} + + cruled.append_rules(new_rules) + + gdebug.deprecate = dep +end + -- Disable automatic placement -awful.rules.rules = { - { rule = { }, properties = { - border_width = 0, - size_hints_honor = false, - x = 0, - y = 0, - width = 100, - height = 100, - border_color = beautiful.border_color_normal -} +set_rules { + { + rule = { }, + properties = { + border_width = 0, + size_hints_honor = false, + x = 0, + y = 0, + width = 100, + height = 100, + border_color = beautiful.border_color_normal + } } } @@ -52,7 +69,7 @@ local steps = { end end, function() - awful.rules.rules = { + set_rules { -- All clients will match this rule. { rule = { },properties = { titlebars_enabled = true, diff --git a/tests/test-urgent.lua b/tests/test-urgent.lua index 169c2512..292d78f4 100644 --- a/tests/test-urgent.lua +++ b/tests/test-urgent.lua @@ -2,6 +2,8 @@ local awful = require("awful") local runner = require("_runner") +local cruled = require("ruled.client") + -- Some basic assertion that the tag is not marked "urgent" already. assert(awful.tag.getproperty(awful.screen.focused().tags[2], "urgent") == nil) @@ -31,7 +33,7 @@ local steps = { -- Select first tag. awful.screen.focused().tags[1]:view_only() - runner.add_to_default_rules({ rule = { class = "XTerm" }, + cruled.append_rule({ rule = { class = "XTerm" }, properties = { tag = "2", focus = true } }) awful.spawn("xterm") @@ -71,7 +73,7 @@ local steps = { -- Select first tag. awful.screen.focused().tags[1]:view_only() - runner.add_to_default_rules({ rule = { class = "XTerm" }, + cruled.append_rule({ rule = { class = "XTerm" }, properties = { tag = "2", focus = true, switch_to_tags = true }}) awful.spawn("xterm") @@ -93,7 +95,7 @@ local steps = { client.get()[1]:kill() manage_cb_done = false - runner.add_to_default_rules({rule = { class = "XTerm" }, + cruled.append_rule({rule = { class = "XTerm" }, properties = { tag = "2", focus = false }}) awful.spawn("xterm")