Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Event for when the application will close #128

Open
DJMcNab opened this issue Jul 31, 2023 · 0 comments
Open

Event for when the application will close #128

DJMcNab opened this issue Jul 31, 2023 · 0 comments

Comments

@DJMcNab
Copy link
Member

DJMcNab commented Jul 31, 2023

We have:

glazier/src/window.rs

Lines 773 to 779 in 618382a

/// Called when the shell requests to close the window, for example because the user clicked
/// the little "X" in the titlebar.
///
/// If you want to actually close the window in response to this request, call
/// [`WindowHandle::close`]. If you don't implement this method, clicking the titlebar "X" will
/// have no effect.
fn request_close(&mut self) {}

However, we don't report when the actual application is closing. This is most useful on macOS, as in other desktop environments (generally) the application is finished when the final window is closed1.
But for consistency, we should have the same API across all backends. This could be used for saving states, for example.
This would be slightly earlier than AppHandler::drop - the event loop might still be running at this point (?)

An implementation for macOS exists in 86f0494 (from lapce's fork)

An implementation note:
This should not be called upon calling Application::quit, for consistency with the Window methods.

AppHandler::drop could possibly be used in that case?

CC @waywardmonkeys, as discussed in Zulip.

Footnotes

  1. Customising this behaviour could make sense - e.g. for close to tray on Windows (and Linux in theory, except that there's no tray)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant