Bug 87989 - New windows stealing focus
Summary: New windows stealing focus
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: metacity
Version: 9
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Havoc Pennington
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-04-04 13:15 UTC by David Balažic
Modified: 2007-04-18 16:52 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2003-06-09 14:26:19 UTC

Attachments (Terms of Use)

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

Note You need to log in before you can comment on or make changes to this bug.