X11 apps never see iconified state: WM_STATE stays Normal when minimized (taskbar RAIL minimize and app-initiated iconify)
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-eventwith ICONIFIED (GTK never synthesizes it); - no
UnmapNotify, novisibility-notify-event, noWM_STATEproperty change; WM_STATEstaysNormalStateforever while the window is minimized;- the window's
map_statestaysViewable, 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:
weston_wm_window_set_wm_state()is only ever called withICCCM_NORMAL_STATE(on MapRequest) orICCCM_WITHDRAWN_STATE(on UnmapNotify / window destroy).ICCCM_ICONIC_STATEis defined but never written.- Client-initiated iconify (
WM_CHANGE_STATE→IconicState) is handled inweston_wm_window_handle_iconic_state()by callingxwayland_interface->set_minimized()— the RAIL window gets hidden Windows-side, but neitherWM_STATEnor_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. - 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), writeWM_STATE = IconicStateand add_NET_WM_STATE_HIDDENto_NET_WM_STATE(per EWMH); on restore, writeWM_STATE = NormalStateand clear the hint. GDK/gtk will then deliverGDK_WINDOW_STATE_ICONIFIEDto X11 apps without any client-side changes. - Wire the Windows-taskbar minimize for XWayland windows to the same path.
Repro
- Install an X11 app, e.g.
sudo apt install gedit. xprop -name gedit WM_STATE→NormalState(window is visible).- Minimize gedit via the Windows taskbar.
xprop -name gedit WM_STATE→ stillNormalState; the process keeps consuming CPU intopwhile 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).
Source: microsoft/wslg