Windows OS implements the following “steal focus” logic:
- Normally, windows of programs are not allowed to steal focus when user is interacting with some window (i.e., there’s some action in the recent some seconds - configurable using
ForegroundLockTimeout
registry setting), unless they are the windows of the already active process (i.e., the process already having user interaction/focus).
- Whenever an active process starts another process, it is treated as the direct request by the user, and thus, the newly spawned process gets a limited privilege to steal the focus - but only in a few seconds from the moment it’s created.
- The process that currently has privilege to steal focus may grant its privilege to another process (again, limited to the few seconds system limitation).
So - the end result is: when the system knows that a new process was launched by user, it assumes that the user wants to see this process’ window as soon as possible. But when the process takes long to start, the system changes its mind, and decides that it will not allow the process to steal focus.
The timeout is configurable (I don’t remember where exactly; definitely in registry, but possibly also in some UI); so this is where it is expected that the users’ preference is defined.
So - despite your claim that @karolus “tries to defend the indefensible”, they are actually perfectly correct - you see the system-defined correct behavior, which occur in accordance to the system settings. It is expected, that a few seconds is the time span where the user is waiting the results of their “launch it” action. If the user does not, it’s the user error to not configure the system to allow less time for the “expect a new process’ window”.
On the other hand, if LibreOffice somehow manages to steal the focus outside of the system-configured time span, then it would definitely be a bug - please feel free to file a bug report then, as @EarnestAl suggested, and don’t forget to leave a notice about that here, mentioning the bug number for the reference.
The code to follow this logic, and some comments explaining this (together with links to MS documentation), are in commit 8d1d82dd63eada8faa2f6eb43ef900764a5fda62.
And also: there is a ForceFocusAndToFront
LibreOffice-specific (i.e., not OS-specific) setting - please check if setting it to false
in expert configuration helps your issue. IIRC, even if we have the privilege to steal focus, we honor this setting.