Bug 197264 - KMail doesn't release focus after closing a mail window
Summary: KMail doesn't release focus after closing a mail window
Status: RESOLVED DUPLICATE of bug 183911
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 4.2.4
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 228714 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-06-20 14:15 UTC by Albert Astals Cid
Modified: 2010-03-21 10:25 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Astals Cid 2009-06-20 14:15:28 UTC
Version:           1.11.90 (using 4.2.90 (KDE 4.2.90 (KDE 4.3 Beta2)), Kubuntu packages)
Compiler:          cc
OS:                Linux (x86_64) release 2.6.28-13-generic

How to reproduce:
 * Open Konsole
 * Open KMail
 * Open a new mail window in kmail
 * Use the mouse/Alt+tab so that the window that comes after new mail window in Alt+tab is Konsole
 * Close the new mail window
 * Konsole is shown
 * Type something
 * Realize that is not konsole but kmail that is getting the text input

That happens in KDE 4.3 beta 2 and KDE 4.2.4 but i think it did work correctly in earlier versions
Comment 1 Thomas McGuire 2009-06-23 20:46:54 UTC
Although I can reproduce it, I have no idea what might be causing this.

Happens also with Kopete, so I assume KWin or kdelibs problem, reassigning to KWin for now.
Comment 2 Martin Flöser 2009-06-23 20:53:05 UTC
To me this is the expected behaviour. Each window is independent. So closing the topmost window in the stacking order will of course give focus to the next window in stacking order - which is in that case konsole.

I am not aware of any change concerning handling of stacking order. I will try to reproduce with 4.2 - as said I'm expecting the same behaviour there.
Comment 3 Albert Astals Cid 2009-06-23 20:56:24 UTC
READ better, Konsole is NOT getting the focus, that's what i complain about
Comment 4 Martin Flöser 2009-06-23 20:59:34 UTC
(In reply to comment #3)
> READ better, Konsole is NOT getting the focus, that's what i complain about
sorry totally missread the last point :-( so forget my comment

And I'm able to reproduce in 4.3 and will try with 4.2
Comment 5 Martin Flöser 2009-06-23 21:27:26 UTC
just tested with 4.2 and the behaviour is reproducable as well.
Comment 6 Gunnstein Lye 2009-09-03 10:06:21 UTC
Confirmed on KDE 4.3.1 r163 (opensuse/packman rpms) using multiple windows of thunderbird, or firefox, or konsole. When an application has multiple windows open, closing one of the windows brings focus to another window of the same application, NOT to the next window in the stacking order (unless of course that window belongs to the same application). The newly focused window is NOT brought to front, so it is not very visible that this happens. This has several times caused me to type into or even close the wrong window - potentially a quite harmful bug.

I confirm this is not an issue with kmail or konsole, it is general and probably lies within kwin.
Comment 7 Gunnstein Lye 2009-12-01 13:19:33 UTC
Wondering why there is little activity on this. I'd expect hordes of people to be annoyed by it. Does it only happen for some users, perhaps?
Comment 8 Thomas Lübking 2009-12-01 16:36:19 UTC
the code is in activation.cpp - apparently the "other group members first" policy is intended.

replacing line 456

   requestFocus( get_focus );

with

   takeActivity( get_focus, ActivityFocus|ActivityRaise, false );

would raise the new client, what sounds reasonable to me (as either the window /is/ on top as it's next in stack or it gets focus by the group exception handling) but there might be other reasons to not raise it...
Comment 9 Gunnstein Lye 2009-12-02 11:40:40 UTC
Thomas Lübking:
group members = other windows of same application?
new client = ?

"focus stays within application" would be less likely to cause data loss if windows were raised when they got focus, but this does not happen (no matter which "focus stealing prevention level" in System Settings > Window Behavior > Focus). The way it is now is counter intuitive:
* Focus a Konsole window
* Focus a KWrite window
* Open another Konsole window, close it again
* Kwrite is now on top, but Konsole has focus
* Type something, the input goes to Konsole
(Tested at all five focus stealing prevention levels, KDE 4.3.3.)

Can this really be intentional??
Expected: In the example above, focus should go to KWrite when the second Konsole is closed.
Comment 10 Thomas Lübking 2009-12-02 17:10:09 UTC
all konsole windows run in one process, that's why they're considered siblings

i read the "intention" from a comment in the code - but have no deeper insight to it.

as mentioned i'd find an autoraise reasonable, but am not in position to decide as i simply know far to few (read: "nothing") about the reasons behind the current behaviour.

please keep in mind that the current behaviour collides with /your/ usecase and setup (click to focus) but _may_ be crucial to provide other setups (focus under mouse or whatever) i.e. an uninformed changed could screw other things deeply (eg. cause race conditions or whatever), that's why i can only point the relevant code change atm.
Comment 11 Martin Flöser 2010-02-27 09:24:55 UTC
*** Bug 228714 has been marked as a duplicate of this bug. ***
Comment 12 Neil Skrypuch 2010-02-27 09:51:18 UTC
I think there's little activity on this because it's not obvious what's happening unless you're actively looking for it.

Since updating to KDE 4 over a year ago, I noticed that kwin would often (but not always) leave nothing in focus after closing a window. I realize now that it wasn't nothing, but the very subtle default window hint for the in focus window plus a large number of open windows made me unable to see what was in focus, other than the fact that it wasn't the window I was expecting to be in focus.

For me, at any particular time I normally have more konsoles open than all non-konsoles combined, so I don't run into this especially frequently. (see bug 228714 for further explanation)

Anyways, while annoying, the above factors are what kept me from reporting this bug until now. Had the bug occurred every time instead of just sometimes, or if it was obvious that the wrong window was in focus, I almost certainly would discovered how to reproduce it, and then reported it within a day or two of trying KDE 4 for the first time.
Comment 13 Martin Flöser 2010-03-21 10:25:31 UTC
In bug #183911 there is a patch attached, just in case anyone wants to try

*** This bug has been marked as a duplicate of bug 183911 ***