4dc4dd630f1a329215ee7ba63077078a244206f0
1 /**************************************************************
3 * Startup code for the Quartz Darwin X Server
4 * Copyright (c) 2008-2012 Apple Inc. All rights reserved.
5 * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
25 * Except as contained in this notice, the name(s) of the above copyright
26 * holders shall not be used in advertising or otherwise to promote the sale,
27 * use or other dealings in this Software without prior written authorization.
30 #include "sanitizedCarbon.h"
32 #ifdef HAVE_DIX_CONFIG_H
33 #include <dix-config.h>
38 #include <CoreFoundation/CoreFoundation.h>
39 #include "quartzCommon.h"
40 #include "X11Controller.h"
42 #include "darwinEvents.h"
52 dix_main(int argc
, char **argv
, char **envp
);
62 server_thread(void *arg
)
64 struct arg args
= *((struct arg
*)arg
);
66 exit(dix_main(args
.argc
, args
.argv
, args
.envp
));
70 create_thread(void *func
, void *arg
)
75 pthread_attr_init(&attr
);
76 pthread_attr_setscope(&attr
, PTHREAD_SCOPE_SYSTEM
);
77 pthread_attr_setdetachstate(&attr
, PTHREAD_CREATE_DETACHED
);
78 pthread_create(&tid
, &attr
, func
, arg
);
79 pthread_attr_destroy(&attr
);
85 QuartzInitServer(int argc
, char **argv
, char **envp
)
87 struct arg
*args
= (struct arg
*)malloc(sizeof(struct arg
));
89 FatalError("Could not allocate memory.\n");
95 if (!create_thread(server_thread
, args
)) {
96 FatalError("can't create secondary thread\n");
101 server_main(int argc
, char **argv
, char **envp
)
106 /* Unset CFProcessPath, so our children don't inherit this kludge we need
107 * to load our nib. If an xterm gets this set, then it fails to
108 * 'open hi.txt' properly.
110 unsetenv("CFProcessPath");
112 // Make a pipe to pass events
113 assert(pipe(fd
) == 0);
114 darwinEventReadFD
= fd
[0];
115 darwinEventWriteFD
= fd
[1];
116 fcntl(darwinEventReadFD
, F_SETFL
, O_NONBLOCK
);
118 for (i
= 1; i
< argc
; i
++) {
119 // Display version info without starting Mac OS X UI if requested
121 "-showconfig") || !strcmp(argv
[i
], "-version")) {
127 X11ControllerMain(argc
, argv
, envp
);