Skip to content

Commit 968222e

Browse files
danginsburgslouken
authored andcommitted
Fix #13057 - fixes bug with NSEventTypeMouseMoved having a NULL window causing us to suppress future mouse move events because the window was considered out of focus.
1 parent d16371b commit 968222e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/video/cocoa/SDL_cocoamouse.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,18 @@ void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event)
450450
// All events except NSEventTypeMouseExited can only happen if the window
451451
// has mouse focus, so we'll always set the focus even if we happen to miss
452452
// NSEventTypeMouseEntered, which apparently happens if the window is
453-
// created under the mouse on macOS 12.7
453+
// created under the mouse on macOS 12.7. But, only set the focus if
454+
// the event acutally has a non-NULL window, otherwise what would happen
455+
// is that after an NSEventTypeMouseEntered there would sometimes be
456+
// NSEventTypeMouseMoved without a window causing us to suppress subsequent
457+
// mouse move events.
454458
NSEventType event_type = [event type];
455459
if (event_type == NSEventTypeMouseExited) {
456460
Cocoa_MouseFocus = NULL;
457461
} else {
458-
Cocoa_MouseFocus = [event window];
462+
if ([event window] != NULL) {
463+
Cocoa_MouseFocus = [event window];
464+
}
459465
}
460466

461467
switch (event_type) {

0 commit comments

Comments
 (0)