Bug 411356 - "Switch to Windows to the Right" with multiple screens goes to back window
Summary: "Switch to Windows to the Right" with multiple screens goes to back window
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.14.5
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL: https://phabricator.kde.org/D23521
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-27 15:28 UTC by cdancette
Modified: 2019-08-31 10:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.17.0
vlad.zahorodnii: ReviewRequest+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cdancette 2019-08-27 15:28:57 UTC
SUMMARY


I am using "Switch to Windows to the Right" and "Switch to Windows to the Left" shortcuts to navigate between opened windows.

Also, I am using two screens.

When I have a few full screen windows open on each screen, sometimes I want to switch focus between my windows on the right screen to the windows on the left screen. So I use the shortcut "Switch to Windows to the Right", but it will switch to a window on the right desktop that is on the back, not the front window like I expect.

Any idea how to fix this ?


STEPS TO REPRODUCE

1. Have two screens. On left screen, open one window. On right screen, open two maxized window (we'll call them front and back window). 
2. Focus on the window on the left screen. Then use the shortcut to "Switch to Windows to the Right". 
3. 

OBSERVED RESULT
The focus goes to the window that is was the back of the right screen (the back windows comes to front)


EXPECTED RESULT
The focus goes to the window that is already on the front of the right screen


SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Debian 10 
KDE Plasma Version: plasmashell 5.14.5

KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Vlad Zahorodnii 2019-08-28 08:30:07 UTC
This problem happens because kwin traverses the stacking order from bottom to top and assigns a score to each client. A client with the best score will be activated next. The score function works purely in terms of geometry. So, if there are several maximized/fullscreen clients, their geometry will be identical and therefore kwin will pick only the bottom-most client.
Comment 2 Vlad Zahorodnii 2019-08-31 10:47:27 UTC
Git commit 9102e41e71ce81ea72d6a2575c1b8cedd37087fb by Vlad Zagorodniy.
Committed on 31/08/2019 at 10:47.
Pushed by vladz into branch 'master'.

Traverse the stacking order backwards when switching between windows

Summary:
In order to pick the next client to activate we traverse the stacking
order from bottom to top and assign to each client a score. The client
with the best score will be activated next. Function that assigns score
bases its decisions purely on geometry. This may backfire if there are
couple maximized or fullscreen clients on the screen - we'll activate
the bottom-most client.

This change toggles direction we traverse the stacking order. If there
are several clients with an identical score, then prefer the top-most
client, the one that the user most likely sees at the moment.
FIXED-IN: 5.17.0

Test Plan: New tests pass.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23521

M  +1    -0    autotests/integration/CMakeLists.txt
A  +585  -0    autotests/integration/activation_test.cpp     [License: GPL (v2)]
M  +1    -1    useractions.cpp

https://commits.kde.org/kwin/9102e41e71ce81ea72d6a2575c1b8cedd37087fb