fix for sheepvm

This commit is contained in:
kanjitalk755 2018-06-16 13:33:13 +09:00
parent 8d89152b79
commit f053fda3c8
2 changed files with 34 additions and 6 deletions

View File

@ -78,6 +78,8 @@ void set_menu_bar_visible_osx(bool visible)
void set_current_directory()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
chdir([[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] UTF8String]);
[pool release];
}

View File

@ -124,6 +124,7 @@
#ifdef USE_SDL
#include <SDL.h>
#include <string>
#endif
#ifndef USE_SDL_VIDEO
@ -673,6 +674,9 @@ static bool install_signal_handlers(void)
}
#ifdef USE_SDL
static std::string sdl_vmdir;
static bool init_sdl()
{
int sdl_flags = 0;
@ -700,6 +704,18 @@ static bool init_sdl()
}
atexit(SDL_Quit);
#if SDL_VERSION_ATLEAST(2,0,0)
for (int i = 0; i < 100; i++) {
SDL_Event event;
SDL_PollEvent(&event);
if (event.type == SDL_DROPFILE) {
sdl_vmdir = event.drop.file;
break;
}
SDL_Delay(1);
}
#endif
#if __MACOSX__
// On Mac OS X hosts, SDL2 will create its own menu bar. This is mostly OK,
// except that it will also install keyboard shortcuts, such as Command + Q,
@ -743,6 +759,22 @@ int main(int argc, char **argv)
#endif
#endif
#ifdef USE_SDL
// Initialize SDL system
if (!init_sdl())
goto quit;
#if SDL_VERSION_ATLEAST(2,0,0)
if (valid_vmdir(sdl_vmdir.c_str())) {
vmdir = sdl_vmdir.c_str();
printf("Using %s as vmdir.\n", vmdir);
if (chdir(vmdir)) {
printf("Failed to chdir to %s. Good bye.", vmdir);
exit(1);
}
}
#endif
#endif
// Parse command line arguments
for (int i=1; i<argc; i++) {
if (strcmp(argv[i], "-NSDocumentRevisionsDebugMode") == 0 || strncmp(argv[i], "-psn_", 5) == 0) {
@ -814,12 +846,6 @@ int main(int argc, char **argv)
}
}
#ifdef USE_SDL
// Initialize SDL system
if (!init_sdl())
goto quit;
#endif
#ifndef USE_SDL_VIDEO
// Open display
x_display = XOpenDisplay(x_display_name);