xserver: Branch 'master' - 14 commits

Ben Byer bbyer at kemper.freedesktop.org
Thu Nov 8 20:42:48 PST 2007


 configure.ac                      |    3 
 hw/darwin/apple/X11Application.m  |  334 ++++++++++++++++++--------------------
 hw/darwin/darwin.h                |    3 
 hw/darwin/quartz/quartz.c         |   87 +++++----
 hw/darwin/quartz/quartz.h         |    1 
 hw/darwin/quartz/quartzKeyboard.c |  154 +++++------------
 hw/darwin/quartz/xpr/xpr.h        |    1 
 hw/darwin/quartz/xpr/xprFrame.c   |   34 +++
 hw/darwin/quartz/xpr/xprScreen.c  |    2 
 mi/miinitext.c                    |    2 
 miext/rootless/rootless.h         |    2 
 miext/rootless/rootlessGC.c       |   50 +++--
 miext/rootless/rootlessWindow.c   |  143 +++++++++++++++-
 13 files changed, 479 insertions(+), 337 deletions(-)

New commits:
commit f2a3728868376a3646832d4af3a29549ce0b8f5d
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 18:49:05 2007 -0800

    Patch to rootless code that should fix many crashes.  Credit to Ken Thomases
    at CodeWeavers for the patch.  From his description:
    
    Fix a display bug with the X server.  The Generic Rootless extension
    installs overrides for certain GC (graphics context) operations.  Within
    these overrides, they temporarily uninstall themselves, perform their work,
    and then reinstall themselves.  Except sometimes they would return early
    and wouldn't reinstall themselves when they should.  Now they do in all cases.
    
    Fix a bug in RootlessCopyWindow where early returns could leave the screen's
    dispatch table entry for CopyWindow unwrapped.  We think that this is
    another case (hopefully the last) of the rootless drawing bug.

diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index b26f52c..7e0778e 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -413,10 +413,12 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 #define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \
                             && IsRoot ((WindowPtr) (pDst)))
 
-#define GC_SKIP_ROOT(pDst)			\
+#define GC_SKIP_ROOT(pDst, pGC)			\
     do {					\
-        if (GC_IS_ROOT (pDst))			\
+        if (GC_IS_ROOT (pDst)) {		\
+            GCOP_WRAP(pGC);			\
             return;				\
+        }					\
     } while (0)
 
 
@@ -426,7 +428,7 @@ RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill spans start ");
 
     if (nInit <= 0) {
@@ -482,7 +484,7 @@ RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
                  int nspans, int sorted)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("set spans start ");
 
     if (nspans <= 0) {
@@ -533,7 +535,7 @@ RootlessPutImage(DrawablePtr dst, GCPtr pGC,
     BoxRec box;
 
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("put image start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -565,7 +567,10 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+    {
+        GCOP_WRAP(pGC);
         return NULL;			/* nothing exposed */
+    }
 
     RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
 
@@ -615,7 +620,10 @@ static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+    {
+        GCOP_WRAP(pGC);
         return NULL;			/* nothing exposed */
+    }
 
     RL_DEBUG_MSG("copy plane start ");
 
@@ -652,7 +660,7 @@ static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
                               int mode, int npt, DDXPointPtr pptInit)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("polypoint start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -746,7 +754,7 @@ static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
                               int mode, int npt, DDXPointPtr pptInit)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly lines start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -821,7 +829,7 @@ static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
                                 int nseg, xSegment *pSeg)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -892,7 +900,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
                                   int nRects, xRectangle *pRects)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly rectangle start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -953,7 +961,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
 static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("poly arc start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -1009,7 +1017,7 @@ static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
                  pGC->fillStyle);
 
@@ -1083,7 +1091,7 @@ static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
                  pGC->fillStyle);
 
@@ -1138,7 +1146,7 @@ static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("fill arc start ");
 
     if (narcsInit > 0) {
@@ -1193,7 +1201,7 @@ static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imagetext8 start ");
 
     if (count > 0) {
@@ -1247,7 +1255,10 @@ static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst))
+    {
+        GCOP_WRAP(pGC);
         return 0;
+    }
 
     RL_DEBUG_MSG("polytext8 start ");
 
@@ -1285,7 +1296,7 @@ static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imagetext16 start ");
 
     if (count > 0) {
@@ -1339,7 +1350,10 @@ static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
     GCOP_UNWRAP(pGC);
 
     if (GC_IS_ROOT(dst))
+    {
+        GCOP_WRAP(pGC);
         return 0;
+    }
 
     RL_DEBUG_MSG("polytext16 start ");
 
@@ -1378,7 +1392,7 @@ static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
 {
     GC_SAVE(pGC);
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("imageglyph start ");
 
     if (nglyphInit > 0) {
@@ -1439,7 +1453,7 @@ static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
                                  CharInfoPtr *ppci, pointer pglyphBase)
 {
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("polyglyph start ");
 
     RootlessStartDrawing((WindowPtr) dst);
@@ -1485,7 +1499,7 @@ RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
     BoxRec box;
 
     GCOP_UNWRAP(pGC);
-    GC_SKIP_ROOT(dst);
+    GC_SKIP_ROOT(dst, pGC);
     RL_DEBUG_MSG("push pixels start ");
 
     RootlessStartDrawing((WindowPtr) dst);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index eb736b7..89c02f8 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -836,13 +836,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         top = TopLevelParent(pWin);
         if (top == NULL) {
             RL_DEBUG_MSG("no parent\n");
-            return;
+            goto out;
         }
 
         winRec = WINREC(top);
         if (winRec == NULL) {
             RL_DEBUG_MSG("not framed\n");
-            return;
+            goto out;
         }
 
         /* Move region to window local coords */
@@ -865,6 +865,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
         RootlessDamageRegion(pWin, prgnSrc);
     }
 
+out:
     REGION_UNINIT(pScreen, &rgnDst);
     fbValidateDrawable(&pWin->drawable);
 
commit 338c1aedbdf3964e542947140f7c50d58542cf12
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:56:44 2007 -0800

    formatting fixes

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 38675a3..461ca39 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -789,44 +789,40 @@ environment?", @"Startup xinitrc dialog");
 
 void X11ApplicationMain (int argc, const char *argv[],
 			 void (*server_thread) (void *), void *server_arg) {
-    NSAutoreleasePool *pool;
-	
+  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
-					  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]) -
-      NSMaxY([[NSScreen mainScreen] visibleFrame]);
-	
-    if (!create_thread (server_thread, server_arg)) {
-      ErrorF("can't create secondary thread\n");
-      exit(1);
-    }
-	
-    [NSApp run];
+  
+  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]) -
+    NSMaxY([[NSScreen mainScreen] visibleFrame]);
+  
+  if (!create_thread (server_thread, server_arg)) {
+    ErrorF("can't create secondary thread\n");
+    exit (1);
+  }
+  
+  [NSApp run];
+  
+  /* not reached */
 }
 
 
