Fixed crash if no window has keyboard focus

Sam Lantinga 2013-12-06 16:12:18 -08:00
parent 4ab350d4f2
commit 44afc2a305
1 changed files with 2 additions and 1 deletions

View File

@ -63,7 +63,7 @@ Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event
SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *window = SDL_GetKeyboardFocus();
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
NSWindow *nswindow;
NSRect windowRect;
CGPoint eventLocation;
@ -93,6 +93,7 @@ Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event
}
/* This is the same coordinate system as Cocoa uses. */
nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
eventLocation = CGEventGetUnflippedLocation(event);
windowRect = [nswindow contentRectForFrameRect:[nswindow frame]];