xserver: Branch 'wip/jeremyhu-debug-more-mainline' - 11 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 2 16:40:35 UTC 2023


Rebased ref, commits from common ancestor:
commit 9a0328be79ac2e0e689d040656fa4bdba8cfc575
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Jan 1 23:01:27 2023 -0800

    WUP
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 576972d8e..8e2966da9 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1143,19 +1143,13 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
 
         /* rect is the intersection of the old location and new location */
         if (BOX_NOT_EMPTY(rect) && src != NULL && dst != NULL) {
-            /* The window drawable still has the old frame position, which
-               means that DST doesn't actually point at the origin of our
-               physical backing store when adjusted by the drawable.x,y
-               position. So sneakily adjust it temporarily while copying.. */
-
-            ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
-            SetPixmapBaseToScreen(dst, newX, newY);
-
-            fbCopyWindowProc(&src->drawable, &dst->drawable, NULL,
-                             &rect, 1, 0, 0, FALSE, FALSE, 0, 0);
-
-            ((PixmapPtr) dst)->devPrivate.ptr = winRec->pixelData;
-            SetPixmapBaseToScreen(dst, oldX, oldY);
+            RegionRec rgnDst;
+            RegionInit(&rgnDst, &rect, 1);
+            if (dst->screen_x || dst->screen_y) {
+                RegionTranslate(&rgnDst, -dst->screen_x, -dst->screen_y);
+            }
+            miCopyRegion(&src->drawable, &dst->drawable, NULL,
+                         &rgnDst, oldX - newX, oldY - newY, fbCopyWindowProc, 0, 0);
         }
     }
 
@@ -1324,7 +1318,7 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
             newW = w + 2 * newBW;
             newH = h + 2 * newBW;
 
-            resize_after = StartFrameResize(pWin, FALSE,
+            resize_after = StartFrameResize(pWin, TRUE,
                                             oldX, oldY, oldW, oldH, oldBW,
                                             newX, newY, newW, newH, newBW);
         }
@@ -1336,7 +1330,7 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
         NORMAL_ROOT(pWin);
 
         if (winRec) {
-            FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
+            FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW,
                               newX, newY, newW, newH, newBW, resize_after);
         }
     }
commit f743c4b7f67a2100927e24cfdeb24c6ebd85ffb6
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Jan 1 10:57:46 2023 -0800

    rootless: Use screen_x and screen_y instead of pixmap pointer hacks
    
    This updates rootless to treat pixmaps consistently with COMPOSITE,
    using the screen_x and screen_y values rather than doing hacky math.
    
    This will allow for proper bounds checking on a given PixmapRec.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 210df75c6..d9aa18858 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2187,7 +2187,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
             PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
 
             pBoundingDraw = &pPix->drawable;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
             relx -= pPix->screen_x;
             rely -= pPix->screen_y;
 #endif
