Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Window Drop behavior #3315

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError};

/// Represents a window.
///
/// The window is closed when dropped.
///
/// # Threading
///
Expand All @@ -28,7 +29,6 @@ pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError};
/// window from a thread other than the main, the code is scheduled to run on
/// the main thread, and your thread may be blocked until that completes.
///
///
/// # Example
///
/// ```no_run
Expand All @@ -52,6 +52,11 @@ pub use cursor_icon::{CursorIcon, ParseError as CursorIconParseError};
/// }
/// });
/// ```
///
/// ## Platform-specific
///
/// **Web:** The [`Window`], which is represented by a `HTMLElementCanvas`, can
/// not be closed by dropping the [`Window`].
pub struct Window {
pub(crate) window: platform_impl::Window,
}
Expand All @@ -63,6 +68,9 @@ impl fmt::Debug for Window {
}

impl Drop for Window {
/// This will close the [`Window`].
///
/// See [`Window`] for more details.
fn drop(&mut self) {
self.window.maybe_wait_on_main(|w| {
// If the window is in exclusive fullscreen, we must restore the desktop
Expand Down