From 8f6ad6201752a8f40607473977c96f058524cb6f Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 31 Mar 2023 14:04:35 +0200 Subject: [PATCH] shell: Set xdg_shell v4 bounds --- src/shell/element/mod.rs | 7 +++++++ src/shell/element/surface.rs | 9 +++++++++ src/shell/layout/floating/mod.rs | 1 + src/shell/layout/tiling/mod.rs | 1 + 4 files changed, 18 insertions(+) diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 8e2d04c9..b66792e0 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -411,6 +411,13 @@ impl CosmicMapped { } } + pub fn set_bounds(&self, size: impl Into>>) { + let size = size.into(); + for (surface, _) in self.windows() { + surface.set_bounds(size.clone()) + } + } + pub fn configure(&self) { for window in match &self.element { CosmicMappedInternal::Stack(s) => { diff --git a/src/shell/element/surface.rs b/src/shell/element/surface.rs index c312c5f7..ac15a12e 100644 --- a/src/shell/element/surface.rs +++ b/src/shell/element/surface.rs @@ -120,6 +120,15 @@ impl CosmicSurface { } } + pub fn set_bounds(&self, size: impl Into>>) { + match self { + CosmicSurface::Wayland(window) => window.toplevel().with_pending_state(|state| { + state.bounds = size.into(); + }), + _ => {} + } + } + pub fn is_activated(&self) -> bool { match self { CosmicSurface::Wayland(window) => window diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 2c3499ba..e878bda0 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -90,6 +90,7 @@ impl FloatingLayout { let layers = layer_map_for_output(&output); let geometry = layers.non_exclusive_zone(); + mapped.set_bounds(geometry.size); let last_geometry = mapped.last_geometry.lock().unwrap().clone(); if let Some(size) = last_geometry.map(|g| g.size) { diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index f157c310..0723078c 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -322,6 +322,7 @@ impl TilingLayout { ) { let output = seat.active_output(); window.output_enter(&output, window.bbox()); + window.set_bounds(output.geometry().size); self.map_internal(window, &output, Some(focus_stack)); self.refresh(); }