diff --git a/exa/exa.c b/exa/exa.c
index b16875845..42047fa2d 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -125,7 +125,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawable)
 void
 exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
 {
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (pDrawable->type == DRAWABLE_WINDOW) {
         *xp = -pPixmap->screen_x;
         *yp = -pPixmap->screen_y;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e632331da..2a31bd3c7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -963,7 +963,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     RegionInit(&rgnDst, NullBox, 0);
 
     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (pPixmap->screen_x || pPixmap->screen_y)
         RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
 #endif
diff --git a/fb/fb.h b/fb/fb.h
index 8ab050d0f..08143a0d4 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -441,7 +441,7 @@ typedef struct {
 #define __fbPixDrawableX(pPix)	((pPix)->drawable.x)
 #define __fbPixDrawableY(pPix)	((pPix)->drawable.y)
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
 #define __fbPixOffXWin(pPix)	(__fbPixDrawableX(pPix) - (pPix)->screen_x)
 #define __fbPixOffYWin(pPix)	(__fbPixDrawableY(pPix) - (pPix)->screen_y)
 #else
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index af5d7bec0..89e3370a6 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -76,7 +76,7 @@ fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
     fbInitializeDrawable(&pPixmap->drawable);
 #endif
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     pPixmap->screen_x = 0;
     pPixmap->screen_y = 0;
 #endif
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index fca871d62..df33af948 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -116,7 +116,7 @@ fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (pPixmap->screen_x || pPixmap->screen_y)
         RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
 #endif
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 1ab2be6c0..fa2d783a1 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -781,7 +781,7 @@ glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_regio
 
     RegionIntersect(&dst_region, &window->borderClip, src_region);
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (pixmap->screen_x || pixmap->screen_y)
         RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
 #endif
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 9aa169cdc..2c8cc3ba0 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -39,7 +39,7 @@ void
 glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
                            int *x, int *y)
 {
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (drawable->type == DRAWABLE_WINDOW) {
         *x = -pixmap->screen_x;
         *y = -pixmap->screen_y;
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 3397bb50c..8cedb7a26 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -872,7 +872,7 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
         return NULL;
 
     pPriv->prime_secondary_pixmap = spix;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     spix->screen_x = mpix->screen_x;
     spix->screen_y = mpix->screen_y;
 #endif
@@ -963,7 +963,7 @@ DRI2CanFlip(DrawablePtr pDraw)
 
     /* Does the window match the pixmap exactly? */
     if (pDraw->x != 0 || pDraw->y != 0 ||
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
         pDraw->x != pWinPixmap->screen_x || pDraw->y != pWinPixmap->screen_y ||
 #endif
         pDraw->width != pWinPixmap->drawable.width ||
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 8d1b742ef..ee29cad0b 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -287,7 +287,7 @@ ms_dri2_copy_region2(ScreenPtr screen, DrawablePtr drawable, RegionPtr pRegion,
     }
 
     if (translate && drawable->type == DRAWABLE_WINDOW) {
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
         PixmapPtr pixmap = get_drawable_pixmap(drawable);
         off_x = -pixmap->screen_x;
         off_y = -pixmap->screen_y;
diff --git a/hw/xwayland/xwayland-present.c b/hw/xwayland/xwayland-present.c
index 99e476b2f..49784de12 100644
--- a/hw/xwayland/xwayland-present.c
+++ b/hw/xwayland/xwayland-present.c
@@ -797,7 +797,7 @@ xwl_present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
                 PixmapPtr old_pixmap = screen->GetWindowPixmap(window);
 
                 /* Replace window pixmap with flip pixmap */
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
                 vblank->pixmap->screen_x = old_pixmap->screen_x;
                 vblank->pixmap->screen_y = old_pixmap->screen_y;
 #endif
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index 5b9b74e3d..47c19d04b 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -1071,7 +1071,7 @@ winCreatePixmapMultiwindow(ScreenPtr pScreen, int width, int height, int depth,
     pPixmap->refcnt = 1;
     pPixmap->devPrivate.ptr = NULL; // later set to pbBits
     pPixmap->primary_pixmap = NULL;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     pPixmap->screen_x = 0;
     pPixmap->screen_y = 0;
 #endif
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index faf54fa4d..54fc26508 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -78,7 +78,7 @@ typedef struct _Pixmap {
     int refcnt;
     int devKind;                /* This is the pitch of the pixmap, typically width*bpp/8. */
     DevUnion devPrivate;        /* When !NULL, devPrivate.ptr points to the raw pixel data. */
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     short screen_x;
     short screen_y;
 #endif
diff --git a/mi/miexpose.c b/mi/miexpose.c
index e54b18b30..6b6938a75 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -461,7 +461,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
         tile_x_off = pWin->drawable.x;
         tile_y_off = pWin->drawable.y;
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
         draw_x_off = pixmap->screen_x;
         draw_y_off = pixmap->screen_y;
         tile_x_off -= draw_x_off;
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index f3fee2eee..20a27557b 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -144,7 +144,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
     RegionRec pixClip;
     int draw_x, draw_y;
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     int screen_x = 0, screen_y = 0;
 #endif
 
@@ -152,7 +152,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
     if (!RegionNotEmpty(pRegion))
         return;
 
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     /*
      * When drawing to a pixmap which is storing window contents,
      * the region presented is in pixmap relative coordinates which
@@ -203,7 +203,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
 
         draw_x = pDamage->pDrawable->x;
         draw_y = pDamage->pDrawable->y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
         /*
          * Need to move everyone to screen coordinates
          * XXX what about off-screen pixmaps with non-zero x/y?
@@ -276,7 +276,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
         if (pDamageRegion == pRegion && (draw_x || draw_y))
             RegionTranslate(pDamageRegion, draw_x, draw_y);
     }
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
     if (screen_x || screen_y)
         RegionTranslate(pRegion, -screen_x, -screen_y);
 #endif
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index d9a4d05e9..40400b395 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -226,20 +226,10 @@ extern RegionRec rootlessHugeRoot;
  *  Can't access the bits before the first word of the drawable's data in
  *  rootless mode, so make sure our base address is always 32-bit aligned.
  */
-#define SetPixmapBaseToScreen(pix, _x, _y) {                                \
-    PixmapPtr   _pPix = (PixmapPtr) (pix);                                  \
-    _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) -              \
-                            ((int)(_x) * _pPix->drawable.bitsPerPixel/8 +   \
-                             (int)(_y) * _pPix->devKind);                   \
-    if (_pPix->drawable.bitsPerPixel != FB_UNIT) {                          \
-        size_t _diff = ((size_t) _pPix->devPrivate.ptr) &               \
-                         (FB_UNIT / CHAR_BIT - 1);                          \
-        _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) -          \
-                                _diff;                                      \
-        _pPix->drawable.x = _diff /                                         \
-                            (_pPix->drawable.bitsPerPixel / CHAR_BIT);      \
-    }                                                                       \
-}
+#define SetPixmapBaseToScreen(pix, _x, _y) do { \
+    pix->screen_x = _x; \
+    pix->screen_y = _y; \
+} while(0)
 
 // Returns TRUE if this window is visible inside a frame
 // (e.g. it is visible and has a top-level or root parent)
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index a1733d213..576972d8e 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -681,11 +681,17 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
     RegionNull(&rgnDst);
     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
+    PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+
     if (gResizeDeathCount == 1) {
         /* Simple case, we only have a single source pixmap. */
 
+        if (pPixmap->screen_x || pPixmap->screen_y) {
+            RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
+        }
+
         miCopyRegion(&gResizeDeathPix[0]->drawable,
-                     &pScreen->GetWindowPixmap(pWin)->drawable, 0,
+                     &pPixmap->drawable, 0,
                      &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
     }
     else {
@@ -700,8 +706,12 @@ RootlessResizeCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
             RegionNull(&clipped);
             RegionIntersect(&rgnDst, &clip, &clipped);
 
+            if (pPixmap->screen_x || pPixmap->screen_y) {
+                RegionTranslate(&clipped, -pPixmap->screen_x, -pPixmap->screen_y);
+            }
+
             miCopyRegion(&gResizeDeathPix[i]->drawable,
-                         &pScreen->GetWindowPixmap(pWin)->drawable, 0,
+                         &pPixmap->drawable, 0,
                          &clipped, dx, dy, fbCopyWindowProc, 0, 0);
 
             RegionUninit(&clipped);
@@ -733,6 +743,9 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     BoxPtr extents;
     int area;
 
+    PixmapPtr pPixmap = fbGetWindowPixmap(pWin);
+    DrawablePtr pDrawable = &pPixmap->drawable;
+
     RL_DEBUG_MSG("copywindowFB start (win %p (%lu)) ", pWin, RootlessWID(pWin));
 
     SCREEN_UNWRAP(pScreen, CopyWindow);
@@ -744,6 +757,10 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     RegionNull(&rgnDst);
     RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
 
+    if (pPixmap->screen_x || pPixmap->screen_y) {
+        RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
+    }
+
     extents = RegionExtents(&rgnDst);
     area = (extents->x2 - extents->x1) * (extents->y2 - extents->y1);
 
@@ -766,9 +783,6 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
             goto out;
         }
 
-        /* Move region to window local coords */
-        RegionTranslate(&rgnDst, -winRec->x, -winRec->y);
-
         RootlessStopDrawing(pWin, FALSE);
 
         SCREENREC(pScreen)->imp->CopyWindow(winRec->wid,
@@ -778,11 +792,10 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
     else {
         RootlessStartDrawing(pWin);
 
-        miCopyRegion((DrawablePtr) pWin, (DrawablePtr) pWin,
+        miCopyRegion(pDrawable, pDrawable,
                      0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
 
-        /* prgnSrc has been translated to dst position */
-        RootlessDamageRegion(pWin, prgnSrc);
+        RootlessDamageRegion(pWin, &rgnDst);
     }
 
  out:
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 46fd9a1fd..200ded348 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -137,7 +137,7 @@ present_check_flip(RRCrtcPtr            crtc,
 
     /* Does the window match the pixmap exactly? */
     if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
         window->drawable.x != pixmap->screen_x || window->drawable.y != pixmap->screen_y ||
 #endif
         window->drawable.width != pixmap->drawable.width ||
commit 3ed92593a14e40219f4dcffd61e859bf1e25e10f
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Wed Dec 14 23:46:42 2022 -0800

    XQuartz debugging
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 7ea888380aca2e681a4abc6f3266bf30dc7c1ea1)

diff --git a/fb/fbpict.c b/fb/fbpict.c
index 9797447b4..2b50d88be 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -290,6 +290,13 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
     fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
     fbGetPixmapBitsData(pixmap, bits, stride, bpp);
 
+    ErrorF("=== create_bits_picture ===\n");
+    xorg_backtrace();
+
+    ErrorF("    fbGetDrawable: pDrawable %p (%d,%d %dx%d): bits base: %p stride: %u bpp: %d xoff: %d yoff: %d\n",
+           pict->pDrawable, pict->pDrawable->x, pict->pDrawable->y, pict->pDrawable->width, pict->pDrawable->height,
+           bits, stride, bpp, *xoff, *yoff);
+
     image = pixman_image_create_bits((pixman_format_code_t) pict->format,
                                      pixmap->drawable.width,
                                      pixmap->drawable.height, (uint32_t *) bits,
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 4ab807ab5..e698f5288 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -26,6 +26,8 @@
 
 #include "fb.h"
 
+extern unsigned long RootlessWID(WindowPtr pWindow);
+
 Bool
 fbCloseScreen(ScreenPtr pScreen)
 {
@@ -87,6 +89,12 @@ _fbGetWindowPixmap(WindowPtr pWindow)
 void
 _fbSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap)
 {
+    ErrorF("_fbSetWindowPixmap: window=%p (%lu) pixmap=%p bits=%p (%d,%d %dx%d %d)\n",
+           pWindow, RootlessWID(pWindow), pPixmap, pPixmap->devPrivate.ptr,
+           pPixmap->drawable.x, pPixmap->drawable.y, pPixmap->drawable.width,
+           pPixmap->drawable.height, pPixmap->drawable.bitsPerPixel);
+
+    xorg_backtrace();
     dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(pWindow), pPixmap);
 }
 
diff --git a/hw/xquartz/bundle/X11.sh b/hw/xquartz/bundle/X11.sh
index 3b8b6799c..3b314a159 100755
--- a/hw/xquartz/bundle/X11.sh
+++ b/hw/xquartz/bundle/X11.sh
@@ -2,10 +2,23 @@
 
 set "$(dirname "$0")"/X11.bin "${@}"
 
+if [ ! -f "${HOME}/Library/Preferences/org.xquartz.X11.plist" ] ; then
+    # Try migrating preferences
+    if [ -f "${HOME}/Library/Preferences/org.macosforge.xquartz.X11.plist" ] ; then
+        cp "${HOME}/Library/Preferences/org.macosforge.xquartz.X11.plist" "${HOME}/Library/Preferences/org.xquartz.X11.plist"
+    elif [ -f "${HOME}/Library/Preferences/org.x.X11.plist" ] ; then
+        cp "${HOME}/Library/Preferences/org.x.X11.plist" "${HOME}/Library/Preferences/org.xquartz.X11.plist"
+    elif [ -f "${HOME}/Library/Preferences/com.apple.X11.plist" ] ; then
+        cp "${HOME}/Library/Preferences/com.apple.X11.plist" "${HOME}/Library/Preferences/org.xquartz.X11.plist"
+    fi
+fi
+
 if [ -x ~/.x11run ]; then
 	exec ~/.x11run "${@}"
 fi
 
+export DYLD_LIBRARY_PATH=/tmp/Xplugin.dst/usr/lib
+
 case $(basename "${SHELL}") in
 	bash)          exec -l "${SHELL}" --login -c 'exec "${@}"' - "${@}" ;;
 	ksh|sh|zsh)    exec -l "${SHELL}" -c 'exec "${@}"' - "${@}" ;;
diff --git a/hw/xquartz/xpr/xprAppleWM.c b/hw/xquartz/xpr/xprAppleWM.c
index 126661766..cdcf465f9 100644
--- a/hw/xquartz/xpr/xprAppleWM.c
+++ b/hw/xquartz/xpr/xprAppleWM.c
@@ -129,6 +129,9 @@ xprFrameDraw(WindowPtr pWin,
     if (wid == 0)
         return BadWindow;
 
+     ErrorF("=== xp_frame_draw %d ===\n", (int)x_cvt_vptr_to_uint(wid));
+     xorg_backtrace();
+
     if (xp_frame_draw(wid, class, attr, outer, inner,
                       title_len, title_bytes) != Success) {
         return BadValue;
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 57d16d42f..300604766 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -45,6 +45,8 @@
 
 #include <dispatch/dispatch.h>
 
+#define DEBUG_XP_LOCK_WINDOW 1
+
 #define DEFINE_ATOM_HELPER(func, atom_name)                      \
     static Atom func(void) {                                       \
         static int generation;                                      \
@@ -353,15 +355,20 @@ xprStartDrawing(RootlessFrameID wid, char **pixelData, int *bytesPerRow)
     xorg_backtrace();
 #endif
 
-    err = xp_lock_window(x_cvt_vptr_to_uint(
-                             wid), NULL, NULL, data, rowbytes, NULL);
+    xp_box out_box;
+    err = xp_lock_window(x_cvt_vptr_to_uint(wid), NULL, NULL, data, rowbytes, &out_box);
     if (err != Success)
         FatalError("Could not lock window %d for drawing (%d).",
-                   (int)x_cvt_vptr_to_uint(
-                       wid), (int)err);
+                   (int)x_cvt_vptr_to_uint(wid), (int)err);
 
 #ifdef DEBUG_XP_LOCK_WINDOW
-    ErrorF("  bits: %p\n", *data);
+    ErrorF("  bits: %p box: (%d,%d %d,%d) rowbytes: %u\n", *data, (int)out_box.x1, (int)out_box.y1, (int)out_box.x2, (int)out_box.y2, *rowbytes);
+    char *bytes = *data;
+    ErrorF("  bytes[0] = %d\n", bytes[0]);
+
+    int size = (out_box.y2 - out_box.y1) * (*rowbytes);
+    ErrorF("  size = %d\n", size);
+    ErrorF("  bytes[%d] = %d\n", size-1, bytes[size-1]);
 #endif
 
     *pixelData = data[0];
diff --git a/include/meson.build b/include/meson.build
index 6c1c1dcd4..49d4e8bc2 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -33,6 +33,9 @@ cc.compiles('''
     #ifndef CLOCK_MONOTONIC
     #error CLOCK_MONOTONIC not defined
     #endif
+    #ifdef __x86_64__
+    #error "x86_64 needs to support 10.9+, so disabling"
+    #endif
 ''',
     name: 'CLOCK_MONOTONIC') ? '1' : false)
 
@@ -150,7 +153,14 @@ conf_data.set('HAVE_GETPEERUCRED', cc.has_function('getpeerucred') ? '1' : false
 conf_data.set('HAVE_GETPROGNAME', cc.has_function('getprogname') ? '1' : false)
 conf_data.set('HAVE_GETZONEID', cc.has_function('getzoneid') ? '1' : false)
 conf_data.set('HAVE_MEMFD_CREATE', cc.has_function('memfd_create') ? '1' : false)
-conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp') ? '1' : false)
+#conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp') ? '1' : false)
+conf_data.set('HAVE_MKOSTEMP', cc.has_function('mkostemp') and
+cc.compiles('''
+    #ifdef __x86_64__
+    #error "x86_64 needs to support 10.9+, so disabling"
+    #endif
+''',
+    name: 'HAVE_MKOSTEMP') ? '1' : false)
 conf_data.set('HAVE_MMAP', cc.has_function('mmap') ? '1' : false)
 conf_data.set('HAVE_OPEN_DEVICE', cc.has_function('open_device') ? '1' : false)
 conf_data.set('HAVE_POLL', cc.has_function('poll') ? '1' : false)
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index f3ae4ebbc..f3fee2eee 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -41,6 +41,8 @@
 #include    "damage.h"
 #include    "damagestr.h"
 
+extern unsigned long RootlessWID(WindowPtr pWindow);
+
 #define wrap(priv, real, mem, func) {\
     priv->mem = real->mem; \
     real->mem = func; \
@@ -1550,10 +1552,20 @@ damageSetWindowPixmap(WindowPtr pWindow, PixmapPtr pPixmap)
     DamagePtr pDamage;
     ScreenPtr pScreen = pWindow->drawable.pScreen;
 
+    ErrorF("damageSetWindowPixmap(%p %lu, %p %p) (%d,%d %dx%d %d)\n",
+           pWindow, RootlessWID(pWindow), pPixmap, pPixmap->devPrivate.ptr,
+           pPixmap->drawable.x, pPixmap->drawable.y, pPixmap->drawable.width,
+           pPixmap->drawable.height, pPixmap->drawable.bitsPerPixel);
+
     damageScrPriv(pScreen);
 
     if ((pDamage = damageGetWinPriv(pWindow))) {
         PixmapPtr pOldPixmap = (*pScreen->GetWindowPixmap) (pWindow);
+
+        ErrorF("pOldPixmap: %p %p (%d,%d %dx%d %d)\n", pOldPixmap, pOldPixmap->devPrivate.ptr,
+               pOldPixmap->drawable.x, pOldPixmap->drawable.y, pOldPixmap->drawable.width,
+               pOldPixmap->drawable.height, pOldPixmap->drawable.bitsPerPixel);
+
         DamagePtr *pPrev = getPixmapDamageRef(pOldPixmap);
 
         while (pDamage) {
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 44c2c3789..5c3b94e86 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -188,22 +188,33 @@ RootlessStartDrawing(WindowPtr pWindow)
                                    top->drawable.bitsPerPixel,
                                    winRec->bytesPerRow, winRec->pixelData);
 
-        RL_DEBUG_MSG("GetScratchPixmapHeader gave us %p %p (%d,%d %dx%d %d) for wid=%lu\n",
-                     winRec->pixmap, winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x,
-                     winRec->pixmap->drawable.y, winRec->pixmap->drawable.width, winRec->pixmap->drawable.height,
-                     winRec->pixmap->drawable.bitsPerPixel, RootlessWID(pWindow));
+//        RL_DEBUG_MSG("GetScratchPixmapHeader gave us pixmap=%p bits=%p (drawable: %d,%d @ %d,%d %dx%d %d bpp) for window=%p (%d,%d %dx%d) wid=%lu (winrec: %dx%d))\n",
+//                     winRec->pixmap, winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x,
+//                     winRec->pixmap->drawable.y, winRec->pixmap->drawable.screen_x, winRec->pixmap->drawable.screen_y,
+//                     winRec->pixmap->drawable.width, winRec->pixmap->drawable.height, winRec->pixmap->drawable.bitsPerPixel,
+//                     pWindow->drawable.x, pWindow->drawable.y, pWindow->drawable.width, pWindow->drawable.height,
+//                     RootlessWID(pWindow), winRec->width, winRec->height);
 
         SetPixmapBaseToScreen(winRec->pixmap,
                               top->drawable.x - bw, top->drawable.y - bw);
 
-        RL_DEBUG_MSG("After SetPixmapBaseToScreen(%d %d %d): %p (%d,%d %dx%d %d) for wid=%lu\n",
-                     top->drawable.x, top->drawable.y, bw, winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x,
-                     winRec->pixmap->drawable.y, winRec->pixmap->drawable.width, winRec->pixmap->drawable.height,
-                     winRec->pixmap->drawable.bitsPerPixel, RootlessWID(pWindow));
+        RL_DEBUG_MSG("After GetScratchPixmapHeader + SetPixmapBaseToScreen(x:%d y:%d bw: %d): pixmap=%p (@ %d,%d) bits=%p (drawable: %d,%d %dx%d %d bpp) for window=%p (drawable: %d,%d %dx%d) wid=%lu (winrec: %dx%d))\n",
+                     top->drawable.x, top->drawable.y, bw,
+                     winRec->pixmap, winRec->pixmap->screen_x, winRec->pixmap->screen_y,
+                     winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x, winRec->pixmap->drawable.y,
+                     winRec->pixmap->drawable.width, winRec->pixmap->drawable.height, winRec->pixmap->drawable.bitsPerPixel,
+                     pWindow, pWindow->drawable.x, pWindow->drawable.y, pWindow->drawable.width, pWindow->drawable.height,
+                     RootlessWID(pWindow), winRec->width, winRec->height);
 
         winRec->is_drawing = TRUE;
     } else {
-        RL_DEBUG_MSG("Skipped call to xprStartDrawing (wid: %lu) because winRec->is_drawing says we already did.\n", RootlessWID(pWindow));
+        RL_DEBUG_MSG("Skipped call to xprStartDrawing (wid: %lu) because winRec->is_drawing says we already did. pixmap=%p (@ %d,%d) bits=%p (drawable: %d,%d %dx%d %d bpp) for window=%p (%d,%d %dx%d) wid=%lu (winrec: %dx%d))\n",
+                     RootlessWID(pWindow),
+                     winRec->pixmap, winRec->pixmap->screen_x, winRec->pixmap->screen_y,
+                     winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x, winRec->pixmap->drawable.y,
+                     winRec->pixmap->drawable.width, winRec->pixmap->drawable.height, winRec->pixmap->drawable.bitsPerPixel,
+                     pWindow, pWindow->drawable.x, pWindow->drawable.y, pWindow->drawable.width, pWindow->drawable.height,
+                     RootlessWID(pWindow), winRec->width, winRec->height);
     }
 
     curPixmap = pScreen->GetWindowPixmap(pWindow);
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 6f2bfe4bd..31af6b071 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -38,7 +38,7 @@
 // #define ROOTLESS_RESIZE_GRAVITY TRUE
 #endif
 
-/*# define ROOTLESSDEBUG*/
+# define ROOTLESSDEBUG
 
 #define ROOTLESS_PROTECT_ALPHA TRUE
 #define ROOTLESS_REDISPLAY_DELAY 10
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 5cecfdff5..a1733d213 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -885,9 +885,8 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
     rect.x2 = min(oldX2, newX2);
     rect.y2 = min(oldY2, newY2);
 
-    RL_DEBUG_MSG("RESIZE TOPLEVEL WINDOW with gravity %i ", gravity);
-    RL_DEBUG_MSG("%d %d %d %d %d   %d %d %d %d %d\n",
-                 oldX, oldY, oldW, oldH, oldBW, newX, newY, newW, newH, newBW);
+    RL_DEBUG_MSG("RESIZE TOPLEVEL WINDOW with gravity %i %d,%d %dx%d bw:%d -> %d,%d %dx%d bw:%d\n",
+                 gravity, oldX, oldY, oldW, oldH, oldBW, newX, newY, newW, newH, newBW);
 
     RootlessRedisplay(pWin);
 
@@ -972,6 +971,9 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
             copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
             gResizeDeathBits = xallocarray(copy_rowbytes, copy_rect_height);
 
+            RL_DEBUG_MSG("Created gResizeDeathBits %p (size= h:%d * rowbytes:%d = %d) and going down an unfixed path...\n", gResizeDeathBits,
+                          copy_rect_height, copy_rowbytes, copy_rect_height * copy_rowbytes);
+
             if (copy_rect_width * copy_rect_height >
                 rootless_CopyBytes_threshold &&
                 SCREENREC(pScreen)->imp->CopyBytes) {
@@ -1011,6 +1013,13 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
             SetPixmapBaseToScreen(gResizeDeathPix[1],
                                   copy_rect.x1, copy_rect.y1);
 
+            RL_DEBUG_MSG("After GetScratchPixmapHeader + SetPixmapBaseToScreen(x:%d y:%d): pixmap=%p (@ %d,%d) bits=%p (drawable: %d,%d %dx%d %d bpp) for (winrec: %dx%d))\n",
+                         copy_rect.x1, copy_rect.y1,
+                         winRec->pixmap, winRec->pixmap->screen_x, winRec->pixmap->screen_y,
+                         winRec->pixmap->devPrivate.ptr, winRec->pixmap->drawable.x, winRec->pixmap->drawable.y,
+                         winRec->pixmap->drawable.width, winRec->pixmap->drawable.height, winRec->pixmap->drawable.bitsPerPixel,
+                         winRec->width, winRec->height);
+
             gResizeDeathCount = 2;
         }
     }
@@ -1021,6 +1030,9 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
 
         gResizeDeathBits = xallocarray(winRec->bytesPerRow, winRec->height);
 
+        RL_DEBUG_MSG("Created gResizeDeathBits %p (size= h:%d * rowbytes:%d = %d)\n", gResizeDeathBits,
+                     winRec->height, winRec->bytesPerRow, winRec->bytesPerRow * winRec->height);
+
         memcpy(gResizeDeathBits, winRec->pixelData,
                winRec->bytesPerRow * winRec->height);
 
@@ -1035,6 +1047,14 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
                                      (void *) gResizeDeathBits);
 
         SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
+
+        RL_DEBUG_MSG("After GetScratchPixmapHeader + SetPixmapBaseToScreen(x:%d y:%d): pixmap=%p (@ %d,%d) bits=%p (drawable: %d,%d %dx%d %d bpp) for (winrec: %dx%d))\n",
+                     oldX, oldY,
+                     gResizeDeathPix[0], gResizeDeathPix[0]->screen_x, gResizeDeathPix[0]->screen_y,
+                     gResizeDeathPix[0]->devPrivate.ptr, gResizeDeathPix[0]->drawable.x, gResizeDeathPix[0]->drawable.y,
+                     gResizeDeathPix[0]->drawable.width, gResizeDeathPix[0]->drawable.height, gResizeDeathPix[0]->drawable.bitsPerPixel,
+                     winRec->width, winRec->height);
+
         gResizeDeathCount = 1;
     }
 
@@ -1071,6 +1091,13 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
                                      winRec->bytesPerRow, winRec->pixelData);
 
         SetPixmapBaseToScreen(gResizeDeathPix[0], oldX, oldY);
+
+        RL_DEBUG_MSG("Stored gResizeDeathPix[0] after GetScratchPixmapHeader + SetPixmapBaseToScreen(x:%d y:%d): gResizeDeathPix[0]=%p (@ %d,%d) bits=%p (drawable: %d,%d %dx%d %d bpp) for (winrec: %dx%d))\n",
+                     oldX, oldY,
+                     gResizeDeathPix[0], gResizeDeathPix[0]->screen_x, gResizeDeathPix[0]->screen_y,
+                     gResizeDeathPix[0]->devPrivate.ptr, gResizeDeathPix[0]->drawable.x, gResizeDeathPix[0]->drawable.y,
+                     gResizeDeathPix[0]->drawable.width, gResizeDeathPix[0]->drawable.height, gResizeDeathPix[0]->drawable.bitsPerPixel,
+                     winRec->width, winRec->height);
     }
 
     /* Use custom CopyWindow when moving gravity bits around
commit f314a1fa9411f83f74af697370ce618d280e4a4a
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Jan 1 23:15:00 2023 -0800

    HAX: Disable gravity in RootlessResizeWindow because it's not working right now...

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index fe09c7fe5..5cecfdff5 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1284,7 +1284,7 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
             newW = w + 2 * newBW;
             newH = h + 2 * newBW;
 
-            resize_after = StartFrameResize(pWin, TRUE,
+            resize_after = StartFrameResize(pWin, FALSE,
                                             oldX, oldY, oldW, oldH, oldBW,
                                             newX, newY, newW, newH, newBW);
         }
@@ -1296,7 +1296,7 @@ RootlessResizeWindow(WindowPtr pWin, int x, int y,
         NORMAL_ROOT(pWin);
 
         if (winRec) {
-            FinishFrameResize(pWin, TRUE, oldX, oldY, oldW, oldH, oldBW,
+            FinishFrameResize(pWin, FALSE, oldX, oldY, oldW, oldH, oldBW,
                               newX, newY, newW, newH, newBW, resize_after);
         }
     }
commit b1abd4e2da9a566e0948bb5e2edb592e97c8ac61
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Jan 1 23:18:13 2023 -0800

    HAX: Disable ROOTLESS_RESIZE_GRAVITY for now
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 4c464b9f5..6f2bfe4bd 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -35,7 +35,7 @@
 #define _ROOTLESSCONFIG_H
 
 #ifdef __APPLE__
-#define ROOTLESS_RESIZE_GRAVITY TRUE
+// #define ROOTLESS_RESIZE_GRAVITY TRUE
 #endif
 
 /*# define ROOTLESSDEBUG*/
commit 2d4f726885f205fe2f7f1f8c3b673d2997639f39
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Tue Jun 14 11:03:31 2022 -0700

    Revert "os/WaitFor: Check timers on every iteration"
    
    Workaround a performance issue that this introduces in XQuartz
    
    Fixes: https://github.com/XQuartz/XQuartz/issues/166
    This reverts commit ac7a4bf44c68c5f323375974b208d4530fb5b60f.
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/os/WaitFor.c b/os/WaitFor.c
index ff1d376e9..8f93845e0 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -192,11 +192,12 @@ WaitForSomething(Bool are_ready)
             ProcessWorkQueue();
         }
 
-        timeout = check_timers();
         are_ready = clients_are_ready();
 
         if (are_ready)
             timeout = 0;
+        else
+            timeout = check_timers();
 
         BlockHandler(&timeout);
         if (NewOutputPending)
commit 1572e05ff0e381bed50b59b87edf17e3a9ec5587
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 11 02:19:19 2016 -0700

    randr: Initialize RandR even if there are currently no screens attached
    
    Failure to do so causes an overvlow in RRClientCallback().
    
    =================================================================
    ==41262==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000103ccfbc8 at pc 0x0001034f32b9 bp 0x7000035a94c0 sp 0x7000035a94b8
    WRITE of size 4 at 0x000103ccfbc8 thread T6
        #0 0x1034f32b8 in RRClientCallback randr.c:72
        #1 0x1038c75e3 in _CallCallbacks dixutils.c:737
        #2 0x10388f406 in CallCallbacks callback.h:83
        #3 0x1038bc49a in NextAvailableClient dispatch.c:3562
        #4 0x103ad094c in AllocNewConnection connection.c:777
        #5 0x103ad1695 in EstablishNewConnections connection.c:863
        #6 0x1038c6630 in ProcessWorkQueue dixutils.c:523
        #7 0x103ab2dbf in WaitForSomething WaitFor.c:175
        #8 0x103880836 in Dispatch dispatch.c:411
        #9 0x1038c2141 in dix_main main.c:301
        #10 0x1032ac75a in server_thread quartzStartup.c:66
        #11 0x7fffc5f16aaa in _pthread_body (libsystem_pthread.dylib+0x3aaa)
        #12 0x7fffc5f169f6 in _pthread_start (libsystem_pthread.dylib+0x39f6)
        #13 0x7fffc5f161fc in thread_start (libsystem_pthread.dylib+0x31fc)
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit f9235000d67a61b0de951598146b4b5e0032384e)

diff --git a/randr/randr.c b/randr/randr.c
index 6d02c2577..a8e4d1514 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -414,9 +414,6 @@ RRExtensionInit(void)
 {
     ExtensionEntry *extEntry;
 
-    if (RRNScreens == 0)
-        return;
-
     if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT,
                                sizeof(RRClientRec) +
                                screenInfo.numScreens * sizeof(RRTimesRec)))
