src/video/cocoa/SDL_cocoamousetap.m
changeset 8005 d8edfca6e3c2
parent 7917 686df9c2b98a
child 8054 2a38ef3eeabb
equal deleted inserted replaced
8004:13da154af020 8005:d8edfca6e3c2
    61 Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
    61 Cocoa_MouseTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
    62 {
    62 {
    63     SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
    63     SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
    64     SDL_Mouse *mouse = SDL_GetMouse();
    64     SDL_Mouse *mouse = SDL_GetMouse();
    65     SDL_Window *window = SDL_GetKeyboardFocus();
    65     SDL_Window *window = SDL_GetKeyboardFocus();
       
    66     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
    66     NSRect windowRect;
    67     NSRect windowRect;
    67     CGPoint eventLocation;
    68     CGPoint eventLocation;
    68 
    69 
    69     switch (type)
    70     switch (type)
    70     {
    71     {
    91         return event;
    92         return event;
    92     }
    93     }
    93 
    94 
    94     /* This is the same coordinate system as Cocoa uses. */
    95     /* This is the same coordinate system as Cocoa uses. */
    95     eventLocation = CGEventGetUnflippedLocation(event);
    96     eventLocation = CGEventGetUnflippedLocation(event);
    96     windowRect = [((SDL_WindowData *) window->driverdata)->nswindow frame];
    97     windowRect = [nswindow contentRectForFrameRect:[nswindow frame]];
    97 
    98 
    98     if (!NSPointInRect(NSPointFromCGPoint(eventLocation), windowRect)) {
    99     if (!NSPointInRect(NSPointFromCGPoint(eventLocation), windowRect)) {
    99 
   100 
   100         /* This is in CGs global screenspace coordinate system, which has a
   101         /* This is in CGs global screenspace coordinate system, which has a
   101          * flipped Y.
   102          * flipped Y.