diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 3a0597f6..484caac7 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -170,7 +170,7 @@ impl CosmicStack { if let Some(mut geo) = p.geometry.lock().unwrap().clone() { geo.loc.y += TAB_HEIGHT; geo.size.h -= TAB_HEIGHT; - window.set_geometry(geo); + window.set_geometry(geo, TAB_HEIGHT as u32); } window.send_configure(); if let Some(idx) = idx { @@ -490,7 +490,7 @@ impl CosmicStack { let win_geo = Rectangle::from_loc_and_size(loc, size); for window in p.windows.lock().unwrap().iter() { - window.set_geometry(win_geo); + window.set_geometry(win_geo, TAB_HEIGHT as u32); } *p.geometry.lock().unwrap() = Some(geo); diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index 512f7e84..3c6ad3f2 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -92,7 +92,7 @@ struct Minimized(AtomicBool); struct Sticky(AtomicBool); #[derive(Default)] -pub struct GlobalGeometry(pub Mutex>>); +struct GlobalGeometry(Mutex>>); pub const SSD_HEIGHT: i32 = 36; pub const RESIZE_BORDER: i32 = 10; @@ -139,14 +139,30 @@ impl CosmicSurface { } } - pub fn set_geometry(&self, geo: Rectangle) { + pub fn global_geometry(&self) -> Option> { *self .0 .user_data() .get_or_insert_threadsafe(GlobalGeometry::default) .0 .lock() - .unwrap() = Some(geo); + .unwrap() + } + + pub fn set_geometry(&self, geo: Rectangle, ssd_height: u32) { + { + let mut geo = geo; + geo.size.h += ssd_height as i32; + geo.loc.y -= ssd_height as i32; + + *self + .0 + .user_data() + .get_or_insert_threadsafe(GlobalGeometry::default) + .0 + .lock() + .unwrap() = Some(geo); + } match self.0.underlying_surface() { WindowSurface::Wayland(toplevel) => { toplevel.with_pending_state(|state| state.size = Some(geo.size.as_logical())) diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index 5e995cd4..dd43457d 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -210,16 +210,11 @@ impl CosmicWindow { pub fn set_geometry(&self, geo: Rectangle) { self.0.with_program(|p| { - let loc = ( - geo.loc.x, - geo.loc.y + if p.has_ssd(true) { SSD_HEIGHT } else { 0 }, - ); - let size = ( - geo.size.w, - std::cmp::max(geo.size.h - if p.has_ssd(true) { SSD_HEIGHT } else { 0 }, 0), - ); + let ssd_height = if p.has_ssd(true) { SSD_HEIGHT } else { 0 }; + let loc = (geo.loc.x, geo.loc.y + ssd_height); + let size = (geo.size.w, std::cmp::max(geo.size.h - ssd_height, 0)); p.window - .set_geometry(Rectangle::from_loc_and_size(loc, size)); + .set_geometry(Rectangle::from_loc_and_size(loc, size), ssd_height as u32); }); } diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index 00f30285..05e71538 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -797,7 +797,7 @@ impl Workspace { } else { None }; - fullscreen.surface.set_geometry(geo); + fullscreen.surface.set_geometry(geo, 0); fullscreen.surface.send_configure(); } @@ -835,7 +835,7 @@ impl Workspace { window.set_fullscreen(true); let geo = self.output.geometry(); - let original_geometry = window.geometry().as_global(); + let original_geometry = window.global_geometry().unwrap_or_default(); let signal = if let Some(surface) = window.wl_surface() { let signal = Arc::new(AtomicBool::new(false)); add_blocker( @@ -848,7 +848,7 @@ impl Workspace { } else { None }; - window.set_geometry(geo); + window.set_geometry(geo, 0); window.send_configure(); self.fullscreen = Some(FullscreenSurface { @@ -878,7 +878,7 @@ impl Workspace { .filter(|f| &f.surface == window && f.ended_at.is_none()) { window.set_fullscreen(false); - window.set_geometry(f.original_geometry); + window.set_geometry(f.original_geometry, 0); self.floating_layer.refresh(); self.tiling_layer.recalculate(); diff --git a/src/wayland/handlers/toplevel_info.rs b/src/wayland/handlers/toplevel_info.rs index 2b196c39..18b16a07 100644 --- a/src/wayland/handlers/toplevel_info.rs +++ b/src/wayland/handlers/toplevel_info.rs @@ -3,7 +3,7 @@ use smithay::utils::{user_data::UserDataMap, Rectangle}; use crate::{ - shell::{element::surface::GlobalGeometry, CosmicSurface}, + shell::CosmicSurface, state::State, utils::prelude::Global, wayland::protocols::toplevel_info::{ @@ -52,13 +52,7 @@ impl Window for CosmicSurface { } fn global_geometry(&self) -> Option> { - self.user_data() - .get_or_insert(GlobalGeometry::default) - .0 - .lock() - .unwrap() - .clone() - .filter(|_| !self.is_minimized()) + CosmicSurface::global_geometry(self) } fn user_data(&self) -> &UserDataMap {