wip: attempt to close winit window (?)

This commit is contained in:
Chance 2025-03-24 23:21:05 -04:00
parent 36431b4654
commit 09d69bf78d
Signed by: caznix
GPG key ID: 489D213143D753FD
2 changed files with 25 additions and 6 deletions

View file

@ -1,3 +1,5 @@
use std::io::{Read, Write};
use std::ops::Deref;
use std::sync::Arc;
use ctx::WgpuCtx;
@ -29,7 +31,7 @@ impl ApplicationHandler for App<'_> {
self.ctx = Some(wgpu_ctx)
}
}
fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
@ -39,11 +41,13 @@ impl ApplicationHandler for App<'_> {
match event {
WindowEvent::CloseRequested => {
if let Some(index) = self.window.iter().position(|window| window.id() == window_id) {
let window = self.window.remove(index);
// how do i close a window :(
window.set_title("Dead window");
let mut window = self.window.remove(index);
let mut window = Arc::into_inner(window);
window = None;
drop(window);
debug!("Window closed, exiting");
println!("Window: {:?} closed, exiting",window_id);
}
if self.window.is_empty() {
event_loop.exit();