Also, sometimes a new window will be mapped (e.g. unminimizing a
window or launching a new application). Most users want to interact
with new windows right away, so these should typically be focused.
This does conflict with the invariants for sloppy and mouse focus
modes, so this wouldn't be true for a strict-pointer-focus mode. For
all other modes (non-strict-pointer-focus modes), there are only two
cases in which a new window shouldn't be focused:
1) If the window takes a while to launch and the user starts
interacting with a different application, the new window should
not take focus.
2) If the window that will appear was not launched by the user
(error dialogs, instant messaging windows, etc.), then the window
should not take focus when it appears.
To handle these cases, Metacity compares timestamps of the event that
caused the launch and the timestamp of the last interaction with the
focused window. (Case 2 is handled by the application providing a
special timestamp of 0 for the launch time, which ensures that the
window that appears doesn't get focus)
If the newly launched window isn't focused, some things should be done
to alert the user that there is a window to work with:
1) The _NET_WM_DEMANDS_ATTENTION hint should be set
2) If the new window isn't modal for the focused window, it should
appear below the focused window so that it doesn't obscure the
focused window that the user is interacting with.
3) If the new window is modal to the focused window, the currently
focused window should lose focus but the modal window should
appear on top.
FWIW The GNOME mutter project contains a detailed explanation about /github. com/GNOME/ mutter/ blob/master/ doc/how- to-get- focus-right. txt
how to handle window focus to never have "focus stealing":
https:/
Quote follows:
Also, sometimes a new window will be mapped (e.g. unminimizing a pointer- focus mode. For pointer- focus modes), there are only two
window or launching a new application). Most users want to interact
with new windows right away, so these should typically be focused.
This does conflict with the invariants for sloppy and mouse focus
modes, so this wouldn't be true for a strict-
all other modes (non-strict-
cases in which a new window shouldn't be focused:
1) If the window takes a while to launch and the user starts
interacting with a different application, the new window should
not take focus.
2) If the window that will appear was not launched by the user
(error dialogs, instant messaging windows, etc.), then the window
should not take focus when it appears.
To handle these cases, Metacity compares timestamps of the event that
caused the launch and the timestamp of the last interaction with the
focused window. (Case 2 is handled by the application providing a
special timestamp of 0 for the launch time, which ensures that the
window that appears doesn't get focus)
If the newly launched window isn't focused, some things should be done DEMANDS_ ATTENTION hint should be set
to alert the user that there is a window to work with:
1) The _NET_WM_
2) If the new window isn't modal for the focused window, it should
appear below the focused window so that it doesn't obscure the
focused window that the user is interacting with.
3) If the new window is modal to the focused window, the currently
focused window should lose focus but the modal window should
appear on top.