commit bd269d0d783d418ef99363478fdf849fd89eed76
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:55:08 2007 -0800

    Fix for off-by-one error in menu bar height calculation -- props to Nicholas Riley!

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 84e295b..38675a3 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -819,7 +819,7 @@ void X11ApplicationMain (int argc, const char *argv[],
 	
     /* Calculate the height of the menubar so we can avoid it. */
     aquaMenuBarHeight = NSHeight([[NSScreen mainScreen] frame]) -
-      NSMaxY([[NSScreen mainScreen] visibleFrame]) - 1;
+      NSMaxY([[NSScreen mainScreen] visibleFrame]);
 	
     if (!create_thread (server_thread, server_arg)) {
       ErrorF("can't create secondary thread\n");
commit b4d14484056e6f4a7374fc1acf3f223be4bd116f
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 03:10:52 2007 -0800

    Undo some last-minute breakage in xpr.h

diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 46baac7..bd8e63e 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -38,8 +38,6 @@ void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);
 Bool xprInit(ScreenPtr pScreen);
 Bool xprIsX11Window(void *nsWindow, int windowNumber);
-WindowPtr xprGetX11Window(xp_window_id wid);
-WindowPtr xprGetXWindowFromAppKit(int windowNumber);
 
 void xprHideWindows(Bool hide);
 
commit 05d5b9baa05a4ba14a4383d8a981bc327d99290c
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 02:28:49 2007 -0800

    removed debugging output

diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 29f54de..762a84b 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -357,7 +357,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinActivate:
-	  ErrorF("kXDarwinActivate\n");
+  //	  ErrorF("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -366,7 +366,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
-	  ErrorF("kXDarwinDeactivate\n");
+  //	  ErrorF("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
@@ -374,18 +374,18 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDisplayChanged:
-	  ErrorF("kXDarwinDisplayChanged\n");
+  //	  ErrorF("kXDarwinDisplayChanged\n");
             QuartzUpdateScreens();
             break;
 
         case kXDarwinWindowState:
-	  ErrorF("kXDarwinWindowState\n");
+  //	  ErrorF("kXDarwinWindowState\n");
             RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
 		  			     xe->u.clientMessage.u.l.longs1);
 	    break;
 	  
         case kXDarwinWindowMoved:
-	  ErrorF("kXDarwinWindowMoved\n");
+  //	  ErrorF("kXDarwinWindowMoved\n");
             RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
 	    break;
 
