diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 7c65e23b..2e6e205b 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -408,6 +408,14 @@ impl CosmicMapped { } } + pub fn last_server_size(&self) -> Option> { + match &self.element { + CosmicMappedInternal::Stack(s) => s.last_server_size(), + CosmicMappedInternal::Window(w) => w.last_server_size(), + _ => unreachable!(), + } + } + pub fn set_geometry(&self, geo: Rectangle) { match &self.element { CosmicMappedInternal::Stack(s) => s.set_geometry(geo), diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 85979dac..7e0cb4ac 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -566,6 +566,13 @@ impl CosmicStack { .with_program(|p| (*p.geometry.lock().unwrap()).map(|geo| geo.size.as_logical())) } + pub fn last_server_size(&self) -> Option> { + let mut size = self.active().last_server_size()?; + // if stacked the window doesn't have SSD, instead it has a tab + size.h += TAB_HEIGHT; + Some(size) + } + pub fn set_geometry(&self, geo: Rectangle) { self.0.with_program(|p| { let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT); diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index 08343425..00d1b5e4 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -230,6 +230,16 @@ impl CosmicWindow { }) } + pub fn last_server_size(&self) -> Option> { + self.0.with_program(|p| { + let mut size = p.window.last_server_size()?; + if p.has_ssd(false) { + size.h += SSD_HEIGHT; + } + Some(size) + }) + } + pub fn set_geometry(&self, geo: Rectangle) { self.0.with_program(|p| { let ssd_height = if p.has_ssd(true) { SSD_HEIGHT } else { 0 }; diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 882df294..0ba0fee5 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -686,7 +686,7 @@ 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() { + } else if let Some(server_size) = window.last_server_size() { mapped_geometry.size = server_size.as_local(); } *window.last_geometry.lock().unwrap() = Some(mapped_geometry);