swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.41k stars 1.1k forks source link

Since wlroots' 8730ca9, mouse clicking stops working forever after doing duplicate mouse clicks with keyboard #8284

Open arzeth opened 1 month ago

arzeth commented 1 month ago

I mostly use numpad to control a mouse.

Step 1: Add this to config

bindsym --to-code {
    KP_Up    seat - cursor move 0   -7
    KP_Home  seat - cursor move -7  -7
    KP_Left  seat - cursor move -7  0
    KP_Right seat - cursor move 7   0
    KP_Down  seat - cursor move 0   7
    KP_Next  seat - cursor move 7   7
    KP_Prior seat - cursor move 7   -7
    KP_End   seat - cursor move -7  7
    Shift+KP_8 seat - cursor move 0   -40
    Shift+KP_Up seat - cursor move 0   -40
    Shift+KP_7 seat - cursor move -40 -40
    Shift+KP_Home seat - cursor move -40 -40
    Shift+KP_4 seat - cursor move -40 0
    Shift+KP_Left seat - cursor move -40 0
    Shift+KP_6 seat - cursor move 40  0
    Shift+KP_Right seat - cursor move 40  0
    Shift+KP_2 seat - cursor move 0   40
    Shift+KP_Down seat - cursor move 0   40
    Shift+KP_3 seat - cursor move 40  40
    Shift+KP_Next seat - cursor move 40  40
    Shift+KP_9 seat - cursor move 40  -40
    Shift+KP_Prior seat - cursor move 40  -40
    Shift+KP_1 seat - cursor move -40 40
    Shift+KP_End seat - cursor move -40 40
              KP_5        seat - cursor press   button1
    --release KP_5        seat - cursor release button1
              KP_Begin    seat - cursor press   button1
    --release KP_Begin    seat - cursor release button1
              KP_Divide   seat - cursor press   button1
    --release KP_Divide   seat - cursor release button1
              KP_Multiply seat - cursor press   button3
    --release KP_Multiply seat - cursor release button3
              KP_Subtract seat - cursor press   button4
    --release KP_Subtract seat - cursor release button4
              KP_Plus     seat - cursor press   button5
    --release KP_Plus     seat - cursor release button5
}

Step 2: Reload the config: swaymsg reload

Step 2: Hold "5" (left click) or "*" (right click) on the numpad for 2 seconds. Stop holding it.

Step 3: Sway continues to think that the left/right mouse button is still being pressed. THOUGH, for some reason, clicking on window titles in the top bar still works (I mean I have bindsym $mod+w layout tabbed, then press Win+W).

Switching between ttys, reconnecting the mouse, or suspending/unsuspending the PC doesn't help (it doesn't reset the mouse state).

I did git revert 8730ca9661eaaab83954bca033745b65c60cf4f8 in wlroots, then recompiled wlroots and then sway, now it works fine.

wlroots' 8730ca9661eaaab83954bca033745b65c60cf4f8 "seat/pointer: handle duplicate presses/releases correctly" https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/8730ca9661eaaab83954bca033745b65c60cf4f8 is by @vyivel

vyivel commented 1 month ago

With your config, holding KP_5 sends button presses repeatedly, while on release only one event is sent. Before 8730ca9661eaaab83954bca033745b65c60cf4f8, wlroots stored pressed buttons for a wl_seat as a set, meaning that if you pressed two (same code) buttons on different devices and then released only one, you'd get a release event despite another button still pressed.

Now pressed buttons are stored as a multiset, and so sending repeated "press" events makes wlroots think the same button is being pressed multiple times and refuse to send ~duplicate~ "early" release events to clients.

Adding --no-repeat to "press" bindings fixes the issue.


@emersion Not exactly sure how to improve user experience with this. Mention the pitfall in sway(5)?

ventureoo commented 1 month ago

I can confirm the same issue on my laptop with sway-git 1.10.r7386.32e5e52 and wlroots-git 0.19.0.r7160.8730ca966-1. That said, right-clicking works fine.

edit: I don't have anything in my config like mentioned in the issue.

emersion commented 1 month ago

If you don't have cursor press/release commands in your config, it's most likely a separate/unrelated one.

Thanks for having a look @vyivel. I agree there's probably not much to be done here besides docs.

Maybe a better approach would be to add support for pointer keysyms: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3803

Riptils commented 1 month ago

Same issue, but I haven't a specific config for my mouse (check my dotfiles if you see anything :shrug:)

emersion commented 1 month ago

@ventureoo @Riptils your issue is unrelated to this issue, most likely it's fixed by https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4777