Xquartz: General Cleanup

General code cleanup, whitespace, dead code removal, added missing prototypes.
Made Xquartz come to foreground later in startup, so it doesn't appear for Xquartz -version
This commit is contained in:
Jeremy Huddleston 2007-12-20 13:17:30 -08:00
parent 767b4c9d9d
commit 36922e8ff4
10 changed files with 85 additions and 149 deletions

View File

@ -242,6 +242,10 @@ static int indexForScanlinePad[ 65 ] = {
#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif #endif
#ifdef __APPLE__
void DarwinHandleGUI(int argc, char **argv, char **envp);
#endif
int int
main(int argc, char *argv[], char *envp[]) main(int argc, char *argv[], char *envp[])
{ {

View File

@ -64,40 +64,38 @@ extern X11Application *X11App;
#endif /* __OBJC__ */ #endif /* __OBJC__ */
extern void X11ApplicationSetWindowMenu (int nitems, const char **items, void X11ApplicationSetWindowMenu (int nitems, const char **items,
const char *shortcuts); const char *shortcuts);
extern void X11ApplicationSetWindowMenuCheck (int idx); void X11ApplicationSetWindowMenuCheck (int idx);
extern void X11ApplicationSetFrontProcess (void); void X11ApplicationSetFrontProcess (void);
extern void X11ApplicationSetCanQuit (int state); void X11ApplicationSetCanQuit (int state);
extern void X11ApplicationServerReady (void); void X11ApplicationServerReady (void);
extern void X11ApplicationShowHideMenubar (int state); void X11ApplicationShowHideMenubar (int state);
extern void X11ApplicationMain (int argc, const char *argv[], void X11ApplicationMain(int argc, char **argv, void (*server_thread) (void *), void *server_arg);
void (*server_thread) (void *),
void *server_arg);
extern int X11EnableKeyEquivalents; extern int X11EnableKeyEquivalents;
extern int quartzHasRoot, quartzEnableRootless; extern int quartzHasRoot, quartzEnableRootless;
#define APP_PREFS "org.x.X11" #define APP_PREFS "org.x.X11"
#define PREFS_APPSMENU "apps_menu" #define PREFS_APPSMENU "apps_menu"
#define PREFS_FAKEBUTTONS "enable_fake_buttons" #define PREFS_FAKEBUTTONS "enable_fake_buttons"
#define PREFS_SYSBEEP "enable_system_beep" #define PREFS_SYSBEEP "enable_system_beep"
#define PREFS_KEYEQUIVS "enable_key_equivalents" #define PREFS_KEYEQUIVS "enable_key_equivalents"
#define PREFS_KEYMAP_FILE "keymap_file" #define PREFS_KEYMAP_FILE "keymap_file"
#define PREFS_SYNC_KEYMAP "sync_keymap" #define PREFS_SYNC_KEYMAP "sync_keymap"
#define PREFS_DEPTH "depth" #define PREFS_DEPTH "depth"
#define PREFS_NO_AUTH "no_auth" #define PREFS_NO_AUTH "no_auth"
#define PREFS_NO_TCP "nolisten_tcp" #define PREFS_NO_TCP "nolisten_tcp"
#define PREFS_DONE_XINIT_CHECK "done_xinit_check" #define PREFS_DONE_XINIT_CHECK "done_xinit_check"
#define PREFS_NO_QUIT_ALERT "no_quit_alert" #define PREFS_NO_QUIT_ALERT "no_quit_alert"
#define PREFS_FAKE_BUTTON2 "fake_button2" #define PREFS_FAKE_BUTTON2 "fake_button2"
#define PREFS_FAKE_BUTTON3 "fake_button3" #define PREFS_FAKE_BUTTON3 "fake_button3"
#define PREFS_ROOTLESS "rootless" #define PREFS_ROOTLESS "rootless"
#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys" #define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
#define PREFS_SWAP_ALT_META "swap_alt_meta" #define PREFS_SWAP_ALT_META "swap_alt_meta"
#define PREFS_XP_OPTIONS "xp_options" #define PREFS_XP_OPTIONS "xp_options"
#define PREFS_ENABLE_STEREO "enable_stereo" #define PREFS_ENABLE_STEREO "enable_stereo"
#endif /* X11APPLICATION_H */ #endif /* X11APPLICATION_H */

View File

@ -32,6 +32,7 @@
#endif #endif
#include "quartzCommon.h" #include "quartzCommon.h"
#include "quartzForeground.h"
#import "X11Application.h" #import "X11Application.h"
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
@ -92,8 +93,8 @@ static mach_port_t _port;
static void send_nsevent (NSEventType type, NSEvent *e); static void send_nsevent (NSEventType type, NSEvent *e);
/* Quartz mode initialization routine. This is often dynamically loaded /* Quartz mode initialization routine. This is often dynamically loaded
but is statically linked into this X server. */ but is statically linked into this X server. */
extern Bool QuartzModeBundleInit(void); Bool QuartzModeBundleInit(void);
static void init_ports (void) { static void init_ports (void) {
kern_return_t r; kern_return_t r;
@ -799,44 +800,43 @@ environment?", @"Startup xinitrc dialog");
[X11App prefs_synchronize]; [X11App prefs_synchronize];
} }
void X11ApplicationMain (int argc, const char *argv[], void X11ApplicationMain (int argc, char **argv, void (*server_thread) (void *), void *server_arg) {
void (*server_thread) (void *), void *server_arg) { NSAutoreleasePool *pool;
NSAutoreleasePool *pool;
#ifdef DEBUG #ifdef DEBUG
while (access ("/tmp/x11-block", F_OK) == 0) sleep (1); while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
#endif #endif
pool = [[NSAutoreleasePool alloc] init]; pool = [[NSAutoreleasePool alloc] init];
X11App = (X11Application *) [X11Application sharedApplication]; X11App = (X11Application *) [X11Application sharedApplication];
init_ports (); init_ports ();
[NSApp read_defaults]; [NSApp read_defaults];
[NSBundle loadNibNamed:@"main" owner:NSApp]; [NSBundle loadNibNamed:@"main" owner:NSApp];
[[NSNotificationCenter defaultCenter] addObserver:NSApp [[NSNotificationCenter defaultCenter] addObserver:NSApp
selector:@selector (became_key:) selector:@selector (became_key:)
name:NSWindowDidBecomeKeyNotification object:nil]; name:NSWindowDidBecomeKeyNotification object:nil];
check_xinitrc (); check_xinitrc ();
/* /*
* The xpr Quartz mode is statically linked into this server. * The xpr Quartz mode is statically linked into this server.
* Initialize all the Quartz functions. * Initialize all the Quartz functions.
*/ */
QuartzModeBundleInit(); QuartzModeBundleInit();
/* Calculate the height of the menubar so we can avoid it. */ /* Calculate the height of the menubar so we can avoid it. */
aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) - aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
NSMaxY([[NSScreen mainScreen] visibleFrame]); NSMaxY([[NSScreen mainScreen] visibleFrame]);
if (!create_thread (server_thread, server_arg)) { if (!create_thread (server_thread, server_arg)) {
ErrorF("can't create secondary thread\n"); ErrorF("can't create secondary thread\n");
exit (1); exit (1);
} }
[NSApp run];
/* not reached */
}
QuartzMoveToForeground();
[NSApp run];
/* not reached */
}
/* event conversion */ /* event conversion */

View File

@ -78,8 +78,4 @@
#endif /* __OBJC__ */ #endif /* __OBJC__ */
extern void X11ControllerMain (int argc, const char *argv[],
void (*server_thread) (void *),
void *server_arg);
#endif /* X11CONTROLLER_H */ #endif /* X11CONTROLLER_H */

View File

@ -337,7 +337,7 @@
/* Setup environment */ /* Setup environment */
temp = getenv("DISPLAY"); temp = getenv("DISPLAY");
if (temp == NULL || temp[0] == 0) { if (temp == NULL || temp[0] == 0) {
snprintf(buf, sizeof(buf), ":%s", display); snprintf(buf, sizeof(buf), ":%s", display);
setenv("DISPLAY", buf, TRUE); setenv("DISPLAY", buf, TRUE);
} }
@ -741,9 +741,3 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
} }
@end @end
void X11ControllerMain (int argc, const char *argv[],
void (*server_thread) (void *), void *server_arg)
{
X11ApplicationMain (argc, argv, server_thread, server_arg);
}

