use winit::{ application::ApplicationHandler, event::WindowEvent, event_loop::{ActiveEventLoop, EventLoop}, window::{Window, WindowId}, }; use super::Client; #[derive(Default)] pub struct App { client: Option, } impl App { pub fn run() { let event_loop = EventLoop::new().unwrap(); event_loop.run_app(&mut App::default()).unwrap(); } } impl ApplicationHandler for App { fn resumed(&mut self, event_loop: &ActiveEventLoop) { if self.client.is_none() { let window = event_loop .create_window(Window::default_attributes()) .unwrap(); let client = Client::new(window.into()); self.client = Some(client); } } fn window_event(&mut self, event_loop: &ActiveEventLoop, _id: WindowId, event: WindowEvent) { self.client.as_mut().unwrap().event(event, event_loop); } }