Please Don't Steal My Focus

This used to be a decent blog. Now its turned into another bash Microsoft for page hits blog. Enjoy your new ad revenue from the Reddit/Digg crowd.

Stealing focus is vital in online poker where you can be surfing etc but when its your turn to move the software pops to the front of the screen.

If not you won’t know when its your turn !

Apart from that apps should never steal focus.

The worst I’ve experienced for doing this was notification application for a music event. It stole the focus just after my bluetooth mouse batteries died. It stopped me from accessing the application for installing bluetooth devices nor could I save any of my programs. In my rage I repeatedly press the power switch and thus broke the case.

Another hate of mine is unnecessary system tray icons. They are usually the same applications that decide they should be started when the machine is booted up thus making it 5 minutes before the machine is usable.

I’ve been upset about this for a while. The Windows Update nag box is the biggest offender, though. I can’t believe that Microsoft allowed it to work that way.

IM clients are another problem. I’m not sure if it’s the use of the flashing task in the task bar or not. But, those new windows (especially in older versions of IM clients) would often pull you out of a full-screen application.

I can see when you may want apps to steal focus. But, I think that they should be allowed to do so only after you are notified of the first attempt and given a choice: “Allow this application to steal focus?” “Always allow this application to steal focus.” “Do not allow…” etc.

Stolen Focus:
I’m typing away blissfully, and from the corner of my eye I see a window come and go, stealing my last few keystrokes. Even worse is when I’m not sure which window popped up and what did I just tell it to do?

For the disabled PC user, every mouse click and keystroke can be a major effort or literal pain. So disabled users will often go to great lengths to automate repetitive tasks and minimize the steps required to perform each task. This includes the use of macros, voice recognition, mouse and keyboard utilities, and special hardware such as head-controlled mice and programmable button boards.

But in spite of these efforts, disabled PC users are often confounded by all-too-common problems found in today’s Windows and Web applications.

Following are 20 problems with PC software that may be minor nits for many users but can be a huge problem for the disabled.

http://www.devtopics.com/pcs-and-the-disabled-20-molehills-that-become-mountains/

This is especially hilarious if you’re the kind of person who enjoys videogames, like me. Especially if the games you like are memory-hungry ones that provoke minute-long bouts of memory swapping whenever you switch out of them from fullscreen mode. I can’t tell you how many times my IM application of choice has screwed over a game of Team Fortress 2 by forcing it to minimize out of the blue in favor of a one-line message from a contact. At the best of times, it results in spending the better part of a round just trying to get back to a playable state; at the worst of times, it takes the entire operating system down with it.

Tip from Simon Peyton Jones’ site:

http://research.microsoft.com/~simonpj/win32-cheat.html

"Microsoft Powertoys is a bunch of small but useful tools. Ones I’ve used or had recommended include:

* TweakUI: a control panel that lets you alter aspects of the Windows user interface. The ones I like are:
      o File-name completion in the cmd shell.
      o Stopping popup windows stealing focus, so that your input goes to the new window."

Herrmann: Sadly, it doesn’t do a good job at it. Even after installing TweakUI and toggling that setting, Pidgin still steals focus all the time.

Hey orange, this is for you:

Happened to my wife yesterday - she was trying to use the BART
website to print herself a one-day parking pass. She was using
an OSX 10.4 powerbook with FireFox and choose Save As PDF.
Unfortunately something went wrong with Firefox at that moment
and another modal dialog appeared.

This dialog unfortunately obscured the first one but for some reason
did not have the focus. She freaked out because now she couldn’t
safely quit the application and she was afraid that she wouldn’t
be able to get back to the site without having to pay again.

Luckily the number for her parking pass was visible on the screen
so she recorded that and called the help line.

I don’t think this is a browser issue, and I think the only solution
is to insist that all modal dialogs implement the ESC key as Cancel.
The vi editor got this right 30 years ago: you should always be
allowed to press ESC to get out of whatever mode you’re in.

Focus-stealing is bad enough but … Microsof’ts source code control CORRUPTS FILES when the OS requests a restart in the middle? And no one sees anything wrong with this?

