Bug 491315 - On x11, modifier-only global shortcuts incorrectly trigger even when keyboard is grabbed
Summary: On x11, modifier-only global shortcuts incorrectly trigger even when keyboard...
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keys (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-05 17:16 UTC by fanzhuyifan
Modified: 2024-08-23 23:56 UTC (History)
5 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fanzhuyifan 2024-08-05 17:16:18 UTC
STEPS TO REPRODUCE
1. Assign a modifier-only shortcut to something
2. Assign the same modifier-only shortcut to something else

OBSERVED RESULT
The old shortcut is triggered when binding the new shortcut.

EXPECTED RESULT
The old shortcut shouldn't be triggered.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
(available in About System)
KDE Plasma Version: 6.1
KDE Frameworks Version: 
Qt Version: 6.8

ADDITIONAL INFORMATION
This also happens during lock screen, which poses a security issue (e.g., see BUG 488268)
Comment 1 duha.bugs 2024-08-05 21:15:29 UTC
I am unable to reproduce this.

The way I tried this was:
1. Add CTRL shortcut to launch dolphin
2. Add CTRL shortcut to launch konsole

When reassigning CTRL to konsole it did **not** open dolphin.

Anything I am missing here?

Operating System: Arch Linux 
KDE Plasma Version: 6.1.80
KDE Frameworks Version: 6.5.0
Qt Version: 6.9.0
Kernel Version: 6.10.2-arch1-1 (64-bit)
Graphics Platform: Wayland
Comment 2 fanzhuyifan 2024-08-05 21:16:59 UTC
(In reply to duha.bugs from comment #1)
> I am unable to reproduce this.
> 
> The way I tried this was:
> 1. Add CTRL shortcut to launch dolphin
> 2. Add CTRL shortcut to launch konsole
> 
> When reassigning CTRL to konsole it did **not** open dolphin.
> 
> Anything I am missing here?


X11. Things work perfectly on wayland
Comment 3 duha.bugs 2024-08-05 21:19:24 UTC
Ah, sorry I missed that. Can confirm on X11.
Comment 4 Bug Janitor Service 2024-08-09 01:58:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kglobalacceld/-/merge_requests/60
Comment 5 fanzhuyifan 2024-08-20 21:39:31 UTC
Git commit d5be3e16b9e2921c88cc8e0181a5b1f2c13ad761 by Yifan Zhu.
Committed on 09/08/2024 at 01:50.
Pushed by fanzhuyifan into branch 'master'.

plugins/xcb: skip xrecord events when keyboard is grabbed

Otherwise modifier-only shortcuts still trigger when keyboard is grabbed
by some other client, e.g. during shortcut assignment and in lockscreen.

Keep track of keyboard grab state by listening to grab/ungrab requests.

Test plan 1:
- Under x11, in system settings, assign Meta to some shortcut.
- Assign meta to another shortcut
- Verify that the old shortcut does not trigger

Test plan 2:
- Under x11, choose multiple keyboard layouts
- assign Alt+Shift as alternate layout switching shortcut
- lock screen
- press Alt+Shift
- Verify that the layout change OSD pops up, and typed password uses the
  new layout
- repeat the last two steps
Related: bug 488268

M  +16   -0    src/plugins/xcb/kglobalaccel_x11.cpp
M  +1    -0    src/plugins/xcb/kglobalaccel_x11.h

https://invent.kde.org/plasma/kglobalacceld/-/commit/d5be3e16b9e2921c88cc8e0181a5b1f2c13ad761