View File

@ -724,16 +724,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
return 1; return 1;
} }
if ( !strcmp( argv[i], "-quartz" ) ) {
ErrorF( "Running in parallel with Mac OS X Quartz window server.\n" );
return 1;
}
// The Mac OS X front end uses this argument, which we just ignore here.
if ( !strcmp( argv[i], "-nostartx" ) ) {
return 1;
}
// This command line arg is passed when launched from the Aqua GUI. // This command line arg is passed when launched from the Aqua GUI.
if ( !strncmp( argv[i], "-psn_", 5 ) ) { if ( !strncmp( argv[i], "-psn_", 5 ) ) {
return 1; return 1;
@ -885,9 +875,9 @@ void ddxUseMsg( void )
ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n"); ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
ErrorF("-version : show the server version.\n"); ErrorF("-version : show the server version.\n");
ErrorF("\n"); ErrorF("\n");
ErrorF("Quartz modes (Experimental / In Development):\n"); // ErrorF("Quartz modes (Experimental / In Development):\n");
ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n"); // ErrorF("-fullscreen : run full screen in parallel with Mac OS X window server.\n");
ErrorF("-rootless : run rootless inside Mac OS X window server.\n"); // ErrorF("-rootless : run rootless inside Mac OS X window server.\n");
ErrorF("\n"); ErrorF("\n");
ErrorF("Options ignored in rootless mode:\n"); ErrorF("Options ignored in rootless mode:\n");
ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n"); ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
@ -905,7 +895,8 @@ void ddxGiveUp( void )
{ {
ErrorF( "Quitting XQuartz...\n" ); ErrorF( "Quitting XQuartz...\n" );
QuartzGiveUp(); //if (!quartzRootless)
// quartzProcs->ReleaseScreens();
} }

View File

@ -61,7 +61,6 @@
// Shared global variables for Quartz modes // Shared global variables for Quartz modes
int quartzEventWriteFD = -1; int quartzEventWriteFD = -1;
int quartzStartClients = 1;
int quartzRootless = -1; int quartzRootless = -1;
int quartzUseSysBeep = 0; int quartzUseSysBeep = 0;
int quartzUseAGL = 1; int quartzUseAGL = 1;
@ -416,12 +415,10 @@ QuartzMessageServerThread(
* QuartzProcessEvent * QuartzProcessEvent
* Process Quartz specific events. * Process Quartz specific events.
*/ */
void QuartzProcessEvent( void QuartzProcessEvent(xEvent *xe) {
xEvent *xe)
{
switch (xe->u.u.type) { switch (xe->u.u.type) {
case kXDarwinControllerNotify: case kXDarwinControllerNotify:
DEBUG_LOG("kXDarwinControllerNotify\n"); DEBUG_LOG("kXDarwinControllerNotify\n");
AppleWMSendEvent(AppleWMControllerNotify, AppleWMSendEvent(AppleWMControllerNotify,
AppleWMControllerNotifyMask, AppleWMControllerNotifyMask,
xe->u.clientMessage.u.l.longs0, xe->u.clientMessage.u.l.longs0,
@ -429,7 +426,7 @@ void QuartzProcessEvent(
break; break;
case kXDarwinPasteboardNotify: case kXDarwinPasteboardNotify:
DEBUG_LOG("kXDarwinPasteboardNotify\n"); DEBUG_LOG("kXDarwinPasteboardNotify\n");
AppleWMSendEvent(AppleWMPasteboardNotify, AppleWMSendEvent(AppleWMPasteboardNotify,
AppleWMPasteboardNotifyMask, AppleWMPasteboardNotifyMask,
xe->u.clientMessage.u.l.longs0, xe->u.clientMessage.u.l.longs0,
@ -437,7 +434,7 @@ void QuartzProcessEvent(
break; break;
case kXDarwinActivate: case kXDarwinActivate:
DEBUG_LOG("kXDarwinActivate\n"); DEBUG_LOG("kXDarwinActivate\n");
QuartzShow(xe->u.keyButtonPointer.rootX, QuartzShow(xe->u.keyButtonPointer.rootX,
xe->u.keyButtonPointer.rootY); xe->u.keyButtonPointer.rootY);
AppleWMSendEvent(AppleWMActivationNotify, AppleWMSendEvent(AppleWMActivationNotify,
@ -446,7 +443,7 @@ void QuartzProcessEvent(
break; break;
case kXDarwinDeactivate: case kXDarwinDeactivate:
DEBUG_LOG("kXDarwinDeactivate\n"); DEBUG_LOG("kXDarwinDeactivate\n");
AppleWMSendEvent(AppleWMActivationNotify, AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMActivationNotifyMask,
AppleWMIsInactive, 0); AppleWMIsInactive, 0);
@ -454,23 +451,23 @@ void QuartzProcessEvent(
break; break;
case kXDarwinDisplayChanged: case kXDarwinDisplayChanged:
DEBUG_LOG("kXDarwinDisplayChanged\n"); DEBUG_LOG("kXDarwinDisplayChanged\n");
QuartzUpdateScreens(); QuartzUpdateScreens();
break; break;
case kXDarwinWindowState: case kXDarwinWindowState:
DEBUG_LOG("kXDarwinWindowState\n"); DEBUG_LOG("kXDarwinWindowState\n");
RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0, RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
xe->u.clientMessage.u.l.longs1); xe->u.clientMessage.u.l.longs1);
break; break;
case kXDarwinWindowMoved: case kXDarwinWindowMoved:
DEBUG_LOG("kXDarwinWindowMoved\n"); DEBUG_LOG("kXDarwinWindowMoved\n");
RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0); RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
break; break;
case kXDarwinToggleFullscreen: case kXDarwinToggleFullscreen:
DEBUG_LOG("kXDarwinToggleFullscreen\n"); DEBUG_LOG("kXDarwinToggleFullscreen\n");
#ifdef DARWIN_DDX_MISSING #ifdef DARWIN_DDX_MISSING
if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot); if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
else if (quartzHasRoot) QuartzHide(); else if (quartzHasRoot) QuartzHide();
@ -481,6 +478,7 @@ void QuartzProcessEvent(
break; break;
case kXDarwinSetRootless: case kXDarwinSetRootless:
DEBUG_LOG("kXDarwinSetRootless\n");
#ifdef DARWIN_DDX_MISSING #ifdef DARWIN_DDX_MISSING
QuartzSetRootless(xe->u.clientMessage.u.l.longs0); QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
if (!quartzEnableRootless && !quartzHasRoot) QuartzHide(); if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
@ -506,34 +504,11 @@ void QuartzProcessEvent(
break; break;
case kXDarwinBringAllToFront: case kXDarwinBringAllToFront:
DEBUG_LOG("kXDarwinBringAllToFront\n"); DEBUG_LOG("kXDarwinBringAllToFront\n");
RootlessOrderAllWindows(); RootlessOrderAllWindows();
break; break;
default: default:
ErrorF("Unknown application defined event type %d.\n", xe->u.u.type); ErrorF("Unknown application defined event type %d.\n", xe->u.u.type);
} }
} }
/*
* QuartzGiveUp
* Cleanup before X server shutdown
* Release the screen and restore the Aqua cursor.
*/
void QuartzGiveUp(void)
{
#if 0
// Trying to switch cursors when quitting causes deadlock
int i;
for (i = 0; i < screenInfo.numScreens; i++) {
if (screenInfo.screens[i]) {
QuartzSuspendXCursor(screenInfo.screens[i]);
}
}
#endif
if (!quartzRootless)
quartzProcs->ReleaseScreens();
}

View File

@ -63,7 +63,6 @@ typedef struct {
// Data stored at startup for Cocoa front end // Data stored at startup for Cocoa front end
extern int quartzEventWriteFD; extern int quartzEventWriteFD;
extern int quartzStartClients;
// User preferences used by Quartz modes // User preferences used by Quartz modes
extern int quartzRootless; extern int quartzRootless;

View File

@ -34,8 +34,8 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <CoreFoundation/CoreFoundation.h> #include <CoreFoundation/CoreFoundation.h>
#include "quartzForeground.h"
#include "quartzCommon.h" #include "quartzCommon.h"
#include "X11Application.h"
#include "darwin.h" #include "darwin.h"
#include "quartz.h" #include "quartz.h"
#include "opaque.h" #include "opaque.h"
@ -52,9 +52,6 @@
char **envpGlobal; // argcGlobal and argvGlobal char **envpGlobal; // argcGlobal and argvGlobal
// are from dix/globals.c // are from dix/globals.c
void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
static void server_thread (void *arg) { static void server_thread (void *arg) {
extern int main(int argc, char **argv, char **envp); extern int main(int argc, char **argv, char **envp);
exit (main (argcGlobal, argvGlobal, envpGlobal)); exit (main (argcGlobal, argvGlobal, envpGlobal));
@ -68,22 +65,16 @@ static void server_thread (void *arg) {
* server. On the second call this function loads the user * server. On the second call this function loads the user
* preferences set by the Mac OS X front end. * preferences set by the Mac OS X front end.
*/ */
void DarwinHandleGUI( void DarwinHandleGUI(int argc, char **argv, char **envp) {
int argc,
char *argv[],
char *envp[] )
{
static Bool been_here = FALSE; static Bool been_here = FALSE;
int i; int i;
int fd[2]; int fd[2];
QuartzMoveToForeground();
if (been_here) { if (been_here) {
return; return;
} }
been_here = TRUE; been_here = TRUE;
// Make a pipe to pass events // Make a pipe to pass events
assert( pipe(fd) == 0 ); assert( pipe(fd) == 0 );
darwinEventReadFD = fd[0]; darwinEventReadFD = fd[0];
@ -95,26 +86,14 @@ void DarwinHandleGUI(
argvGlobal = argv; argvGlobal = argv;
envpGlobal = envp; envpGlobal = envp;
quartzStartClients = 1;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
// Display version info without starting Mac OS X UI if requested // Display version info without starting Mac OS X UI if requested
if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) { if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
DarwinPrintBanner(); DarwinPrintBanner();
exit(0); 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;
}
} }
/* Initially I ran the X server on the main thread, and received /* Initially I ran the X server on the main thread, and received
events on the second thread. But now we may be using Carbon, events on the second thread. But now we may be using Carbon,
that needs to run on the main thread. (Otherwise, when it's that needs to run on the main thread. (Otherwise, when it's
@ -127,6 +106,6 @@ void DarwinHandleGUI(
extern void _InitHLTB(void); extern void _InitHLTB(void);
_InitHLTB(); _InitHLTB();
X11ControllerMain(argc, argv, server_thread, NULL); X11ApplicationMain(argc, argv, server_thread, NULL);
exit(0); exit(0);
} }

View File

@ -31,7 +31,7 @@
#include "screenint.h" #include "screenint.h"
extern Bool QuartzModeBundleInit(void); Bool QuartzModeBundleInit(void);
void AppleDRIExtensionInit(void); void AppleDRIExtensionInit(void);
void xprAppleWMInit(void); void xprAppleWMInit(void);