Skip to content

feat(linux): wire Wayland WM state, X11 PropertyNotify wake, and Mutter/Ubuntu X11 tiling & borderless fixes - #2283

Merged
Hona merged 1 commit into
devfrom
feat/313-wayland-wm-state-x11-notify
Nov 25, 2026
Merged

Hona merged 1 commit into
devfrom
feat/313-wayland-wm-state-x11-notify

Conversation

@Hona

@Hona Hona commented Nov 25, 2026

Copy link
Copy Markdown
Member

Refs #313

Wires the Wayland backend (xdg-decoration + xdg_toplevel configure state) and X11 PropertyNotify wake through vendored winit, and fixes all four X11 issues reported from live testing #2249 on GNOME Shell 50.1 (Ubuntu 26.04 / XWayland). Shipped together in one PR so vendor/winit.patch only changes once.

Wayland backend + vendor/winit.patch (+220 lines)

  • WindowExtWayland::wayland_wm_state(&self) -> Option<(bool, Option<[bool; 4]>, Option<u16>)> (vendor/winit/src/platform/wayland.rs, wayland/window/mod.rs, wayland/window/state.rs):
    • Returns None before the initial configure (all Unknown / None) and on X11.
    • Reads configure.decoration_mode directly (Server vs Client, never inferred from capabilities).
    • Gates tiled_edges on xdg_toplevel.version() >= 2 and wm_capabilities on xdg_toplevel.version() >= 5 so sctk's default WindowManagerCapabilities::all() never leaks as known on older compositors.
    • Wakes WindowState::configure when decoration_mode or capabilities change without a size change, syncing chrome without wasting frames for views that never read WM state.
  • Pure cross-platform mapper (crates/rune/src/window/chrome/linux_wm_state.rs): decodes WindowManagerCapabilities (WINDOW_MENU, MAXIMIZE, FULLSCREEN, MINIMIZE; close stays None) and tiled edges, matching Chromium (ui/ozone/platform/wayland/host/wayland_window.h) and GTK4 (GdkToplevelCapabilities).
  • Layer-shell overlays: not xdg_toplevel surfaces; never call sync_chrome_core and remain DecorationMode::Unknown, tiled_edges: None, and all WindowActions None.

X11 PropertyNotify wake + live GNOME Shell 50.1 / Mutter fixes

  • WindowExtX11::take_wm_state_changed(&self) -> bool (vendor/winit/src/platform/x11.rs, x11/atoms.rs, x11/window.rs, x11/event_processor.rs, crates/rune/src/window/host/events.rs): sets a per-window AtomicBool and emits RedrawRequested when PropertyNotify fires on _NET_WM_STATE, _NET_WM_ALLOWED_ACTIONS, _GTK_EDGE_CONSTRAINTS, or _NET_FRAME_EXTENTS. Ordinary redraws only check the atomic (zero X11 IPC); pre-map Unknown transitions to Server/Client as soon as Mutter writes properties even without a resize or focus change.
  • Titled window tiling stayed NONE (crates/rune/src/platform/x11/wm_state.rs): Mutter's update_gtk_edge_constraints (src/x11/window-x11.c) writes _GTK_EDGE_CONSTRAINTS on priv->frame->xwindow (the reparented frame parent), not the client window. Rune now queries query_tree and reads _GTK_EDGE_CONSTRAINTS from the reparented parent frame when absent on the client window.
  • Borderless (and titled) half-tiling on Ubuntu 26.04 missed left/right: Ubuntu's ubuntu-tiling-assistant intercepts Super+Left/Right and calls window.set_maximize_flags(VERTICAL) on a half-width frame instead of meta_window_tile, so Mutter writes _GTK_EDGE_CONSTRAINTS = 0x99 (TOP_TILED | BOTTOM_TILED only) plus _NET_WM_STATE_MAXIMIZED_VERT. Rune now checks _NET_WM_STATE_MAXIMIZED_VERT && !_NET_WM_STATE_MAXIMIZED_HORZ (and the horizontal twin) against the monitor's _NET_WORKAREA (intersected with the active monitor rect, matching GTK4's gdk_x11_screen_get_work_area) to recover the flush side edge without affecting floating vertically-maximized windows.
  • Borderless decoration_mode() stayed Unknown: Mutter's update_net_frame_extents only writes _NET_FRAME_EXTENTS when priv->frame != NULL. When _NET_FRAME_EXTENTS is absent, Rune now reports DecorationMode::Client only when the app explicitly requested no native frame (!window.is_decorated()), the window is managed by an EWMH WM (_NET_WM_STATE or _NET_WM_ALLOWED_ACTIONS present), and it was not reparented into a WM frame (parent == root). Titled windows without _NET_FRAME_EXTENTS remain Unknown.

Note for downstream apps: vendor/winit.patch changed; apps pinning dev must update their [patch.crates-io] winit rev.

Verification

  • Verified vendor/winit.patch applies cleanly with zero warnings to a fresh unpack of winit-0.30.13 and reproduces vendor/winit identically.
  • Cross-platform unit tests (linux_wm_state_tests.rs, wm_state_tests.rs, x11/wm_state_tests.rs covering exact Mutter bitmasks 0xAA/0x55/0x59/0x95/0x99, reparented frame fallback, Ubuntu half-tile work-area edges, Wayland v1/v2..4/v5 gating, and headless reactivity) passed on Windows and macOS (30 passed).
  • Compiled doctests, cargo check -p rune -p rune-kit --examples --benches --tests (Windows, macOS, Linux container), cargo clippy -p rune --lib --bins --tests --example custom_titlebar (Windows, macOS, Linux container), cargo check-wasm, and cargo check-webgl all passed.
  • Not run live: no live Wayland or X11/XWayland desktop session here (and linking the full rune lib test binary inside the Linux container hit OOM SIGKILL; Linux check --examples --benches --tests and clippy --tests passed).

Copilot AI balanced review requested due to automatic review settings November 25, 2026 11:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants