Index: SDL_cocoaevents.m =================================================================== --- SDL_cocoaevents.m (revision 1665) +++ SDL_cocoaevents.m (revision 1666) @@ -39,6 +39,7 @@ @interface SDLApplication : NSApplication - (void)terminate:(id)sender; +- (void)sendEvent:(NSEvent *)theEvent; @end @@ -50,6 +51,39 @@ SDL_SendQuit(); } +// Dispatch events here so that we can handle events caught by +// nextEventMatchingMask in SDL, as well as events caught by other +// processes (such as CEF) that are passed down to NSApp. +- (void)sendEvent:(NSEvent *)theEvent +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + switch ([theEvent type]) { + case NSLeftMouseDown: + case NSOtherMouseDown: + case NSRightMouseDown: + case NSLeftMouseUp: + case NSOtherMouseUp: + case NSRightMouseUp: + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDragged: /* usually middle mouse dragged */ + case NSMouseMoved: + case NSScrollWheel: + Cocoa_HandleMouseEvent(_this, theEvent); + break; + case NSKeyDown: + case NSKeyUp: + case NSFlagsChanged: + Cocoa_HandleKeyEvent(_this, theEvent); + break; + default: + break; + } + + [super sendEvent:theEvent]; +} + @end // SDLApplication /* setAppleMenu disappeared from the headers in 10.4 */ @@ -316,29 +350,7 @@ break; } - switch ([event type]) { - case NSLeftMouseDown: - case NSOtherMouseDown: - case NSRightMouseDown: - case NSLeftMouseUp: - case NSOtherMouseUp: - case NSRightMouseUp: - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: /* usually middle mouse dragged */ - case NSMouseMoved: - case NSScrollWheel: - Cocoa_HandleMouseEvent(_this, event); - break; - case NSKeyDown: - case NSKeyUp: - case NSFlagsChanged: - Cocoa_HandleKeyEvent(_this, event); - break; - default: - break; - } - /* Pass through to NSApp to make sure everything stays in sync */ + // Pass events down to SDLApplication to be handled in sendEvent: [NSApp sendEvent:event]; } [pool release];