1
/**************************************************************
3
* Startup code for the Quartz Darwin X Server
5
**************************************************************/
7
* Copyright (c) 2001-2003 Torrey T. Lyons. All Rights Reserved.
9
* Permission is hereby granted, free of charge, to any person obtaining a
10
* copy of this software and associated documentation files (the "Software"),
11
* to deal in the Software without restriction, including without limitation
12
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
* and/or sell copies of the Software, and to permit persons to whom the
14
* Software is furnished to do so, subject to the following conditions:
16
* The above copyright notice and this permission notice shall be included in
17
* all copies or substantial portions of the Software.
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
* THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
* DEALINGS IN THE SOFTWARE.
27
* Except as contained in this notice, the name(s) of the above copyright
28
* holders shall not be used in advertising or otherwise to promote the sale,
29
* use or other dealings in this Software without prior written authorization.
31
/* $XFree86: xc/programs/Xserver/hw/darwin/quartz/quartzStartup.c,v 1.3 2003/01/19 06:35:13 torrey Exp $ */
35
#include <CoreFoundation/CoreFoundation.h>
36
#include "quartzCommon.h"
41
int NSApplicationMain(int argc, char *argv[]);
43
char **envpGlobal; // argcGlobal and argvGlobal
44
// are from dix/globals.c
46
// GLX bundle function pointers
47
typedef void (*GlxExtensionInitPtr)(void);
48
static GlxExtensionInitPtr GlxExtensionInit = NULL;
50
typedef void (*GlxWrapInitVisualsPtr)(miInitVisualsProcPtr *);
51
static GlxWrapInitVisualsPtr GlxWrapInitVisuals = NULL;
56
* This function is called first from main(). The first time
57
* it is called we start the Mac OS X front end. The front end
58
* will call main() again from another thread to run the X
59
* server. On the second call this function loads the user
60
* preferences set by the Mac OS X front end.
67
static Bool been_here = FALSE;
72
QuartzReadPreferences();
77
// Make a pipe to pass events
78
assert( pipe(fd) == 0 );
79
darwinEventFD = fd[0];
80
quartzEventWriteFD = fd[1];
81
fcntl(darwinEventFD, F_SETFL, O_NONBLOCK);
83
// Store command line arguments to pass back to main()
88
// Determine if we need to start X clients
89
// and what display mode to use
90
quartzStartClients = 1;
91
for (i = 1; i < argc; i++) {
92
if (!strcmp(argv[i], "-nostartx")) {
93
quartzStartClients = 0;
94
} else if (!strcmp( argv[i], "-fullscreen")) {
96
} else if (!strcmp( argv[i], "-rootless")) {
102
main_exit = NSApplicationMain(argc, argv);
109
* The Quartz mode X server needs to dynamically load the appropriate
110
* bundle before initializing GLX.
112
static void LoadGlxBundle(void)
114
CFBundleRef mainBundle;
115
CFStringRef bundleName;
117
CFBundleRef glxBundle;
119
// Get the main bundle for the application
120
mainBundle = CFBundleGetMainBundle();
122
// Choose the bundle to load
123
ErrorF("Loading GLX bundle ");
125
bundleName = CFSTR("glxAGL.bundle");
126
ErrorF("glxAGL.bundle (using Apple's OpenGL)\n");
128
bundleName = CFSTR("glxMesa.bundle");
129
ErrorF("glxMesa.bundle (using Mesa)\n");
132
// Look for the appropriate GLX bundle in the main bundle by name
133
bundleURL = CFBundleCopyResourceURL(mainBundle, bundleName,
136
FatalError("Could not find GLX bundle.");
139
// Make a bundle instance using the URLRef
140
glxBundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
142
if (!CFBundleLoadExecutable(glxBundle)) {
143
FatalError("Could not load GLX bundle.");
146
// Find the GLX init functions
147
GlxExtensionInit = (void *) CFBundleGetFunctionPointerForName(
148
glxBundle, CFSTR("GlxExtensionInit"));
150
GlxWrapInitVisuals = (void *) CFBundleGetFunctionPointerForName(
151
glxBundle, CFSTR("GlxWrapInitVisuals"));
153
if (!GlxExtensionInit || !GlxWrapInitVisuals) {
154
FatalError("Could not initialize GLX bundle.");
157
// Release the CF objects
158
CFRelease(mainBundle);
159
CFRelease(bundleURL);
164
* DarwinGlxExtensionInit
165
* Initialize the GLX extension.
167
void DarwinGlxExtensionInit(void)
169
if (!GlxExtensionInit)
177
* DarwinGlxWrapInitVisuals
179
void DarwinGlxWrapInitVisuals(
180
miInitVisualsProcPtr *procPtr)
182
if (!GlxWrapInitVisuals)
185
GlxWrapInitVisuals(procPtr);
189
int QuartzProcessArgument( int argc, char *argv[], int i )
191
// fullscreen: CoreGraphics full-screen mode
192
// rootless: Cocoa rootless mode
193
// quartz: Default, either fullscreen or rootless
195
if ( !strcmp( argv[i], "-fullscreen" ) ) {
196
ErrorF( "Running full screen in parallel with Mac OS X Quartz window server.\n" );
197
#ifdef QUARTZ_SAFETY_DELAY
198
ErrorF( "Quitting in %d seconds if no controller is found.\n",
199
QUARTZ_SAFETY_DELAY );
204
if ( !strcmp( argv[i], "-rootless" ) ) {
205
ErrorF( "Running rootless inside Mac OS X window server.\n" );
206
#ifdef QUARTZ_SAFETY_DELAY
207
ErrorF( "Quitting in %d seconds if no controller is found.\n",
208
QUARTZ_SAFETY_DELAY );
213
if ( !strcmp( argv[i], "-quartz" ) ) {
214
ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
215
#ifdef QUARTZ_SAFETY_DELAY
216
ErrorF( "Quitting in %d seconds if no controller is found.\n",
217
QUARTZ_SAFETY_DELAY );
222
// The Mac OS X front end uses this argument, which we just ignore here.
223
if ( !strcmp( argv[i], "-nostartx" ) ) {
227
// This command line arg is passed when launched from the Aqua GUI.
228
if ( !strncmp( argv[i], "-psn_", 5 ) ) {
b'\\ No newline at end of file'