commit 88e111f033ceb65ba4ecbd30f7a033384569e73b
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Sep 11 02:47:00 2016 -0700

    glx: Initialize glx even if there are currently no screens attached
    
    Failure to do so causes an overvlow in glxClientCallback
    
    Application Specific Information:
    X.Org X Server 1.18.99.1 Build Date: 20160911
    =================================================================
    ==52118==ERROR: AddressSanitizer: SEGV on unknown address 0x000102b27b80 (pc 0x000103433245 bp 0x70000de67c20 sp 0x70000de67c00 T6)
        #0 0x103433244 in __asan::asan_free(void*, __sanitizer::BufferedStackTrace*, __asan::AllocType) (libclang_rt.asan_osx_dynamic.dylib+0x3244)
        #1 0x10347aeee in wrap_free (libclang_rt.asan_osx_dynamic.dylib+0x4aeee)
        #2 0x102e6a5ed in glxClientCallback glxext.c:301
        #3 0x102b672a3 in _CallCallbacks dixutils.c:737
        #4 0x102b2f0c6 in CallCallbacks callback.h:83
        #5 0x102b5c15a in NextAvailableClient dispatch.c:3562
        #6 0x102d7060c in AllocNewConnection connection.c:777
        #7 0x102d71355 in EstablishNewConnections connection.c:863
        #8 0x102b662f0 in ProcessWorkQueue dixutils.c:523
        #9 0x102d52a7f in WaitForSomething WaitFor.c:175
        #10 0x102b204f6 in Dispatch dispatch.c:411
        #11 0x102b61e01 in dix_main main.c:301
        #12 0x10254c42a in server_thread quartzStartup.c:66
        #13 0x7fffc5f16aaa in _pthread_body (libsystem_pthread.dylib+0x3aaa)
        #14 0x7fffc5f169f6 in _pthread_start (libsystem_pthread.dylib+0x39f6)
        #15 0x7fffc5f161fc in thread_start (libsystem_pthread.dylib+0x31fc)
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
    (cherry picked from commit 1d2293101fca46c9a68c553f1be8e815c40de69a)

