xserver: Branch 'master'

Jeremy Huddleston jeremyhu at kemper.freedesktop.org
Thu Dec 20 13:21:31 PST 2007


 dix/main.c                  |    4 ++
 hw/xquartz/X11Application.h |   52 +++++++++++++++++------------------
 hw/xquartz/X11Application.m |   64 ++++++++++++++++++++++----------------------
 hw/xquartz/X11Controller.h  |    4 --
 hw/xquartz/X11Controller.m  |    8 -----
 hw/xquartz/darwin.c         |   19 +++----------
 hw/xquartz/quartz.c         |   51 ++++++++---------------------------
 hw/xquartz/quartzCommon.h   |    1 
 hw/xquartz/quartzStartup.c  |   29 ++-----------------
 hw/xquartz/xpr/xpr.h        |    2 -
 10 files changed, 85 insertions(+), 149 deletions(-)

New commits:
commit 42802a8e6b3d3795acc4f8b7597ea5a48619b5cd
Author: Jeremy Huddleston <jeremy at yuffie.local>
Date:   Thu Dec 20 13:17:30 2007 -0800

    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
    (cherry picked from commit 36922e8ff4316c93843aa3fe959cf8df3c7d5892)

diff --git a/dix/main.c b/dix/main.c
index 532b325..9114f00 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -238,6 +238,10 @@ static int indexForScanlinePad[ 65 ] = {
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#ifdef __APPLE__
+void DarwinHandleGUI(int argc, char **argv, char **envp);
+#endif
+
 int
 main(int argc, char *argv[], char *envp[])
 {
diff --git a/hw/xquartz/X11Application.h b/hw/xquartz/X11Application.h
index 8615657..c42e6a5 100644
--- a/hw/xquartz/X11Application.h
+++ b/hw/xquartz/X11Application.h
@@ -64,40 +64,38 @@ extern X11Application *X11App;
 
 #endif /* __OBJC__ */
 
-extern void X11ApplicationSetWindowMenu (int nitems, const char **items,
+void X11ApplicationSetWindowMenu (int nitems, const char **items,
 					 const char *shortcuts);
-extern void X11ApplicationSetWindowMenuCheck (int idx);
-extern void X11ApplicationSetFrontProcess (void);
-extern void X11ApplicationSetCanQuit (int state);
-extern void X11ApplicationServerReady (void);
-extern void X11ApplicationShowHideMenubar (int state);
+void X11ApplicationSetWindowMenuCheck (int idx);
+void X11ApplicationSetFrontProcess (void);
+void X11ApplicationSetCanQuit (int state);
+void X11ApplicationServerReady (void);
+void X11ApplicationShowHideMenubar (int state);
 
-extern void X11ApplicationMain (int argc, const char *argv[],
-				void (*server_thread) (void *),
-				void *server_arg);
+void X11ApplicationMain(int argc, char **argv, void (*server_thread) (void *), void *server_arg);
 
 extern int X11EnableKeyEquivalents;
 extern int quartzHasRoot, quartzEnableRootless;
 
 #define APP_PREFS "org.x.X11"
 
-#define PREFS_APPSMENU		"apps_menu"
-#define PREFS_FAKEBUTTONS	"enable_fake_buttons"
-#define PREFS_SYSBEEP		"enable_system_beep"
-#define PREFS_KEYEQUIVS		"enable_key_equivalents"
-#define PREFS_KEYMAP_FILE	"keymap_file"
-#define PREFS_SYNC_KEYMAP	"sync_keymap"
-#define PREFS_DEPTH		"depth"
-#define PREFS_NO_AUTH		"no_auth"
-#define PREFS_NO_TCP		"nolisten_tcp"
-#define PREFS_DONE_XINIT_CHECK	"done_xinit_check"
-#define PREFS_NO_QUIT_ALERT	"no_quit_alert"
-#define PREFS_FAKE_BUTTON2	"fake_button2"
-#define PREFS_FAKE_BUTTON3	"fake_button3"
-#define PREFS_ROOTLESS		"rootless"
-#define PREFS_FULLSCREEN_HOTKEYS "fullscreen_hotkeys"
-#define PREFS_SWAP_ALT_META	"swap_alt_meta"
-#define PREFS_XP_OPTIONS	"xp_options"
-#define PREFS_ENABLE_STEREO	"enable_stereo"
+#define PREFS_APPSMENU              "apps_menu"
+#define PREFS_FAKEBUTTONS           "enable_fake_buttons"
+#define PREFS_SYSBEEP               "enable_system_beep"
+#define PREFS_KEYEQUIVS             "enable_key_equivalents"
+#define PREFS_KEYMAP_FILE           "keymap_file"
+#define PREFS_SYNC_KEYMAP           "sync_keymap"
+#define PREFS_DEPTH                 "depth"
+#define PREFS_NO_AUTH               "no_auth"
+#define PREFS_NO_TCP                "nolisten_tcp"
+#define PREFS_DONE_XINIT_CHECK      "done_xinit_check"
+#define PREFS_NO_QUIT_ALERT         "no_quit_alert"
+#define PREFS_FAKE_BUTTON2          "fake_button2"
+#define PREFS_FAKE_BUTTON3          "fake_button3"
+#define PREFS_ROOTLESS              "rootless"
+#define PREFS_FULLSCREEN_HOTKEYS    "fullscreen_hotkeys"
+#define PREFS_SWAP_ALT_META         "swap_alt_meta"
+#define PREFS_XP_OPTIONS            "xp_options"
+#define PREFS_ENABLE_STEREO         "enable_stereo"
 
 #endif /* X11APPLICATION_H */
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 8d4076a..92a503b 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -32,6 +32,7 @@
 #endif
 
 #include "quartzCommon.h"
+#include "quartzForeground.h"
 
 #import "X11Application.h"
 #include <Carbon/Carbon.h>
@@ -82,8 +83,8 @@ static mach_port_t _port;
 static void send_nsevent (NSEventType type, NSEvent *e);
 
 /* Quartz mode initialization routine. This is often dynamically loaded
- but is statically linked into this X server. */
-extern Bool QuartzModeBundleInit(void);
+   but is statically linked into this X server. */
+Bool QuartzModeBundleInit(void);
 
 static void init_ports (void) {
     kern_return_t r;
@@ -789,44 +790,43 @@ environment?", @"Startup xinitrc dialog");
     [X11App prefs_synchronize];
 }
 
-void X11ApplicationMain (int argc, const char *argv[],
-			 void (*server_thread) (void *), void *server_arg) {
-  NSAutoreleasePool *pool;
-  
+void X11ApplicationMain (int argc, char **argv, void (*server_thread) (void *), void *server_arg) {
+    NSAutoreleasePool *pool;
+
 #ifdef DEBUG
-  while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
+    while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
 #endif
   
-  pool = [[NSAutoreleasePool alloc] init];
-  X11App = (X11Application *) [X11Application sharedApplication];
-  init_ports ();
-  [NSApp read_defaults];
-  [NSBundle loadNibNamed:@"main" owner:NSApp];
-  [[NSNotificationCenter defaultCenter] addObserver:NSApp
+    pool = [[NSAutoreleasePool alloc] init];
+    X11App = (X11Application *) [X11Application sharedApplication];
+    init_ports ();
+    [NSApp read_defaults];
+    [NSBundle loadNibNamed:@"main" owner:NSApp];
+    [[NSNotificationCenter defaultCenter] addObserver:NSApp
 					selector:@selector (became_key:)
 					name:NSWindowDidBecomeKeyNotification object:nil];
-  check_xinitrc ();
-	
-  /*
-   * The xpr Quartz mode is statically linked into this server.
-   * Initialize all the Quartz functions.
-   */
-  QuartzModeBundleInit();
-  
-  /* Calculate the height of the menubar so we can avoid it. */
-  aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
+    check_xinitrc ();
+
+    /*
+     * The xpr Quartz mode is statically linked into this server.
+     * Initialize all the Quartz functions.
+     */
+    QuartzModeBundleInit();
+
+    /* Calculate the height of the menubar so we can avoid it. */
+    aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
     NSMaxY([[NSScreen mainScreen] visibleFrame]);
   
-  if (!create_thread (server_thread, server_arg)) {
-    ErrorF("can't create secondary thread\n");
-    exit (1);
-  }
-  
-  [NSApp run];
-  
-  /* not reached */
-}
+    if (!create_thread (server_thread, server_arg)) {
+        ErrorF("can't create secondary thread\n");
+        exit (1);
+    }
+
+    QuartzMoveToForeground();
 
+    [NSApp run];
+    /* not reached */
+}
 
 /* event conversion */
 
diff --git a/hw/xquartz/X11Controller.h b/hw/xquartz/X11Controller.h
index f1399dc..bfbb04f 100644
--- a/hw/xquartz/X11Controller.h
+++ b/hw/xquartz/X11Controller.h
@@ -78,8 +78,4 @@
 
 #endif /* __OBJC__ */
 
-extern void X11ControllerMain (int argc, const char *argv[],
-			       void (*server_thread) (void *),
-			       void *server_arg);
-
 #endif /* X11CONTROLLER_H */
diff --git a/hw/xquartz/X11Controller.m b/hw/xquartz/X11Controller.m
index 0f64e45..ecd88ab 100644
--- a/hw/xquartz/X11Controller.m
+++ b/hw/xquartz/X11Controller.m
@@ -337,7 +337,7 @@
       /* Setup environment */
       temp = getenv("DISPLAY");
       if (temp == NULL || temp[0] == 0) {
-	snprintf(buf, sizeof(buf), ":%s", display);
+    snprintf(buf, sizeof(buf), ":%s", display);
 	setenv("DISPLAY", buf, TRUE);
       }
 	
@@ -741,9 +741,3 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
 }
 
 @end
-
-void X11ControllerMain (int argc, const char *argv[],
-			void (*server_thread) (void *), void *server_arg)
-{
-  X11ApplicationMain (argc, argv, server_thread, server_arg);
-}
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index d932bcd..06e88bd 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -715,16 +715,6 @@ int ddxProcessArgument( int argc, char *argv[], int i )
         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.
     if ( !strncmp( argv[i], "-psn_", 5 ) ) {
         return 1;
@@ -876,9 +866,9 @@ void ddxUseMsg( void )
     ErrorF("-keymap <file> : read the keymapping from a file instead of the kernel.\n");
     ErrorF("-version : show the server version.\n");
     ErrorF("\n");
-    ErrorF("Quartz modes (Experimental / In Development):\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("Quartz modes (Experimental / In Development):\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("\n");
     ErrorF("Options ignored in rootless mode:\n");
     ErrorF("-size <height> <width> : use a screen resolution of <height> x <width>.\n");
@@ -896,7 +886,8 @@ void ddxGiveUp( void )
 {
     ErrorF( "Quitting XQuartz...\n" );
 
-    QuartzGiveUp();
+    //if (!quartzRootless)
+    //    quartzProcs->ReleaseScreens();
 }
 
 
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 2063300..75f4e5e 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -61,7 +61,6 @@
 
 // Shared global variables for Quartz modes
 int                     quartzEventWriteFD = -1;
-int                     quartzStartClients = 1;
 int                     quartzRootless = -1;
 int                     quartzUseSysBeep = 0;
 int                     quartzUseAGL = 1;
@@ -408,12 +407,10 @@ QuartzMessageServerThread(
  * QuartzProcessEvent
  *  Process Quartz specific events.
  */
-void QuartzProcessEvent(
-    xEvent *xe)
-{
+void QuartzProcessEvent(xEvent *xe) {
     switch (xe->u.u.type) {
         case kXDarwinControllerNotify:
-	  DEBUG_LOG("kXDarwinControllerNotify\n");
+            DEBUG_LOG("kXDarwinControllerNotify\n");
             AppleWMSendEvent(AppleWMControllerNotify,
                              AppleWMControllerNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -421,7 +418,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinPasteboardNotify:
-	  DEBUG_LOG("kXDarwinPasteboardNotify\n");
+            DEBUG_LOG("kXDarwinPasteboardNotify\n");
             AppleWMSendEvent(AppleWMPasteboardNotify,
                              AppleWMPasteboardNotifyMask,
                              xe->u.clientMessage.u.l.longs0,
@@ -429,7 +426,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  DEBUG_LOG("kXDarwinActivate\n");
+            DEBUG_LOG("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -438,7 +435,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-  	  DEBUG_LOG("kXDarwinDeactivate\n");
+            DEBUG_LOG("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -446,23 +443,23 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	    DEBUG_LOG("kXDarwinDisplayChanged\n");
+            DEBUG_LOG("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  DEBUG_LOG("kXDarwinWindowState\n");
+            DEBUG_LOG("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  DEBUG_LOG("kXDarwinWindowMoved\n");
-	  RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
+            DEBUG_LOG("kXDarwinWindowMoved\n");
+            RootlessNativeWindowMoved ((WindowPtr)xe->u.clientMessage.u.l.longs0);
 	    break;
 
         case kXDarwinToggleFullscreen:
-	  DEBUG_LOG("kXDarwinToggleFullscreen\n");
+            DEBUG_LOG("kXDarwinToggleFullscreen\n");
 #ifdef DARWIN_DDX_MISSING
             if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
             else if (quartzHasRoot) QuartzHide();
@@ -473,6 +470,7 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinSetRootless:
+            DEBUG_LOG("kXDarwinSetRootless\n");
 #ifdef DARWIN_DDX_MISSING
             QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
             if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
@@ -498,34 +496,11 @@ void QuartzProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-  	  DEBUG_LOG("kXDarwinBringAllToFront\n");
-	    RootlessOrderAllWindows();
+            DEBUG_LOG("kXDarwinBringAllToFront\n");
+            RootlessOrderAllWindows();
             break;
 
         default:
             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();
-}
diff --git a/hw/xquartz/quartzCommon.h b/hw/xquartz/quartzCommon.h
index 50b50f6..a0d4673 100644
--- a/hw/xquartz/quartzCommon.h
+++ b/hw/xquartz/quartzCommon.h
@@ -64,7 +64,6 @@ typedef struct {
 
 // Data stored at startup for Cocoa front end
 extern int              quartzEventWriteFD;
-extern int              quartzStartClients;
 
 // User preferences used by Quartz modes
 extern int              quartzRootless;
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 87bcada..50ce2a6 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -34,8 +34,8 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <CoreFoundation/CoreFoundation.h>
-#include "quartzForeground.h"
 #include "quartzCommon.h"
+#include "X11Application.h"
 #include "darwin.h"
 #include "quartz.h"
 #include "opaque.h"
@@ -52,9 +52,6 @@
 char **envpGlobal;      // argcGlobal and argvGlobal
                         // are from dix/globals.c
 
-
-void X11ControllerMain(int argc, char *argv[], void (*server_thread) (void *), void *server_arg);
-
 static void server_thread (void *arg) {
   extern int main(int argc, char **argv, char **envp);
   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
  *  preferences set by the Mac OS X front end.
  */
-void DarwinHandleGUI(
-    int         argc,
-    char        *argv[],
-    char        *envp[] )
-{
+void DarwinHandleGUI(int argc, char **argv, char **envp) {
     static Bool been_here = FALSE;
     int         i;
     int         fd[2];
 
-    QuartzMoveToForeground();
-    
     if (been_here) {
         return;
     }
     been_here = TRUE;
-
+    
     // Make a pipe to pass events
     assert( pipe(fd) == 0 );
     darwinEventReadFD = fd[0];
@@ -95,26 +86,14 @@ void DarwinHandleGUI(
     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;
-        }
     }
 
-
     /* 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
@@ -127,6 +106,6 @@ void DarwinHandleGUI(
     extern void _InitHLTB(void);
     
     _InitHLTB();    
-    X11ControllerMain(argc, argv, server_thread, NULL);
+    X11ApplicationMain(argc, argv, server_thread, NULL);
     exit(0);
 }
diff --git a/hw/xquartz/xpr/xpr.h b/hw/xquartz/xpr/xpr.h
index ddc6d0c..b8c69df 100644
--- a/hw/xquartz/xpr/xpr.h
+++ b/hw/xquartz/xpr/xpr.h
@@ -31,7 +31,7 @@
 
 #include "screenint.h"
 
-extern Bool QuartzModeBundleInit(void);
+Bool QuartzModeBundleInit(void);
 
 void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);


More information about the xorg-commit mailing list