From 042ac8550f4f3843ca0b9366f772bb9e959c0c09 Mon Sep 17 00:00:00 2001 From: drendog Date: Wed, 3 Dec 2025 19:35:56 +0100 Subject: [PATCH] feat: add missing setters on layer surface --- crates/adapters/src/lib.rs | 7 ++++++- crates/composition/src/shell.rs | 35 ++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/adapters/src/lib.rs b/crates/adapters/src/lib.rs index c2f47eb..212769e 100644 --- a/crates/adapters/src/lib.rs +++ b/crates/adapters/src/lib.rs @@ -27,6 +27,11 @@ pub mod platform { } pub mod wayland { - pub use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_surface_v1::Anchor; + pub use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{ + zwlr_layer_shell_v1::Layer as WaylandLayer, + zwlr_layer_surface_v1::{ + Anchor, KeyboardInteractivity as WaylandKeyboardInteractivity, + }, + }; } } diff --git a/crates/composition/src/shell.rs b/crates/composition/src/shell.rs index efd680d..223d8e1 100644 --- a/crates/composition/src/shell.rs +++ b/crates/composition/src/shell.rs @@ -11,12 +11,15 @@ use layer_shika_adapters::platform::calloop::{ use layer_shika_adapters::platform::slint_interpreter::{ CompilationResult, ComponentInstance, Value, }; -use layer_shika_adapters::platform::wayland::Anchor; +use layer_shika_adapters::platform::wayland::{Anchor, WaylandKeyboardInteractivity, WaylandLayer}; use layer_shika_adapters::{ AppState, ShellWindowConfig, WaylandWindowConfig, WindowState, WindowingSystemFacade, }; use layer_shika_domain::config::WindowConfig; use layer_shika_domain::errors::DomainError; +use layer_shika_domain::value_objects::keyboard_interactivity::KeyboardInteractivity; +use layer_shika_domain::value_objects::layer::Layer; +use layer_shika_domain::value_objects::margins::Margins; use std::cell::RefCell; use std::collections::HashMap; use std::os::unix::io::AsFd; @@ -41,6 +44,36 @@ impl LayerSurfaceHandle<'_> { self.window_state.layer_surface().set_exclusive_zone(zone); } + pub fn set_margins(&self, margins: Margins) { + self.window_state.layer_surface().set_margin( + margins.top, + margins.right, + margins.bottom, + margins.left, + ); + } + + pub fn set_keyboard_interactivity(&self, mode: KeyboardInteractivity) { + let wayland_mode = match mode { + KeyboardInteractivity::None => WaylandKeyboardInteractivity::None, + KeyboardInteractivity::Exclusive => WaylandKeyboardInteractivity::Exclusive, + KeyboardInteractivity::OnDemand => WaylandKeyboardInteractivity::OnDemand, + }; + self.window_state + .layer_surface() + .set_keyboard_interactivity(wayland_mode); + } + + pub fn set_layer(&self, layer: Layer) { + let wayland_layer = match layer { + Layer::Background => WaylandLayer::Background, + Layer::Bottom => WaylandLayer::Bottom, + Layer::Top => WaylandLayer::Top, + Layer::Overlay => WaylandLayer::Overlay, + }; + self.window_state.layer_surface().set_layer(wayland_layer); + } + pub fn commit(&self) { self.window_state.commit_surface(); }