Bug 499341

Summary: Task switcher select the entry at the wrong index if the most recent used window is filtered
Product: [Plasma] kwin Reporter: ariasuni <aria>
Component: tabboxAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate
Priority: NOR    
Version First Reported In: 6.2.5   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.3.0
Sentry Crash Report:

Description ariasuni 2025-01-30 19:33:56 UTC
SUMMARY
In the “Task Switcher” KCM, if I filter windows with “All other screens” (or “All other desktops”) option, then when invoking the task switcher with the shortcut, it’ll often start with the wrong index.

Usually, when using alt+tab, then the first item is the currently focused window, and the second one is selected. However, in case where the currently focused window is filtered, the selected item is incorrect. More precisely, the index of the selected item is equal to the index of the first window appearing in the task switcher if the windows weren’t filtered.

As an example, let’s say I have windows on two different screens:
- screen 1: 1 2 3
- screen 2: 4 5 6
I’ll be using [] to indicate selection in the task switcher tab box.

Case 1: most recently used are 1 4 2 3 5 6
Invoking the task switcher on screen 1 will display 4 [5] 6, instead of the expected [4] 5 6
The index is shifted by one, because without the filter, there would 1 at the top of the list.

Case 2: most recently used are 1 2 4 3 5 6
Invoking the task switcher on screen 1 will display 4 5 [6]
The index is shifted by two, because without the filter, there would 1 and 2 at the top of the list.

Case 3: most recently used are 1 2 3 4 5 6
Invoking the task switcher on screen 1 will display [4] 5 6
The index is shifted by three, causing it to be correct by accident, because without the filter, there would 1, 2 and 3 at the top of the list.

STEPS TO REPRODUCE
1. Use two screens
2. In “Task Switcher” KCM, for one of the task switcher, check “Screens” and select “All other screens”
3. Use the configured task switcher to select a window of the other screen

OBSERVED RESULT
The task switcher very often doesn’t selected the most recently used window matching the settings of the task switcher.

EXPECTED RESULT
The task switcher select the most recently used window matching the settings of the task switcher.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.1
Kernel Version: 6.12.10-zen1-1-zen (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
I’m using alt+tab to switch between the windows of my current screen, and win+tab to switch between the windows of the other screen, so win+tab (in theory) works to select the window on top of the other screen or the other windows if I press again tab while maintaining win, a setup which I’ve found very useful and practical (except for the bug reported here).
Comment 1 ariasuni 2025-01-30 20:04:34 UTC
Investigating the bug and the code further, I realized it may already be fixed in the master branch:
https://invent.kde.org/plasma/kwin/-/merge_requests/6697
Comment 2 Nate Graham 2025-01-31 15:29:45 UTC
Even better, in the Plasma 6.3 branch!