Bug 87989

Summary: New windows stealing focus
Product: [Retired] Red Hat Linux Reporter: David Balažic <david.balazic>
Component: metacityAssignee: Havoc Pennington <hp>
Severity: medium Docs Contact:
Priority: medium    
Version: 9CC: mitr, wtanaka
Target Milestone: ---Keywords: MoveUpstream, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-06-09 14:26:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description David Balažic 2003-04-04 13:15:14 UTC
Description of problem:

I start a program, for example mozilla by clicking on its panel icon.
As it takes several seconds to start/appear, I go to type in another already
existing window. In the middle of my typing , the mozilla window appears and the
last part of my typing goes to the mozilla windows, instead of the other window.
My typed chars are aither lost, or worse trigger some unwanted function in
mozilla. ( Think deleteing some chars in an editor and a file manager window
pops up and deletes some file of yours. )

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. start any graphical program that takes a while to appear
2. go use some other window
Actual results:

The new window appears and takes focus

Expected results:

Focus should stay with the window the user is using.

Additional info:

Comment 1 Wesley Tanaka 2003-06-05 20:25:44 UTC
This is especially bad in the following situation:

0) run some IM program like gaim
1) start typing password into terminal window
2) someone writes you a message.  their window steals the focus
3) you finish typing your password in the chat window and send it to them.

Comment 2 Havoc Pennington 2003-06-05 20:42:57 UTC
There's a reasonably general solution here using startup notification; 
it's only going to work with GTK/Qt apps that use the new startup notification 
stuff though. This should fix Mozilla.

For GAIM though, GAIM should be fixed, it's about that simple.

Comment 3 Miloslav Trmac 2003-06-06 16:08:58 UTC
kwin has some work in this area, see
Search for "Prevention of focus stealing"

Comment 4 Havoc Pennington 2003-06-06 16:12:39 UTC
Yes, KWin work is the startup notification based stuff I'm talking about.

Comment 5 David Balažic 2003-06-09 07:40:20 UTC
I thought the simple solution is "the window manager should not change focus, 
unless the user requests it"

Comment 6 Havoc Pennington 2003-06-09 14:04:12 UTC
95% of the time if someone chooses a menu item or button that opens a new window, 
they intend to immediately use said window. So the default should be to focus the 
window - the user has requested to use that window. Which is why Windows, Mac
Classic, Mac OS X, etc. all have this default.

Comment 7 David Balažic 2003-06-09 14:16:33 UTC
For menus, yes, that is normal, but if a pre-existing window suddenly decides 
to jump in my face, that is different. It should not steal focus.
The difference in this two cases is obvious and should not be hard to implement 
either. Same thing for newly created windows. They should appear in the 
background, or wait until the user "approves" their apperance or whatever. Just 
don't let them steal the focus.

Comment 8 Havoc Pennington 2003-06-09 14:26:19 UTC
The WM can keep existing windows from raising themselves, but that 
breaks a lot of apps that have legitimate reasons to do that. 
Not all windows in X are what you think of as windows - tooltips, popup menus, 
etc. are also windows. Metacity originally did not allow apps to raise 
windows and it broke various apps. You just need to file bugs against those apps
that do things wrongly, because to allow the legitimate uses the WM must allow
the illegitimate ones also.

New windows are just what I'm talking about with the 95%. People should not 
have to explicitly focus new windows, because they almost always want them 
focused. So the computer should just do that. For the cases where you 
opened the window but aren't planning to use it, it's simple enough to 
move the focus back.

Anyway, duplicate of http://bugzilla.gnome.org/show_bug.cgi?id=82921