No OS should steal focus, Windows absolutely is guilty of it.
I chose what happens after. Can recommend. I wasn't even aware of my privilege.
Reproduction steps:
- Start a reply to this comment in your browser, type some example words.
- Create a BAT file with the following contents:
@echo off
timeout /t 15 /nobreak >nul
start notepad.exe
- Run the BAT file.
- Immediately switch back to the browser tab, and place your focus into the HN reply box. Type a word.
- Wait for notepad to open
- Continue typing. Your typing will go into Notepad and not the browser tab you had focused last.
This occurs commonly and continuously on Windows, it is damn obnoxious. The OS should never ever change focus, it should however flash the window/taskbar, that is acceptable, but not shift my typing into whatever arbitrary program opened. This used to be fixable via "ForegroundLockTimeout" which is what classic TweakUI altered, but was killed in Vista.If you're a Visual Studio user, it is a daily annoyance. You hit Start/Play, go about your work, and then suddenly some time later focus shifts out from under you.
Focus should change only in response to user commands.
When you launch an application or open a dialog, you expect the new window to "steal" focus. When you close a dialog, you expect focus to go back to the main window. If it didn't, it would impair usability.
So how would an OS decide when "stealing focus" is allowed and when it is not?
Like, I'm frustrated with it too. I hate when an app pops up a dialog while I'm typing and my next keystroke dismisses it and I have no idea what I've done. But at the same time, I'd hate to have to manually switch focus to a pop-up dialog every single time before dismissing it with Enter or Escape too -- that would be way too annoying in the other direction.