Author: branden
Date: 2003-10-15 14:01:06 -0500 (Wed, 15 Oct 2003)
New Revision: 73

Modified:
   trunk/Xrender.c
   trunk/debian/changelog
Log:
Steal patch from upstream CVS that works around breakage in the Xinerama
implementation in the XFree86 X server, which only reports depths with an
associated visual, when it should return all available depths.  Thanks to
Marc Wilson for help tracking down the problem and the solution.
(Closes: #215845)

- Xrender.c


Modified: trunk/Xrender.c
===================================================================
--- trunk/Xrender.c     2003-10-15 08:26:04 UTC (rev 72)
+++ trunk/Xrender.c     2003-10-15 19:01:06 UTC (rev 73)
@@ -1,5 +1,5 @@
 /*
- * $Id: Xrender.c,v 1.17 2003/06/08 17:56:37 keithp Exp $
+ * $Id: Xrender.c,v 1.18 2003/06/23 21:12:08 keithp Exp $
  *
  * Copyright © 2000 SuSE, Inc.
  *
@@ -80,6 +80,33 @@
                         DEPTH_MASK(24) | \
                         DEPTH_MASK(32))
     
+typedef struct _DepthCheckRec {
+    struct _DepthCheckRec *next;
+    Display *dpy;
+    CARD32  missing;
+    unsigned long serial;
+} DepthCheckRec, *DepthCheckPtr;
+
+static DepthCheckPtr   depthChecks;
+
+static int
+XRenderDepthCheckErrorHandler (Display *dpy, XErrorEvent *evt)
+{
+    if (evt->request_code == X_CreatePixmap && evt->error_code == BadValue)
+    {
+       DepthCheckPtr   d;
+       _XLockMutex(_Xglobal_lock);
+       for (d = depthChecks; d; d = d->next)
+           if (d->dpy == dpy)
+           {
+               if ((long) (evt->serial - d->serial) >= 0)
+                   d->missing |= DEPTH_MASK(evt->resourceid);
+               break;
+           }
+       _XUnlockMutex (_Xglobal_lock);
+    }
+}
+
 static Bool
 XRenderHasDepths (Display *dpy)
 {
@@ -88,13 +115,66 @@
     for (s = 0; s < ScreenCount (dpy); s++)
     {
        CARD32              depths = 0;
+       CARD32              missing;
        Screen              *scr = ScreenOfDisplay (dpy, s);
        int                 d;
 
        for (d = 0; d < scr->ndepths; d++)
            depths |= DEPTH_MASK(scr->depths[d].depth);
-       if (~depths & REQUIRED_DEPTHS)
-           return False;
+       missing = ~depths & REQUIRED_DEPTHS;
+       if (missing)
+       {
+           DepthCheckRec   dc, **dp;
+           XErrorHandler   previousHandler;
+
+           /*
+            * Ok, this is ugly.  It should be sufficient at this
+            * point to just return False, but Xinerama is broken at
+            * this point and only advertises depths which have an
+            * associated visual.  Of course, the other depths still
+            * work, but the only way to find out is to try them.
+            */
+           dc.dpy = dpy;
+           dc.missing = 0;
+           dc.serial = XNextRequest (dpy);
+           _XLockMutex(_Xglobal_lock);
+           dc.next = depthChecks;
+           depthChecks = &dc;
+           _XUnlockMutex (_Xglobal_lock);
+           /*
+            * I suspect this is not really thread safe, but Xlib doesn't
+            * provide a lot of options here
+            */
+           previousHandler = XSetErrorHandler (XRenderDepthCheckErrorHandler);
+           /*
+            * Try each missing depth and see if pixmap creation succeeds
+            */
+           for (d = 1; d <= 32; d++)
+               /* don't check depth 1 == Xcursor recurses... */
+               if ((missing & DEPTH_MASK(d)) && d != 1)
+               {
+                   Pixmap  p;
+                   p = XCreatePixmap (dpy, RootWindow (dpy, s), 1, 1, d);
+                   XFreePixmap (dpy, p);
+               }
+           XSync (dpy, False);
+           XSetErrorHandler (previousHandler);
+           /*
+            * Unhook from the list of depth check records
+            */
+           _XLockMutex(_Xglobal_lock);
+           for (dp = &depthChecks; *dp; dp = &(*dp)->next)
+           {
+               if (*dp == &dc)
+               {
+                   *dp = dc.next;
+                   break;
+               }
+           }
+           _XUnlockMutex (_Xglobal_lock);
+           if (dc.missing)
+               return False;
+       }
     }
     return True;
 }

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2003-10-15 08:26:04 UTC (rev 72)
+++ trunk/debian/changelog      2003-10-15 19:01:06 UTC (rev 73)
@@ -34,8 +34,15 @@
     include myself.
     - debian/control
 
- -- Branden Robinson <[EMAIL PROTECTED]>  Wed, 15 Oct 2003 03:25:23 -0500
+  * Steal patch from upstream CVS that works around breakage in the Xinerama
+    implementation in the XFree86 X server, which only reports depths with an
+    associated visual, when it should return all available depths.  Thanks to
+    Marc Wilson for help tracking down the problem and the solution.
+    (Closes: #215845)
+    - Xrender.c
 
+ -- Branden Robinson <[EMAIL PROTECTED]>  Wed, 15 Oct 2003 13:56:07 -0500
+
 xrender (0.8.3-2) unstable; urgency=medium
 
   * Urgency medium because the problem fixed by this release bites a lot of


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to