@@ -395,7 +395,7 @@ void DarwinModeProcessEvent(
             else if (quartzHasRoot) QuartzHide();
             else QuartzShow();
 #else
-	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+    //	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
 #endif
             break;
 
@@ -404,7 +404,7 @@ void DarwinModeProcessEvent(
             QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
             if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
 #else
-	    ErrorF("kXDarwinSetRootless not implemented\n");
+    //	    ErrorF("kXDarwinSetRootless not implemented\n");
 #endif
             break;
 
@@ -425,7 +425,7 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinBringAllToFront:
-	  ErrorF("kXDarwinBringAllToFront\n");
+  //	  ErrorF("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
commit 9a8abcfa6d6d0cdc17be02a3443a7e116eb07d07
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 02:22:39 2007 -0800

    Fixed focus problem (clicking on an X11 window that sits behind
    an Aqua window would not always bring it to the top of the stack.

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 0a080db..84e295b 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -201,6 +201,8 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
       if (_x_active) [self activateX:NO];
     } else if ([self modalWindow] == nil) {
       /* Must be an X window. Tell appkit it doesn't have focus. */
+      WindowPtr pWin = xprGetXWindowFromAppKit([e windowNumber]);
+      if (pWin) RootlessReorderWindow(pWin);
       for_appkit = NO;
       
       if ([self isActive]) {
diff --git a/hw/darwin/quartz/xpr/xpr.h b/hw/darwin/quartz/xpr/xpr.h
index 73a88c0..46baac7 100644
--- a/hw/darwin/quartz/xpr/xpr.h
+++ b/hw/darwin/quartz/xpr/xpr.h
@@ -38,6 +38,9 @@ void AppleDRIExtensionInit(void);
 void xprAppleWMInit(void);
 Bool xprInit(ScreenPtr pScreen);
 Bool xprIsX11Window(void *nsWindow, int windowNumber);
+WindowPtr xprGetX11Window(xp_window_id wid);
+WindowPtr xprGetXWindowFromAppKit(int windowNumber);
+
 void xprHideWindows(Bool hide);
 
 Bool QuartzInitCursor(ScreenPtr pScreen);
diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index aa38845..ddb6d2d 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -424,6 +424,37 @@ xprGetXWindow(xp_window_id wid)
     return winRec != NULL ? winRec->win : NULL;
 }
 
+/*
+ * Given the id of a physical window, try to find the top-level (or root)
+ * X window that it represents.
+ */
+WindowPtr
+xprGetXWindowFromAppKit(int windowNumber)
+{
+    RootlessWindowRec *winRec;
+    Bool ret;
+    xp_window_id wid;
+
+    if (window_hash == NULL)
+        return FALSE;
+
+    /* need to lock, since this function can be called by any thread */
+
+    pthread_mutex_lock(&window_hash_mutex);
+
+    if (xp_lookup_native_window(windowNumber, &wid))
+        ret = xprGetXWindow(wid) != NULL;
+    else
+        ret = FALSE;
+
+    pthread_mutex_unlock(&window_hash_mutex);
+
+    if (!ret) return NULL;
+    winRec = x_hash_table_lookup(window_hash, (void *) wid, NULL);
+
+    return winRec != NULL ? winRec->win : NULL;
+}
+
 
 /*
  * The windowNumber is an AppKit window number. Returns TRUE if xpr is
commit b34d2ffc38002f7c4980c138f57e9a828cd79c37
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 01:56:37 2007 -0800

    formatting changes.

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 6b235ad..0a080db 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -183,116 +183,111 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
 }
 
 - (void) sendEvent:(NSEvent *)e {
-    NSEventType type;
-    BOOL for_appkit, for_x;
-	
-    type = [e type];
-	
-    /* By default pass down the responder chain and to X. */
-    for_appkit = YES;
-    for_x = YES;
-	
-    switch (type) {
-    case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
-    case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
-      if ([e window] != nil) {
-	/* Pointer event has a window. Probably something for the kit. */
-	
-	for_x = NO;
-	
-	if (_x_active) [self activateX:NO];
-      } else if ([self modalWindow] == nil) {
-	/* Must be an X window. Tell appkit it doesn't have focus. */
-			
-	for_appkit = NO;
+  NSEventType type;
+  BOOL for_appkit, for_x;
+  
+  type = [e type];
+  
+  /* By default pass down the responder chain and to X. */
+  for_appkit = YES;
+  for_x = YES;
+  
+  switch (type) {
+  case NSLeftMouseDown: case NSRightMouseDown: case NSOtherMouseDown:
+  case NSLeftMouseUp: case NSRightMouseUp: case NSOtherMouseUp:
+    if ([e window] != nil) {
+      /* Pointer event has an (AppKit) window. Probably something for the kit. */
+      for_x = NO;
+      if (_x_active) [self activateX:NO];
+    } else if ([self modalWindow] == nil) {
+      /* Must be an X window. Tell appkit it doesn't have focus. */
+      for_appkit = NO;
+      
+      if ([self isActive]) {
+	[self deactivate];
 	
-	if ([self isActive]) {
-	  [self deactivate];
-	  
-	  if (!_x_active && quartzProcs->IsX11Window([e window], [e windowNumber]))
-	    [self activateX:YES];
-	}
+	if (!_x_active && quartzProcs->IsX11Window([e window],
+						   [e windowNumber]))
+	  [self activateX:YES];
       }
-      break;
+    }
+    break;
       
-    case NSKeyDown: case NSKeyUp:
-      if (_x_active) {
-	static int swallow_up;
-	
-	/* No kit window is focused, so send it to X. */
-	
-	for_appkit = NO;
-	
-	if (type == NSKeyDown) {
-	  /* Before that though, see if there are any global
-	     shortcuts bound to it. */
-	  
-	  if (X11EnableKeyEquivalents
-	      && [[self mainMenu] performKeyEquivalent:e]) {
-	    swallow_up = [e keyCode];
-	    for_x = NO;
-	  } else if (!quartzEnableRootless
+  case NSKeyDown: case NSKeyUp:
+    if (_x_active) {
+      static int swallow_up;
+      
+      /* No kit window is focused, so send it to X. */
+      for_appkit = NO;
+      if (type == NSKeyDown) {
+	/* Before that though, see if there are any global
+	   shortcuts bound to it. */
+	
+	if (X11EnableKeyEquivalents
+	    && [[self mainMenu] performKeyEquivalent:e]) {
+	  swallow_up = [e keyCode];
+	  for_x = NO;
+	} else if (!quartzEnableRootless
 		   && ([e modifierFlags] & ALL_KEY_MASKS)
 		   == (NSCommandKeyMask | NSAlternateKeyMask)
 		   && ([e keyCode] == 0 /*a*/
-		       || [e keyCode] == 53 /*Esc*/)) {
-	    swallow_up = 0;
-	    for_x = NO;
+		    || [e keyCode] == 53 /*Esc*/)) {
+	  swallow_up = 0;
+	  for_x = NO;
 #ifdef DARWIN_DDX_MISSING
-	    QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
+	  QuartzMessageServerThread (kXDarwinToggleFullscreen, 0);
 #endif
-	  }
-	} else {
-	  /* If we saw a key equivalent on the down, don't pass
-	     the up through to X. */
-	  
-	  if (swallow_up != 0 && [e keyCode] == swallow_up) {
-	    swallow_up = 0;
-	    for_x = NO;
-	  }
 	}
-      }
-      else for_x = NO;
-      break;
-		
-    case NSFlagsChanged:
-      /* For the l33t X users who remap modifier keys to normal keysyms. */
-      if (!_x_active)
-	for_x = NO;
-      break;
-		
-    case NSAppKitDefined:
-      switch ([e subtype]) {
-      case NSApplicationActivatedEventType:
-	for_x = NO;
-	if ([self modalWindow] == nil) {
-	  for_appkit = NO;
-	  
-	  /* FIXME: hack to avoid having to pass the event to appkit,
-	     which would cause it to raise one of its windows. */
-	  _appFlags._active = YES;
-	  
-	  [self activateX:YES];
-	  if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
+      } else {
+	/* If we saw a key equivalent on the down, don't pass
+	   the up through to X. */
+	
+	if (swallow_up != 0 && [e keyCode] == swallow_up) {
+	  swallow_up = 0;
+	  for_x = NO;
 	}
-	break;
-			
-      case 18: /* ApplicationDidReactivate */
-	if (quartzHasRoot) for_appkit = NO;
-	break;
-			
-      case NSApplicationDeactivatedEventType:
-	for_x = NO;
-	[self activateX:NO];
-	break;
+      }
+    } else for_x = NO;
+    break;
+    
+  case NSFlagsChanged:
+    /* For the l33t X users who remap modifier keys to normal keysyms. */
+    if (!_x_active) for_x = NO;
+    break;
+    
+  case NSAppKitDefined:
+    switch ([e subtype]) {
+    case NSApplicationActivatedEventType:
+      for_x = NO;
+      if ([self modalWindow] == nil) {
+	for_appkit = NO;
+	
+	/* FIXME: hack to avoid having to pass the event to appkit,
+	   which would cause it to raise one of its windows. */
+	_appFlags._active = YES;
+	
+	[self activateX:YES];
+	if ([e data2] & 0x10) X11ApplicationSetFrontProcess();
       }
       break;
       
-    default: break; /* for gcc */
+    case 18: /* ApplicationDidReactivate */
+      if (quartzHasRoot) for_appkit = NO;
+      break;
+      
+    case NSApplicationDeactivatedEventType:
+      for_x = NO;
+      [self activateX:NO];
+      break;
     }
-	
-    if (for_appkit) [super sendEvent:e];
-    if (for_x) send_nsevent (type, e);
+    break;
+    
+  default: break; /* for gcc */
+  }
+  
+  if (for_appkit) [super sendEvent:e];
+  
+  if (for_x) send_nsevent (type, e);
 }
 
 - (void) set_window_menu:(NSArray *)list {
@@ -596,52 +591,51 @@ static NSMutableArray * cfarray_to_nsarray (CFArrayRef in) {
     CFPreferencesAppSynchronize (kCFPreferencesCurrentApplication);
 }
 
-- (void) read_defaults {
-  const char *tem;
-  
-  quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
-			   default:quartzUseSysBeep];
-  quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
-			       default:quartzEnableRootless];
+- (void) read_defaults
+{
+    const char *tem;
+	
+    quartzUseSysBeep = [self prefs_get_boolean:@PREFS_SYSBEEP
+                        default:quartzUseSysBeep];
+    quartzEnableRootless = [self prefs_get_boolean:@PREFS_ROOTLESS
+                        default:quartzEnableRootless];
 #ifdef DARWIN_DDX_MISSING
-  quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
-					    @PREFS_FULLSCREEN_HOTKEYS default:
-					    !quartzFullscreenDisableHotkeys];
-  quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
-			       default:quartzXpluginOptions];
+    quartzFullscreenDisableHotkeys = ![self prefs_get_boolean:
+					      @PREFS_FULLSCREEN_HOTKEYS default:
+					      !quartzFullscreenDisableHotkeys];
+    quartzXpluginOptions = [self prefs_get_integer:@PREFS_XP_OPTIONS
+                            default:quartzXpluginOptions];
 #endif
-  
-  darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
-			    default:darwinSwapAltMeta];
-  darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
-			    default:darwinFakeButtons];
-  if (darwinFakeButtons) {
-    const char *fake2, *fake3;
-    
-    fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
-    fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
-													      
-     if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
-     if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
-		
-  }
 	
-  X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
-				  default:X11EnableKeyEquivalents];
+    darwinSwapAltMeta = [self prefs_get_boolean:@PREFS_SWAP_ALT_META
+                         default:darwinSwapAltMeta];
+    darwinFakeButtons = [self prefs_get_boolean:@PREFS_FAKEBUTTONS
+                         default:darwinFakeButtons];
+    if (darwinFakeButtons) {
+      const char *fake2, *fake3;
+      
+      fake2 = [self prefs_get_string:@PREFS_FAKE_BUTTON2 default:NULL];
+      fake3 = [self prefs_get_string:@PREFS_FAKE_BUTTON3 default:NULL];
+      
+      if (fake2 != NULL) darwinFakeMouse2Mask = DarwinParseModifierList(fake2);
+      if (fake3 != NULL) darwinFakeMouse3Mask = DarwinParseModifierList(fake3);
+    }
+	
+    X11EnableKeyEquivalents = [self prefs_get_boolean:@PREFS_KEYEQUIVS
+                               default:X11EnableKeyEquivalents];
 	
-  darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
-			   default:darwinSyncKeymap];
+    darwinSyncKeymap = [self prefs_get_boolean:@PREFS_SYNC_KEYMAP
+                        default:darwinSyncKeymap];
 	
-  tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
-
-  if (tem != NULL) darwinKeymapFile = strdup (tem);
-  else darwinKeymapFile = NULL;
+    tem = [self prefs_get_string:@PREFS_KEYMAP_FILE default:NULL];
+    if (tem != NULL) darwinKeymapFile = strdup (tem);
+    else             darwinKeymapFile = NULL;
 	
-  darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
-			     default:darwinDesiredDepth];
+    darwinDesiredDepth = [self prefs_get_integer:@PREFS_DEPTH
+                          default:darwinDesiredDepth];
 	
