Bug 183911 - when a window is closed, a completely hidden window can get focus, but is not raised
Summary: when a window is closed, a completely hidden window can get focus, but is not...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Unspecified
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 180059 187358 197264 237044 237187 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-10 15:30 UTC by Daniel Thaler
Modified: 2011-03-08 03:13 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
cropped screen shot showing a focused window that is not raised (113.22 KB, image/jpeg)
2009-05-27 17:04 UTC, Tom
Details
First attempt (523 bytes, patch)
2009-12-19 15:36 UTC, Dimitar Toshev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Thaler 2009-02-10 15:30:16 UTC
Version:            (using KDE 4.2.0)
Installed from:    Unlisted Binary Package

When I close a window that is part of a group on the taskbar, another window of that group is activated, even if it is completely hidden behind another window. It is not raised automatically.
Additionally, if I select this active window on the taskbar, it is minimized instead of being raised.
Comment 1 Tom 2009-05-27 17:04:30 UTC
Created attachment 34049 [details]
cropped screen shot showing a focused window that is not raised
Comment 2 Tom 2009-05-27 17:06:34 UTC
How to reproduce:

1) launch thunderbird and firefox

2) reply-to an email. There are three windows open, and the reply is on top. Arrange windows so that all three are partially visible.

3) Click the firefox window to raise and focus it.

4) Move the firefox window so you can see the title bar and closing box on the reply-to window.

5) Click the closing box on the reply-to window. Focus will go to the thunderbird window, however, the unfocused firefox window will be on top. See the attached jpeg.

I've tried different settings in the click-to-focus window behavior. It has no effect on this bug. With click set to "active and raise", but *not* pass the click through you will find that clicking the interior of the focused, non-raised thunderbird window will *not* further raise or activate it. The border of the thunderbird window must be clicked. This bug is reproducable even with "active, raise, and pass click" is enabled.
Comment 3 Martin Flöser 2009-05-27 17:51:02 UTC
I just tried to reproduce with combination of kmail and konqueror and I was not able to reproduce. Could that be a special case of thunderbird? Are you able to reproduce with non Mozilla applications?
Comment 4 Tom 2009-05-27 18:32:37 UTC
Yep, I just reproduced with Emacs (as well as Firefox) and two windows from Konsole. It might be related to the task bar's concept of where to focus when there are several windows open for an application, and one of that application's windows is closed. Instead of giving focus on the window at the top of the stack of windows, focus is given to a window from the application whose window was just closed.

I run Konsole, then open another Konsole window with ctrk-shift-m or New-Window. Click and drag to get windows stacked in this order:

top window: second Konsole window which will be closed
middle window: Firefox 
bottom window: first Konsole window that will get focus, but not raise.

Close the top konsole window. Focus goes to the bottom Konsole window, and keystrokes go to this window.

Also reproduced with Emacs and two Konsole windows. The stacking order/click order is key. Create all 3 windows. Raise and focus Emacs/Firefox. Raise and focus the second Konsole window. Close the top Konsole window.

I seem to be running KDE 4.2.2-5 for fc10.

[tull ~]$ uname -a
Linux tull.achs.virginia.edu 2.6.27.21-170.2.56.fc10.i686 #1 SMP Mon Mar 23 23:37:54 EDT 2009 i686 i686 i386 GNU/Linux
[tull ~]$
Comment 5 Ivan Yosifov 2009-09-02 10:29:31 UTC
I am probably experiencing the same issue with KDE 4.3.1 on ubuntu. If the window stack top to bottom is like this: firefox, something non-firefox ( say konsole ), firefox, closing the top firefox transfers keyboard focus to the bottom firefox but doesn't rise it so konsole remains on top. This can get extremely confusing if the konsole is maximized for example.

