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.
This commit is contained in:
@@ -2112,20 +2112,19 @@ static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NSTrackingArea is how Cocoa tells you when the mouse cursor has entered or
|
||||||
|
// left certain regions. We put one over our entire window so we know when
|
||||||
|
// it has "mouse focus."
|
||||||
- (void)updateTrackingAreas
|
- (void)updateTrackingAreas
|
||||||
{
|
{
|
||||||
[super updateTrackingAreas];
|
[super updateTrackingAreas];
|
||||||
|
|
||||||
if (@available(macOS 12.0, *)) {
|
SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)_sdlWindow->internal;
|
||||||
// we (currently) use the tracking areas as a workaround for older macOSes, but we might be safe everywhere...
|
if (_trackingArea) {
|
||||||
} else {
|
[self removeTrackingArea:_trackingArea];
|
||||||
SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)_sdlWindow->internal;
|
|
||||||
if (_trackingArea) {
|
|
||||||
[self removeTrackingArea:_trackingArea];
|
|
||||||
}
|
|
||||||
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways owner:windata.listener userInfo:nil];
|
|
||||||
[self addTrackingArea:_trackingArea];
|
|
||||||
}
|
}
|
||||||
|
_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingMouseEnteredAndExited|NSTrackingActiveAlways owner:windata.listener userInfo:nil];
|
||||||
|
[self addTrackingArea:_trackingArea];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user