From 22cf1c8b70c41cb6497d2fbd20e818b09bc5e89f Mon Sep 17 00:00:00 2001 From: drendog Date: Fri, 16 Aug 2024 16:00:14 +0200 Subject: [PATCH] refactor: remove window system lifetime as it's not necessary --- src/windowing/mod.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/windowing/mod.rs b/src/windowing/mod.rs index ba3f62a..51f7fec 100644 --- a/src/windowing/mod.rs +++ b/src/windowing/mod.rs @@ -10,7 +10,7 @@ use log::{debug, info}; use slint::{platform::femtovg_renderer::FemtoVGRenderer, ComponentHandle, LogicalPosition}; use slint_interpreter::{ComponentDefinition, ComponentInstance}; use smithay_client_toolkit::reexports::{ - calloop::{self, EventLoop}, + calloop::{EventLoop, LoopHandle}, protocols_wlr::layer_shell::v1::client::{ zwlr_layer_shell_v1::{self, ZwlrLayerShellV1}, zwlr_layer_surface_v1::{Anchor, KeyboardInteractivity, ZwlrLayerSurfaceV1}, @@ -137,7 +137,7 @@ impl WindowingSystemBuilder { self } - pub fn build(self) -> Result> { + pub fn build(self) -> Result { if self.config.component_definition.is_none() { return Err(anyhow::anyhow!("Slint component not set")); } @@ -146,24 +146,25 @@ impl WindowingSystemBuilder { } } -pub struct WindowingSystem<'a> { +pub struct WindowingSystem { state: Rc>, connection: Rc, event_queue: Rc>>, component_instance: Option>, display: WlDisplay, config: WindowConfig, - event_loop: EventLoop<'a, ()>, + event_loop: EventLoop<'static, ()>, event_loop_handler: Option, } -impl<'a> WindowingSystem<'a> { +impl WindowingSystem { fn new(config: WindowConfig) -> Result { info!("Initializing WindowingSystem"); let connection = Rc::new(Connection::connect_to_env()?); let state = Rc::new(RefCell::new(WindowState::new(&config))); let display = connection.display(); let event_queue = Rc::new(RefCell::new(connection.new_event_queue())); + let global_list = Self::initialize_registry(&connection)?; let (compositor, output, layer_shell, seat) = Self::bind_globals(&global_list, &event_queue.borrow().handle())?; @@ -366,7 +367,7 @@ impl<'a> WindowingSystem<'a> { Ok(()) } - pub fn event_loop_handle(&self) -> calloop::LoopHandle<'a, ()> { + pub fn event_loop_handle(&self) -> LoopHandle<'static, ()> { self.event_loop.handle() }