From 44a665d381eb5c53f1ea11a58367b3bae4ff336d Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 16 Oct 2019 02:54:15 -0400 Subject: [PATCH] awful.rules: Use the `awful.client/mouse` default buttons and keys. --- lib/awful/keyboard.lua | 9 +++++++++ lib/awful/rules.lua | 9 +++++++++ objects/client.c | 11 +++++++++++ 3 files changed, 29 insertions(+) diff --git a/lib/awful/keyboard.lua b/lib/awful/keyboard.lua index f415ca43..34792723 100644 --- a/lib/awful/keyboard.lua +++ b/lib/awful/keyboard.lua @@ -197,4 +197,13 @@ function module.remove_client_keybinding(key) return false end +capi.client.connect_signal("scanning", function() + capi.client.emit_signal("request::default_keybindings", "context") +end) + +-- Private function to be used by `ruled.client`. +function module._get_client_keybindings() + return default_keys +end + return module diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index 4b1e86bb..9f4a6c40 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -121,6 +121,8 @@ local protected_call = require("gears.protected_call") local aspawn = require("awful.spawn") local gdebug = require("gears.debug") local gmatcher = require("gears.matcher") +local amouse = require("awful.mouse") +local akeyboard = require("awful.keyboard") local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1) local rules = {} @@ -529,6 +531,13 @@ end -- @staticfct awful.rules.execute crules._execute = function(_, c, props, callbacks) + + -- Set the default buttons and keys + local btns = amouse._get_client_mousebindings() + local keys = akeyboard._get_client_keybindings() + props.keys = props.keys or keys + props.buttons = props.buttons or btns + -- This has to be done first, as it will impact geometry related props. if props.titlebars_enabled and (type(props.titlebars_enabled) ~= "function" or props.titlebars_enabled(c,props)) then diff --git a/objects/client.c b/objects/client.c index 734592ba..150bc0bf 100644 --- a/objects/client.c +++ b/objects/client.c @@ -255,6 +255,17 @@ * `startup`). */ +/** Emitted during startup to gather the default client keybindings. + * + * This signals gives a chance to all module to register new client keybindings. + * Assuming the client rules does not overwrite them with the `keys` property, + * they will be added to all clients. + * + * @signal request::default_keybindings + * @tparam string context The reason why the signal was sent (currently always + * `startup`). + */ + /** When a client gets tagged. * @signal tagged * @tag t The tag object.