From 9d2e8e6756bc8a0039132dccac6a1770c053229a Mon Sep 17 00:00:00 2001 From: drendog Date: Sun, 18 Jan 2026 17:46:27 +0100 Subject: [PATCH] refactor: minor changes --- crates/adapters/src/lib.rs | 2 +- crates/adapters/src/wayland/ops.rs | 7 +++- .../src/wayland/outputs/output_manager.rs | 14 ++++--- .../wayland/session_lock/manager/callbacks.rs | 4 -- .../src/wayland/session_lock/manager/mod.rs | 9 +++-- .../src/wayland/session_lock/manager/state.rs | 10 +++-- .../adapters/src/wayland/session_lock/mod.rs | 4 +- crates/adapters/src/wayland/shell_adapter.rs | 40 +++++++++++++------ .../src/wayland/surfaces/app_state.rs | 4 +- 9 files changed, 59 insertions(+), 35 deletions(-) diff --git a/crates/adapters/src/lib.rs b/crates/adapters/src/lib.rs index 89c499c..81c6de8 100644 --- a/crates/adapters/src/lib.rs +++ b/crates/adapters/src/lib.rs @@ -9,7 +9,7 @@ pub use rendering::femtovg::popup_window::PopupWindow; pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig}; pub use wayland::ops::WaylandSystemOps; pub use wayland::session_lock::{ - create_lock_property_operation_with_output_filter, LockSurfaceOutputContext, OutputFilter, + LockSurfaceOutputContext, OutputFilter, create_lock_property_operation_with_output_filter, }; pub use wayland::shell_adapter::WaylandShellSystem; pub use wayland::surfaces::app_state::AppState; diff --git a/crates/adapters/src/wayland/ops.rs b/crates/adapters/src/wayland/ops.rs index af24b40..15df414 100644 --- a/crates/adapters/src/wayland/ops.rs +++ b/crates/adapters/src/wayland/ops.rs @@ -5,8 +5,8 @@ use crate::wayland::surfaces::app_state::AppState; use layer_shika_domain::value_objects::lock_config::LockConfig; use layer_shika_domain::value_objects::lock_state::LockState; use layer_shika_domain::value_objects::output_handle::OutputHandle; -use slint_interpreter::{ComponentInstance, CompilationResult}; use slint_interpreter::Value; +use slint_interpreter::{CompilationResult, ComponentInstance}; use smithay_client_toolkit::reexports::calloop::LoopHandle; use std::rc::Rc; @@ -38,7 +38,10 @@ pub trait WaylandSystemOps { filter: OutputFilter, ); - fn register_session_lock_property_operation(&mut self, property_operation: LockPropertyOperation); + fn register_session_lock_property_operation( + &mut self, + property_operation: LockPropertyOperation, + ); fn session_lock_component_name(&self) -> Option; diff --git a/crates/adapters/src/wayland/outputs/output_manager.rs b/crates/adapters/src/wayland/outputs/output_manager.rs index a215a49..f3526f0 100644 --- a/crates/adapters/src/wayland/outputs/output_manager.rs +++ b/crates/adapters/src/wayland/outputs/output_manager.rs @@ -161,11 +161,15 @@ impl OutputManager { _output_id: &ObjectId, queue_handle: &QueueHandle, ) -> Result<(SurfaceState, ObjectId)> { - let layer_shell = self.context.layer_shell.as_ref().ok_or_else(|| { - LayerShikaError::InvalidInput { - message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(), - } - })?; + let layer_shell = + self.context + .layer_shell + .as_ref() + .ok_or_else(|| LayerShikaError::InvalidInput { + message: + "wlr-layer-shell protocol not available - cannot create layer surfaces" + .into(), + })?; let setup_params = SurfaceSetupParams { compositor: &self.context.compositor, diff --git a/crates/adapters/src/wayland/session_lock/manager/callbacks.rs b/crates/adapters/src/wayland/session_lock/manager/callbacks.rs index 161b8eb..650d2ee 100644 --- a/crates/adapters/src/wayland/session_lock/manager/callbacks.rs +++ b/crates/adapters/src/wayland/session_lock/manager/callbacks.rs @@ -220,10 +220,6 @@ impl Clone for LockPropertyOperation { } } -pub fn create_lock_property_operation(name: impl Into, value: Value) -> LockPropertyOperation { - LockPropertyOperation::new(name, value) -} - pub fn create_lock_property_operation_with_output_filter( name: impl Into, value: Value, diff --git a/crates/adapters/src/wayland/session_lock/manager/mod.rs b/crates/adapters/src/wayland/session_lock/manager/mod.rs index 18ab4a3..b9c17bd 100644 --- a/crates/adapters/src/wayland/session_lock/manager/mod.rs +++ b/crates/adapters/src/wayland/session_lock/manager/mod.rs @@ -24,8 +24,8 @@ use wayland_client::{ use wayland_protocols::ext::session_lock::v1::client::ext_session_lock_v1::ExtSessionLockV1; pub use callbacks::{ - create_lock_property_operation_with_output_filter, LockCallback, LockPropertyOperation, - OutputFilter, + LockCallback, LockPropertyOperation, OutputFilter, + create_lock_property_operation_with_output_filter, }; pub use state::{ActiveLockSurface, LockConfigureContext, LockSurfaceOutputContext}; @@ -331,7 +331,10 @@ impl SessionLockManager { self.callbacks.push(callback); } - pub(crate) fn register_property_operation(&mut self, property_operation: LockPropertyOperation) { + pub(crate) fn register_property_operation( + &mut self, + property_operation: LockPropertyOperation, + ) { for (_, surface) in &self.lock_surfaces { surface.apply_property_operation(&property_operation); } diff --git a/crates/adapters/src/wayland/session_lock/manager/state.rs b/crates/adapters/src/wayland/session_lock/manager/state.rs index ef37408..1a09867 100644 --- a/crates/adapters/src/wayland/session_lock/manager/state.rs +++ b/crates/adapters/src/wayland/session_lock/manager/state.rs @@ -179,15 +179,17 @@ impl ActiveLockSurface { for property_op in &context.property_operations { if property_op.should_apply(&callback_context) { - if let Err(err) = - property_op.apply_to_component(component.component_instance()) - { + if let Err(err) = property_op.apply_to_component(component.component_instance()) { info!( "Failed to set lock property '{}': {err}", property_op.name() ); } else { - info!("Set lock property '{}' on output {:?}", property_op.name(), context.output_handle); + info!( + "Set lock property '{}' on output {:?}", + property_op.name(), + context.output_handle + ); } } else { info!( diff --git a/crates/adapters/src/wayland/session_lock/mod.rs b/crates/adapters/src/wayland/session_lock/mod.rs index a0a261f..8fe041c 100644 --- a/crates/adapters/src/wayland/session_lock/mod.rs +++ b/crates/adapters/src/wayland/session_lock/mod.rs @@ -3,6 +3,6 @@ pub mod lock_surface; pub mod manager; pub use manager::{ - create_lock_property_operation_with_output_filter, LockCallback, LockPropertyOperation, - LockSurfaceOutputContext, OutputFilter, SessionLockManager, + LockCallback, LockPropertyOperation, LockSurfaceOutputContext, OutputFilter, + SessionLockManager, create_lock_property_operation_with_output_filter, }; diff --git a/crates/adapters/src/wayland/shell_adapter.rs b/crates/adapters/src/wayland/shell_adapter.rs index 07168ca..40db0f3 100644 --- a/crates/adapters/src/wayland/shell_adapter.rs +++ b/crates/adapters/src/wayland/shell_adapter.rs @@ -159,11 +159,15 @@ impl WaylandShellSystem { pointer: &Rc, layer_surface_config: &LayerSurfaceConfig, ) -> Result> { - let layer_shell = global_ctx.layer_shell.as_ref().ok_or_else(|| { - LayerShikaError::InvalidInput { - message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(), - } - })?; + let layer_shell = + global_ctx + .layer_shell + .as_ref() + .ok_or_else(|| LayerShikaError::InvalidInput { + message: + "wlr-layer-shell protocol not available - cannot create layer surfaces" + .into(), + })?; let mut setups = Vec::new(); @@ -473,7 +477,9 @@ impl WaylandShellSystem { .map_err(|e| LayerShikaError::PlatformSetup { source: e })?; app_state.set_slint_platform(Rc::clone(&platform)); - info!("Minimal state initialized successfully (no layer surfaces, empty Slint platform for session locks)"); + info!( + "Minimal state initialized successfully (no layer surfaces, empty Slint platform for session locks)" + ); Ok(app_state) } @@ -485,11 +491,15 @@ impl WaylandShellSystem { event_queue: &mut EventQueue, pointer: &Rc, ) -> Result> { - let layer_shell = global_ctx.layer_shell.as_ref().ok_or_else(|| { - LayerShikaError::InvalidInput { - message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(), - } - })?; + let layer_shell = + global_ctx + .layer_shell + .as_ref() + .ok_or_else(|| LayerShikaError::InvalidInput { + message: + "wlr-layer-shell protocol not available - cannot create layer surfaces" + .into(), + })?; let mut setups = Vec::new(); @@ -902,8 +912,12 @@ impl WaylandSystemOps for WaylandShellSystem { .register_session_lock_callback_with_filter(callback_name, handler, filter); } - fn register_session_lock_property_operation(&mut self, property_operation: LockPropertyOperation) { - self.state.register_session_lock_property_operation(property_operation); + fn register_session_lock_property_operation( + &mut self, + property_operation: LockPropertyOperation, + ) { + self.state + .register_session_lock_property_operation(property_operation); } fn session_lock_component_name(&self) -> Option { diff --git a/crates/adapters/src/wayland/surfaces/app_state.rs b/crates/adapters/src/wayland/surfaces/app_state.rs index 59de79b..29e6e25 100644 --- a/crates/adapters/src/wayland/surfaces/app_state.rs +++ b/crates/adapters/src/wayland/surfaces/app_state.rs @@ -14,7 +14,9 @@ use crate::wayland::session_lock::lock_context::SessionLockContext; use crate::wayland::session_lock::manager::callbacks::{ create_lock_callback, create_lock_callback_with_output_filter, }; -use crate::wayland::session_lock::{LockCallback, LockPropertyOperation, OutputFilter, SessionLockManager}; +use crate::wayland::session_lock::{ + LockCallback, LockPropertyOperation, OutputFilter, SessionLockManager, +}; use layer_shika_domain::entities::output_registry::OutputRegistry; use layer_shika_domain::value_objects::handle::SurfaceHandle; use layer_shika_domain::value_objects::lock_config::LockConfig;