Bug 413670 - Keyboard modifier event for Capslock fired (incorrectly?) on key release in Wayland
Summary: Keyboard modifier event for Capslock fired (incorrectly?) on key release in W...
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-31 13:41 UTC by Janek Bevendorff
Modified: 2022-02-18 04:37 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janek Bevendorff 2019-10-31 13:41:20 UTC
SUMMARY
I am trying to implement the detection of caps lock in my application for Wayland. This in itself already requires around 30 lines of code using KWayland (way worse with the plain C API), compared to the single-line solutions for Windows or macOS or the three lines for X11, but worst of all, I noticed that the modifier change event is called both on key press and key release with different bit flags set.

The first activation has bit #2 set, the second activate does not, so my application thinks that caps lock had been released again until I press any other key, which triggers the event a third time.

I thought at first that this was just a bug in my implementation, but then I noticed that the caps lock indicator in the Plasma tray has the same issue and is only shown as long as I hold caps lock down.

STEPS TO REPRODUCE
1. subscribe to KWayland::Client::Keyboard::modifiersChanged() for a keyboard
2. log the status of the `locked` bitmask
3. press and release caps lock

OBSERVED RESULT
Event is triggered a second time on key release with `locked & 0x10 == 0`.

EXPECTED RESULT
Event is either triggered only on key press or key release does not unset the caps lock bit

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon
KDE Plasma Version: 5.17.80
KDE Frameworks Version: 5.64.0
Qt Version: 5.13.1

ADDITIONAL INFORMATION

I tried using the KDE-proprietary org_kde_kwin_keystate protocol extension as an alternative that requires fewer LOCs, but the compositor doesn't even announce this extension.
Comment 1 David Redondo 2022-01-19 15:18:15 UTC
Can you share a simple example program and/or a wayland log of the wrong behavior you are seeing?
Comment 2 Bug Janitor Service 2022-02-03 04:37:57 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Bug Janitor Service 2022-02-18 04:37:08 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!