Comment by JoBrad

1 day ago

Windows has had a “prevent apps from stealing focus” option for at least a decade. It was one of the things that I still dislike the most about macOS, and Apple can absolutely address this.

Windows has no such option, and regularly steals focus, particularly Visual Studio/Debug tools/applications loading. It had an option for a short period with the original TweakUI, but Microsoft removed support for it even in the registry.

No OS should steal focus, Windows absolutely is guilty of it.

  • Many Linux display managers let you chose what to do, when a window requests focus. For me on Sway, it just turns the border red.

    I chose what happens after. Can recommend. I wasn't even aware of my privilege.

  • I've found that the login dialog in Win 11 no longer consistently takes focus on the password field. Really annoying to login blind and find your typing was rejected because it doesn't do the sensible thing any more.

    • When I hit Win+L to lock my screen and come back 4 hours later to input my pin, I turn on my monitor (that I turned off because every 5 minutes Windows turns it on and off again), push esc or Ctrl a few times to clear off the image, and start typing in my PIN. 90% of the time by the time my monitor displays the picture, it's sitting at the unlock screen with the last 2 digits of my 4-digit PIN

  • Windows itself isn't guilty of this in my experience (lifetime of use until Linux switch last year), but other apps like shitty Akamai. Some years ago a coworker wrote this blog post and a simple tool to find out which programs are doing it: https://forwardscattering.org/post/30

    • Windows is absolutely guilty of this, and it is trivial to reproduce.

      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.

      1 reply →

    • Why does a window manager allow applications to steal focus?

      Focus should change only in response to user commands.

How does that even work?

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.

Where's that hiding? Discord is horrifically guilty of this across every OS, so I'd love a way to quash that on at least one.

  • GNOME on Linux prevents it. You get a notification "Discord updater is ready" instead which you can activate if you want to give it focus - which I never do. F the Discord updater.