IMHO every desktop environment (yes, looking at you, macOS) should aggressively block focus stealing. The only conditions under which focus should change:

- I've just launched the application

- I've clicked on a window

- I've clicked the window's icon in the dock

- I've cmd-tabbed (or equivalent) to this window

- The currently focused window has produced a modal dialog, that prevents all input events from going into the original window. (Whether and when modal dialogs are OK is debatable.)

Matthew 5:37, "anything more comes from evil".

I've just launched the application

Honestly even this is questionable. If a running app gets focus between me asking for the new app to launch and that app actually launching, I probably want the existing app that has focus to keep focus until I actively click on the window of the new app.

I'd amend rollcat's statement to say something like: "I've just launched this application and not pressed another key or clicked a mouse button since then."

Once you do that, too fucking late application. Should've been faster, now you don't get focus until I actively do something.

That being said, I've only ever really noticed focus stealing issues happening on Windows or OS X, never Linux.

Correct, so the launch token should get invalidated when the user breaks the figurative focus queue by changing focus

Agree.

Applications should take about 1s to launch (median for Apple's native apps), including under moderate load, so this problem should never be perceptible. But the fallback behavior you describe is perfectly reasonable.

I think it's unreasonable for any app to be so slow to launch that this matters. Modern SSDs have 7000MB/s or more read speeds. Assuming a ridiculously bloated app of 100MB, that's enough to load the whole thing into RAM in less than a frame at the most common monitor refresh rate. The only explanation for slow load times on modern hardware is bad software.

I think it's unreasonable for any app to be so slow to launch that this matters.

That doesn't change the fact that very many apps are in fact that slow that it does matter.

I'm on an HDD and Signal Desktop is 400+ MB, so

The network is always down, the disk is always slow, and the OS never schedules your threads. Keep those in mind and your code might be good

I bet there's concerns with users who don't have a robust mental model of what applications/windows are currently alive or starting up or whatever just losing track of a window completely if it doesn't grab focus, and getting annoyed at programs seemingly failing to start up at all (because they only create a window hidden behind a newly focused window).

One-size-fits-all woes I guess.

There's a bounce animation with the application icon in the dock, and then there's a dot next to the icon to show that the application is open. That should be enough for all users.

Bring back splash screens! If your application takes ages to open, throw up a nice little title card.

Powe user ish thing i guess, but i do start multiple applications without waiting for any launch to finish, and I'd love for the one I actually want to stay focused.

I would add "I've just opened this file" which is close to "just launched the app". That requires a bit of plumbing though since it's user interaction with another app which then tells the system to open the file (and hence launch the app for it). It sounds like that's what KDE is doing here, passing the user permission (granted by double click) on to whatever opens the file.

In general I agree that most system access should only be allowed if its an actual user intent through the GUI or whatever. Obviously certain things might be granted exceptions, but the norm should be more restrictive.

> I've just launched the application

I'd even have a special sub-criterion under this: The application may only take focus once it is _ready to actually use_.

Slack is a prime example of how apps steal focus multiple times during startup: I start the app, cmd+tab to something else whilst I'm waiting, and it steals focus again at least 3 times before it's actually loaded and usable.

You can have focus once I can actually do something, not to show me "HEY LOOK I'VE LOADED YET ANOTHER BLOATED COMPONENT!"

[deleted]

Determining when an app is fully ready to actually use sounds like it might have Halting Problem issues?

The very fundamental problem is just, that the fact that the process/application/service has a PID/displays a window does not equal to the fact, that the service/application is ready to serve requests/the user.

This is why there are protocols like sd_notify [1] or readinessProbe [2] to determine the actual state of the launched service/process/application.

[1] https://www.freedesktop.org/software/systemd/man/254/sd_noti...

[2] https://kubernetes.io/docs/concepts/configuration/liveness-r...

[deleted]
[deleted]