-  enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
-			default:false];
+    enable_stereo = [self prefs_get_boolean:@PREFS_ENABLE_STEREO
+                     default:false];
 }
 
 /* This will end up at the end of the responder chain. */
commit 50dac9b2cb3b40810fb79253adc0265a838a497b
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Nov 7 01:35:48 2007 -0800

    Fixed Spaces issue, correctly -- dragging an X window from one
    Space to another in Expose mode now works.

diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index 70ce57e..e633858 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -131,7 +131,6 @@ enum {
             = LASTEvent+1,    // (from X.h list of event names)
     kXDarwinUpdateButtons,    // update state of mouse buttons 2 and up
     kXDarwinScrollWheel,      // scroll wheel event
-
     /*
      * Quartz-specific events -- not used in IOKit mode
      */
@@ -142,6 +141,8 @@ enum {
     kXDarwinReadPasteboard,   // copy Mac OS X pasteboard into X cut buffer
     kXDarwinWritePasteboard,  // copy X cut buffer onto Mac OS X pasteboard
     kXDarwinBringAllToFront,  // bring all X windows to front
+    kXDarwinToggleFullscreen, // Enable/Disable fullscreen mode
+    kXDarwinSetRootless,      // Set rootless mode
     /*
      * AppleWM events
      */
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 25061a8..29f54de 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -342,8 +342,22 @@ void DarwinModeProcessEvent(
     xEvent *xe)
 {
     switch (xe->u.u.type) {
+        case kXDarwinControllerNotify:
+            AppleWMSendEvent(AppleWMControllerNotify,
+                             AppleWMControllerNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
+
+        case kXDarwinPasteboardNotify:
+            AppleWMSendEvent(AppleWMPasteboardNotify,
+                             AppleWMPasteboardNotifyMask,
+                             xe->u.clientMessage.u.l.longs0,
+                             xe->u.clientMessage.u.l.longs1);
+            break;
 
         case kXDarwinActivate:
+	  ErrorF("kXDarwinActivate\n");
             QuartzShow(xe->u.keyButtonPointer.rootX,
                        xe->u.keyButtonPointer.rootY);
             AppleWMSendEvent(AppleWMActivationNotify,
@@ -352,12 +366,48 @@ void DarwinModeProcessEvent(
             break;
 
         case kXDarwinDeactivate:
+	  ErrorF("kXDarwinDeactivate\n");
             AppleWMSendEvent(AppleWMActivationNotify,
                              AppleWMActivationNotifyMask,
                              AppleWMIsInactive, 0);
             QuartzHide();
             break;
 
+        case kXDarwinDisplayChanged:
+	  ErrorF("kXDarwinDisplayChanged\n");
+            QuartzUpdateScreens();
+            break;
+
+        case kXDarwinWindowState:
+	  ErrorF("kXDarwinWindowState\n");
+            RootlessNativeWindowStateChanged(xe->u.clientMessage.u.l.longs0,
+		  			     xe->u.clientMessage.u.l.longs1);
+	    break;
+	  
+        case kXDarwinWindowMoved:
+	  ErrorF("kXDarwinWindowMoved\n");
+            RootlessNativeWindowMoved (xe->u.clientMessage.u.l.longs0);
+	    break;
+
+        case kXDarwinToggleFullscreen:
+#ifdef DARWIN_DDX_MISSING
+            if (quartzEnableRootless) QuartzSetFullscreen(!quartzHasRoot);
+            else if (quartzHasRoot) QuartzHide();
+            else QuartzShow();
+#else
+	    ErrorF("kXDarwinToggleFullscreen not implemented\n");
+#endif
+            break;
+
+        case kXDarwinSetRootless:
+#ifdef DARWIN_DDX_MISSING
+            QuartzSetRootless(xe->u.clientMessage.u.l.longs0);
+            if (!quartzEnableRootless && !quartzHasRoot) QuartzHide();
+#else
+	    ErrorF("kXDarwinSetRootless not implemented\n");
+#endif
+            break;
+
         case kXDarwinSetRootClip:
             QuartzSetRootClip((BOOL)xe->u.clientMessage.u.l.longs0);
             break;
@@ -374,46 +424,13 @@ void DarwinModeProcessEvent(
             QuartzWritePasteboard();
             break;
 
-        /*
-         * AppleWM events
-         */
-        case kXDarwinControllerNotify:
-            AppleWMSendEvent(AppleWMControllerNotify,
-                             AppleWMControllerNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinPasteboardNotify:
-            AppleWMSendEvent(AppleWMPasteboardNotify,
-                             AppleWMPasteboardNotifyMask,
-                             xe->u.clientMessage.u.l.longs0,
-                             xe->u.clientMessage.u.l.longs1);
-            break;
-
-        case kXDarwinDisplayChanged:
-            QuartzUpdateScreens();
-            break;
-
         case kXDarwinBringAllToFront:
+	  ErrorF("kXDarwinBringAllToFront\n");
 	    RootlessOrderAllWindows();
             break;
 
-        case kXDarwinWindowState:
-	  ErrorF("kXDarwinWindowState\n");
-	  break;
-    case kXDarwinWindowMoved: {
-	  WindowPtr pWin = (WindowPtr)xe->u.clientMessage.u.l.longs0;
-	  short x = xe->u.clientMessage.u.l.longs1,
-	        y = xe->u.clientMessage.u.l.longs2;
-	  ErrorF("kXDarwinWindowMoved(%p, %hd, %hd)\n", pWin, x, y);
-	  RootlessMoveWindow(pWin, x, y, pWin->nextSib, VTMove);
-    }
-	  break;
-
         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);
     }
 }
 
diff --git a/hw/darwin/quartz/quartz.h b/hw/darwin/quartz/quartz.h
index fa7499d..172f323 100644
--- a/hw/darwin/quartz/quartz.h
+++ b/hw/darwin/quartz/quartz.h
@@ -122,6 +122,7 @@ typedef struct _QuartzModeProcs {
 } QuartzModeProcsRec, *QuartzModeProcsPtr;
 
 extern QuartzModeProcsPtr quartzProcs;
+extern int quartzHasRoot, quartzEnableRootless;
 
 Bool QuartzLoadDisplayBundle(const char *dpyBundleName);
 
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index d9fdb6a..b4a5b2a 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -74,6 +74,8 @@ typedef struct _RootlessWindowRec {
 
     unsigned int is_drawing :1;	// Currently drawing?
     unsigned int is_reorder_pending :1;
+    unsigned int is_offscreen :1;
+    unsigned int is_obscured :1;
 } RootlessWindowRec, *RootlessWindowPtr;
 
 
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 4a3c0f6..eb736b7 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -36,13 +36,23 @@
 #include <stddef.h> /* For NULL */
 #include <limits.h> /* For CHAR_BIT */
 #include <assert.h>
+#ifdef __APPLE__
+//#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include "mi.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include <Xplugin.h>
+//#include <X11/extensions/applewm.h>
+extern int darwinMainScreenX, darwinMainScreenY;
+#endif
+#include "fb.h"
+
+#define AppleWMNumWindowLevels 5
 
 #include "rootlessCommon.h"
 #include "rootlessWindow.h"
 
-#include "fb.h"
-
-
 #ifdef ROOTLESS_GLOBAL_COORDS
 #define SCREEN_TO_GLOBAL_X \
     (dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
@@ -53,6 +63,127 @@
 #define SCREEN_TO_GLOBAL_Y 0
 #endif
 
+#define DEFINE_ATOM_HELPER(func,atom_name)                      \
+  static Atom func (void) {                                       \
+    static unsigned int generation;                             \
+    static Atom atom;                                           \
+    if (generation != serverGeneration) {                       \
+      generation = serverGeneration;                          \
+      atom = MakeAtom (atom_name, strlen (atom_name), TRUE);  \
+    }                                                           \
+    return atom;                                                \
+  }
+
+DEFINE_ATOM_HELPER (xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_native_window_id, "_NATIVE_WINDOW_ID")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static Bool no_configure_window;
+static Bool windows_hidden;
+// TODO - abstract xp functions
+
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+  0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+  202, 203, 204, 205, 201, 200
+};
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+                  const xp_window_changes *values)
+{
+  if (!no_configure_window)
+    return xp_configure_window (id, mask, values);
+  else
+    return XP_Success;
+}
+
+/*static inline unsigned long
+current_time_in_seconds (void)
+{
+  unsigned long t = 0;
+
+  t += currentTime.milliseconds / 1000;
+  t += currentTime.months * 4294967;
+
+  return t;
+  } */
+
+static inline Bool
+rootlessHasRoot (ScreenPtr pScreen)
+{
+  return WINREC (WindowTable[pScreen->myNum]) != NULL;
+}
+
+void
+RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state)
+{
+  WindowPtr pWin;
+  RootlessWindowRec *winRec;
+
+  pWin = xprGetXWindow (id);
+  if (pWin == NULL) return;
+
+  winRec = WINREC (pWin);
+  if (winRec == NULL) return;
+
+  winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0);
+  winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0);
+  //  pWin->rootlessUnhittable = winRec->is_offscreen;
+}
+
+void
+RootlessNativeWindowMoved (WindowPtr pWin)
+{
+  xp_box bounds;
+  int sx, sy;
+  XID vlist[2];
+  Mask mask;
+  ClientPtr client;
+  RootlessWindowRec *winRec = WINREC(pWin);
+
+  if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return;
+
+  sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
+  sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+
+  /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
+
+  vlist[0] = (INT16) bounds.x1 - sx;
+  vlist[1] = (INT16) bounds.y1 - sy;
+  mask = CWX | CWY;
+
+  /* pretend we're the owner of the window! */
+  client = LookupClient (pWin->drawable.id, NullClient);
+
+  /* Don't want to do anything to the physical window (avoids 
+     notification-response feedback loops) */
+
+  no_configure_window = TRUE;
+  ConfigureWindow (pWin, mask, vlist, client);
+  no_configure_window = FALSE;
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+static void
+set_screen_origin (WindowPtr pWin)
+{
+  long data[2];
+
+  if (!IsRoot (pWin))
+    return;
+
+  /* FIXME: move this to an extension? */
+
+  data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
+	     + darwinMainScreenX);
+  data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+	     + darwinMainScreenY);
+
+  ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER,
+			32, PropModeReplace, 2, data, TRUE);
+}
 
 /*
  * RootlessCreateWindow
@@ -565,7 +696,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
     RL_DEBUG_MSG("restackwindow end\n");
 }
 
-
 /*
  * Specialized window copy procedures
  */
