diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-23 18:34:28 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-23 18:34:28 +0100 |
commit | 57bb47ab1092dac7bffd707f35efa131b9bd99c3 (patch) | |
tree | cfc51622a0a0d324cc08fd849cc6ccf36b24f141 /client/src/window.rs | |
parent | d4c9a59ed41c11bf3edccc37d531da46e4fcd218 (diff) | |
download | twclient-57bb47ab1092dac7bffd707f35efa131b9bd99c3.tar twclient-57bb47ab1092dac7bffd707f35efa131b9bd99c3.tar.bz2 twclient-57bb47ab1092dac7bffd707f35efa131b9bd99c3.tar.zst |
snaps from client are displayed but with timing issues
Diffstat (limited to 'client/src/window.rs')
-rw-r--r-- | client/src/window.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/client/src/window.rs b/client/src/window.rs index 0bcac6a..a7e1859 100644 --- a/client/src/window.rs +++ b/client/src/window.rs @@ -1,4 +1,6 @@ -use crate::renderer::Renderer; +use std::sync::Arc; + +use crate::{client::Client, renderer::Renderer}; use log::warn; use winit::{ application::ApplicationHandler, @@ -8,12 +10,16 @@ use winit::{ }; pub struct WindowState { + temp_client: Option<Arc<Client>>, window: Option<(Window, Renderer<'static>)>, } impl WindowState { - pub fn new() -> Self { - Self { window: None } + pub fn new(client: Arc<Client>) -> Self { + Self { + window: None, + temp_client: Some(client), + } } } impl ApplicationHandler for WindowState { @@ -21,7 +27,11 @@ impl ApplicationHandler for WindowState { let window = event_loop .create_window(WindowAttributes::default().with_maximized(true)) .unwrap(); - let renderer = Renderer::new(unsafe { std::mem::transmute(&window) }).unwrap(); + let renderer = Renderer::new( + unsafe { std::mem::transmute(&window) }, + self.temp_client.take().unwrap(), + ) + .unwrap(); self.window = Some((window, renderer)) } @@ -31,7 +41,7 @@ impl ApplicationHandler for WindowState { _window_id: WindowId, event: WindowEvent, ) { - if let Some((win, ren)) = &mut self.window { + if let Some((_win, ren)) = &mut self.window { match event { WindowEvent::CloseRequested => { event_loop.exit(); @@ -43,7 +53,6 @@ impl ApplicationHandler for WindowState { if let Err(e) = ren.redraw() { warn!("{e:?}") } - win.request_redraw(); } _ => (), } |