diff --git a/CHANGELOG.md b/CHANGELOG.md index 820d3e84..1e7b653c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Unreleased` header. - **Breaking:** On Web, remove queuing fullscreen request in absence of transient activation. - On Web, fix setting cursor icon overriding cursor visibility. - **Breaking:** On Web, return `RawWindowHandle::WebCanvas` instead of `RawWindowHandle::Web`. +- **Breaking:** On Web, macOS and iOS, return `HandleError::Unavailable` when a window handle is not available. # 0.29.5 diff --git a/src/platform_impl/ios/window.rs b/src/platform_impl/ios/window.rs index 692e70b1..63588266 100644 --- a/src/platform_impl/ios/window.rs +++ b/src/platform_impl/ios/window.rs @@ -529,9 +529,11 @@ impl Window { pub(crate) fn raw_window_handle_rwh_06( &self, ) -> Result { - Ok(self - .maybe_wait_on_main(|w| crate::SendSyncWrapper(w.raw_window_handle_rwh_06())) - .0) + if let Some(mtm) = MainThreadMarker::new() { + Ok(self.inner.get(mtm).raw_window_handle_rwh_06()) + } else { + Err(rwh_06::HandleError::Unavailable) + } } } diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 9fe312a4..4b204bb0 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -95,9 +95,11 @@ impl Window { pub(crate) fn raw_window_handle_rwh_06( &self, ) -> Result { - Ok(self - .maybe_wait_on_main(|w| crate::SendSyncWrapper(w.raw_window_handle_rwh_06())) - .0) + if let Some(mtm) = MainThreadMarker::new() { + Ok(self.window.get(mtm).raw_window_handle_rwh_06()) + } else { + Err(rwh_06::HandleError::Unavailable) + } } } diff --git a/src/window.rs b/src/window.rs index e1d0ac34..aacc5c4d 100644 --- a/src/window.rs +++ b/src/window.rs @@ -1532,7 +1532,8 @@ impl rwh_06::HasWindowHandle for Window { fn window_handle(&self) -> Result, rwh_06::HandleError> { let raw = self.window.raw_window_handle_rwh_06()?; - // SAFETY: The window handle will never be deallocated while the window is alive. + // SAFETY: The window handle will never be deallocated while the window is alive, + // and the main thread safety requirements are upheld internally by each platform. Ok(unsafe { rwh_06::WindowHandle::borrow_raw(raw) }) } }