diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am index 66d1b9b9e..46b6d8e06 100644 --- a/hw/xquartz/Makefile.am +++ b/hw/xquartz/Makefile.am @@ -30,6 +30,7 @@ libXquartz_la_SOURCES = \ quartz.c \ quartzAudio.c \ quartzCocoa.m \ + quartzForeground.c \ quartzKeyboard.c \ quartzPasteboard.c \ quartzStartup.c @@ -47,5 +48,6 @@ EXTRA_DIST = \ quartzCommon.h \ quartzCursor.c \ quartzCursor.h \ + quartzForeground.h \ quartz.h \ quartzPasteboard.h diff --git a/hw/xquartz/bundle/Info.plist b/hw/xquartz/bundle/Info.plist index 9437f77cd..3d07da97c 100644 --- a/hw/xquartz/bundle/Info.plist +++ b/hw/xquartz/bundle/Info.plist @@ -3,35 +3,37 @@ CFBundleDevelopmentRegion - English + English CFBundleExecutable - X11 + X11 CFBundleGetInfoString - X11 + X11 CFBundleIconFile - X11.icns + X11.icns CFBundleIdentifier - org.x.X11 + org.x.X11 CFBundleInfoDictionaryVersion - 6.0 + 6.0 CFBundleName - X11 + X11 CFBundlePackageType - APPL + APPL CFBundleShortVersionString - 2.1.0 + 2.1.1 CFBundleSignature - x11a + x11a CSResourcesFileMapped - + NSHumanReadableCopyright - Copyright © 2003-2007, Apple Inc. + Copyright © 2003-2007, Apple Inc. Copyright © 2003, XFree86 Project, Inc. Copyright © 2003-2007, X.org Project, Inc. NSMainNibFile - main + main NSPrincipalClass - X11Application + X11Application + LSBackgroundOnly + diff --git a/hw/xquartz/bundle/bundle-main.c b/hw/xquartz/bundle/bundle-main.c index 6f9744c2e..fc64850f3 100644 --- a/hw/xquartz/bundle/bundle-main.c +++ b/hw/xquartz/bundle/bundle-main.c @@ -37,46 +37,39 @@ int launcher_main(int argc, char **argv); int server_main(int argc, char **argv); int main(int argc, char **argv) { - Display *display; - + int launchd = 0; + size_t i; + int retval; + fprintf(stderr, "X11.app: main(): argc=%d\n", argc); - int i; for(i=0; i < argc; i++) { - fprintf(stderr, "\targv[%d] = %s\n", i, argv[i]); + fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]); } /* First check if launchd started us */ - if(argc == 2 && !strncmp(argv[1], "-launchd", 8)) { - argc--; - argv[1] = argv[0]; - argv++; - fprintf(stderr, "X11.app: main(): launchd called us, running server_main()"); - return server_main(argc, argv); - } - - /* If we have a process serial number and it's our only arg, act as if - * the user double clicked the app bundle: launch app_to_run if possible - */ - if(argc == 1 || (argc == 2 && !strncmp(argv[1], "-psn_", 5))) { - /* Now, try to open a display, if so, run the launcher */ - display = XOpenDisplay(NULL); - if(display) { - fprintf(stderr, "X11.app: main(): closing the display"); - /* Could open the display, start the launcher */ - XCloseDisplay(display); - - /* Give 2 seconds for the server to start... - * TODO: *Really* fix this race condition - */ - usleep(2000); - fprintf(stderr, "X11.app: main(): running launcher_main()"); - return launcher_main(argc, argv); + for(i=1; i < argc; i++) { + if(!strncmp(argv[i], "-launchd", 8)) { + launchd = 1; + break; } } - /* Couldn't open the display or we were called with arguments, - * just want to start a server. - */ + /* Start the server */ fprintf(stderr, "X11.app: main(): running server_main()"); - return server_main(argc, argv); + retval = server_main(argc, argv); + if(retval != 0) + return retval; + + /* If we weren't started by launcd, then run the launcher. */ + if(!launchd) { + /* Give 2 seconds for the server to start... + * TODO: *Really* fix this race condition + */ + usleep(2000); + fprintf(stderr, "X11.app: main(): running launcher_main()"); + return launcher_main(argc, argv); + } + + return 0; } + diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index 36318042b..427761cda 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -708,6 +708,11 @@ void ddxInitGlobals(void) */ int ddxProcessArgument( int argc, char *argv[], int i ) { + if( !strcmp( argv[i], "-launchd" ) ) { + ErrorF( "Launchd command line argument noticed.\n" ); + return 1; + } + if ( !strcmp( argv[i], "-fullscreen" ) ) { ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" ); return 1; diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c index e20c16b7a..87bcadac8 100644 --- a/hw/xquartz/quartzStartup.c +++ b/hw/xquartz/quartzStartup.c @@ -34,6 +34,7 @@ #include #include #include +#include "quartzForeground.h" #include "quartzCommon.h" #include "darwin.h" #include "quartz.h" @@ -76,6 +77,8 @@ void DarwinHandleGUI( int i; int fd[2]; + QuartzMoveToForeground(); + if (been_here) { return; }