fix: consider SSD/tab height when calculating last server size

This commit is contained in:
Hojjat 2026-04-14 18:06:34 -06:00 committed by Jacob Kauffmann
parent 769ca13647
commit fdf015cbcf
4 changed files with 26 additions and 1 deletions

View file

@ -408,6 +408,14 @@ impl CosmicMapped {
} }
} }
pub fn last_server_size(&self) -> Option<Size<i32, Logical>> {
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<i32, Global>) { pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
match &self.element { match &self.element {
CosmicMappedInternal::Stack(s) => s.set_geometry(geo), CosmicMappedInternal::Stack(s) => s.set_geometry(geo),

View file

@ -566,6 +566,13 @@ impl CosmicStack {
.with_program(|p| (*p.geometry.lock().unwrap()).map(|geo| geo.size.as_logical())) .with_program(|p| (*p.geometry.lock().unwrap()).map(|geo| geo.size.as_logical()))
} }
pub fn last_server_size(&self) -> Option<Size<i32, Logical>> {
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<i32, Global>) { pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
self.0.with_program(|p| { self.0.with_program(|p| {
let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT); let loc = (geo.loc.x, geo.loc.y + TAB_HEIGHT);

View file

@ -230,6 +230,16 @@ impl CosmicWindow {
}) })
} }
pub fn last_server_size(&self) -> Option<Size<i32, Logical>> {
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<i32, Global>) { pub fn set_geometry(&self, geo: Rectangle<i32, Global>) {
self.0.with_program(|p| { self.0.with_program(|p| {
let ssd_height = if p.has_ssd(true) { SSD_HEIGHT } else { 0 }; let ssd_height = if p.has_ssd(true) { SSD_HEIGHT } else { 0 };

View file

@ -686,7 +686,7 @@ impl FloatingLayout {
&& let Some(pending_size) = window.pending_size() && let Some(pending_size) = window.pending_size()
{ {
mapped_geometry.size = pending_size.as_local(); 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(); mapped_geometry.size = server_size.as_local();
} }
*window.last_geometry.lock().unwrap() = Some(mapped_geometry); *window.last_geometry.lock().unwrap() = Some(mapped_geometry);