aboutsummaryrefslogtreecommitdiff
path: root/client/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/window.rs')
-rw-r--r--client/src/window.rs21
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();
}
_ => (),
}