Bug 486034 - clicklockd, a mouse accessibility tool doesn't work correctly on Wayland
Summary: clicklockd, a mouse accessibility tool doesn't work correctly on Wayland
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: 6.0.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-23 19:15 UTC by Bruno Filipe
Modified: 2024-05-03 22:59 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Filipe 2024-04-23 19:15:13 UTC
SUMMARY
Hello, I'm a quadriplegic KDE user and can't migrate to Wayland due to this issue, I appreciate and thank in advance any help even though I realize it's a really niche use-case.
Clicklockd is a open source tool that mimics a Windows accessibility feature known as Clicklock. It's the only public tool that does it correctly.

As described by it's author, germag:
"Clicklockd enables you to highlight or drag without holding down the mouse button. This feature allows you to hold the mouse button for a few seconds, move the mouse to the new location, and then click it again. The effect is the same as a drag and drop but without having to hold the mouse button for a long time."

Instead of the expected behavior, clicks doesn't lock at all and single clicks are turned into double clicks. 

It works fine on Plasma X11 and other Wayland DE's/compositors like GNOME, and only depends on libudev, so the dev believies it's likely something related to how Plasma/kwin Wayland handles inputs.

STEPS TO REPRODUCE
1. Build and run clicklockd (https://github.com/germag/clicklockd)

OBSERVED RESULT
. Clicklock won't work correctly and single clicks become double clicks instead.

EXPECTED RESULT
When we hold left click for x seconds, specified in argument like "-t 1.5s" passed to clicklockd, that click should be held on until another click comes in.

SOFTWARE/OS VERSIONS
KDE Plasma 6.0.4 on Arch Linux

ADDITIONAL INFORMATION

Github issue and discussion with developer: https://github.com/germag/clicklockd/issues/6
Comment 1 Zamundaaa 2024-04-24 14:46:35 UTC
Can confirm. KWin is lacking the key press deduplication logic that's required for multiple devices on the same seat to cooperate with each other.
Comment 2 Bruno Filipe 2024-04-25 00:27:04 UTC
(In reply to Zamundaaa from comment #1)
> Can confirm. KWin is lacking the key press deduplication logic that's
> required for multiple devices on the same seat to cooperate with each other.

Hey Zamundaaa, thanks for the quick confirmation.

I got a bit of practical evidence on what's happening after playing a bit with libinput debug (sudo libinput debug-events --verbose) , along with clicklockd and also a script using python-evsieve to simulate my scenario.

In summary, like you already said, the current issue in kwin Wayland behavior is that when the same key is pressed/released on multiple seats it lacks any logic to avoid repeating events to mess with each other. In my scenario what happens is this:

-event4   POINTER_BUTTON          +1.541s       BTN_LEFT (272) pressed, seat count: 1 # Real mouse BTN_LEFT pressed, from neutral state - Self-explanatory
-event15  POINTER_BUTTON          +1.541s       BTN_LEFT (272) pressed, seat count: 2 # Virtual mouse BTN_LEFT pressed - This click should be ignored since we're already in pressed state on another seat (real mouse), but it is not. It generates a double-click instead.
-event4   POINTER_BUTTON          +3.125s       BTN_LEFT (272) released, seat count: 1 # Real mouse BTN_LEFT released - This one should also be ignored since virtual is still in pressed state, but it is not.
 event4   POINTER_BUTTON          +4.589s       BTN_LEFT (272) pressed, seat count: 2 # Real mouse BTN_LEFT pressed again - Also should be ignored since virtual is still in pressed state, but it is not.
 event4   POINTER_BUTTON          +4.677s       BTN_LEFT (272) released, seat count: 1 # Real mouse BTN_LEFT released - Also should be ignored since virtual is still in pressed state, but it is not. 
-event15  POINTER_BUTTON          +4.677s       BTN_LEFT (272) released, seat count: 0 # Virtual BTN_LEFT released - Now kwin/Plasma should actually release effectively.

A bit difficult to explain, but something like this.
Comment 3 Bruno Filipe 2024-05-03 03:28:36 UTC
Here's some reference for expected multiseat behavior (from https://wayland.freedesktop.org/libinput/doc/latest/seats.html)

if the same button is pressed on different devices, the button should only be considered logically pressed once.

if the same button is released on one device, the button should be considered logically down if still down on another device.

if two different buttons or keys are pressed on different devices, the logical state is that of both buttons/keys down.

if a button is pressed on one device and another device moves, this should count as dragging.

if two touches are down on different devices, the logical state is that of two touches down.
Comment 4 Bruno Filipe 2024-05-03 22:59:35 UTC
Hey, took a try at fixing this: https://invent.kde.org/plasma/kwin/-/merge_requests/5696