Skip to content

Replace Closed event with CloseRequested and Destroyed#476

Merged
august64 merged 3 commits intorust-windowing:masterfrom
august64:closed-destroyed
Apr 24, 2018
Merged

Replace Closed event with CloseRequested and Destroyed#476
august64 merged 3 commits intorust-windowing:masterfrom
august64:closed-destroyed

Conversation

@august64
Copy link
Copy Markdown
Member

Resolves #434

This is implemented and tested on Windows, macOS, X11, and Wayland.

Migrating to the new events is easy, since most people just need to replace all of their Closed with CloseRequested.

Implements rust-windowing#434

The existing Closed event had ambiguous meaning, both in name and in
cross-platform behavior. Closed is now split into two more precise events:

* CloseRequested - the window has been requested to close, most commonly by
having clicked the window's close button. Whether or not you respond by
closing the window is up to you.

* Destroyed - the window has been destroyed, and can no longer be safely
used.

Most notably, now you can reliably implement classic patterns like
prompting the user to save their work before closing, and have the
opportunity to perform any necessary cleanup.

Migrating to the new API is straightforward. In most cases, you can simply
replace all existing usages of Closed with CloseRequested. For more
information, see the example programs, particularly handling_close and
multiwindow.

iOS applications must replace all usages of Closed with Destroyed, and
require no other changes.
@elinorbgr
Copy link
Copy Markdown
Contributor

LGTM for the wayland part.

Copy link
Copy Markdown
Contributor

@Xaeroxe Xaeroxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows code LGTM. Thanks! This looks a lot more stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants