#1511·wslg

X11 apps never see iconified state: WM_STATE stays Normal when minimized (taskbar RAIL minimize and app-initiated iconify)

Author: ajax16384Created Sep 18, 2026Updated Sep 18, 2026
Labelsenhancement

Environment

  • WSL2 + WSLg (any user distro; verified on current Microsoft Store WSL)
  • Any X11 application (GTK3 verified; affects all X11 toolkits)
  • GDK_BACKEND=x11 (XWayland)

Symptom

When an X11 window is minimized (either by clicking the Windows taskbar button or by the app requesting iconify), the X client receives no notification:

  • no window-state-event with ICONIFIED (GTK never synthesizes it);
  • no UnmapNotify, no visibility-notify-event, no WM_STATE property change;
  • WM_STATE stays NormalState forever while the window is minimized;
  • the window's map_state stays Viewable, so XGetWindowAttributes-based detection also fails.

Consequences: GTK/Qt X11 apps keep rendering at full rate while minimized (CPU/GPU burn), and apps that react to minimize/restore (launchers, tray apps) never see the transition.

What does work: the root property _NET_ACTIVE_WINDOW is updated correctly (including None when no windows are active), so it can be used as a workaround signal, and focus events still arrive (unreliably).

Root cause (weston-mirror @ working)

In xwayland/window-manager.c:

  1. weston_wm_window_set_wm_state() is only ever called with ICCCM_NORMAL_STATE (on MapRequest) or ICCCM_WITHDRAWN_STATE (on UnmapNotify / window destroy). ICCCM_ICONIC_STATE is defined but never written.
  2. Client-initiated iconify (WM_CHANGE_STATEIconicState) is handled in weston_wm_window_handle_iconic_state() by calling xwayland_interface->set_minimized() — the RAIL window gets hidden Windows-side, but neither WM_STATE nor _NET_WM_STATE (_NET_WM_STATE_HIDDEN) is updated and the X window is not unmapped, so the client has no way to learn it was iconified.
  3. Taskbar-initiated minimize never reaches XWM at all (handled entirely on the RDP/RAIL side), so even the unmap path is not triggered.

Suggested fix

  • In the set_minimized() path (and on RAIL-side minimize of XWayland windows), write WM_STATE = IconicState and add _NET_WM_STATE_HIDDEN to _NET_WM_STATE (per EWMH); on restore, write WM_STATE = NormalState and clear the hint. GDK/gtk will then deliver GDK_WINDOW_STATE_ICONIFIED to X11 apps without any client-side changes.
  • Wire the Windows-taskbar minimize for XWayland windows to the same path.

Repro

  1. Install an X11 app, e.g. sudo apt install gedit.
  2. xprop -name gedit WM_STATENormalState (window is visible).
  3. Minimize gedit via the Windows taskbar.
  4. xprop -name gedit WM_STATE → still NormalState; the process keeps consuming CPU in top while minimized (keeps rendering frames nobody sees).

Impact

All X11 GUI apps under WSLg: wasted CPU/GPU while minimized, broken minimize/restore logic in apps that rely on iconify state (custom launchers, tray applications, remote-control tools).