Cocoa mouse code: Replaced NSPointInRect with NSMouseInRect (thanks Eric Wasylishen!) Fixes bug #3312.
authorAlex Szpakowski <slime73@gmail.com>
Sun, 01 May 2016 21:41:30 -0300
changeset 10159d41acf6379f6
parent 10158 941261e0db9f
child 10160 63efcc489846
Cocoa mouse code: Replaced NSPointInRect with NSMouseInRect (thanks Eric Wasylishen!) Fixes bug #3312.
src/video/cocoa/SDL_cocoamouse.m
src/video/cocoa/SDL_cocoamousetap.m
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoamouse.m	Sun May 01 19:51:10 2016 -0300
     1.2 +++ b/src/video/cocoa/SDL_cocoamouse.m	Sun May 01 21:41:30 2016 -0300
     1.3 @@ -316,7 +316,7 @@
     1.4  
     1.5      for (NSScreen *screen in [NSScreen screens]) {
     1.6          NSRect frame = [screen frame];
     1.7 -        if (NSPointInRect(cocoaLocation, frame)) {
     1.8 +        if (NSMouseInRect(cocoaLocation, frame, NO)) {
     1.9              *x = (int) cocoaLocation.x;
    1.10              *y = (int) ((frame.origin.y + frame.size.height) - cocoaLocation.y);
    1.11              break;
    1.12 @@ -398,7 +398,7 @@
    1.13      /* Ignore events that aren't inside the client area (i.e. title bar.) */
    1.14      if ([event window]) {
    1.15          NSRect windowRect = [[[event window] contentView] frame];
    1.16 -        if (!NSPointInRect([event locationInWindow], windowRect)) {
    1.17 +        if (!NSMouseInRect([event locationInWindow], windowRect, NO)) {
    1.18              return;
    1.19          }
    1.20      }
     2.1 --- a/src/video/cocoa/SDL_cocoamousetap.m	Sun May 01 19:51:10 2016 -0300
     2.2 +++ b/src/video/cocoa/SDL_cocoamousetap.m	Sun May 01 21:41:30 2016 -0300
     2.3 @@ -96,7 +96,7 @@
     2.4      eventLocation = CGEventGetUnflippedLocation(event);
     2.5      windowRect = [nswindow contentRectForFrameRect:[nswindow frame]];
     2.6  
     2.7 -    if (!NSPointInRect(NSPointFromCGPoint(eventLocation), windowRect)) {
     2.8 +    if (!NSMouseInRect(NSPointFromCGPoint(eventLocation), windowRect, NO)) {
     2.9  
    2.10          /* This is in CGs global screenspace coordinate system, which has a
    2.11           * flipped Y.
    2.12 @@ -109,10 +109,10 @@
    2.13              newLocation.x = NSMaxX(windowRect) - 1.0;
    2.14          }
    2.15  
    2.16 -        if (eventLocation.y < NSMinY(windowRect)) {
    2.17 +        if (eventLocation.y <= NSMinY(windowRect)) {
    2.18              newLocation.y -= (NSMinY(windowRect) - eventLocation.y + 1);
    2.19 -        } else if (eventLocation.y >= NSMaxY(windowRect)) {
    2.20 -            newLocation.y += (eventLocation.y - NSMaxY(windowRect) + 1);
    2.21 +        } else if (eventLocation.y > NSMaxY(windowRect)) {
    2.22 +            newLocation.y += (eventLocation.y - NSMaxY(windowRect));
    2.23          }
    2.24  
    2.25          CGWarpMouseCursorPosition(newLocation);
     3.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun May 01 19:51:10 2016 -0300
     3.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun May 01 21:41:30 2016 -0300
     3.3 @@ -839,14 +839,7 @@
     3.4      /* Ignore events that aren't inside the client area (i.e. title bar.) */
     3.5      if ([theEvent window]) {
     3.6          NSRect windowRect = [[[theEvent window] contentView] frame];
     3.7 -
     3.8 -        /* add one to size, since NSPointInRect is exclusive of the bottom
     3.9 -           edges, which mean it misses the top of the window by one pixel
    3.10 -           (as the origin is the bottom left). */
    3.11 -        windowRect.size.width += 1;
    3.12 -        windowRect.size.height += 1;
    3.13 -
    3.14 -        if (!NSPointInRect([theEvent locationInWindow], windowRect)) {
    3.15 +        if (!NSMouseInRect([theEvent locationInWindow], windowRect, NO)) {
    3.16              return;
    3.17          }
    3.18      }