commit ce7cfbe261b7fd4fcd09d1a4a61344d1555a71f2
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 20:10:51 2007 -0800

    Fixed check to refer to DarwinApp, not all Darwin targets

diff --git a/mi/miinitext.c b/mi/miinitext.c
index b40e8bd..6fa180b 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -672,7 +672,7 @@ InitVisualWrap()
 {
     miResetInitVisuals();
 #ifdef GLXEXT
-#ifdef __DARWIN__
+#ifdef INXDARWINAPP
     DarwinGlxWrapInitVisuals(&miInitVisualsProc);
 #endif
 #endif
commit d68bd5510437c1fd3850e020f7cd90901fae8e1b
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Nov 8 20:08:49 2007 -0800

    fixing GLX in Xquartz

diff --git a/configure.ac b/configure.ac
index cd78dc4..1df8874 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1746,7 +1746,8 @@ return 0;}
 #               LDFLAGS=$save_LDFLAGS
 #               ])
                xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+               DARWIN_GLX_LIBS='$(top_builddir)/GL/apple/indirect.o $(top_builddir)/GL/glx/libglx.la'
+	       DARWIN_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $DARWIN_GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
commit a6ac9002956767fefa37aac95513e21ac5246d15
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 5 20:25:10 2007 -0800

    formatting cleanup

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index 40b5e92..b40d81e 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -1,8 +1,7 @@
 /*
    quartzKeyboard.c
 
-   Code to build a keymap using the Carbon Keyboard Layout API,
-   which is supported on Mac OS X 10.2 and newer.
+   Code to build a keymap using the Carbon Keyboard Layout API.
 
    Copyright (c) 2003, 2007 Apple Inc.
 
@@ -150,15 +149,11 @@ unsigned int
 DarwinModeSystemKeymapSeed (void)
 {
     static unsigned int seed;
-
     static KeyboardLayoutRef last_key_layout;
     KeyboardLayoutRef key_layout;
 
     KLGetCurrentKeyboardLayout (&key_layout);
-
-    if (key_layout != last_key_layout)
-        seed++;
-
+    if (key_layout != last_key_layout) seed++;
     last_key_layout = key_layout;
 
     return seed;
@@ -190,10 +185,8 @@ macroman2ucs (unsigned char c)
         0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
     };
 
-    if (c < 128)
-        return c;
-    else
-        return table[c - 128];
+    if (c < 128) return c;
+    else         return table[c - 128];
 }
 
 static KeySym
@@ -202,10 +195,7 @@ make_dead_key (KeySym in)
     int i;
 
     for (i = 0; i < sizeof (dead_keys) / sizeof (dead_keys[0]); i++)
-    {
-        if (dead_keys[i].normal == in)
-            return dead_keys[i].dead;
-    }
+        if (dead_keys[i].normal == in) return dead_keys[i].dead;
 
     return in;
 }
@@ -249,53 +239,39 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
        an X11 keysym (which may just the bit that says "this is
        Unicode" if it can't find the real symbol.) */
 
