forked from nonsensical-dev/zenyx-engine
feat: attempt to close winit window (?)
This commit is contained in:
parent
d26499823b
commit
3eb358259d
2 changed files with 25 additions and 6 deletions
17
Cargo.lock
generated
17
Cargo.lock
generated
|
@ -2200,14 +2200,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"tracing-attributes",
|
||||||
"tracing-core",
|
"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]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.33"
|
version = "0.1.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ttf-parser"
|
name = "ttf-parser"
|
||||||
|
@ -3109,13 +3124,13 @@ dependencies = [
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
"futures",
|
"futures",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"regex",
|
"regex",
|
||||||
"rustyline",
|
"rustyline",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tracing",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ctx::WgpuCtx;
|
use ctx::WgpuCtx;
|
||||||
|
@ -29,7 +31,7 @@ impl ApplicationHandler for App<'_> {
|
||||||
self.ctx = Some(wgpu_ctx)
|
self.ctx = Some(wgpu_ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn window_event(
|
fn window_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event_loop: &ActiveEventLoop,
|
event_loop: &ActiveEventLoop,
|
||||||
|
@ -39,11 +41,13 @@ impl ApplicationHandler for App<'_> {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
if let Some(index) = self.window.iter().position(|window| window.id() == window_id) {
|
if let Some(index) = self.window.iter().position(|window| window.id() == window_id) {
|
||||||
let window = self.window.remove(index);
|
let mut window = self.window.remove(index);
|
||||||
// how do i close a window :(
|
let mut window = Arc::into_inner(window);
|
||||||
window.set_title("Dead window");
|
window = None;
|
||||||
|
drop(window);
|
||||||
|
|
||||||
debug!("Window closed, exiting");
|
|
||||||
|
println!("Window: {:?} closed, exiting",window_id);
|
||||||
}
|
}
|
||||||
if self.window.is_empty() {
|
if self.window.is_empty() {
|
||||||
event_loop.exit();
|
event_loop.exit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue