From 9ad5c916f3e9153d94c65b0b3c992009610fe73f Mon Sep 17 00:00:00 2001 From: Salvatore Gabriele La Greca <35406071+thegabriele97@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:56:34 +0100 Subject: [PATCH] layout/floating: allow size altering if window was maximized (#2038) --- src/shell/element/surface.rs | 15 +++++++++++++++ src/shell/layout/floating/mod.rs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index 0c0c2e70..570dd946 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -182,6 +182,21 @@ impl CosmicSurface { } } + pub fn last_server_size(&self) -> Option> { + match self.0.underlying_surface() { + WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| { + let attributes = states + .data_map + .get::() + .unwrap() + .lock() + .unwrap(); + attributes.current_server_state().size + }), + WindowSurface::X11(_) => None, + } + } + pub fn global_geometry(&self) -> Option> { *self .0 diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 01fcb3f0..882df294 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -686,6 +686,8 @@ impl FloatingLayout { && let Some(pending_size) = window.pending_size() { mapped_geometry.size = pending_size.as_local(); + } else if let Some(server_size) = window.active_window().last_server_size() { + mapped_geometry.size = server_size.as_local(); } *window.last_geometry.lock().unwrap() = Some(mapped_geometry); }