-    for (i = 0; i < num_keycodes; i++)
-    {
+    for (i = 0; i < num_keycodes; i++) {
         static const int mods[4] = {0, MOD_SHIFT, MOD_OPTION,
                                     MOD_OPTION | MOD_SHIFT};
 
         k = info->keyMap + i * GLYPHS_PER_KEY;
 
-        for (j = 0; j < 4; j++)
-        {
-            if (is_uchr)
-            {
+        for (j = 0; j < 4; j++) {
+            if (is_uchr)  {
                 UniChar s[8];
                 UniCharCount len;
-                UInt32 dead_key_state, extra_dead;
+                UInt32 dead_key_state = 0, extra_dead = 0;
 
-                dead_key_state = 0;
                 err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
                                       mods[j] >> 8, keyboard_type, 0,
                                       &dead_key_state, 8, &len, s);
-                if (err != noErr)
-                    continue;
+                if (err != noErr) continue;
 
-                if (len == 0 && dead_key_state != 0)
-                {
+                if (len == 0 && dead_key_state != 0) {
                     /* Found a dead key. Work out which one it is, but
                        remembering that it's dead. */
-
-                    extra_dead = 0;
                     err = UCKeyTranslate (chr_data, i, kUCKeyActionDown,
                                           mods[j] >> 8, keyboard_type,
                                           kUCKeyTranslateNoDeadKeysMask,
                                           &extra_dead, 8, &len, s);
-                    if (err != noErr)
-                        continue;
+                    if (err != noErr) continue;
                 }
 
-                if (len > 0 && s[0] != 0x0010)
-                {
+                if (len > 0 && s[0] != 0x0010) {
                     k[j] = ucs2keysym (s[0]);
-    
-                    if (dead_key_state != 0)
-                        k[j] = make_dead_key (k[j]);
+                    if (dead_key_state != 0) k[j] = make_dead_key (k[j]);
                 }
-            }
-            else
-            {
-                UInt32 c, state = 0;
+            } else { // kchr
+	      UInt32 c, state = 0, state2 = 0;
                 UInt16 code;
 
                 code = i | mods[j];
@@ -307,67 +283,50 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
                    us the actual dead character. */
 
                 if (state != 0)
-                {
-                    UInt32 state2 = 0;
                     c = KeyTranslate (chr_data, code | 128, &state2);
-                }
 
                 /* Characters seem to be in MacRoman encoding. */
 
-                if (c != 0 && c != 0x0010)
-                {
+                if (c != 0 && c != 0x0010) {
                     k[j] = ucs2keysym (macroman2ucs (c & 255));
 
-                    if (state != 0)
-                        k[j] = make_dead_key (k[j]);
+                    if (state != 0) k[j] = make_dead_key (k[j]);
                 }
             }
         }
-
-        if (k[3] == k[2])
-            k[3] = NoSymbol;
-        if (k[2] == k[1])
-            k[2] = NoSymbol;
-        if (k[1] == k[0])
-            k[1] = NoSymbol;
-        if (k[0] == k[2] && k[1] == k[3])
-            k[2] = k[3] = NoSymbol;
+	
+        if (k[3] == k[2]) k[3] = NoSymbol;
+        if (k[2] == k[1]) k[2] = NoSymbol;
+        if (k[1] == k[0]) k[1] = NoSymbol;
+        if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
     }
 
     /* Fix up some things that are normally missing.. */
 
-    if (HACK_MISSING)
-    {
-        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++)
-        {
+    if (HACK_MISSING) {
+        for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
             k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
 
-            if (k[0] == NoSymbol && k[1] == NoSymbol
+            if    (k[0] == NoSymbol && k[1] == NoSymbol
                 && k[2] == NoSymbol && k[3] == NoSymbol)
-            {
-                k[0] = known_keys[i].keysym;
-            }
+	      k[0] = known_keys[i].keysym;
         }
     }
 
     /* And some more things. We find the right symbols for the numeric
        keypad, but not the KP_ keysyms. So try to convert known keycodes. */
 
-    if (HACK_KEYPAD)
-    {
+    if (HACK_KEYPAD) {
         for (i = 0; i < sizeof (known_numeric_keys)
-                        / sizeof (known_numeric_keys[0]); i++)
-        {
+                        / sizeof (known_numeric_keys[0]); i++) {
             k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
 
             if (k[0] == known_numeric_keys[i].normal)
-            {
                 k[0] = known_numeric_keys[i].keypad;
-            }
         }
     }
-	if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
-
+    if(currentKeyLayoutRef)	CFRelease(currentKeyLayoutRef);
+    
     return TRUE;
 }
 
commit 67e96be13cdb45be31db121ce216295cd9496d20
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Mon Nov 5 20:01:34 2007 -0800

    Fixed logic error that prevent JIS (Japanese) keyboard layouts from
    being detected.

diff --git a/hw/darwin/quartz/quartzKeyboard.c b/hw/darwin/quartz/quartzKeyboard.c
index b580a8e..40b5e92 100644
--- a/hw/darwin/quartz/quartzKeyboard.c
+++ b/hw/darwin/quartz/quartzKeyboard.c
@@ -222,36 +222,27 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
     KeySym *k;
 
     TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
-	if (currentKeyLayoutRef)
-	{
-		CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
-		if (currentKeyLayoutDataRef)
-			chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
-	}
-	
-	if(chr_data == NULL) {
-		KLGetCurrentKeyboardLayout (&key_layout);
-		KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
-
-		if (chr_data != NULL)
-		{
-			is_uchr = 1;
-			keyboard_type = LMGetKbdType ();
-		}
-		else
-		{
-			KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
-
-			if (chr_data == NULL)
-			{
-				ErrorF ( "Couldn't get uchr or kchr resource\n");
-				return FALSE;
-			}
-
-			is_uchr = 0;
-			num_keycodes = 128;
-		}    
-	}
+    keyboard_type = LMGetKbdType ();
+    if (currentKeyLayoutRef) {
+      CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
+      if (currentKeyLayoutDataRef) chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetCurrentKeyboardLayout (&key_layout);
+      KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
+    }
+    
+    if (chr_data == NULL) {
+      KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
+      is_uchr = 0;
+      num_keycodes = 128;
+    }
+    
+    if (chr_data == NULL) {
+      ErrorF ( "Couldn't get uchr or kchr resource\n");
+      return FALSE;
+    }
 
     /* Scan the keycode range for the Unicode character that each
        key produces in the four shift states. Then convert that to
commit 154fb6417e5d0bae5191984beac5ce045ce754bb
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sat Nov 3 05:34:19 2007 -0700

    Initial support for Spaces -- if you use Expose to drag an X11
    window to another Space, it will work correctly (as opposed
    to just leaving a ghost window).  We accomplish this by listening
    for the notification from Xplugin that our window has been moved,
    and then we ask X11 to move the window to the new location.

diff --git a/hw/darwin/quartz/xpr/xprFrame.c b/hw/darwin/quartz/xpr/xprFrame.c
index c395f07..aa38845 100644
--- a/hw/darwin/quartz/xpr/xprFrame.c
+++ b/hw/darwin/quartz/xpr/xprFrame.c
@@ -67,6 +67,7 @@ static inline xp_error
 xprConfigureWindow(xp_window_id id, unsigned int mask,
                    const xp_window_changes *values)
 {
+  //  ErrorF("xprConfigureWindow()\n");
     if (!no_configure_window)
         return xp_configure_window(id, mask, values);
     else
@@ -184,7 +185,7 @@ xprMoveFrame(RootlessFrameID wid, ScreenPtr pScreen, int newX, int newY)
 
     wc.x = newX;
     wc.y = newY;
-
+    //    ErrorF("xprMoveFrame(%d, %p, %d, %d)\n", wid, pScreen, newX, newY);
     xprConfigureWindow((xp_window_id) wid, XP_ORIGIN, &wc);
 }
 
commit 169f83e366f678ac5441ad21beb84c9b8c65d28e
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Nov 4 19:14:10 2007 -0800

    Disable deferred updates in xp_init to fix performance problems
    -- thanks to Eric Gouriou for pointing out the issue

diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 709e6e8..886ef34 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -228,7 +228,7 @@ xprDisplayInit(void)
     else
         darwinScreensFound =  1;
 
-    if (xp_init(XP_IN_BACKGROUND) != Success)
+    if (xp_init(XP_IN_BACKGROUND | XP_NO_DEFERRED_UPDATES) != Success)
         FatalError("Could not initialize the Xplugin library.");
 
     xp_select_events(XP_EVENT_DISPLAY_CHANGED


More information about the xorg-commit mailing list