awful.mouse: Add a `append_mousebindings` function.

To preserve the symetry between the `button` and `key` API.
This commit is contained in:
Emmanuel Lepage Vallee 2019-10-16 02:27:00 -04:00
parent 370e754006
commit 80c65c5175
2 changed files with 21 additions and 1 deletions

View File

@ -148,6 +148,7 @@ local default_keys = {}
-- @emits client_keybinding::added -- @emits client_keybinding::added
-- @emitstparam client_keybinding::added awful.key key The key. -- @emitstparam client_keybinding::added awful.key key The key.
-- @see awful.key -- @see awful.key
-- @see awful.keyboard.append_client_keybindings
function module.append_client_keybinding(key) function module.append_client_keybinding(key)
table.insert(default_keys, key) table.insert(default_keys, key)
@ -167,7 +168,6 @@ end
-- @emitstparam client_keybinding::added awful.key key The key. -- @emitstparam client_keybinding::added awful.key key The key.
-- @see awful.key -- @see awful.key
-- @see awful.keyboard.append_client_keybinding -- @see awful.keyboard.append_client_keybinding
function module.append_client_keybindings(keys) function module.append_client_keybindings(keys)
for _, key in ipairs(keys) do for _, key in ipairs(keys) do
module.append_client_keybinding(key) module.append_client_keybinding(key)

View File

@ -434,9 +434,29 @@ local default_buttons = {}
function mouse.append_client_mousebinding(button) function mouse.append_client_mousebinding(button)
table.insert(default_buttons, button) table.insert(default_buttons, button)
for _, c in ipairs(capi.client.get(nil, false)) do
c:append_mousebinding(button)
end
capi.client.emit_signal("client_mousebinding::added", button) capi.client.emit_signal("client_mousebinding::added", button)
end end
--- Add a `awful.button`s to the default client buttons.
--
-- @staticfct awful.mouse.append_client_mousebindings
-- @tparam table buttons A table containing `awful.button` objects.
-- @see awful.button
-- @see awful.keyboard.append_client_keybinding
-- @see awful.mouse.append_client_mousebinding
-- @see awful.keyboard.append_client_keybindings
function mouse.append_client_mousebindings(buttons)
for _, button in ipairs(buttons) do
mouse.append_client_mousebinding(button)
end
end
for _, b in ipairs {"left", "right", "middle"} do for _, b in ipairs {"left", "right", "middle"} do
mouse.object["is_".. b .."_mouse_button_pressed"] = function() mouse.object["is_".. b .."_mouse_button_pressed"] = function()
return capi.mouse.coords().buttons[1] return capi.mouse.coords().buttons[1]