Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing global mousebindings is bugged #3806

Open
Clusterfonk opened this issue May 7, 2023 · 1 comment
Open

removing global mousebindings is bugged #3806

Clusterfonk opened this issue May 7, 2023 · 1 comment
Milestone

Comments

@Clusterfonk
Copy link

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) 
@gadefox
Copy link

gadefox commented May 9, 2023

I fixed the problem with the following changes:

  1. 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
  1. 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

@Elv13 Elv13 added this to the v4.4 milestone Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants