From 4a7ed015f6d04f22997056dc23aafc4ebc952c22 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 18 May 2026 21:44:52 -0400 Subject: [PATCH] feat: padding setting on surface creation --- src/app/cosmic.rs | 9 ++++++++- src/surface/action.rs | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/cosmic.rs b/src/app/cosmic.rs index edca03e6..0f5ef322 100644 --- a/src/app/cosmic.rs +++ b/src/app/cosmic.rs @@ -1539,6 +1539,7 @@ impl Cosmic { live_settings: &LiveSettings, ) -> Task> { use iced_winit::commands::corner_radius; + use iced_winit::commands::layer_surface::set_padding; let id = id_wrapper.inner(); @@ -1563,9 +1564,14 @@ impl Cosmic { if let Some(cur_rad) = corners(id_wrapper, rounded, &*t, self.app.core().auto_corner_radius) { - cmds.push(corner_radius::corner_radius(id, Some(cur_rad)).discard()) + cmds.push(corner_radius::corner_radius(id, Some(cur_rad)).discard()); } } + if let (SurfaceIdWrapper::LayerSurface(id), Some(padding)) = + (id_wrapper, live_settings.padding) + { + cmds.push(set_padding(id, padding)); + } Task::batch(cmds) } @@ -1586,6 +1592,7 @@ impl Cosmic { &LiveSettings { blur: Some(self.blur_enabled), corners: None, + padding: None, }, ); self.surface_views.insert( diff --git a/src/surface/action.rs b/src/surface/action.rs index 1a647293..fc38b31d 100644 --- a/src/surface/action.rs +++ b/src/surface/action.rs @@ -8,6 +8,8 @@ use crate::Application; use iced::{Rectangle, window}; #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] use iced_runtime::platform_specific::wayland::CornerRadius; +#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] +use iced_runtime::platform_specific::wayland::layer_surface::IcedMargin; use std::any::Any; use std::sync::Arc; @@ -38,6 +40,9 @@ pub fn destroy_layer_shell(id: iced_core::window::Id) -> Action { #[derive(Debug, Default, Copy, Clone)] pub struct LiveSettings { + #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] + /// Override the surface padding value for the surface type. + pub padding: Option, #[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))] /// Override the default corner radius value for the surface type. pub corners: Option,