mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-16 16:44:06 +00:00
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
|
||||
{
|
||||
[super updateTrackingAreas];
|
||||
|
||||
if (@available(macOS 12.0, *)) {
|
||||
// we (currently) use the tracking areas as a workaround for older macOSes, but we might be safe everywhere...
|
||||
} else {
|
||||
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];
|
||||
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];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user