refactor: remove unnecessary cell

WIP/draft
drendog 2024-08-18 03:38:47 +02:00
parent 4798275ed0
commit fa353f4838
Signed by: dwenya
GPG Key ID: 8DD77074645332D0
2 changed files with 14 additions and 10 deletions

View File

@ -1,6 +1,9 @@
use crate::impl_empty_dispatch; use crate::impl_empty_dispatch;
use log::info; 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::{ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
zwlr_layer_shell_v1::ZwlrLayerShellV1, zwlr_layer_shell_v1::ZwlrLayerShellV1,
zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1}, zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1},
@ -67,7 +70,7 @@ impl Dispatch<WlOutput, ()> for WindowState {
info!("WlOutput size changed to {}x{}", width, height); info!("WlOutput size changed to {}x{}", width, height);
let width = width.try_into().unwrap_or_default(); let width = width.try_into().unwrap_or_default();
let height = height.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 } => { wl_output::Event::Description { ref description } => {
info!("WlOutput description: {:?}", description); info!("WlOutput description: {:?}", description);

View File

@ -1,4 +1,3 @@
use std::cell::Cell;
use std::rc::Rc; use std::rc::Rc;
use log::info; use log::info;
use slint::{LogicalPosition, PhysicalSize}; use slint::{LogicalPosition, PhysicalSize};
@ -13,7 +12,7 @@ pub struct WindowState {
surface: Option<Rc<WlSurface>>, surface: Option<Rc<WlSurface>>,
layer_surface: Option<Rc<ZwlrLayerSurfaceV1>>, layer_surface: Option<Rc<ZwlrLayerSurfaceV1>>,
size: PhysicalSize, size: PhysicalSize,
output_size: Cell<PhysicalSize>, output_size: PhysicalSize,
pointer: Option<Rc<WlPointer>>, pointer: Option<Rc<WlPointer>>,
window: Option<Rc<FemtoVGWindow>>, window: Option<Rc<FemtoVGWindow>>,
current_pointer_position: LogicalPosition, current_pointer_position: LogicalPosition,
@ -28,7 +27,7 @@ impl WindowState {
surface: None, surface: None,
layer_surface: None, layer_surface: None,
size: PhysicalSize::default(), size: PhysicalSize::default(),
output_size: Cell::new(PhysicalSize::default()), output_size: PhysicalSize::default(),
pointer: None, pointer: None,
window: None, window: None,
current_pointer_position: LogicalPosition::default(), current_pointer_position: LogicalPosition::default(),
@ -71,9 +70,6 @@ impl WindowState {
self.size self.size
} }
pub fn output_size(&self) -> PhysicalSize {
self.output_size.get()
}
pub const fn current_pointer_position(&self) -> LogicalPosition { pub const fn current_pointer_position(&self) -> LogicalPosition {
self.current_pointer_position self.current_pointer_position
} }
@ -92,9 +88,14 @@ impl WindowState {
self.height self.height
} }
pub fn set_output_size(&self, width: u32, height: u32) { pub fn set_output_size(&mut self, output_size: PhysicalSize) {
self.output_size.set(PhysicalSize::new(width, height)); self.output_size = output_size;
} }
pub const fn output_size(&self) -> PhysicalSize {
self.output_size
}
pub fn set_window(&mut self, window: Rc<FemtoVGWindow>) { pub fn set_window(&mut self, window: Rc<FemtoVGWindow>) {
self.window = Some(window); self.window = Some(window);
} }