refactor: remove unnecessary reference to window

WIP/draft
drendog 2024-08-16 14:48:30 +02:00
parent ce5fd96278
commit a8c21ad2bc
Signed by: dwenya
GPG Key ID: 8DD77074645332D0
2 changed files with 5 additions and 7 deletions

View File

@ -149,7 +149,6 @@ impl WindowingSystemBuilder {
pub struct WindowingSystem<'a> { pub struct WindowingSystem<'a> {
state: Rc<RefCell<WindowState>>, state: Rc<RefCell<WindowState>>,
connection: Rc<Connection>, connection: Rc<Connection>,
window: Option<Rc<FemtoVGWindow>>,
event_queue: Rc<RefCell<EventQueue<WindowState>>>, event_queue: Rc<RefCell<EventQueue<WindowState>>>,
component_instance: Option<Rc<ComponentInstance>>, component_instance: Option<Rc<ComponentInstance>>,
display: WlDisplay, display: WlDisplay,
@ -184,7 +183,6 @@ impl<'a> WindowingSystem<'a> {
let mut system = Self { let mut system = Self {
state, state,
connection, connection,
window: None,
event_queue, event_queue,
component_instance: None, component_instance: None,
display, display,
@ -295,7 +293,6 @@ impl<'a> WindowingSystem<'a> {
let (window, component_instance) = let (window, component_instance) =
self.initialize_slint_ui(renderer, component_definition)?; self.initialize_slint_ui(renderer, component_definition)?;
self.window = Some(Rc::clone(&window));
self.state.borrow_mut().set_window(window); self.state.borrow_mut().set_window(window);
self.component_instance = Some(component_instance); self.component_instance = Some(component_instance);
@ -348,7 +345,7 @@ impl<'a> WindowingSystem<'a> {
pub fn initialize_event_loop_handler(&mut self) { pub fn initialize_event_loop_handler(&mut self) {
let event_loop_handler = EventLoopHandler::new( let event_loop_handler = EventLoopHandler::new(
Rc::downgrade(self.window.as_ref().unwrap()), Rc::downgrade(self.state.borrow().window().as_ref().unwrap()),
Rc::downgrade(&self.event_queue), Rc::downgrade(&self.event_queue),
Rc::downgrade(&self.connection), Rc::downgrade(&self.connection),
Rc::downgrade(&self.state), Rc::downgrade(&self.state),
@ -377,7 +374,7 @@ impl<'a> WindowingSystem<'a> {
info!("Starting WindowingSystem main loop"); info!("Starting WindowingSystem main loop");
self.initialize_event_loop_handler(); self.initialize_event_loop_handler();
self.setup_event_sources()?; self.setup_event_sources()?;
if let Some(window) = &self.window { if let Some(window) = &self.state.borrow().window() {
window.render_frame_if_dirty(); window.render_frame_if_dirty();
} }
@ -391,7 +388,7 @@ impl<'a> WindowingSystem<'a> {
} }
pub fn window(&self) -> Rc<FemtoVGWindow> { pub fn window(&self) -> Rc<FemtoVGWindow> {
Rc::clone(self.window.as_ref().unwrap()) Rc::clone(self.state().window().as_ref().unwrap())
} }
pub fn state(&self) -> Ref<WindowState> { pub fn state(&self) -> Ref<WindowState> {

View File

@ -67,9 +67,10 @@ impl WindowState {
self.current_pointer_position = logical_position; self.current_pointer_position = logical_position;
} }
pub fn size(&self) -> PhysicalSize { pub const fn size(&self) -> PhysicalSize {
self.size self.size
} }
pub fn output_size(&self) -> PhysicalSize { pub fn output_size(&self) -> PhysicalSize {
self.output_size.get() self.output_size.get()
} }