Trying to understand GNOME's background detection

Install org.gnu.emacs from Flathub

Run this from CLI:

flatpak run org.gnu.emacs --daemon

Now Emacs runs in background. Not reported from GNOME Shell, though. Let’s kill it from System Monitor.

Now run this:

flatpak run org.gnu.emacs

Emacs runs in foreground. A new window is spawned. Let’s hide it.

M-: (make-frame-invisible nil t)

The window disappears and now GNOME lists Emacs as an “app known to be running without a window”.

From what I’ve seen, GNOME infers background apps by tracking their windows state, is it? Then how can an app start as a background app? Does it need to create a windows that is already invisible?