macOS: fix panic during drag_window

Return error from it instead of unwrapping.
This commit is contained in:
Shane Celis 2024-10-22 07:00:53 -04:00 committed by GitHub
parent fb6b1d487b
commit a5f5ce6a3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -186,6 +186,7 @@ changelog entry.
- On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name.
- On macOS, fix `WindowEvent::Moved` sometimes being triggered unnecessarily on resize.
- On MacOS, package manifest definitions of `LSUIElement` will no longer be overridden with the
- On macOS, package manifest definitions of `LSUIElement` will no longer be overridden with the
default activation policy, unless explicitly provided during initialization.
- On macOS, fix crash when calling `drag_window()` without a left click present.
- On X11, key events forward to IME anyway, even when it's disabled.

View file

@ -284,8 +284,7 @@ impl CoreWindow for Window {
}
fn drag_window(&self) -> Result<(), RequestError> {
self.maybe_wait_on_main(|delegate| delegate.drag_window());
Ok(())
self.maybe_wait_on_main(|delegate| delegate.drag_window())
}
fn drag_resize_window(

View file

@ -1171,10 +1171,12 @@ impl WindowDelegate {
}
#[inline]
pub fn drag_window(&self) {
pub fn drag_window(&self) -> Result<(), RequestError> {
let mtm = MainThreadMarker::from(self);
let event = NSApplication::sharedApplication(mtm).currentEvent().unwrap();
let event =
NSApplication::sharedApplication(mtm).currentEvent().ok_or(RequestError::Ignored)?;
self.window().performWindowDragWithEvent(&event);
Ok(())
}
#[inline]