An OS restart request is just that: a request. Any app worth its salt should check the “dirty” state, pop up a “save” confirmation (or if it is in the middle of a critical operation stall until that finishes), and wait for the user to hit “save” AND commit everything to disk before telling the OS it is done by shutting down.

I’ve seen this work on Windows, so I know it’s not an OS X only thing. It’s just bad programmers not properly reacting to OS messages.

As for those saying it doesn’t happen on OS X: it does. Prime candidate is my workplace-required Norton Antivirus, which pops up its “live update” window whenever and wherever it pleases. I also notice that ChronoSync occasionally “borrows” focus (it doesn’t pop to the front, and the keyboard doesn’t trigger its “Abort” button, but it does interrupt the flow of writing for a word or two at a time, intermitently). It’s just that most OS X developers use the less-invasive methods for getting a user’s attention (bring up an alert sheet which bounces the dock icon) …

Anyway, back to the original topic: does IE still not care that you have a long missive typed in a text field when asked to restart? I know Firefox and Safari have long-since discovered that, more often than not, the thing I’ve been typing is relevant to me and I don’t want to just shut down the app without submitting it …

Disagree. I agree about the potential for damage. I was getting source one day (which takes forever). While typing happily away, my plug-in popped up and I happened to hit the letter commanding it to overwrite my local code wiping out some work.
I want a way to prevent these kind of actions, but I don’t mind the pop-up itself. I can’t do the task bar flash thing because I have mine hidden (I need the real estate). I tried to configure my meeting reminders from outlook to pop-up but they’ve made that impossible in the current version. I can’t see the task bar flash and I often miss the sound because I have headphones plugged in that I’m not wearing at the moment. So I’m late to meetings.

Switch to GNU/Linux. Most window managers do a perfect job at focus stealing prevention ;). I use KWin ATM. No app has ever stolen my focus.

Mike P: “one time i had a massive query i had constructed for use the next day. that evening windoze did an update and rebooted so the query was gone forever. so much for automatic updates.”

Sorry, Mike, but if you took the time to write a “massive query” to use the next day, and then walked away for the night without saving it first, that isn’t a Windows problem; that’s an incompetent user problem.

You can’t blame “windoze” for your own stupidity. Blame Windows for the things it does wrong (like the dialog we’re discussing here). But don’t blame it for what isn’t it’s fault.

Brian: “To everyone Bitching about the 5 minute forced restart. If I’m not mistaken, this setting only applies if you’re receiving updates from an SMS Server, and the system policy is to force a reboot. If this is happening on your home computer then something is borked, as in all my years of using XP, I’ve never seen that.”

If you’re running XP and not seeing this, you have automatic updates turned off, or don’t have an internet connection on your machine. I’m using a fresh install of Windows XP Media Edition (which is XP Pro with a handful of media enhancements added) with SP2; until I found out you could fix this issue using Group Policy Editor, it drove me nuts.

elijan sejic: "Not good if you were wacthing that XXX torrent file you just downloaded.

And don’t look me like that for using Norton - it’s a workstation at work."

So you were watching “that XXX torrent file you just downloaded” on “a workstation at work”? Is that a terribly good idea? And does your employer know about this? g

MiddleMan: “This used to be a decent blog. Now its turned into another bash Microsoft for page hits blog. Enjoy your new ad revenue from the Reddit/Digg crowd.”

I don’t see it that way. There’s nothing wrong for criticizing MS for things it does wrong; the problem is with the “Reddit/Digg” and /. crowd that insists on bashing MS for everything, even things it has no control over (see my response above to Mike P for an example). Your post is another example of a totally ludicrous post (as bad in a different way as Mike P’s), as you seem to think that MS is absolutely perfect and should never have a negative thing said about them.

However, if you feel that negative about Jeff’s posts here, I’m sure he’ll be glad to refund the membership dues that you paid in full, and you can simply delete the bookmark you have to codinghorror.com.

And Jeff? If the refund is an issue for you (like say you spent that vast amount you collected from MiddleMan already on your mortgage or something), drop me a note and I’ll chip in to help you out. g

Mike Time: "Stealing focus is vital in online poker where you can be surfing etc but when its your turn to move the software pops to the front of the screen.

