-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Winit window does not close after exit, but stays in a Not responding state #4135
Copy link
Copy link
Closed
Closed
Copy link
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backend
Description
Description
Hello - I love your work on this spectacular library!
I am facing an issue tho that I cannot seem to fix. It seems to be related to #3668 and I tried the fix mentioned there but with no luck. Essentially I'm trying to close the window and continue the app flow normally (then reopen later when its time for a break - its a breaktimer app, but I haven't written that logic yet). I am still trying to do step one: Close window and continue app flow, but it's not being closed! The app flow is continuing, but the window remains in a Not responding state. exiting is being called too.
Please let me know if I'm missing anything, and if it's a bug, I'd be happy to open a PR! (I would need some pointers first tho 🙏🏼)
Thank you!
struct Application {
window: Option<Window>,
}
impl Application {
fn new() -> Application {
Self { window: None }
}
}
impl ApplicationHandler for Application {
fn resumed(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) {
self.window = Some(
event_loop
.create_window(
WindowAttributes::default()
.with_decorations(false)
.with_window_level(winit::window::WindowLevel::AlwaysOnTop),
)
.unwrap(),
);
}
fn exiting(&mut self, event_loop: &winit::event_loop::ActiveEventLoop) {
println!("exit");
self.window.take();
}
fn window_event(
&mut self,
event_loop: &winit::event_loop::ActiveEventLoop,
window_id: winit::window::WindowId,
event: winit::event::WindowEvent,
) {
match event {
WindowEvent::KeyboardInput {
event:
KeyEvent {
logical_key: Key::Named(NamedKey::Escape),
..
},
..
} if window_id == self.window.as_ref().unwrap().id() => {
event_loop.exit();
}
WindowEvent::CloseRequested => {
let _ = self.window.take();
event_loop.exit();
}
_ => {}
}
}
}
fn run_window() {
let mut event_loop = EventLoop::builder()
.with_activation_policy(winit::platform::macos::ActivationPolicy::Accessory)
.build()
.unwrap();
let _ = event_loop.run_app_on_demand(&mut Application::new());
}
fn main (){
run_window();
loop {
println!("Do anything");
thread::sleep(Duration::from_secs(1));
}
}
macOS version
ProductName: macOS
ProductVersion: 15.3.1
BuildVersion: 24D70Winit version
0.30.9
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backend