iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
24.62k stars 1.15k forks source link

Trigger the CloseRequested event on every attempt to close the application #1941

Open Digitalone1 opened 1 year ago

Digitalone1 commented 1 year ago

Is there an existing issue for this?

Is this issue related to iced?

What happened?

As pointed out in #195 and https://github.com/GyulyVGC/sniffnet/issues/291 the CloseRequested is not triggered when:

You are discussing there, but maybe it's better to make a dedicated issue.

What is the expected behavior?

Trigger the CloseRequested event, not only on the two points listed above, but on every attempt to close the application.

Version

master

Operating System

Linux

Do you have any log output?

No output needed.
hecrj commented 1 year ago

Ctrl+C in a terminal is a global process interrupt and should be handled by you.

I can confirm that winit is not producing a CloseRequested event when pressing Cmd+Q on macOS. We should report that there.

GyulyVGC commented 1 year ago

I can confirm that winit is not producing a CloseRequested event when pressing Cmd+Q on macOS. We should report that there.

I don't know if it can be of any help, but I noticed that Cmd+Q doesn't even let Application::run correctly return from the invocation.

GyulyVGC commented 11 months ago

I can confirm that winit is not producing a CloseRequested event when pressing Cmd+Q on macOS. We should report that there.

This is a pretty important feature for my app since several configurations must be saved before exiting. At the same time I don't want to put pressure on you to solve this in the short term, but I was wondering if you could give me some hints that can help me fix it @hecrj

abique commented 4 months ago

Reference some related issues: https://github.com/rust-windowing/winit/issues/1992 https://github.com/rust-windowing/winit/issues/2776