From fa353f483803ad6f2acc470dd74e2f5dd5e8341d Mon Sep 17 00:00:00 2001 From: drendog Date: Sun, 18 Aug 2024 03:38:47 +0200 Subject: [PATCH] refactor: remove unnecessary cell --- src/windowing/state/dispatches.rs | 7 +++++-- src/windowing/state/mod.rs | 17 +++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/windowing/state/dispatches.rs b/src/windowing/state/dispatches.rs index 4ad5ae2..e50b532 100644 --- a/src/windowing/state/dispatches.rs +++ b/src/windowing/state/dispatches.rs @@ -1,6 +1,9 @@ use crate::impl_empty_dispatch; use log::info; -use slint::platform::{PointerEventButton, WindowEvent}; +use slint::{ + platform::{PointerEventButton, WindowEvent}, + PhysicalSize, +}; use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{ zwlr_layer_shell_v1::ZwlrLayerShellV1, zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1}, @@ -67,7 +70,7 @@ impl Dispatch for WindowState { info!("WlOutput size changed to {}x{}", width, height); let width = width.try_into().unwrap_or_default(); let height = height.try_into().unwrap_or_default(); - state.set_output_size(width, height); + state.set_output_size(PhysicalSize::new(width, height)); } wl_output::Event::Description { ref description } => { info!("WlOutput description: {:?}", description); diff --git a/src/windowing/state/mod.rs b/src/windowing/state/mod.rs index 7416def..c006d78 100644 --- a/src/windowing/state/mod.rs +++ b/src/windowing/state/mod.rs @@ -1,4 +1,3 @@ -use std::cell::Cell; use std::rc::Rc; use log::info; use slint::{LogicalPosition, PhysicalSize}; @@ -13,7 +12,7 @@ pub struct WindowState { surface: Option>, layer_surface: Option>, size: PhysicalSize, - output_size: Cell, + output_size: PhysicalSize, pointer: Option>, window: Option>, current_pointer_position: LogicalPosition, @@ -28,7 +27,7 @@ impl WindowState { surface: None, layer_surface: None, size: PhysicalSize::default(), - output_size: Cell::new(PhysicalSize::default()), + output_size: PhysicalSize::default(), pointer: None, window: None, current_pointer_position: LogicalPosition::default(), @@ -71,9 +70,6 @@ impl WindowState { self.size } - pub fn output_size(&self) -> PhysicalSize { - self.output_size.get() - } pub const fn current_pointer_position(&self) -> LogicalPosition { self.current_pointer_position } @@ -92,9 +88,14 @@ impl WindowState { self.height } - pub fn set_output_size(&self, width: u32, height: u32) { - self.output_size.set(PhysicalSize::new(width, height)); + pub fn set_output_size(&mut self, output_size: PhysicalSize) { + self.output_size = output_size; } + + pub const fn output_size(&self) -> PhysicalSize { + self.output_size + } + pub fn set_window(&mut self, window: Rc) { self.window = Some(window); }