feat: attempt to close winit window (?)

This commit is contained in:
Chance 2025-03-24 23:21:05 -04:00 committed by BitSyndicate
parent d6806d4dbe
commit 8f0c8dbb3d
2 changed files with 25 additions and 6 deletions

17
Cargo.lock generated
View file

@ -2200,14 +2200,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
dependencies = [
"once_cell",
]
[[package]]
name = "ttf-parser"
@ -3109,13 +3124,13 @@ dependencies = [
"dirs-next",
"futures",
"lazy_static",
"log",
"once_cell",
"parking_lot",
"regex",
"rustyline",
"thiserror 2.0.12",
"tokio",
"tracing",
"wgpu",
"winit",
]

View file

@ -1,3 +1,5 @@
use std::io::{Read, Write};
use std::ops::Deref;
use std::sync::Arc;
use ctx::WgpuCtx;
@ -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();