diff --git a/glx/glxext.c b/glx/glxext.c
index 99f866104..9a0493388 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -281,24 +281,6 @@ GlxPushProvider(__GLXprovider * provider)
     __glXProviderStack = provider;
 }
 
-static Bool
-checkScreenVisuals(void)
-{
-    int i, j;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-        ScreenPtr screen = screenInfo.screens[i];
-        for (j = 0; j < screen->numVisuals; j++) {
-            if ((screen->visuals[j].class == TrueColor ||
-                 screen->visuals[j].class == DirectColor) &&
-                screen->visuals[j].nplanes > 12)
-                return TRUE;
-        }
-    }
-
-    return FALSE;
-}
-
 static void
 GetGLXDrawableBytes(void *value, XID id, ResourceSizePtr size)
 {
@@ -472,10 +454,6 @@ static Bool
 xorgGlxServerPreInit(const ExtensionEntry *extEntry)
 {
     if (glxGeneration != serverGeneration) {
-        /* Mesa requires at least one True/DirectColor visual */
-        if (!checkScreenVisuals())
-            return FALSE;
-
         __glXContextRes = CreateNewResourceType((DeleteType) ContextGone,
                                                 "GLXContext");
         __glXDrawableRes = CreateNewResourceType((DeleteType) DrawableGone,
commit 89bad0227b4f9502f6f7013a68dedb58cc2d925f
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Thu Dec 22 08:37:10 2022 -0800

    Set thread priorities to user interactive or user initiated as appropriate
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index dd96e89f7..752ddc3f6 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -735,6 +735,9 @@ create_thread(void *(*func)(void *), void *arg)
     pthread_attr_init(&attr);
     pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    if (&pthread_attr_set_qos_class_np) {
+        pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INITIATED, 0);
+    }
     pthread_create(&tid, &attr, func, arg);
     pthread_attr_destroy(&attr);
 
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index fd87e968b..15c1bc5d8 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -129,6 +129,9 @@ create_thread(void *(*func)(void *), void *arg)
     pthread_attr_init(&attr);
     pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    if (&pthread_attr_set_qos_class_np) {
+        pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INITIATED, 0);
+    }
     pthread_create(&tid, &attr, func, arg);
     pthread_attr_destroy(&attr);
 
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 732eba983..9137edb66 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -74,6 +74,9 @@ create_thread(void *func, void *arg)
     pthread_attr_init(&attr);
     pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    if (&pthread_attr_set_qos_class_np) {
+        pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE, 0);
+    }
     pthread_create(&tid, &attr, func, arg);
     pthread_attr_destroy(&attr);
 
diff --git a/os/inputthread.c b/os/inputthread.c
index 3469cfc1c..bd0a8335f 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -479,6 +479,12 @@ InputThreadInit(void)
     if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) != 0)
         ErrorF("input-thread: error setting thread scope\n");
 
