From 9e88d3e3f86a1248b72fdb9bab59d9936a3323a6 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Mon, 1 Dec 2025 19:28:00 +0200 Subject: Let a new window pick its own size instead of forcing a guessed placeholder Root-caused "windows spawn small and square, not remembering placement or size": new_managed_window hardcoded a fresh toplevel's geometry to 800x632 before the client had said anything about its own preferred size, and sync_geometry forced that guess onto the client's very first xdg_toplevel::configure unconditionally. Per xdg-shell, size: None on that first configure is how every mainstream compositor lets a client pick its own natural size instead; this one never did, so every app converged on the same placeholder rectangle regardless of what it would have chosen. Window::size_is_provisional marks a size that really was just the guess (not a remembered geometry, a rule's explicit geometry action, or a maximize/phone-mode fill, none of which are guesses). sync_geometry sends size: None for such a window's first configure; a new adopt_provisional_size, called from the commit handler, adopts the client's own real first size into Window::geometry the moment it commits one, clamping only position so a bigger-than-guessed window can't hang off its monitor's edge. Live-verified in a nested compositor: a zenity dialog now renders at its own compact natural size instead of being stretched to the old guess. --- crates/wayland/src/state/lifecycle.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/wayland/src/state/lifecycle.rs') diff --git a/crates/wayland/src/state/lifecycle.rs b/crates/wayland/src/state/lifecycle.rs index 1749a3c..1afa738 100644 --- a/crates/wayland/src/state/lifecycle.rs +++ b/crates/wayland/src/state/lifecycle.rs @@ -10,6 +10,15 @@ impl CompState { w.app_id = with_toplevel_app_id(toplevel.wl_surface()).unwrap_or_default(); w.geometry = srdwm_core::Rect::new(0, 0, 800, 600 + TITLEBAR_HEIGHT as i32 as u32); wm.add_window(w); + // See `Window::size_is_provisional`'s own doc comment: only + // when `add_window` actually used the guessed `800x600` above + // (not a remembered size, a rule's own `geometry` action, or a + // maximize/phone-mode fill) does the client get to pick its own + // size instead - `sync_geometry`/`adopt_provisional_size` are + // what actually act on membership here. + if wm.window(id).is_some_and(|w| w.size_is_provisional) { + self.provisional_size.insert(id); + } // Starts the open-slide tween (see `WindowAnim`'s doc comment): // the window's first `sync_geometry` call below will see this, // register the tween, and place it here - a few pixels below -- cgit v1.2.3