Skip to content

Commit

Permalink
macOS: fix panic during drag_window
Browse files Browse the repository at this point in the history
Return error from it instead of unwrapping.
  • Loading branch information
shanecelis authored and jgcodes2020 committed Oct 22, 2024
1 parent af399dc commit 5b40621
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/changelog/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ changelog entry.
### Fixed

- On Orbital, `MonitorHandle::name()` now returns `None` instead of a dummy name.
- On macOS, fix `SurfaceEvent::Moved` sometimes being triggered unnecessarily on resize.
- On MacOS, package manifest definitions of `LSUIElement` will no longer be overridden with the
- 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
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.
3 changes: 1 addition & 2 deletions src/platform_impl/apple/appkit/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions src/platform_impl/apple/appkit/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5b40621

Please sign in to comment.