diff --git a/src/rendering/femtovg_window.rs b/src/rendering/femtovg_window.rs index 91785cf..b9c0dc9 100644 --- a/src/rendering/femtovg_window.rs +++ b/src/rendering/femtovg_window.rs @@ -47,13 +47,13 @@ impl FemtoVGWindow { } pub fn set_scale_factor(&self, scale_factor: f32) { - info!("Setting scale factor to {}", scale_factor); + info!("Setting scale factor to {scale_factor}"); self.scale_factor.set(scale_factor); self.window() .dispatch_event(WindowEvent::ScaleFactorChanged { scale_factor }); } - pub fn scale_factor(&self) -> f32 { + pub const fn scale_factor(&self) -> f32 { self.scale_factor.get() } } diff --git a/src/rendering/slint_platform.rs b/src/rendering/slint_platform.rs index c290127..1a46099 100644 --- a/src/rendering/slint_platform.rs +++ b/src/rendering/slint_platform.rs @@ -11,13 +11,13 @@ pub struct CustomSlintPlatform { } impl CustomSlintPlatform { - pub fn new(window: Rc) -> Self { + pub const fn new(window: Rc) -> Self { Self { window } } } impl Platform for CustomSlintPlatform { - fn create_window_adapter(&self) -> Result, PlatformError> { + fn create_window_adapter(&self) -> Result, PlatformError> { Result::Ok(Rc::clone(&self.window) as Rc) } } diff --git a/src/windowing/mod.rs b/src/windowing/mod.rs index 06e888c..15da7b9 100644 --- a/src/windowing/mod.rs +++ b/src/windowing/mod.rs @@ -37,6 +37,22 @@ mod config; mod macros; mod state; +type GlobalObjects = ( + WlCompositor, + WlOutput, + ZwlrLayerShellV1, + WlSeat, + Option, + Option, +); + +type SurfaceObjects = ( + Rc, + Rc, + Option>, + Option>, +); + pub struct WindowingSystem { state: WindowState, connection: Rc, @@ -108,17 +124,7 @@ impl WindowingSystem { fn initialize_globals( connection: &Connection, queue_handle: &QueueHandle, - ) -> Result< - ( - WlCompositor, - WlOutput, - ZwlrLayerShellV1, - WlSeat, - Option, - Option, - ), - LayerShikaError, - > { + ) -> Result { let global_list = registry_queue_init::(connection) .map(|(global_list, _)| global_list) .map_err(|e| LayerShikaError::GlobalInitialization(e.to_string()))?; @@ -166,12 +172,7 @@ impl WindowingSystem { viewporter: Option<&WpViewporter>, queue_handle: &QueueHandle, config: &WindowConfig, - ) -> ( - Rc, - Rc, - Option>, - Option>, - ) { + ) -> SurfaceObjects { let surface = Rc::new(compositor.create_surface(queue_handle, ())); let layer_surface = Rc::new(layer_shell.get_layer_surface( &surface, @@ -273,7 +274,7 @@ impl WindowingSystem { self.event_loop .run(None, &mut self.state, move |shared_data| { if let Err(e) = Self::process_events(connection, event_queue, shared_data) { - error!("Error processing events: {}", e); + error!("Error processing events: {e}"); } }) .map_err(|e| LayerShikaError::EventLoop(e.to_string())) diff --git a/src/windowing/state/dispatches.rs b/src/windowing/state/dispatches.rs index 61fac1a..267d8e2 100644 --- a/src/windowing/state/dispatches.rs +++ b/src/windowing/state/dispatches.rs @@ -49,10 +49,7 @@ impl Dispatch for WindowState { width, height, } => { - info!( - "Layer surface configured with compositor size: {}x{}", - width, height - ); + info!("Layer surface configured with compositor size: {width}x{height}"); layer_surface.ack_configure(serial); let output_width = state.output_size().width; @@ -112,19 +109,19 @@ impl Dispatch for WindowState { ) { match event { wl_output::Event::Mode { width, height, .. } => { - info!("WlOutput size changed to {}x{}", width, height); + info!("WlOutput size changed to {width}x{height}"); let width = width.try_into().unwrap_or_default(); let height = height.try_into().unwrap_or_default(); state.set_output_size(PhysicalSize::new(width, height)); } wl_output::Event::Description { ref description } => { - info!("WlOutput description: {:?}", description); + info!("WlOutput description: {description:?}"); } wl_output::Event::Scale { ref factor } => { - info!("WlOutput factor scale: {:?}", factor); + info!("WlOutput factor scale: {factor:?}"); } wl_output::Event::Name { ref name } => { - info!("WlOutput name: {:?}", name); + info!("WlOutput name: {name:?}"); } wl_output::Event::Geometry { x, @@ -136,7 +133,7 @@ impl Dispatch for WindowState { model, transform, } => { - info!("WlOutput geometry: x={}, y={}, physical_width={}, physical_height={}, subpixel={:?}, make={:?}, model={:?}, transform={:?}", x, y, physical_width, physical_height, subpixel, make, model, transform); + info!("WlOutput geometry: x={x}, y={y}, physical_width={physical_width}, physical_height={physical_height}, subpixel={subpixel:?}, make={make:?}, model={model:?}, transform={transform:?}"); } wl_output::Event::Done => { info!("WlOutput done"); diff --git a/src/windowing/state/mod.rs b/src/windowing/state/mod.rs index de73417..d468567 100644 --- a/src/windowing/state/mod.rs +++ b/src/windowing/state/mod.rs @@ -67,12 +67,11 @@ impl WindowState { }) } + #[allow(clippy::cast_precision_loss)] + #[allow(clippy::cast_possible_wrap)] pub fn update_size(&mut self, width: u32, height: u32) { if width == 0 || height == 0 { - info!( - "Skipping update_size with zero dimension: {}x{}", - width, height - ); + info!("Skipping update_size with zero dimension: {width}x{height}"); return; } @@ -181,7 +180,7 @@ impl WindowState { self.height } - pub fn set_output_size(&mut self, output_size: PhysicalSize) { + pub const fn set_output_size(&mut self, output_size: PhysicalSize) { self.output_size = output_size; }