mirror of
https://codeberg.org/waydeer/layer-shika.git
synced 2026-01-22 08:15:54 +00:00
refactor: minor changes
This commit is contained in:
parent
6264cca368
commit
9d2e8e6756
9 changed files with 59 additions and 35 deletions
|
|
@ -9,7 +9,7 @@ pub use rendering::femtovg::popup_window::PopupWindow;
|
||||||
pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig};
|
pub use wayland::config::{MultiSurfaceConfig, ShellSurfaceConfig, WaylandSurfaceConfig};
|
||||||
pub use wayland::ops::WaylandSystemOps;
|
pub use wayland::ops::WaylandSystemOps;
|
||||||
pub use wayland::session_lock::{
|
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::shell_adapter::WaylandShellSystem;
|
||||||
pub use wayland::surfaces::app_state::AppState;
|
pub use wayland::surfaces::app_state::AppState;
|
||||||
|
|
|
||||||
|
|
@ -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_config::LockConfig;
|
||||||
use layer_shika_domain::value_objects::lock_state::LockState;
|
use layer_shika_domain::value_objects::lock_state::LockState;
|
||||||
use layer_shika_domain::value_objects::output_handle::OutputHandle;
|
use layer_shika_domain::value_objects::output_handle::OutputHandle;
|
||||||
use slint_interpreter::{ComponentInstance, CompilationResult};
|
|
||||||
use slint_interpreter::Value;
|
use slint_interpreter::Value;
|
||||||
|
use slint_interpreter::{CompilationResult, ComponentInstance};
|
||||||
use smithay_client_toolkit::reexports::calloop::LoopHandle;
|
use smithay_client_toolkit::reexports::calloop::LoopHandle;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|
@ -38,7 +38,10 @@ pub trait WaylandSystemOps {
|
||||||
filter: OutputFilter,
|
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<String>;
|
fn session_lock_component_name(&self) -> Option<String>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,11 +161,15 @@ impl OutputManager {
|
||||||
_output_id: &ObjectId,
|
_output_id: &ObjectId,
|
||||||
queue_handle: &QueueHandle<AppState>,
|
queue_handle: &QueueHandle<AppState>,
|
||||||
) -> Result<(SurfaceState, ObjectId)> {
|
) -> Result<(SurfaceState, ObjectId)> {
|
||||||
let layer_shell = self.context.layer_shell.as_ref().ok_or_else(|| {
|
let layer_shell =
|
||||||
LayerShikaError::InvalidInput {
|
self.context
|
||||||
message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(),
|
.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 {
|
let setup_params = SurfaceSetupParams {
|
||||||
compositor: &self.context.compositor,
|
compositor: &self.context.compositor,
|
||||||
|
|
|
||||||
|
|
@ -220,10 +220,6 @@ impl Clone for LockPropertyOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_lock_property_operation(name: impl Into<String>, value: Value) -> LockPropertyOperation {
|
|
||||||
LockPropertyOperation::new(name, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_lock_property_operation_with_output_filter<F>(
|
pub fn create_lock_property_operation_with_output_filter<F>(
|
||||||
name: impl Into<String>,
|
name: impl Into<String>,
|
||||||
value: Value,
|
value: Value,
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ use wayland_client::{
|
||||||
use wayland_protocols::ext::session_lock::v1::client::ext_session_lock_v1::ExtSessionLockV1;
|
use wayland_protocols::ext::session_lock::v1::client::ext_session_lock_v1::ExtSessionLockV1;
|
||||||
|
|
||||||
pub use callbacks::{
|
pub use callbacks::{
|
||||||
create_lock_property_operation_with_output_filter, LockCallback, LockPropertyOperation,
|
LockCallback, LockPropertyOperation, OutputFilter,
|
||||||
OutputFilter,
|
create_lock_property_operation_with_output_filter,
|
||||||
};
|
};
|
||||||
pub use state::{ActiveLockSurface, LockConfigureContext, LockSurfaceOutputContext};
|
pub use state::{ActiveLockSurface, LockConfigureContext, LockSurfaceOutputContext};
|
||||||
|
|
||||||
|
|
@ -331,7 +331,10 @@ impl SessionLockManager {
|
||||||
self.callbacks.push(callback);
|
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 {
|
for (_, surface) in &self.lock_surfaces {
|
||||||
surface.apply_property_operation(&property_operation);
|
surface.apply_property_operation(&property_operation);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,15 +179,17 @@ impl ActiveLockSurface {
|
||||||
|
|
||||||
for property_op in &context.property_operations {
|
for property_op in &context.property_operations {
|
||||||
if property_op.should_apply(&callback_context) {
|
if property_op.should_apply(&callback_context) {
|
||||||
if let Err(err) =
|
if let Err(err) = property_op.apply_to_component(component.component_instance()) {
|
||||||
property_op.apply_to_component(component.component_instance())
|
|
||||||
{
|
|
||||||
info!(
|
info!(
|
||||||
"Failed to set lock property '{}': {err}",
|
"Failed to set lock property '{}': {err}",
|
||||||
property_op.name()
|
property_op.name()
|
||||||
);
|
);
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ pub mod lock_surface;
|
||||||
pub mod manager;
|
pub mod manager;
|
||||||
|
|
||||||
pub use manager::{
|
pub use manager::{
|
||||||
create_lock_property_operation_with_output_filter, LockCallback, LockPropertyOperation,
|
LockCallback, LockPropertyOperation, LockSurfaceOutputContext, OutputFilter,
|
||||||
LockSurfaceOutputContext, OutputFilter, SessionLockManager,
|
SessionLockManager, create_lock_property_operation_with_output_filter,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -159,11 +159,15 @@ impl WaylandShellSystem {
|
||||||
pointer: &Rc<WlPointer>,
|
pointer: &Rc<WlPointer>,
|
||||||
layer_surface_config: &LayerSurfaceConfig,
|
layer_surface_config: &LayerSurfaceConfig,
|
||||||
) -> Result<Vec<OutputSetup>> {
|
) -> Result<Vec<OutputSetup>> {
|
||||||
let layer_shell = global_ctx.layer_shell.as_ref().ok_or_else(|| {
|
let layer_shell =
|
||||||
LayerShikaError::InvalidInput {
|
global_ctx
|
||||||
message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(),
|
.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();
|
let mut setups = Vec::new();
|
||||||
|
|
||||||
|
|
@ -473,7 +477,9 @@ impl WaylandShellSystem {
|
||||||
.map_err(|e| LayerShikaError::PlatformSetup { source: e })?;
|
.map_err(|e| LayerShikaError::PlatformSetup { source: e })?;
|
||||||
app_state.set_slint_platform(Rc::clone(&platform));
|
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)
|
Ok(app_state)
|
||||||
}
|
}
|
||||||
|
|
@ -485,11 +491,15 @@ impl WaylandShellSystem {
|
||||||
event_queue: &mut EventQueue<AppState>,
|
event_queue: &mut EventQueue<AppState>,
|
||||||
pointer: &Rc<WlPointer>,
|
pointer: &Rc<WlPointer>,
|
||||||
) -> Result<Vec<OutputSetup>> {
|
) -> Result<Vec<OutputSetup>> {
|
||||||
let layer_shell = global_ctx.layer_shell.as_ref().ok_or_else(|| {
|
let layer_shell =
|
||||||
LayerShikaError::InvalidInput {
|
global_ctx
|
||||||
message: "wlr-layer-shell protocol not available - cannot create layer surfaces".into(),
|
.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();
|
let mut setups = Vec::new();
|
||||||
|
|
||||||
|
|
@ -902,8 +912,12 @@ impl WaylandSystemOps for WaylandShellSystem {
|
||||||
.register_session_lock_callback_with_filter(callback_name, handler, filter);
|
.register_session_lock_callback_with_filter(callback_name, handler, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_session_lock_property_operation(&mut self, property_operation: LockPropertyOperation) {
|
fn register_session_lock_property_operation(
|
||||||
self.state.register_session_lock_property_operation(property_operation);
|
&mut self,
|
||||||
|
property_operation: LockPropertyOperation,
|
||||||
|
) {
|
||||||
|
self.state
|
||||||
|
.register_session_lock_property_operation(property_operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session_lock_component_name(&self) -> Option<String> {
|
fn session_lock_component_name(&self) -> Option<String> {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@ use crate::wayland::session_lock::lock_context::SessionLockContext;
|
||||||
use crate::wayland::session_lock::manager::callbacks::{
|
use crate::wayland::session_lock::manager::callbacks::{
|
||||||
create_lock_callback, create_lock_callback_with_output_filter,
|
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::entities::output_registry::OutputRegistry;
|
||||||
use layer_shika_domain::value_objects::handle::SurfaceHandle;
|
use layer_shika_domain::value_objects::handle::SurfaceHandle;
|
||||||
use layer_shika_domain::value_objects::lock_config::LockConfig;
|
use layer_shika_domain::value_objects::lock_config::LockConfig;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue