Skip to content

Commit 1cf1cd4

Browse files
authored
Merge pull request #2282 from Browsers-software/fix-mouse-events-on-macos13
Fix mouse enter/leave events on macos 13 fixes #2280
2 parents 2561615 + edf0bac commit 1cf1cd4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

druid-shell/src/backend/mac/window.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,18 @@ impl WindowBuilder {
290290
let frame = NSView::frame(content_view);
291291
view.initWithFrame_(frame);
292292

293+
// The rect of the tracking area doesn't matter, because
294+
// we use the InVisibleRect option where the OS syncs the size automatically.
295+
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
296+
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
297+
| NSTrackingAreaOptions::MouseMoved
298+
| NSTrackingAreaOptions::ActiveAlways
299+
| NSTrackingAreaOptions::InVisibleRect;
300+
let tracking_area = NSTrackingArea::alloc(nil)
301+
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
302+
.autorelease();
303+
view.addTrackingArea(tracking_area);
304+
293305
let () = msg_send![window, setDelegate: view];
294306

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

581-
// The rect of the tracking area doesn't matter, because
582-
// we use the InVisibleRect option where the OS syncs the size automatically.
583-
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
584-
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
585-
| NSTrackingAreaOptions::MouseMoved
586-
| NSTrackingAreaOptions::ActiveAlways
587-
| NSTrackingAreaOptions::InVisibleRect;
588-
let tracking_area = NSTrackingArea::alloc(nil)
589-
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
590-
.autorelease();
591-
view.addTrackingArea(tracking_area);
592-
593593
(view.autorelease(), queue_handle)
594594
}
595595
}

0 commit comments

Comments
 (0)