Skip to content

Commit 47717f2

Browse files
committed
cocoa: Always add a window-sized NSTrackingArea to each window.
Previously this was only done on older macOSes, but it seems to work on all versions, afaict. Reference Issue #12725.
1 parent f61d956 commit 47717f2

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,20 +2112,19 @@ - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
21122112
}
21132113
}
21142114

2115+
// NSTrackingArea is how Cocoa tells you when the mouse cursor has entered or
2116+
// left certain regions. We put one over our entire window so we know when
2117+
// it has "mouse focus."
21152118
- (void)updateTrackingAreas
21162119
{
21172120
[super updateTrackingAreas];
21182121

2119-
if (@available(macOS 12.0, *)) {
2120-
// we (currently) use the tracking areas as a workaround for older macOSes, but we might be safe everywhere...
2121-
} else {
2122-
SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)_sdlWindow->internal;
2123-
if (_trackingArea) {
2124-
[self removeTrackingArea:_trackingArea];
2125-
}
2126-
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways owner:windata.listener userInfo:nil];
2127-
[self addTrackingArea:_trackingArea];
2122+
SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)_sdlWindow->internal;
2123+
if (_trackingArea) {
2124+
[self removeTrackingArea:_trackingArea];
21282125
}
2126+
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways owner:windata.listener userInfo:nil];
2127+
[self addTrackingArea:_trackingArea];
21292128
}
21302129
@end
21312130

0 commit comments

Comments
 (0)