예제 #1
0
int
server_main(int argc, char **argv, char **envp)
{
    int i;
    int fd[2];

    /* Unset CFProcessPath, so our children don't inherit this kludge we need
     * to load our nib.  If an xterm gets this set, then it fails to
     * 'open hi.txt' properly.
     */
    unsetenv("CFProcessPath");

    // Make a pipe to pass events
    assert(pipe(fd) == 0);
    darwinEventReadFD = fd[0];
    darwinEventWriteFD = fd[1];
    fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);

    for (i = 1; i < argc; i++) {
        // Display version info without starting Mac OS X UI if requested
        if (!strcmp(argv[i],
                    "-showconfig") || !strcmp(argv[i], "-version")) {
            DarwinPrintBanner();
            exit(0);
        }
    }

    X11ControllerMain(argc, argv, envp);
    exit(0);
}
예제 #2
0
/*
 * DarwinHandleGUI
 *  This function is called first from main(). The first time
 *  it is called we start the Mac OS X front end. The front end
 *  will call main() again from another thread to run the X
 *  server. On the second call this function loads the user
 *  preferences set by the Mac OS X front end.
 */
void DarwinHandleGUI(
    int         argc,
    char        *argv[],
    char        *envp[] )
{
    static Bool been_here = FALSE;
    int         main_exit, i;
    int         fd[2];

    if (been_here) {
#ifdef INXDARWINAPP
        QuartzReadPreferences();
#endif
        return;
    }
    been_here = TRUE;

    // Make a pipe to pass events
    assert( pipe(fd) == 0 );
    darwinEventReadFD = fd[0];
    darwinEventWriteFD = fd[1];
    fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);

    // Store command line arguments to pass back to main()
    argcGlobal = argc;
    argvGlobal = argv;
    envpGlobal = envp;

    quartzStartClients = 1;
    for (i = 1; i < argc; i++) {
        // Display version info without starting Mac OS X UI if requested
        if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
            DarwinPrintBanner();
            exit(0);
        }

        // Determine if we need to start X clients
        // and what display mode to use
        if (!strcmp(argv[i], "-nostartx")) {
            quartzStartClients = 0;    
        } else if (!strcmp( argv[i], "-fullscreen")) {
            quartzRootless = 0;
        } else if (!strcmp( argv[i], "-rootless")) {
            quartzRootless = 1;
        }
    }

#ifdef INXQUARTZ
    /* Initially I ran the X server on the main thread, and received
       events on the second thread. But now we may be using Carbon,
       that needs to run on the main thread. (Otherwise, when it's
       prebound, it will initialize itself on the wrong thread)
       
       grr.. but doing that means that if the X thread gets scheduled
       before the main thread when we're _not_ prebound, things fail,
       so initialize by hand. */
    extern void _InitHLTB(void);
    
    _InitHLTB();
    
    X11ControllerMain(argc, argv, server_thread, NULL);
#else
    main_exit = NSApplicationMain(argc, argv);
#endif
    exit(main_exit);
}