The solution appears to simply be unconditionally rising windows when they gain focus, even if the previously focused window belongs to the same application.
Comment 6 Ivan Yosifov 2009-10-07 19:55:06 UTC
Still happening in 4.3.2 on ubuntu 9.10
Comment 7 Henrik Pauli 2009-10-11 21:40:44 UTC
It seems that kwin focuses the most recently used *related* window instead of just the most recently used window (as it has for the last over a decade).  It should definitely either raise the (unexpectedly) focused window, or follow the old behaviour.  Preferably the latter.
Comment 8 Peter Mühlenpfordt 2009-11-26 09:10:53 UTC
*** This bug has been confirmed by popular vote. ***
Comment 9 Dimitar Toshev 2009-12-19 15:36:17 UTC
Created attachment 39173 [details]
First attempt
Comment 10 Dimitar Toshev 2009-12-19 15:39:00 UTC
(In reply to comment #9)
The fix seems trivial enough, but I'm not sure if this is desirable behaviour when the focus policy is something like focus-follows-mouse. Advice welcome.
Comment 11 Martin Flöser 2010-03-21 10:25:31 UTC
*** Bug 197264 has been marked as a duplicate of this bug. ***
Comment 12 Thomas Lübking 2010-05-10 01:22:34 UTC
*** Bug 237044 has been marked as a duplicate of this bug. ***
Comment 13 Alexander Wauck 2010-05-10 02:19:14 UTC
Question: why does kwin focus the most recently used window from the same program instead of the most recently used window overall?  Why is this only applied to focus, not order?
Comment 14 Martin Flöser 2010-05-16 13:26:52 UTC
*** Bug 237187 has been marked as a duplicate of this bug. ***
Comment 15 Brendon Higgins 2010-10-02 12:58:12 UTC
Still exists in 4.5.1. A few times I have erroneously entered data, and even alt-f4 closed wrong applications by accident, because the foreground window was not actually the one that had the focus, and hid the window that did have the focus. It's particularly easy to miss using plasma-netbook configuration as every window is maximised. It's confusing and irritating behaviour when it bites you.
Comment 16 Albert Astals Cid 2010-10-02 13:10:28 UTC
I see i'm not the only one that lost work/data because of this.

@kwin dudes: What can we do to make the fix come quicker? I see there is a patch in #9, have you guys had a look at it? If it's not Ok, can you hint at what part of KWin might be the responsible one?

Thanks
Comment 17 Sönke Hahn 2010-10-02 14:47:59 UTC
This might be useful:

It seems to be reproducible with any two programs, where one hosts two focusable windows in a single process. So with two konsole windows and some other window (e.g. kate) the described behavior is reproducible, with two konqueror windows it isn't.

Also, I think, this could be considered a security risk. It's easy to mistakenly type in sensitive data into a focused but hidden application. Especially since some applications (e.g. a bash hosted in konsole) don't give much visual feedback when entering your password.
Comment 18 Chani 2010-10-02 15:50:38 UTC
hmm, I think I commented on one of the duplicates... anyways, +1 for fixing this. I'd also prefer last-window instead of last-window-in-that-process.

it probably needs upgrading to take activities into account anyways, so maybe I should take a look at that code (not today though)
Comment 19 Martin Flöser 2010-10-02 16:33:35 UTC
> @kwin dudes: What can we do to make the fix come quicker? I see there is a
> patch in #9, have you guys had a look at it? If it's not Ok, can you hint
> at what part of KWin might be the responsible one?
Patches attached to bug reports are easily lost. I would say that we are 
simply overloaded by too many bugs and we are in a state where bugzilla is a 
burdon and not a help. Maybe the patch should be opened at reviewboard?
Comment 20 Thomas Lübking 2010-10-02 16:40:18 UTC
"fix" that is simple. (patch in #9 is wrong.
the behaviour was (likely) changed on commt 802097
// http://websvn.kde.org/trunk/KDE/kdebase/workspace/kwin/activation.cpp?r1=742984&r2=802097 (lunakl)

choose the "fix" is hard, either 
- revert the commit and only consider mainwindows
- apply this patch (ignore siblings entirely)

Index: activation.cpp
===================================================================
--- activation.cpp      (Revision 1180288)
+++ activation.cpp      (Arbeitskopie)
@@ -455,11 +455,13 @@
                     if( c == NULL && !ci->isOnScreen( activeScreen()))
                         continue;
                     }
-                if( windows.contains( ci ))
-                    {
-                    get_focus = ci;
-                    break;
-                    }
+                   // http://websvn.kde.org/trunk/KDE/kdebase/workspace/kwin/activation.cpp?r1=742984&r2=802097
+//                 if( windows.contains( ci ))
+//                     {
+//                     get_focus = ci;
+//                     raiseClient( ci ); // also raise - we don't know where it came from
+//                     break;
+//                     }
                 if( get_focus == NULL )
                     get_focus = ci;
                 }

- uncomment this patch (raise them)
- make the patch more complex (check whether and how much the candidate is obscured)
Comment 21 Martin Flöser 2010-10-03 11:13:59 UTC
*** Bug 187358 has been marked as a duplicate of this bug. ***
Comment 22 FiNeX 2010-10-10 18:23:17 UTC
*** Bug 180059 has been marked as a duplicate of this bug. ***
Comment 23 Thomas Lübking 2010-11-16 21:13:35 UTC
http://svn.reviewboard.kde.org/r/5830/
Comment 24 Thomas Lübking 2010-12-20 19:22:29 UTC
SVN commit 1208125 by luebking:

adjust activateNextClient() policy
(on a client close, don't activate any random client in the 
group but only the leader -and raise it- or the last active client)
http://svn.reviewboard.kde.org/r/5830/
BUG: 183911


 M  +24 -20    activation.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1208125
Comment 25 Davor Cubranic 2011-03-08 03:13:28 UTC
Thanks Thomas, can't wait to see this shipped in next KUbuntu!