From e4e7567174ef2e693acad85ceffc5e6e51e5d0b2 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Mon, 22 Dec 2025 18:26:20 +0100 Subject: [PATCH] element: Clip to tile size if available instead of element geometry --- src/shell/element/mod.rs | 6 ++++++ src/shell/element/stack.rs | 9 +++++++++ src/shell/element/window.rs | 8 ++++++++ src/shell/grabs/moving.rs | 2 ++ src/shell/layout/floating/mod.rs | 2 ++ src/shell/layout/tiling/mod.rs | 4 ++++ 6 files changed, 31 insertions(+) diff --git a/src/shell/element/mod.rs b/src/shell/element/mod.rs index 6167f04f..812d572e 100644 --- a/src/shell/element/mod.rs +++ b/src/shell/element/mod.rs @@ -596,6 +596,7 @@ impl CosmicMapped { &self, renderer: &mut R, location: smithay::utils::Point, + max_size: Option>, output_scale: smithay::utils::Scale, scale: f64, alpha: f32, @@ -615,6 +616,7 @@ impl CosmicMapped { .shadow_render_element::>( renderer, location, + max_size, output_scale, scale, alpha, @@ -624,6 +626,7 @@ impl CosmicMapped { .shadow_render_element::>( renderer, location, + max_size, output_scale, scale, alpha, @@ -637,6 +640,7 @@ impl CosmicMapped { &self, renderer: &mut R, location: smithay::utils::Point, + max_size: Option>, scale: smithay::utils::Scale, alpha: f32, scanout_override: Option, @@ -826,6 +830,7 @@ impl CosmicMapped { CosmicMappedInternal::Stack(s) => s.render_elements::>( renderer, location, + max_size, scale, alpha, scanout_override, @@ -834,6 +839,7 @@ impl CosmicMapped { .render_elements::>( renderer, location, + max_size, scale, alpha, scanout_override, diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 139d642a..56e878f8 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -660,6 +660,7 @@ impl CosmicStack { &self, renderer: &mut R, location: Point, + max_size: Option>, output_scale: Scale, scale: f64, alpha: f32, @@ -697,6 +698,10 @@ impl CosmicStack { let mut geo = SpaceElement::geometry(&windows[active]).to_f64(); geo.size.h += TAB_HEIGHT as f64; + if let Some(max_size) = max_size { + geo.size = geo.size.clamp(Size::default(), max_size.to_f64()); + } + geo = geo.upscale(scale); geo.loc += location.to_f64().to_logical(output_scale); @@ -722,6 +727,7 @@ impl CosmicStack { &self, renderer: &mut R, location: Point, + max_size: Option>, scale: Scale, alpha: f32, scanout_override: Option, @@ -769,6 +775,9 @@ impl CosmicStack { let mut geo = SpaceElement::geometry(&windows[active]).to_f64(); geo.loc += location.to_f64().to_logical(scale); geo.size.h += TAB_HEIGHT as f64; + if let Some(max_size) = max_size { + geo.size = geo.size.clamp(Size::default(), max_size.to_f64()); + } let window_key = CosmicMappedKey(CosmicMappedKeyInner::Stack(Arc::downgrade(&self.0.0))); diff --git a/src/shell/element/window.rs b/src/shell/element/window.rs index 5dcf462b..e67e2533 100644 --- a/src/shell/element/window.rs +++ b/src/shell/element/window.rs @@ -358,6 +358,7 @@ impl CosmicWindow { &self, renderer: &mut R, location: Point, + max_size: Option>, output_scale: Scale, scale: f64, alpha: f32, @@ -411,6 +412,9 @@ impl CosmicWindow { } geo = geo.upscale(scale); geo.loc += location.to_f64().to_logical(output_scale); + if let Some(max_size) = max_size { + geo.size = geo.size.clamp(Size::default(), max_size.to_f64()); + } let window_key = CosmicMappedKey(CosmicMappedKeyInner::Window(Arc::downgrade(&self.0.0))); @@ -434,6 +438,7 @@ impl CosmicWindow { &self, renderer: &mut R, location: Point, + max_size: Option>, scale: Scale, alpha: f32, scanout_override: Option, @@ -490,6 +495,9 @@ impl CosmicWindow { if has_ssd { geo.size.h += SSD_HEIGHT as f64; } + if let Some(max_size) = max_size { + geo.size = geo.size.clamp(Size::default(), max_size.to_f64()); + } if (has_ssd || clip) && !is_maximized { let window_key = diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index 1078af2b..f59f93d6 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -194,6 +194,7 @@ impl MoveGrabState { renderer, (render_location - self.window.geometry().loc) .to_physical_precise_round(output_scale), + None, output_scale, alpha, Some(false), @@ -210,6 +211,7 @@ impl MoveGrabState { let shadow_element = self.window.shadow_render_element( renderer, (render_location - self.window.geometry().loc).to_physical_precise_round(output_scale), + None, output_scale, scale, alpha, diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 11cc89ec..1f3a7334 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -1506,6 +1506,7 @@ impl FloatingLayout { render_location .as_logical() .to_physical_precise_round(output_scale), + None, output_scale.into(), alpha, None, @@ -1516,6 +1517,7 @@ impl FloatingLayout { render_location .as_logical() .to_physical_precise_round(output_scale), + None, output_scale.into(), 1., alpha, diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index b39431ab..16f1068e 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -5026,6 +5026,7 @@ where shadow_elements.extend(mapped.shadow_render_element( renderer, geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, + Some(geo.size.as_logical()), Scale::from(output_scale), 1., alpha, @@ -5034,6 +5035,7 @@ where let window_elements = mapped.render_elements::>( renderer, geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, + Some(geo.size.as_logical()), Scale::from(output_scale), alpha, None, @@ -5565,6 +5567,7 @@ where renderer, geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, + Some(geo.size.as_logical()), Scale::from(output_scale), scale.x.min(scale.y), alpha, @@ -5574,6 +5577,7 @@ where //original_location, geo.loc.as_logical().to_physical_precise_round(output_scale) - elem_geometry.loc, + Some(geo.size.as_logical()), Scale::from(output_scale), alpha, None,