+#ifdef __APPLE__
+    if (&pthread_attr_set_qos_class_np) {
+        pthread_attr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE, 0);
+    }
+#endif
+
     DebugF("input-thread: creating thread\n");
     pthread_create(&inputThreadInfo->thread, &attr,
                    &InputThreadDoWork, NULL);
commit 3c4b6d118ae11406de6689ed6dd3b7c62960ea51
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Nov 27 22:25:49 2022 -0800

    Revert "meson: Don't build COMPOSITE for XQuartz"
    
    This will allow us to remove build-time conditionalization on COMPOSITE
    while still allowing XQuartz to disable it and use ROOTLESS.
    
    This reverts commit 9c0373366988cc0b909ba31e61c43cc46e054b40.

diff --git a/include/meson.build b/include/meson.build
index 1ca0e76cf..6c1c1dcd4 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -199,9 +199,7 @@ conf_data.set('UNIXCONN', host_machine.system() != 'windows' ? '1' : false)
 conf_data.set('IPv6', build_ipv6 ? '1' : false)
 
 conf_data.set('BIGREQS', '1')
-if build_composite
-    conf_data.set('COMPOSITE', '1')
-endif
+conf_data.set('COMPOSITE', '1')
 conf_data.set('DAMAGE', '1')
 conf_data.set('DBE', '1')
 conf_data.set('DGA', build_dga ? '1' : false)
