Bug 304950

Summary: alt+tab works wrong with "one window per application"
Product: [Plasma] kwin Reporter: Aleh <aleh>
Component: tabboxAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED FIXED    
Severity: normal CC: aldo-public, kwin-bugs-null
Priority: NOR Flags: mgraesslin: ReviewRequest+
Version: 4.9.0   
Target Milestone: 4.9.1   
Platform: openSUSE   
OS: Linux   
URL: https://git.reviewboard.kde.org/r/106139/
Latest Commit: Version Fixed In: 4.9.1
Sentry Crash Report:

Description Aleh 2012-08-10 21:54:55 UTC
I have some applications with 1 window and 1 application with more than 1 window.  I have set sort order to "recently used" and use "one window per application". After switching to multiwindow application alt+tab shows first not recently used window, but starts from the previous position, before i switched to multiwindow application.

Reproducible: Always
Comment 1 Aldoo 2012-08-19 20:18:08 UTC
I confirm this in KDE 4.9.0, OpenSuse packages.
Comment 2 Martin Flöser 2012-08-19 20:22:04 UTC
I have problems understanding this bug report. Could you please provide detailed steps how to reproduce the issue as requested in the bug creation wizard?

1. do foo
2. do bar
3. do baz

Expected result:
foobar is shown

Actual result:
barbaz is shown

Please elaborate also the example, don't be that abstract like 1 window and 1 application. That makes it difficult to follow what is the problem.
Comment 3 Thomas Lübking 2012-08-19 20:33:17 UTC
Enable "One Window per application"
Open at least two kwrite windows and two other windows
Focus a non kwrite window then one of the kwrite windows then the next.
Start alt+tab.

The window you focused before the first kwrite window does not get the focus but some other.

The claim is it would be the third last window, but it seems rather "random" to me.

The other write window should of course not be selected but the one before focusing the first kwrite window
Comment 4 Aldoo 2012-08-19 20:43:31 UTC
Note this only happens when there actually are several windows of one application and when you alt-tab from one of these windows.
As Thomas said, then it is expected the first window of the task list should be focused. Instead, it is the next in the list (after the previous position of the window that was previously focused) which is focused. Say I have 2 instances of kwrite, and kwrite is 4th in the task list, if I alt-tab to kwrite, next time I alt-tab, it's the fifth application of the list that receives the focus.
Comment 5 Martin Flöser 2012-08-20 18:19:36 UTC
ok, I can reproduce this issue and I think I understand it. I'll try to find a way to unit test it, but it's quite warm this evening in my office :-)
Comment 6 Martin Flöser 2012-08-23 06:48:54 UTC
patch added to review board. I would appreciate some testing as it was impossible to write a unit test :-) My own testing seemed to show it working.
Comment 7 Martin Flöser 2012-08-26 18:10:31 UTC
Git commit 567f8cc50082ce5307aa7163fdf3176446a1df5a by Martin Gräßlin.
Committed on 23/08/2012 at 08:39.
Pushed by graesslin into branch 'KDE/4.9'.

Start building up of ClientModel with the first Client to include

So far the first Client to be shown in the list (that is the
currently active window) was inserted as the last client into
the list by prepending it to the list.

This meant that if another Client actually blocks the inclusion
of the currently selected Client (e.g. only one window per app)
the currently active Client never got included in this list.

This change ensures that the recently used model switching has
the starting Client as the first Client in the list and also
simplifies the code.

Stacking order switching mode is not adjusted as it seems rather
broken, like the comment already says.
FIXED-IN: 4.9.1
REVIEW: 106139

M  +4    -11   kwin/tabbox/clientmodel.cpp
M  +3    -0    kwin/tabbox/tabbox.cpp

http://commits.kde.org/kde-workspace/567f8cc50082ce5307aa7163fdf3176446a1df5a