2006-12-26

GNOME "focus stealing prevention" a sick joke

Yet another in the long line of things that sound like a good idea on paper but work terribly in practice is GNOME's so-called "focus stealing prevention". Supposedly, this is supposed to ensure that a new pop-up window doesn't steal the focus from what you're doing. In practice, it means that:

  • Clicking on the Firefox icon in the GNOME panel opens a new Firefox window, but doesn't give it the focus. So you start typing into Google's search box, or hit control-L or whatever, and the application you were using before you clicked to start Firefox gets those keystrokes instead of Firefox. Despite the fact that the user's action clearly said "I want to work with Firefox now".

  • Clicking on links in other programs opens a new Firefox window, but again, focus stays where it was so it's a pain to interact with this new window, pretty much forcing the use of the mouse. Also, the new window won't necessarily be on top. Despite the fact that the user's action clearly said "I want to follow this link now". (The actual default behavior, at least on Ubuntu 6.10, is even worse: if you already have a Firefox window open, you'll get a new tab in one of your existing windows, so not only has the computer done something non-obvious, it's done a decent job of hiding the fact that it's done anything at all.)

  • Java programs that want to pass the focus between their own windows can no longer necessarily do what they want. Despite the fact that this may be in response to a clear and explicit user action. (Fixed in Java 7, I believe, though it will be some time before that's of any use to most users. Presumably fixed in such a way that well-behaved and badly-behaved applications alike can go back to doing what they like.)

  • Programs like Evolution – one of the most important GNOME programs – still happily steal the focus. I was writing a mail earlier (Evolution's bad behavior prompted this rant) and Evolution popped up some dialog that was dismissed by one of the keys in "ing", since I was part-way through typing the word "thing". I've no idea what that dialog said, since all I saw was a flash. I've also no idea what my response to it was, or what that caused to happen, and what problems/misconfiguration lie in store for me now. Despite the fact that the user's clear intention was to keep writing the damn mail.


I just don't believe that focus stealing was a technological problem in the first place. It was a social problem of getting developers to write well-behaved programs. There will always be a need for a program to pass focus around between its own windows based on user actions to smooth out the user's work flow. There will always a need for programs to hand focus (and topmost window status) to other programs based on user actions. So you can't take those abilities away (though you can make them harder to make use of, as we've seen with GNOME). And as long as you have these two abilities, you'll be able to write crappy programs like Evolution or GAIM that consistently and uselessly steal the focus.

Not only do naughty programs like Evolution get to continue to misbehave, but funnily enough, Firefox, which suffered the heavy usability damage described above (Firefox bug 223492) from this GNOME "feature", is one of the best-behaved programs on any of my desktops when it comes to not stealing focus. It carefully places what would traditionally be error dialogs inside the window as content instead (such as the "Try Again" button when a page fails to load), leaving focus wherever it used to be, be that with another program or elsewhere in Firefox.

Finally, although some authors whose programs may have improved their programs now breakage has forced them to become educated, that doesn't help future authors. Adding something to your library that provides Firefox-style in-window dialogs or whatever, though, and/or documentation that explains the problems of focus and includes suggestions of alternatives that may work for various kinds of application: that wouldn't break existing (well-behaved!) applications, and would potentially get us into a much better position. If they wanted something to break, why didn't they break the dialog popping-up code? Alternatively, they could have submitted patches to annoying applications they cared about. Evolution's the only application I use at the moment that's badly-behaved. (Though it's difficult to submit a bug report when you've not the faintest idea what the accidentally-dismissed dialog was.)

What we have at the moment, though, just makes everything slightly worse.

Some days I'm vaguely optimistic about Linux on the desktop. Firefox, for example, is pretty damn good on Linux. But other days, I despair. For example: if people want a technological problem to fix, how about making the clipboard persist when applications exit, like it does on Mac OS and Windows? We've only been waiting for that for 20 years now...