If not you won’t know when its your turn !"

If you’re playing online poker, you should play online poker and not do something else. That way you’ll know when it’s your turn, and won’t need focus to be stolen.

Besides… Are you suggesting that Microsoft somehow create an API call that can only be used by online poker games to steal focus, but not be used by other applications? How exactly would that work? Would the poker game have to register with MS in order to get the information about the API? If so, what’s to prevent them from using the API in another type of application as well?

Or do we have the poker game creator get the game’s name embedded into Windows itself, so that the kernel can reject calls to the API unless the game is on the list? In that case, what happens if Vista contains the list now, and tomorrow you create a new poker game - how do you get added to the list so you can use the API? Do you wait until the next service pack for Vista? What if you’ve missed the deadline for that? Do you wait for the next release of Windows? Vista was only five years late.

You can’t allow one type of program to do something that others can’t. For instance, you can’t let one video driver do something that all other video drivers can’t do.

Peter C O Johansson: “I can’t tell you how many times my IM application of choice has screwed over a game of Team Fortress 2 by forcing it to minimize out of the blue in favor of a one-line message from a contact. At the best of times, it results in spending the better part of a round just trying to get back to a playable state; at the worst of times, it takes the entire operating system down with it.”

As I said before and now say again, that’s not Windows’ fault. It’s yours, for leaving your IM application running while you play such a resource intensive game, thereby allowing it to interrupt.

It’s fine to hammer on MS and/or Windows for things they do wrong, but you can’t blame your own screwups on them.

Tom Dibble: "An OS restart request is just that: a request. Any app worth its salt should check the “dirty” state, pop up a “save” confirmation (or if it is in the middle of a critical operation stall until that finishes), and wait for the user to hit “save” AND commit everything to disk before telling the OS it is done by shutting down.

I’ve seen this work on Windows, so I know it’s not an OS X only thing. It’s just bad programmers not properly reacting to OS messages."

Well, you’re mostly right. g A well-behaved application will request a restart, and if any running process says “No”, the restart request is denied.

However, the Windows API does allow that request to be phrased as a requirement; that’s done using the same API function (InitiateShutdown) with the SHUTDOWN_FORCE_OTHERS, SHUTDOWN_FORCE_SELF and SHUTDOWN_POWEROFF (and possibly the SHUTDOWN_GRACE_OVERRIDE) flags. That means that an ill-behaved application can force you to restart, even if you don’t want to do so. I suppose this was done so that the OS itself could force a restart, but MS couldn’t restrict it to only being used by the OS, as with some of the parameters it is quite useful from a systems/network administrator standpoint.

This is one thing unix has gotten right for over 30 years. Sloppy focus all the way!

This has always pissed me off… I dunno how many times i’ve IMed my friends chunks of code by accident. The IM client I’ve been using the last couple years, Adium, has a preference for its incoming-message-focus behavior which has been helped keep my blood pressure nice n low =)

Imagine what ?
Yesterday I got a requirement to work on which talks about EXACTLY this. In fact, the requirement talks about implementing a new feature in existing application, that will pop-up a dialogue when user tries to query some data on the form. And what is the purpose of the new screen ? Bingo…audit user access…and the icing on the cake is the new screen needs to be displayed randomly…
Sometimes, I really feel people think that computer is a magician…
:slight_smile:

KenW: If you’re running XP and not seeing this, you have automatic updates turned off, or don’t have an internet connection on your machine. I’m using a fresh install of Windows XP Media Edition (which is XP Pro with a handful of media enhancements added) with SP2; until I found out you could fix this issue using Group Policy Editor, it drove me nuts.

Are we talking about the same thing here? I was referring to the Forced reboot in 5 minutes. While I admit I don’t have my home PC set to Automatically install updates currently, I can’t think of the countdown for a forced reboot ever appearing. I only ever see that on my Work PC hooked up to the SMS server.

At home, my Automatic updates are set to Download, and notify, and I DO get the Updates have been installed, you need to reboot nag message.

So … buy a Leopard
This and many more problems fixed …

Scot, the “fix” only works if the programmers let it work. It’s enabled by default in Vista, and we still have problems with evil programmers deciding to steal the focus.