diff --git a/meson.build b/meson.build
index dc77b85a3..fd85ad86a 100644
--- a/meson.build
+++ b/meson.build
@@ -276,10 +276,8 @@ else
     build_xquartz = get_option('xquartz') == 'true'
 endif
 
-build_composite = true
 build_rootless = false
 if build_xquartz
-    build_composite = false
     build_rootless = true
 endif
 
@@ -770,9 +768,7 @@ subdir('fb')
 subdir('mi')
 subdir('os')
 # X extensions
-if build_composite
-    subdir('composite')
-endif
+subdir('composite')
 subdir('damageext')
 subdir('dbe')
 subdir('miext/damage')
@@ -806,6 +802,7 @@ libxserver = [
     libxserver_mi,
     libxserver_dix,
 
+    libxserver_composite,
     libxserver_damageext,
     libxserver_dbe,
     libxserver_randr,
@@ -822,10 +819,6 @@ libxserver = [
     libxserver_os,
 ]
 
-if build_composite
-    libxserver += libxserver_composite
-endif
-
 libxserver += libxserver_dri3
 
 subdir('hw')
commit 261cfd22ff687f2e4b3291351477a67563679ef3
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sun Nov 27 22:23:43 2022 -0800

    xquartz: Disable COMPOSITE at runtime
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 353e1d2bc..de82e2280 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -72,6 +72,10 @@ FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN;
 
 extern int noPanoramiXExtension;
 
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
+
 #define DEFAULT_CLIENT X11BINDIR "/xterm"
 #define DEFAULT_STARTX X11BINDIR "/startx -- " X11BINDIR "/Xquartz"
 #define DEFAULT_SHELL  "/bin/sh"
@@ -635,6 +639,11 @@ main(int argc, char **argv, char **envp)
     /* The server must not run the PanoramiX operations. */
     noPanoramiXExtension = TRUE;
 
+#ifdef COMPOSITE
+    /* https://gitlab.freedesktop.org/xorg/xserver/-/issues/1409 */
+    noCompositeExtension = TRUE;
+#endif
+
     /* Setup the initial crasherporter info */
     strlcpy(__crashreporter_info_buff__, __crashreporter_info__base,
             sizeof(__crashreporter_info_buff__));


More information about the xorg-commit mailing list