| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | misrepresented as being the original software. |
| | | 3. This notice may not be removed or altered from any source distribution. |
| | | */ |
| | | #include "SDL_config.h" |
| | | #include "../../SDL_internal.h" |
| | | |
| | | #if SDL_VIDEO_DRIVER_COCOA |
| | | |
| | |
| | | static CGEventRef |
| | | Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) |
| | | { |
| | | SDL_MouseData *driverdata = (SDL_MouseData*)refcon; |
| | | SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon; |
| | | SDL_Mouse *mouse = SDL_GetMouse(); |
| | | SDL_Window *window = SDL_GetKeyboardFocus(); |
| | | NSWindow *nswindow; |
| | | NSRect windowRect; |
| | | CGPoint eventLocation; |
| | | |
| | |
| | | case kCGEventTapDisabledByTimeout: |
| | | case kCGEventTapDisabledByUserInput: |
| | | { |
| | | CGEventTapEnable(((SDL_MouseEventTapData*)(driverdata->tapdata))->tap, true); |
| | | CGEventTapEnable(tapdata->tap, true); |
| | | return NULL; |
| | | } |
| | | default: |
| | |
| | | } |
| | | |
| | | /* This is the same coordinate system as Cocoa uses. */ |
| | | nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; |
| | | eventLocation = CGEventGetUnflippedLocation(event); |
| | | windowRect = [((SDL_WindowData *) window->driverdata)->nswindow frame]; |
| | | windowRect = [nswindow contentRectForFrameRect:[nswindow frame]]; |
| | | |
| | | if (!NSPointInRect(NSPointFromCGPoint(eventLocation), windowRect)) { |
| | | |