IT lexicon › Programming › WM_Sn

WM_Sn

Programming På svenska → Updated: 2026-10-09

ICCCM 2.0's selection, one per screen, that a window manager takes ownership of when it starts — so another can take over cleanly with --replace instead of killing it.

That there can be only one window manager per screen is enforced by the X server itself: only one client may select SubstructureRedirect on the root window, and the next gets BadAccess and the familiar "another window manager is already running". The lock says nothing about who is running, though, and offers no way to switch without killing. In 1994 ICCCM 2.0 borrowed a tool from the clipboard: selections. A starting window manager takes ownership of the selection WM_S0 for screen 0, WM_S1 for the next, with XSetSelectionOwner on an invisible window of its own. If there is already an owner, the newcomer exits — unless started with --replace. Then it takes the selection anyway, the old owner receives a SelectionClear, releases its windows in an orderly fashion and exits.

That is the mechanism behind compiz --replace, the command half the Linux world typed in 2006 to swap Metacity for a spinning cube, and behind the same flag in Openbox, KWin and xfwm4. The pattern was then reused for everything that may exist only once: _NET_WM_CM_Sn for the compositor, _NET_SYSTEM_TRAY_Sn for the system tray and _XSETTINGS_Sn for the settings daemon. Holding the selection does not mean the owner can do anything in particular — that is what _NET_SUPPORTING_WM_CHECK is for — but it states unambiguously that a window manager exists and which window to send requests to. Window managers that never bothered with the ritual are still around, and they have to be killed the old way.

← Back to the lexicon