Skip to content

Commit

Permalink
Merge pull request #2282 from Browsers-software/fix-mouse-events-on-m…
Browse files Browse the repository at this point in the history
…acos13

Fix mouse enter/leave events on macos 13 fixes #2280
  • Loading branch information
raphlinus authored Oct 27, 2022
2 parents 2561615 + edf0bac commit 1cf1cd4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions druid-shell/src/backend/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ impl WindowBuilder {
let frame = NSView::frame(content_view);
view.initWithFrame_(frame);

// The rect of the tracking area doesn't matter, because
// we use the InVisibleRect option where the OS syncs the size automatically.
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
| NSTrackingAreaOptions::MouseMoved
| NSTrackingAreaOptions::ActiveAlways
| NSTrackingAreaOptions::InVisibleRect;
let tracking_area = NSTrackingArea::alloc(nil)
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
.autorelease();
view.addTrackingArea(tracking_area);

let () = msg_send![window, setDelegate: view];

if let Some(menu) = self.menu {
Expand Down Expand Up @@ -578,18 +590,6 @@ fn make_view(handler: Box<dyn WinHandler>) -> (id, Weak<Mutex<Vec<IdleKind>>>) {
let options: NSAutoresizingMaskOptions = NSViewWidthSizable | NSViewHeightSizable;
view.setAutoresizingMask_(options);

// The rect of the tracking area doesn't matter, because
// we use the InVisibleRect option where the OS syncs the size automatically.
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
| NSTrackingAreaOptions::MouseMoved
| NSTrackingAreaOptions::ActiveAlways
| NSTrackingAreaOptions::InVisibleRect;
let tracking_area = NSTrackingArea::alloc(nil)
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
.autorelease();
view.addTrackingArea(tracking_area);

(view.autorelease(), queue_handle)
}
}
Expand Down

0 comments on commit 1cf1cd4

Please sign in to comment.