mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed processing mouse and keyboard events in hatari, which uses the old SDLMain.m without creating an SDLApplication instance
This commit is contained in:
parent
83cb2b63a3
commit
824ecc8f7a
@ -48,13 +48,12 @@
|
|||||||
SDL_SendQuit();
|
SDL_SendQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch events here so that we can handle events caught by
|
static SDL_bool s_bShouldHandleEventsInSDLApplication = SDL_FALSE;
|
||||||
// nextEventMatchingMask in SDL, as well as events caught by other
|
|
||||||
// processes (such as CEF) that are passed down to NSApp.
|
static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||||
- (void)sendEvent:(NSEvent *)theEvent
|
|
||||||
{
|
{
|
||||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||||
|
|
||||||
switch ([theEvent type]) {
|
switch ([theEvent type]) {
|
||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown:
|
||||||
case NSOtherMouseDown:
|
case NSOtherMouseDown:
|
||||||
@ -77,7 +76,17 @@
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
if (s_bShouldHandleEventsInSDLApplication) {
|
||||||
|
Cocoa_DispatchEvent(theEvent);
|
||||||
|
}
|
||||||
|
|
||||||
[super sendEvent:theEvent];
|
[super sendEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +357,8 @@ Cocoa_RegisterApp(void)
|
|||||||
[SDLApplication sharedApplication];
|
[SDLApplication sharedApplication];
|
||||||
SDL_assert(NSApp != nil);
|
SDL_assert(NSApp != nil);
|
||||||
|
|
||||||
|
s_bShouldHandleEventsInSDLApplication = SDL_TRUE;
|
||||||
|
|
||||||
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
|
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
@ -400,6 +411,10 @@ Cocoa_PumpEvents(_THIS)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!s_bShouldHandleEventsInSDLApplication) {
|
||||||
|
Cocoa_DispatchEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
// Pass events down to SDLApplication to be handled in sendEvent:
|
// Pass events down to SDLApplication to be handled in sendEvent:
|
||||||
[NSApp sendEvent:event];
|
[NSApp sendEvent:event];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user