diff --git a/src/video/quartz/SDL_QuartzWindow.h b/src/video/quartz/SDL_QuartzWindow.h index a1939ba7d..ce850251d 100644 --- a/src/video/quartz/SDL_QuartzWindow.h +++ b/src/video/quartz/SDL_QuartzWindow.h @@ -27,6 +27,10 @@ typedef unsigned int NSUInteger; /* Subclass of NSWindow to fix genie effect and support resize events */ @interface SDL_QuartzWindow : NSWindow +{ + BOOL watchForMouseUp; +} + - (void)miniaturize:(id)sender; - (void)display; - (void)setFrame:(NSRect)frameRect display:(BOOL)flag; diff --git a/src/video/quartz/SDL_QuartzWindow.m b/src/video/quartz/SDL_QuartzWindow.m index 1b006bfc4..ff757bd91 100644 --- a/src/video/quartz/SDL_QuartzWindow.m +++ b/src/video/quartz/SDL_QuartzWindow.m @@ -128,6 +128,30 @@ static void QZ_SetPortAlphaOpaque () { } } +/* QZ_DoActivate() calls a low-level CoreGraphics routine to adjust + the cursor position, if input is being grabbed. If app activation is + triggered by a mouse click in the title bar, then the window manager + gets confused and thinks we're dragging the window. The solution + below postpones the activate event to avoid this scenario. */ +- (void)becomeKeyWindow +{ + NSEvent *event = [self currentEvent]; + if ([event type] == NSLeftMouseDown && [event window] == self) + watchForMouseUp = YES; + else + [super becomeKeyWindow]; +} + +- (void)sendEvent:(NSEvent *)event +{ + [super sendEvent:event]; + if (watchForMouseUp && [event type] == NSLeftMouseUp) + { + watchForMouseUp = NO; + [super becomeKeyWindow]; + } +} + - (void)appDidHide:(NSNotification*)note { SDL_PrivateAppActive (0, SDL_APPACTIVE);