Merge pull request #3355 from Elv13/fix_3352

Fix the mouse button properties
This commit is contained in:
mergify[bot] 2021-05-31 17:03:14 +00:00 committed by GitHub
commit 149d18e0e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 2 deletions

View File

@ -341,9 +341,9 @@ function mouse.remove_client_mousebinding(button)
return false
end
for _, b in ipairs {"left", "right", "middle"} do
for k, b in ipairs {"left", "middle", "right"} do
mouse.object["is_".. b .."_mouse_button_pressed"] = function()
return capi.mouse.coords().buttons[1]
return capi.mouse.coords().buttons[k]
end
end
@ -367,6 +367,10 @@ end)
capi.mouse.set_index_miss_handler(function(_,key)
if mouse.object["get_"..key] then
return mouse.object["get_"..key]()
elseif mouse.object[key] and key:sub(1, 3) == "is_" then
return mouse.object[key]()
elseif mouse.object[key] then
return mouse.object[key]
else
return props[key]
end

View File

@ -0,0 +1,41 @@
require("awful.mouse")
local steps = {}
-- warning: order is important
local buttons = {"left", "middle", "right"}
-- Check the is_****_mouse_button_pressed properties.
for k, v in ipairs(buttons) do
-- Press the button.
table.insert(steps, function()
root.fake_input("button_press", k)
return true
end)
-- Check the property matrix.
table.insert(steps, function()
if not mouse["is_"..v.."_mouse_button_pressed"] then return end
for _, v2 in ipairs(buttons) do
assert(mouse["is_"..v2.."_mouse_button_pressed"] == (v == v2))
end
root.fake_input("button_release", k)
return true
end)
-- Release the button.
table.insert(steps, function()
if mouse["is_"..v.."_mouse_button_pressed"] then return end
return true
end)
end
require("_runner").run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80