From 8b6ea8243a2355faa47816dc04c4c36954d895c0 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Wed, 16 Oct 2019 02:47:16 -0400 Subject: [PATCH] awful.mouse: Add a function to remove a default client button. --- lib/awful/mouse/init.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/awful/mouse/init.lua b/lib/awful/mouse/init.lua index 2ddf0b37b..67045f62f 100644 --- a/lib/awful/mouse/init.lua +++ b/lib/awful/mouse/init.lua @@ -457,6 +457,29 @@ function mouse.append_client_mousebindings(buttons) end end +--- Remove a mousebinding from the default client buttons. +-- +-- @staticfct awful.mouse.remove_client_mousebinding +-- @tparam awful.button button The button. +-- @treturn boolean True if the button was removed and false if it wasn't found. +-- @see awful.keyboard.append_client_keybinding + +function mouse.remove_client_mousebinding(button) + for k, v in ipairs(default_buttons) do + if button == v then + table.remove(default_buttons, k) + + for _, c in ipairs(capi.client.get(nil, false)) do + c:remove_mousebinding(button) + end + + return true + end + end + + return false +end + for _, b in ipairs {"left", "right", "middle"} do mouse.object["is_".. b .."_mouse_button_pressed"] = function() return capi.mouse.coords().buttons[1]