chore(layer shell): add padding action

This commit is contained in:
Ashley Wulber 2026-04-20 15:33:26 -04:00 committed by Ashley Wulber
parent e0c7d353aa
commit f6fa506f6c
3 changed files with 54 additions and 12 deletions

View file

@ -6,8 +6,8 @@ use cctk::sctk::{
};
use iced_core::layout::Limits;
use iced_core::window::Id;
use iced_core::Rectangle;
use iced_core::window::Id;
/// output for layer surface
#[derive(Debug, Clone)]
@ -150,6 +150,13 @@ pub enum Action {
/// layer of the layer surface
layer: Layer,
},
/// padding of the surface geometry
Padding {
/// id of the layer surface
id: Id,
/// padding of the surface geometry
padding: IcedMargin,
},
}
impl fmt::Debug for Action {
@ -162,35 +169,51 @@ impl fmt::Debug for Action {
),
Action::Size { id, width, height } => write!(
f,
"Action::LayerSurfaceAction::Size {{ id: {:#?}, width: {:?}, height: {:?} }}", id, width, height
"Action::LayerSurfaceAction::Size {{ id: {:#?}, width: {:?}, height: {:?} }}",
id, width, height
),
Action::Destroy(id) => write!(
f,
"Action::LayerSurfaceAction::Destroy {{ id: {:#?} }}", id
"Action::LayerSurfaceAction::Destroy {{ id: {:#?} }}",
id
),
Action::Anchor { id, anchor } => write!(
f,
"Action::LayerSurfaceAction::Anchor {{ id: {:#?}, anchor: {:?} }}", id, anchor
"Action::LayerSurfaceAction::Anchor {{ id: {:#?}, anchor: {:?} }}",
id, anchor
),
Action::ExclusiveZone { id, exclusive_zone } => write!(
f,
"Action::LayerSurfaceAction::ExclusiveZone {{ id: {:#?}, exclusive_zone: {exclusive_zone} }}", id
"Action::LayerSurfaceAction::ExclusiveZone {{ id: {:#?}, exclusive_zone: {exclusive_zone} }}",
id
),
Action::Margin { id, margin } => write!(
f,
"Action::LayerSurfaceAction::Margin {{ id: {:#?}, margin: {:?} }}", id, margin
"Action::LayerSurfaceAction::Margin {{ id: {:#?}, margin: {:?} }}",
id, margin
),
Action::KeyboardInteractivity { id, keyboard_interactivity } => write!(
Action::KeyboardInteractivity {
id,
keyboard_interactivity,
} => write!(
f,
"Action::LayerSurfaceAction::KeyboardInteractivity {{ id: {:#?}, keyboard_interactivity: {:?} }}", id, keyboard_interactivity
"Action::LayerSurfaceAction::KeyboardInteractivity {{ id: {:#?}, keyboard_interactivity: {:?} }}",
id, keyboard_interactivity
),
Action::InputZone { id, zone } => write!(
f,
"Action::LayerSurfaceAction::InputZone {{ id: {:#?}, zone: {:?} }}", id, zone
"Action::LayerSurfaceAction::InputZone {{ id: {:#?}, zone: {:?} }}",
id, zone
),
Action::Layer { id, layer } => write!(
f,
"Action::LayerSurfaceAction::Layer {{ id: {:#?}, layer: {:?} }}", id, layer
"Action::LayerSurfaceAction::Layer {{ id: {:#?}, layer: {:?} }}",
id, layer
),
Action::Padding { id, padding } => write!(
f,
"Action::LayerSurfaceAction::Padding {{ id: {:#?}, padding: {:?} }}",
id, padding
),
}
}

View file

@ -2,7 +2,7 @@
use crate::core::window::Id as SurfaceId;
use iced_runtime::{
self,
self, Action, Task,
platform_specific::{
self,
wayland::{
@ -10,7 +10,7 @@ use iced_runtime::{
layer_surface::{IcedMargin, SctkLayerSurfaceSettings},
},
},
task, Action, Task,
task,
};
pub use cctk::sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer};
@ -114,3 +114,14 @@ pub fn set_layer<Message>(id: SurfaceId, layer: Layer) -> Task<Message> {
)),
))
}
pub fn set_padding<Message>(
id: SurfaceId,
padding: IcedMargin,
) -> Task<Message> {
task::effect(Action::PlatformSpecific(
platform_specific::Action::Wayland(wayland::Action::LayerSurface(
wayland::layer_surface::Action::Padding { id, padding },
)),
))
}

View file

@ -1229,6 +1229,14 @@ impl SctkState {
}
},
platform_specific::wayland::layer_surface::Action::Padding { id, padding } => {
// corner radius padding
if let Some((protocol_object, _)) = self.corner_radii.get_mut(&id) {
if let CornerRadiusWrapper::Wlr(protocol_object) = protocol_object.0.as_ref() {
protocol_object.set_padding(padding.top, padding.right, padding.bottom, padding.left);
}
}
},
},
Action::Popup(action) => match action {
platform_specific::wayland::popup::Action::Popup { popup: settings } => {