awesome
awesome copied to clipboard
removing global mousebindings is bugged
Output of awesome --version
:
awesome v4.3-1593-g6f000aad2 (Too long)
• Compiled against Lua 5.4.4 (running with 0.9.2)
• API level: 4
• D-Bus support: yes
• xcb-errors support: no
• execinfo support: yes
• xcb-randr version: 1.6
• LGI version: /usr/share/lua/5.4/lgi/version.lua
• Transparency enabled: yes
• Custom search paths: no
How to reproduce the issue: The issue presists even when using delays
local left = awful.button({}, awful.button.names.LEFT, function() print("left") end)
awful.mouse.append_global_mousebindings(left)
awful.mouse.remove_global_mousebinding(left)
Actual result: callback function still called when pressing the assigned button. dumping root.buttons() shows the the button still being assigned
Expected result: The created button should be removed and the callback should not be fired upon clicking the assigned button
** How I discovered this ** While implementing a way to click away popups, removing a mousebinding had no effect at all. Using mousegrabber for this has many other problems. I feel like there is no clean way to implement this as of yet.
Further information Funny enough just adding a right button to the example given above, gives the correct behaviour. BUT this only worked in this example. In my popup the global mousebindings would never get removed no matter how i ordered the execution or how many buttons I assigned/removed.
local left = awful.button({}, awful.button.names.LEFT, function() print("left") end)
local right = awful.button({}, awful.button.names.RIGHT, function() print("right") end)
awful.mouse.append_global_mousebindings(left)
awful.mouse.append_global_mousebindings(right)
awful.mouse.remove_global_mousebinding(left)
awful.mouse.remove_global_mousebinding(right)
I fixed the problem with the following changes:
- add new function in gears.table.lua
function gtable.removeitem(t, item)
for k, v in ipairs(t) do
if v == item then
table.remove(t, k)
return true
end
end
return false
end
- change remove_global_mousebinding function:
function mouse.remove_global_mousebinding(button)
local rbtns = capi.root._buttons()
for _, v in ipairs(button) do
gtable.removeitem(rbtns, v)
end
capi.root._buttons(rbtns)
end