Skip to content

Commit 60b3949

Browse files
committed
Fix mouse enter/leave events on macos 13 fixes
1 parent 281fe4b commit 60b3949

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
@@ -349,6 +349,18 @@ impl WindowBuilder {
349349
let frame = NSView::frame(content_view);
350350
view.initWithFrame_(frame);
351351

352+
// The rect of the tracking area doesn't matter, because
353+
// we use the InVisibleRect option where the OS syncs the size automatically.
354+
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
355+
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
356+
| NSTrackingAreaOptions::MouseMoved
357+
| NSTrackingAreaOptions::ActiveAlways
358+
| NSTrackingAreaOptions::InVisibleRect;
359+
let tracking_area = NSTrackingArea::alloc(nil)
360+
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
361+
.autorelease();
362+
view.addTrackingArea(tracking_area);
363+
352364
let () = msg_send![window, setDelegate: view];
353365

354366
if let Some(menu) = self.menu {
@@ -645,18 +657,6 @@ fn make_view(
645657
let options: NSAutoresizingMaskOptions = NSViewWidthSizable | NSViewHeightSizable;
646658
view.setAutoresizingMask_(options);
647659

648-
// The rect of the tracking area doesn't matter, because
649-
// we use the InVisibleRect option where the OS syncs the size automatically.
650-
let rect = NSRect::new(NSPoint::new(0., 0.), NSSize::new(0., 0.));
651-
let opts = NSTrackingAreaOptions::MouseEnteredAndExited
652-
| NSTrackingAreaOptions::MouseMoved
653-
| NSTrackingAreaOptions::ActiveAlways
654-
| NSTrackingAreaOptions::InVisibleRect;
655-
let tracking_area = NSTrackingArea::alloc(nil)
656-
.initWithRect_options_owner_userInfo(rect, opts, view, nil)
657-
.autorelease();
658-
view.addTrackingArea(tracking_area);
659-
660660
view.setWantsBestResolutionOpenGLSurface_(YES);
661661

662662
// On Mojave, views automatically become layer-backed shortly after being added to

0 commit comments

Comments
 (0)