Bug 454474 - KWin tabbox: pass down keys autorepeat flag
Summary: KWin tabbox: pass down keys autorepeat flag
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: effects-tabbox (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-27 09:14 UTC by ratijas
Modified: 2024-12-03 22:41 UTC (History)
1 user (show)

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


Attachments
KWin tabbox - autorepeat (2.09 MB, video/mp4)
2022-05-27 09:14 UTC, ratijas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ratijas 2022-05-27 09:14:13 UTC
Created attachment 149250 [details]
KWin tabbox - autorepeat

SUMMARY

Currently in tabbox code, code in C++ and QML/JS there's no `autorepeat` flag for key events.

I looked at the code, but seemed like quite a complicated and custom handling of shortcuts, keeping track of pressed modifiers (so that the tabbox does not close while user is holding down Alt key of the Alt+Tab/Alt+Shift+Tab shortcuts) etc. It turned out to be non-trivial to fix, especially since it deals with raw xcb events (and I didn't find an autorepeat information in those structs).

Can we still add that flag when keys are really held down, please?

STEPS TO REPRODUCE
1. Open more than 1 window
2. Press & hold Alt+Tab

OBSERVED RESULT
Selection cycles through the tabbox, endlessly wrapping at the edges. QML code in tabbox implementations does not receive "autorepeat" flag with Keys.onPressed event.

EXPECTED RESULT
Autorepeat mode should be detectable in code, and acted upon to provide slightly different behavior from discrete key presses.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.25.80
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.4
Kernel Version: 5.17.9-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION
My usecase it to add "boundary checks" handling, so that auto-repeated Alt+Tabs would stop at the end of a window list instead of cycling forever.

Here an example of already implemented and merged functionality:
https://invent.kde.org/plasma/kscreen/-/merge_requests/90

Note that in case of this specific KScreen OSD I'd like to also support pressing and holding Meta+P to cycle through the list.
Comment 1 Nate Graham 2022-05-27 14:26:13 UTC
Seems reasonable to me.
Comment 2 Bug Janitor Service 2024-12-02 22:07:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6853
Comment 3 Ismael Asensio 2024-12-03 22:41:59 UTC
Git commit 017eed549dc0f11bcd225194912fd5f10a9c4bfd by Ismael Asensio.
Committed on 03/12/2024 at 22:25.
Pushed by iasensio into branch 'master'.

tabbox: Do not wrap around the window list when the shortcut is held

When the tabbox shortcut (ex. Alt-Tab) is held pressed, due to the
autorepeat keys mechanism, we'll receive a lot of rapid key events
and quickly iterate through the window list, potentially wrapping
around in an infinite loop.

Instead, let's detect if the key event is in autorepeat and stop the
rapid iteration at the bounds of the window list. Wrapping around is
still possible by releasing and pressing the non-modifier key
(generally `Tab`) again.

Wayland-only for now due to the difficulty of detecting a held key
from a xcb_key_press_event.
FIXED-IN: 6.3.0

M  +9    -0    src/tabbox/tabbox.cpp

https://invent.kde.org/plasma/kwin/-/commit/017eed549dc0f11bcd225194912fd5f10a9c4bfd