Bug 464805 - Modifier only shortcuts assigned through system settings-shortcuts trigger on "press" action instead of "release"
Summary: Modifier only shortcuts assigned through system settings-shortcuts trigger on...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kglobalaccel
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.249.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: fanzhuyifan
URL:
Keywords:
: 479807 481373 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-25 15:48 UTC by Dmitrii Chermnykh
Modified: 2024-03-25 19:25 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitrii Chermnykh 2023-01-25 15:48:14 UTC
SUMMARY
Modifier only shortcuts on X11 trigger on "press" action instead of "release". This results in triggering multiple shortcuts when pressing a shortcut with modifier. 


STEPS TO REPRODUCE
1. Bind a shortcut to a modifier (for example "super/meta" key for krunner)
2. Bind meta+space to another shortcut (in my case it triggers keyboard layout switch via fcitx5)
3. Press meta+space

OBSERVED RESULT
Both shortcuts got triggered (keyboard layout switch + krunner)

EXPECTED RESULT
Only meta+space shortcut triggers (keyboard layout switch)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Xorg 21.1.6-1
Comment 1 Nate Graham 2023-01-25 18:07:11 UTC
Works for me on Wayland FWIW.
Comment 2 Patrick Silva 2023-01-25 21:00:33 UTC
possibly duplicate of bug 452113
Comment 3 Nate Graham 2023-01-25 21:23:16 UTC
Hmm, maybe the have the same root cause? Needs investigation.
Comment 4 David Edmundson 2023-05-04 08:40:59 UTC
There are two paths for modifier only shortcuts:

 - kwin did a path of modifier shortcuts, which was release only 

 - in kglobalaccel a modifier only shortcut will fire on press, like another shortcut.

It's slightly more complex as that kglobalaccel usage was designed to cover press-to-talk like cases. Those can't be delayed. It will need to be a flag on shortcut bind or done exclusively client side
Comment 5 Oded Arbel 2023-05-25 13:40:40 UTC
I can reproduce this issue in Plasma 6 on Wayland:

When setting a modifier only shortcut, it triggers on key press. If the same modifier is used in another shortcut (for example CTRL vs CTRL+S) than both events are being triggered, though if the modifier-only shortcut is quick enough to grab focus away from the application that is supposed to handle the second shortcut, then it might not happen at all.

For example:

STEPS TO REPRODUCE:
1. In the keyboard shortcut settings, find Krunner and add to it a shortcut of "Control".
2. Start another application that can "save" on CTRL+S - for example, Firefox.
3. Press CTRL+S

OBSERVED RESULT
Krunner appears.

EXPECTED RESULT
The "Save" dialog should come up.
Comment 6 Andrey 2023-05-25 13:47:10 UTC
(In reply to Nate Graham from comment #1)
> Works for me on Wayland FWIW.

What was your test Nate? Can you confirm the fail above?
Comment 7 Oded Arbel 2023-05-28 10:50:48 UTC
(In reply to Oded Arbel from comment #5)
> I can reproduce this issue in Plasma 6 on Wayland:
> ...
> STEPS TO REPRODUCE:
> 1. In the keyboard shortcut settings, find Krunner and add to it a shortcut
> of "Control".
> 2. Start another application that can "save" on CTRL+S - for example,
> Firefox.
> 3. Press CTRL+S

Setting up modifier-only shortcuts using kwinrc ([ModifierOnlyShortcuts] section), instead of using the System Settings shortcuts KCM, the modifier-only shortcut does trigger correctly on release.

I'm not sure what the KCM is doing that is different than setting the kwinrc setting, but there are obviously two different systems that pertain to do the same thing, where one of them is doing it wrong.
Comment 8 Vlad Zahorodnii 2024-01-17 15:54:34 UTC
*** Bug 479807 has been marked as a duplicate of this bug. ***
Comment 9 Dmitrii Chermnykh 2024-02-15 20:19:07 UTC
*** Bug 481373 has been marked as a duplicate of this bug. ***
Comment 10 fanzhuyifan 2024-02-15 20:54:18 UTC
Moved to kglobalaccel since the modifier-only shortcuts handled by kwin activate on release, and this is about regular shortcuts handled by a different code path.
Comment 11 fanzhuyifan 2024-02-15 20:57:34 UTC
Also just a heads-up that I plan to take a look at this some time.
Comment 13 fanzhuyifan 2024-03-20 17:02:06 UTC
Git commit d20d58d4729fd94b3373b803de89054c2e2550de by Yifan Zhu.
Committed on 20/03/2024 at 17:00.
Pushed by fanzhuyifan into branch 'master'.

Enhance modifier-only shortcuts

Trigger modifier-only shortcuts trigger on release, and support multi-key
modifier-only shortcuts, which trigger only when all the modifiers are
released within some interval.
Related: bug 470256

M  +50   -19   src/globalshortcutsregistry.cpp
M  +15   -0    src/globalshortcutsregistry.h
M  +38   -1    src/sequencehelpers_p.cpp
M  +2    -0    src/sequencehelpers_p.h

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