mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Fix macOS client/server failing to start from terminal
The macOS client and server were completely unusable when run from a terminal. They blocked forever in `[NSApp run];` which was called by Sys_InitProtocolHandler(). `applicationDidFinishLaunching` was never called to exit the NSApp run loop. Use SDL's SDL_DROPFILE event to receive URLs to handle on macOS instead. This also handles URLs while the game is running (connect to new server) instead of nothing happening when clicking a link while the game is running.
This commit is contained in:
parent
d19b91263f
commit
570e53d9fb
4 changed files with 29 additions and 64 deletions
|
@ -1172,6 +1172,28 @@ static void IN_ProcessEvents( void )
|
|||
}
|
||||
break;
|
||||
|
||||
#if defined(PROTOCOL_HANDLER) && defined(__APPLE__)
|
||||
case SDL_DROPFILE:
|
||||
{
|
||||
char *filename = e.drop.file;
|
||||
|
||||
// Handle macOS open URL event. URL protocol scheme must be set in Info.plist.
|
||||
if( !Q_strncmp( filename, PROTOCOL_HANDLER ":", strlen( PROTOCOL_HANDLER ":" ) ) )
|
||||
{
|
||||
char *protocolCommand = Sys_ParseProtocolUri( filename );
|
||||
|
||||
if( protocolCommand )
|
||||
{
|
||||
Cbuf_ExecuteText( EXEC_APPEND, va( "%s\n", protocolCommand ) );
|
||||
free( protocolCommand );
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free( filename );
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1254,6 +1276,10 @@ void IN_Init( void *windowData )
|
|||
in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH );
|
||||
in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE );
|
||||
|
||||
#if defined(PROTOCOL_HANDLER) && defined(__APPLE__)
|
||||
SDL_EventState( SDL_DROPFILE, SDL_ENABLE );
|
||||
#endif
|
||||
|
||||
SDL_StartTextInput( );
|
||||
|
||||
mouseAvailable = ( in_mouse->value != 0 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue