exit event loop properly
This commit is contained in:
parent
06de4a85e5
commit
883bd7ea69
2 changed files with 23 additions and 17 deletions
|
@ -12,14 +12,14 @@ crashreport = "1.0.1"
|
||||||
dirs-next = "2.0.0"
|
dirs-next = "2.0.0"
|
||||||
|
|
||||||
lazy_static.workspace = true
|
lazy_static.workspace = true
|
||||||
once_cell = "1.20.2"
|
once_cell = "1.21.1"
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
rustyline = { version = "15.0.0", features = ["derive", "rustyline-derive"] }
|
rustyline = { version = "15.0.0", features = ["derive", "rustyline-derive"] }
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
tokio = { version = "1.42.0", features = ["macros", "parking_lot","rt-multi-thread"] }
|
tokio = { version = "1.44.1", features = ["macros", "parking_lot","rt-multi-thread"] }
|
||||||
wgpu = "24.0.1"
|
wgpu = "24.0.3"
|
||||||
winit = "0.30.8"
|
winit = "0.30.9"
|
||||||
bytemuck = "1.21.0"
|
bytemuck = "1.21.0"
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
cgmath = "0.18.0"
|
cgmath = "0.18.0"
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Read, Write};
|
|
||||||
use std::ops::Deref;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ctx::WgpuCtx;
|
use ctx::WgpuCtx;
|
||||||
|
@ -43,15 +41,16 @@ impl ApplicationHandler for App<'_> {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
if let Some(window) = self.windows.remove(&window_id) {
|
if let Some(window) = self.windows.remove(&window_id) {
|
||||||
let mut window = Arc::into_inner(window);
|
let mut window = Arc::into_inner(window);
|
||||||
|
window = None;
|
||||||
|
// _ = window;
|
||||||
drop(window);
|
drop(window);
|
||||||
|
event_loop.exit();
|
||||||
println!("Window: {:?} closed, exiting", window_id);
|
println!("Window: {:?} closed, exiting", window_id);
|
||||||
}
|
}
|
||||||
if self.windows.is_empty() {
|
// if self.windows.is_empty() {
|
||||||
event_loop.exit();
|
// event_loop.exit();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
device_id,
|
device_id,
|
||||||
|
@ -76,7 +75,7 @@ impl ApplicationHandler for App<'_> {
|
||||||
winit::keyboard::KeyCode::Escape => {
|
winit::keyboard::KeyCode::Escape => {
|
||||||
debug!("Escape key pressed, spawning new window");
|
debug!("Escape key pressed, spawning new window");
|
||||||
let win_attr =
|
let win_attr =
|
||||||
Window::default_attributes().with_title("Zenyx - New Window");
|
Window::default_attributes().with_title(format!("Zenyx - New Window {}",self.windows.len()));
|
||||||
let new_window = Arc::new(
|
let new_window = Arc::new(
|
||||||
event_loop
|
event_loop
|
||||||
.create_window(win_attr)
|
.create_window(win_attr)
|
||||||
|
@ -93,12 +92,19 @@ impl ApplicationHandler for App<'_> {
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
WindowEvent::RedrawRequested => {
|
WindowEvent::RedrawRequested => {
|
||||||
for window in self.windows.values() {
|
if let Some(ctx) = &mut self.ctx {
|
||||||
if let Some(ctx) = &mut self.ctx {
|
ctx.draw();
|
||||||
ctx.draw();
|
}
|
||||||
|
match self.windows.get(&window_id) {
|
||||||
|
Some(window) => {
|
||||||
|
if let Some(ctx) = &mut self.ctx {
|
||||||
|
ctx.draw();
|
||||||
|
}
|
||||||
|
window.request_redraw();
|
||||||
}
|
}
|
||||||
window.request_redraw();
|
None => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
WindowEvent::Resized(size) => {
|
WindowEvent::Resized(size) => {
|
||||||
if let Some(window) = self.windows.get(&window_id) {
|
if let Some(window) = self.windows.get(&window_id) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue