Cocoa: ignore mouseDown events in a window's titlebar.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 31 May 2015 00:50:30 -0400
changeset 9685 525f13ccf27f
parent 9684 c7db25205399
child 9686 d84e21b0b0ba
Cocoa: ignore mouseDown events in a window's titlebar. These events accidentally slipping in sometimes appears to be a bug (or maybe new behavior) in 10.10, as previous versions of Mac OS X don't appear to ever trigger this. Thanks to Paulo Marques for pointing out the fix on the SDL mailing list! Fixes Bugzilla #2842 (again).
src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri May 29 22:24:38 2015 +0200
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sun May 31 00:50:30 2015 -0400
@@ -751,6 +751,14 @@
 {
     int button;
 
+    /* Ignore events that aren't inside the client area (i.e. title bar.) */
+    if ([theEvent window]) {
+        const NSRect windowRect = [[[theEvent window] contentView] frame];
+        if (!NSPointInRect([theEvent locationInWindow], windowRect)) {
+            return;
+        }
+    }
+
     if ([self processHitTest:theEvent]) {
         return;  /* dragging, drop event. */
     }