feat: attempt to close winit window (?)
This commit is contained in:
parent
d26499823b
commit
3eb358259d
2 changed files with 25 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue