[Xquartz-changes] xserver: Branch 'PR-290-1.9' - 30 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Thu Apr 22 11:08:32 PDT 2010


Rebased ref, commits from common ancestor:
commit ff61c466bb1aaa7f5b45e31f8d5e2482bbede573
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Apr 18 01:32:09 2010 -0700

    Fixes it, but not sure what the real fix is...
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 6776064..45a4b1e 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -524,6 +524,7 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
+#include "../fb/fb.h"
 #endif 
 
 void
@@ -551,6 +552,19 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
     if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
 	return;
 
@@ -608,6 +622,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 	    return;
 	pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
 	drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+	ErrorF("     Draw: %d %d %d %d\n",
+	       drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
 	draw_x_off = pixmap->screen_x;
 	draw_y_off = pixmap->screen_y;
@@ -670,6 +690,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     dixChangeGC (NullClient, pGC, gcmask, NULL, gcval);
     ValidateGC (drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = REGION_NUM_RECTS(prgn);
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
commit b32faeb3de189518c60c5252a5ef01e7842091fc
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Apr 21 08:40:57 2010 -0700

    mi: move ROOTLESS hunks
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 1a7cd0c..6776064 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -554,21 +554,19 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
 	return;
 
-#ifdef ROOTLESS
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
-#endif
-    
     if (what == PW_BACKGROUND)
     {
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	while (pWin->backgroundState == ParentRelative)
 	    pWin = pWin->parent;
 
@@ -590,6 +588,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     {
 	PixmapPtr   pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+	       pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	tile_x_off = drawable->x;
 	tile_y_off = drawable->y;
 	
commit b0aeb3b03acd634d3aa28cbee99a66eb8f9cf8dd
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Apr 21 08:38:53 2010 -0700

    mi: Add some sanity checking to miPaintWindow
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 1c9c3a4..1a7cd0c 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -551,6 +551,9 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
+    if(!drawable || drawable->type == UNDRAWABLE_WINDOW)
+	return;
+
 #ifdef ROOTLESS
     if(IsFramedWindow(pWin)) {
         RootlessStartDrawing(pWin);
commit 533336bd70c8f4e50b66018b5b92a6f6db3df81a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun Apr 18 01:22:27 2010 -0700

    rootless: Remove an unneeded comment
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index e78e2c8..55c7b96 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1553,10 +1553,6 @@ RootlessDisableRoot (ScreenPtr pScreen)
 	return;
            
     RootlessDestroyFrame (pRoot, winRec);
-    /* 
-     * gstaplin: I fixed the usage of this DeleteProperty so that it would compile.
-     * QUESTION: Where is this xa_native_window_id set?
-     */
     DeleteProperty (serverClient, pRoot, xa_native_window_id ());
 }
 
commit 6ee09419f9982723dace4e53ef1e97571fa4f1d7
Author: Oliver McFadden <oliver.mcfadden at nokia.com>
Date:   Thu Apr 22 10:29:44 2010 +0300

    x-list.c: null-returning function malloc() was called without checking
    
    Signed-off-by: Oliver McFadden <oliver.mcfadden at nokia.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/xpr/x-list.c b/hw/xquartz/xpr/x-list.c
index 3596dd3..77c9309 100644
--- a/hw/xquartz/xpr/x-list.c
+++ b/hw/xquartz/xpr/x-list.c
@@ -97,6 +97,7 @@ X_PFX (list_prepend) (x_list *lst, void *data)
         int i;
 
         b = malloc (sizeof (x_list_block));
+        assert(b != NULL);
 
         for (i = 0; i < NODES_PER_BLOCK - 1; i++)
             b->l[i].next = &(b->l[i+1]);
commit 35d208125fa0ec78e8d694adc52886b977e789cf
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Apr 21 18:28:13 2010 +0300

    xfree86: fix not reached code in fi1236 driver from i2c
    
    This issue was introduced in the first dump of the code in 2004. I haven't
    check what's the correct fix for it so I simply kept the behaviour of someone
    calling this and removed the unreachable code.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/i2c/fi1236.c b/hw/xfree86/i2c/fi1236.c
index 7c39edb..61224ea 100644
--- a/hw/xfree86/i2c/fi1236.c
+++ b/hw/xfree86/i2c/fi1236.c
@@ -398,10 +398,6 @@ int TUNER_get_afc_hint(FI1236Ptr f)
 {
 if(f->afc_timer_installed)return TUNER_STILL_TUNING;
 return f->last_afc_hint;
-if(f->type==TUNER_TYPE_MT2032)
-	return MT2032_get_afc_hint(f);
-	else
-	return FI1236_get_afc_hint(f);
 }
 
 static void MT2032_dump_status(FI1236Ptr f)
commit 7ac6a6b7d0dfc5e021270b2898accd3425aa008a
Merge: 0782894... f7ef6fd...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 21 16:07:38 2010 -0700

    Merge remote branch 'vignatti/for-keith'
    
    Conflicts:
    	exa/exa.c
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --cc exa/exa.c
index dcfa4b3,b2bd1c5..da37972
--- a/exa/exa.c
+++ b/exa/exa.c
@@@ -776,14 -778,14 +776,12 @@@ exaCloseScreen(int i, ScreenPtr pScreen
      unwrap(pExaScr, pScreen, ChangeWindowAttributes);
      unwrap(pExaScr, pScreen, BitmapToRegion);
      unwrap(pExaScr, pScreen, CreateScreenResources);
-     if (ps) {
- 	unwrap(pExaScr, ps, Composite);
- 	if (pExaScr->SavedGlyphs)
- 	    unwrap(pExaScr, ps, Glyphs);
- 	unwrap(pExaScr, ps, Trapezoids);
- 	unwrap(pExaScr, ps, Triangles);
- 	unwrap(pExaScr, ps, AddTraps);
-     }
 -#ifdef RENDER
+     unwrap(pExaScr, ps, Composite);
+     if (pExaScr->SavedGlyphs)
+ 	unwrap(pExaScr, ps, Glyphs);
+     unwrap(pExaScr, ps, Trapezoids);
+     unwrap(pExaScr, ps, Triangles);
+     unwrap(pExaScr, ps, AddTraps);
 -#endif
  
      xfree (pExaScr);
  
commit 0782894b5702adcf6f4a90861793b717f3856fa5
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 21 16:00:28 2010 -0700

    Xvfb: Usage message typo fix.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 0428f0a..60915fd 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -248,7 +248,7 @@ ddxUseMsg(void)
 {
     ErrorF("-screen scrn WxHxD     set screen's width, height, depth\n");
     ErrorF("-pixdepths list-of-int support given pixmap depths\n");
-    ErrorF("+/-render		   turn on/of RENDER extension support"
+    ErrorF("+/-render		   turn on/off RENDER extension support"
 	   "(default on)\n");
     ErrorF("-linebias n            adjust thin line pixelization\n");
     ErrorF("-blackpixel n          pixel value for black\n");
commit ee3412b8702072c3a0b006bd20dd3bc7071d721c
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Apr 21 15:58:23 2010 -0700

    Restore some unused win32 debug code accidentally removed with unifdef
    
    unifdef found some code covered by
    
    which it decided to remove. This patch simply restores that in case
    someone wants it back.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index ac30621..c225a44 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -894,6 +894,9 @@ winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
   SIZE szWin;
   POINT ptSrc;
 #endif
+#if CYGMULTIWINDOW_DEBUG && 0
+  winDebug ("winMWExtWMUpdateRegion (%08x)\n", pRLWinPriv);
+#endif
 #if 0
   szWin.cx = pRLWinPriv->dwWidth;
   szWin.cy = pRLWinPriv->dwHeight;
@@ -935,6 +938,10 @@ winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
 {
   win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
   const BoxRec *pEnd;
+#if CYGMULTIWINDOW_DEBUG && 0
+  winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
+	    pRLWinPriv, nCount, pRects, shift_x, shift_y);
+#endif
 
   for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
         RECT rcDmg;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index a985c20..4d7afee 100755
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -519,6 +519,9 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
       break;
 
     case WM_MOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+      winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
+#endif
       /* Unpack the client area mouse coordinates */
       ptMouse.x = GET_X_LPARAM(lParam);
       ptMouse.y = GET_Y_LPARAM(lParam);
@@ -573,6 +576,9 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
       return 0;
       
     case WM_NCMOUSEMOVE:
+#if CYGMULTIWINDOW_DEBUG && 0
+      winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
+#endif
       /*
        * We break instead of returning 0 since we need to call
        * DefWindowProc to get the mouse cursor changes
commit e3d2a7a613366c26e5316cf582d9a8c6c6692b0a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 21 11:47:24 2010 +1000

    Revert "mi: don't thrash resources when displaying the software cursor across screens"
    
    This commit leads to a segfault on the very first XTS test case.
    
    Backtrace:
    0: /opt/xorg/bin/Xorg (xorg_backtrace+0x3b) [0x80a33db]
    1: /opt/xorg/bin/Xorg (0x8048000+0x62a75) [0x80aaa75]
    2: (vdso) (__kernel_rt_sigreturn+0x0) [0x5d140c]
    3: /lib/libc.so.6 (0x9bb000+0x73579) [0xa2e579]
    4: /lib/libc.so.6 (realloc+0xe0) [0xa2e830]
    5: /opt/xorg/bin/Xorg (Xrealloc+0x33) [0x80a3f33]
    6: /opt/xorg/bin/Xorg (0x8048000+0x1ab79) [0x8062b79]
    7: /opt/xorg/bin/Xorg (0x8048000+0x1ac4e) [0x8062c4e]
    8: /opt/xorg/bin/Xorg (RegisterExtensionNames+0x2ce) [0x8062fbe]
    9: /opt/xorg/bin/Xorg (AddExtension+0x19a) [0x807bd7a]
    10: /opt/xorg//lib/xorg/modules/extensions/libextmod.so (0x728000+0x1169a)
    [0x73969a]
    11: /opt/xorg/bin/Xorg (InitExtensions+0x85) [0x80c0eb5]
    12: /opt/xorg/bin/Xorg (0x8048000+0x1a51d) [0x806251d]
    13: /lib/libc.so.6 (__libc_start_main+0xe6) [0x9d1bb6]
    14: /opt/xorg/bin/Xorg (0x8048000+0x1a2a1) [0x80622a1]
    Segmentation fault at address 0x10b2d5f8
    
    valgrind output:
    ==5069== Invalid read of size 4
    ==5069==    at 0x80F928D: FreePicture (picture.c:1531)
    ==5069==    by 0x818DDEF: miDCDeviceCleanup (midispcur.c:867)
    ==5069==    by 0x81B97F0: miSpriteDeviceCursorCleanup (misprite.c:968)
    ==5069==    by 0x80995FA: miPointerDeviceCleanup (mipointer.c:292)
    ==5069==    by 0x807973E: CloseDevice (devices.c:840)
    ==5069==    by 0x80799B6: CloseDownDevices (devices.c:933)
    ==5069==    by 0x8062705: main (main.c:309)
    ==5069==  Address 0x4cce844 is 12 bytes inside a block of size 84 free'd
    ==5069==    at 0x40057F6: free (vg_replace_malloc.c:325)
    ==5069==    by 0x80A3DE0: Xfree (utils.c:1154)
    ==5069==    by 0x80F9332: FreePicture (picture.c:1576)
    ==5069==    by 0x80FBB4B: PictureDestroyWindow (picture.c:69)
    ==5069==    by 0x810B1A3: damageDestroyWindow (damage.c:1840)
    ==5069==    by 0x80864F1: FreeWindowResources (window.c:846)
    ==5069==    by 0x8086812: DeleteWindow (window.c:925)
    ==5069==    by 0x806B53E: FreeClientResources (resource.c:806)
    ==5069==    by 0x806B60F: FreeAllResources (resource.c:823)
    ==5069==    by 0x80626E4: main (main.c:299)
    ==5069==
    ==5069== Invalid write of size 4
    ==5069==    at 0x80F9295: FreePicture (picture.c:1531)
    ==5069==    by 0x818DDEF: miDCDeviceCleanup (midispcur.c:867)
    ==5069==    by 0x81B97F0: miSpriteDeviceCursorCleanup (misprite.c:968)
    ==5069==    by 0x80995FA: miPointerDeviceCleanup (mipointer.c:292)
    ==5069==    by 0x807973E: CloseDevice (devices.c:840)
    ==5069==    by 0x80799B6: CloseDownDevices (devices.c:933)
    ==5069==    by 0x8062705: main (main.c:309)
    ==5069==  Address 0x4cce844 is 12 bytes inside a block of size 84 free'd
    ==5069==    at 0x40057F6: free (vg_replace_malloc.c:325)
    ==5069==    by 0x80A3DE0: Xfree (utils.c:1154)
    ==5069==    by 0x80F9332: FreePicture (picture.c:1576)
    ==5069==    by 0x80FBB4B: PictureDestroyWindow (picture.c:69)
    ==5069==    by 0x810B1A3: damageDestroyWindow (damage.c:1840)
    ==5069==    by 0x80864F1: FreeWindowResources (window.c:846)
    ==5069==    by 0x8086812: DeleteWindow (window.c:925)
    ==5069==    by 0x806B53E: FreeClientResources (resource.c:806)
    ==5069==    by 0x806B60F: FreeAllResources (resource.c:823)
    ==5069==    by 0x80626E4: main (main.c:299)
    
    XTS test case: Xproto pAllocColor
    
    This reverts commit 00b8b7ad61b6f818271fb4d1e383113170309d72.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/mi/midispcur.c b/mi/midispcur.c
index 3a31b74..3fb7e02 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -59,9 +59,9 @@ static DevPrivateKey miDCScreenKey = &miDCScreenKeyIndex;
 
 static Bool	miDCCloseScreen(int index, ScreenPtr pScreen);
 
-/* per device per-screen private data */
-static int miDCSpriteKeyIndex[MAXSCREENS];
-static DevPrivateKey miDCSpriteKey = miDCSpriteKeyIndex;
+/* per device private data */
+static int miDCSpriteKeyIndex;
+static DevPrivateKey miDCSpriteKey = &miDCSpriteKeyIndex;
 
 typedef struct {
     GCPtr	    pSourceGC, pMaskGC;
@@ -75,10 +75,10 @@ typedef struct {
 #endif
 } miDCBufferRec, *miDCBufferPtr;
 
-#define MIDCBUFFER(dev, screen) \
+#define MIDCBUFFER(dev) \
  ((DevHasCursor(dev)) ? \
-  (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey + (screen)->myNum) : \
-  (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey + (screen)->myNum))
+  (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey) : \
+  (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey))
 
 /* 
  * The core pointer buffer will point to the index of the virtual core pointer
@@ -158,6 +158,10 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs)
     return TRUE;
 }
 
+#define tossGC(gc)  (gc ? FreeGC (gc, (GContext) 0) : 0)
+#define tossPix(pix)	(pix ? (*pScreen->DestroyPixmap) (pix) : TRUE)
+#define tossPict(pict)	(pict ? FreePicture (pict, 0) : 0)
+
 static Bool
 miDCCloseScreen (int index, ScreenPtr pScreen)
 {
@@ -179,6 +183,7 @@ miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
 }
 
 #ifdef ARGB_CURSOR
+#define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win))
 
 static VisualPtr
 miDCGetWindowVisual (WindowPtr pWin)
@@ -410,8 +415,12 @@ miDCPutBits (
     (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y);
 }
 
+#define EnsureGC(gc,win) (gc || miDCMakeGC(&gc, win))
+
 static GCPtr
-miDCMakeGC(WindowPtr pWin)
+miDCMakeGC(
+    GCPtr	*ppGC,
+    WindowPtr	pWin)
 {
     GCPtr pGC;
     int   status;
@@ -422,6 +431,7 @@ miDCMakeGC(WindowPtr pWin)
     pGC = CreateGC((DrawablePtr)pWin,
 		   GCSubwindowMode|GCGraphicsExposures, gcvals, &status,
 		   (XID)0, serverClient);
+    *ppGC = pGC;
     return pGC;
 }
 
@@ -446,11 +456,22 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
     pWin = WindowTable[pScreen->myNum];
-    pBuffer = MIDCBUFFER(pDev, pScreen);
+    pBuffer = MIDCBUFFER(pDev);
 
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
+        /* see comment in miDCPutUpCursor */
+        if (pBuffer->pRootPicture && 
+                pBuffer->pRootPicture->pDrawable &&
+                pBuffer->pRootPicture->pDrawable->pScreen != pScreen)
+        {
+            tossPict(pBuffer->pRootPicture);
+            pBuffer->pRootPicture = NULL;
+        }
+
+	if (!EnsurePicture(pBuffer->pRootPicture, &pWin->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -463,6 +484,33 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     else
 #endif
     {
+        /**
+         * XXX: Before MPX, the sourceGC and maskGC were attached to the
+         * screen, and would switch as the screen switches.  With mpx we have
+         * the GC's attached to the device now, so each time we switch screen
+         * we need to make sure the GC's are allocated on the new screen.
+         * This is ... not optimal. (whot)
+         */
+        if (pBuffer->pSourceGC && pScreen != pBuffer->pSourceGC->pScreen)
+        {
+            tossGC(pBuffer->pSourceGC);
+            pBuffer->pSourceGC = NULL;
+        }
+
+        if (pBuffer->pMaskGC && pScreen != pBuffer->pMaskGC->pScreen)
+        {
+            tossGC(pBuffer->pMaskGC);
+            pBuffer->pMaskGC = NULL;
+        }
+
+	if (!EnsureGC(pBuffer->pSourceGC, pWin))
+	    return FALSE;
+	if (!EnsureGC(pBuffer->pMaskGC, pWin))
+	{
+	    FreeGC (pBuffer->pSourceGC, (GContext) 0);
+	    pBuffer->pSourceGC = 0;
+	    return FALSE;
+	}
 	miDCPutBits ((DrawablePtr)pWin, pPriv,
 		     pBuffer->pSourceGC, pBuffer->pMaskGC,
 		     x, y, pCursor->bits->width, pCursor->bits->height,
@@ -483,7 +531,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
 
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
-    pBuffer = MIDCBUFFER(pDev, pScreen);
+    pBuffer = MIDCBUFFER(pDev);
 
     pSave = pBuffer->pSave;
     pWin = WindowTable[pScreen->myNum];
@@ -496,7 +544,14 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
 	if (!pSave)
 	    return FALSE;
     }
-
+    /* see comment in miDCPutUpCursor */
+    if (pBuffer->pSaveGC && pBuffer->pSaveGC->pScreen != pScreen)
+    {
+        tossGC(pBuffer->pSaveGC);
+        pBuffer->pSaveGC = NULL;
+    }
+    if (!EnsureGC(pBuffer->pSaveGC, pWin))
+	return FALSE;
     pGC = pBuffer->pSaveGC;
     if (pSave->drawable.serialNumber != pGC->serialNumber)
 	ValidateGC ((DrawablePtr) pSave, pGC);
@@ -517,13 +572,20 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
 
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
-    pBuffer = MIDCBUFFER(pDev, pScreen);
+    pBuffer = MIDCBUFFER(pDev);
     pSave = pBuffer->pSave;
 
     pWin = WindowTable[pScreen->myNum];
     if (!pSave)
 	return FALSE;
-
+    /* see comment in miDCPutUpCursor */
+    if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen)
+    {
+        tossGC(pBuffer->pRestoreGC);
+        pBuffer->pRestoreGC = NULL;
+    }
+    if (!EnsureGC(pBuffer->pRestoreGC, pWin))
+	return FALSE;
     pGC = pBuffer->pRestoreGC;
     if (pWin->drawable.serialNumber != pGC->serialNumber)
 	ValidateGC ((DrawablePtr) pWin, pGC);
@@ -545,7 +607,7 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
 
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
-    pBuffer = MIDCBUFFER(pDev, pScreen);
+    pBuffer = MIDCBUFFER(pDev);
 
     pSave = pBuffer->pSave;
     pWin = WindowTable[pScreen->myNum];
@@ -554,7 +616,14 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
      */
     if (!pSave)
 	return FALSE;
-
+    /* see comment in miDCPutUpCursor */
+    if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen)
+    {
+        tossGC(pBuffer->pRestoreGC);
+        pBuffer->pRestoreGC = NULL;
+    }
+    if (!EnsureGC(pBuffer->pRestoreGC, pWin))
+	return FALSE;
     pGC = pBuffer->pRestoreGC;
     if (pWin->drawable.serialNumber != pGC->serialNumber)
 	ValidateGC ((DrawablePtr) pWin, pGC);
@@ -593,7 +662,14 @@ miDCChangeSave (DeviceIntPtr pDev, ScreenPtr pScreen,
 	(*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC,
 			       0, sourcey, -dx, copyh, x + dx, desty);
     }
-
+    /* see comment in miDCPutUpCursor */
+    if (pBuffer->pSaveGC && pBuffer->pSaveGC->pScreen != pScreen)
+    {
+        tossGC(pBuffer->pSaveGC);
+        pBuffer->pSaveGC = NULL;
+    }
+    if (!EnsureGC(pBuffer->pSaveGC, pWin))
+	return FALSE;
     pGC = pBuffer->pSaveGC;
     if (pSave->drawable.serialNumber != pGC->serialNumber)
 	ValidateGC ((DrawablePtr) pSave, pGC);
@@ -690,7 +766,7 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						  miDCScreenKey);
     pWin = WindowTable[pScreen->myNum];
-    pBuffer = MIDCBUFFER(pDev, pScreen);
+    pBuffer = MIDCBUFFER(pDev);
 
     pTemp = pBuffer->pTemp;
     if (!pTemp ||
@@ -733,9 +809,17 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 #ifdef ARGB_CURSOR
     if (pPriv->pPicture)
     {
-	if (!pBuffer->pTempPicture)
-            miDCMakePicture(&pBuffer->pTempPicture, &pTemp->drawable, pWin);
+        /* see comment in miDCPutUpCursor */
+        if (pBuffer->pTempPicture && 
+                pBuffer->pTempPicture->pDrawable &&
+                pBuffer->pTempPicture->pDrawable->pScreen != pScreen)
+        {
+            tossPict(pBuffer->pTempPicture);
+            pBuffer->pTempPicture = NULL;
+        }
 
+	if (!EnsurePicture(pBuffer->pTempPicture, &pTemp->drawable, pWin))
+	    return FALSE;
 	CompositePicture (PictOpOver,
 			  pPriv->pPicture,
 			  NULL,
@@ -748,12 +832,38 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     else
 #endif
     {
+	if (!pBuffer->pPixSourceGC)
+	{
+	    pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pTemp,
+		GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
+	    if (!pBuffer->pPixSourceGC)
+		return FALSE;
+	}
+	if (!pBuffer->pPixMaskGC)
+	{
+	    pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pTemp,
+		GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
+	    if (!pBuffer->pPixMaskGC)
+		return FALSE;
+	}
 	miDCPutBits ((DrawablePtr)pTemp, pPriv,
 		     pBuffer->pPixSourceGC, pBuffer->pPixMaskGC,
 		     dx, dy, pCursor->bits->width, pCursor->bits->height,
 		     source, mask);
     }
 
+    /* see comment in miDCPutUpCursor */
+    if (pBuffer->pRestoreGC && pBuffer->pRestoreGC->pScreen != pScreen)
+    {
+        tossGC(pBuffer->pRestoreGC);
+        pBuffer->pRestoreGC = NULL;
+    }
+    /*
+     * copy the temporary pixmap onto the screen
+     */
+
+    if (!EnsureGC(pBuffer->pRestoreGC, pWin))
+	return FALSE;
     pGC = pBuffer->pRestoreGC;
     if (pWin->drawable.serialNumber != pGC->serialNumber)
 	ValidateGC ((DrawablePtr) pWin, pGC);
@@ -767,113 +877,51 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
 static Bool
 miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
-    miDCBufferPtr   pBuffer;
-    WindowPtr       pWin;
-    XID             gcval = FALSE;
-    int             status;
-    int             i;
-
-    if (!DevHasCursor(pDev))
-        return TRUE;
-
-    for (i = 0; i < screenInfo.numScreens; i++)
-    {
-        pScreen = screenInfo.screens[i];
-
-        pBuffer = xalloc(sizeof(miDCBufferRec));
-        if (!pBuffer)
-            goto failure;
-
-        dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer);
-        pWin = WindowTable[pScreen->myNum];
-
-        pBuffer->pSourceGC = miDCMakeGC(pWin);
-        if (!pBuffer->pSourceGC)
-            goto failure;
-
-        pBuffer->pMaskGC = miDCMakeGC(pWin);
-        if (!pBuffer->pMaskGC)
-            goto failure;
-
-        pBuffer->pSaveGC = miDCMakeGC(pWin);
-        if (!pBuffer->pSaveGC)
-            goto failure;
-
-        pBuffer->pRestoreGC = miDCMakeGC(pWin);
-        if (!pBuffer->pRestoreGC)
-            goto failure;
-
-        pBuffer->pMoveGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pMoveGC)
-            goto failure;
-
-        pBuffer->pPixSourceGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pPixSourceGC)
-            goto failure;
-
-        pBuffer->pPixMaskGC = CreateGC ((DrawablePtr)pWin,
-            GCGraphicsExposures, &gcval, &status, (XID)0, serverClient);
-        if (!pBuffer->pPixMaskGC)
-            goto failure;
-
+    miDCBufferPtr pBuffer;
+
+    pBuffer = xalloc(sizeof(miDCBufferRec));
+    dixSetPrivate(&pDev->devPrivates, miDCSpriteKey, pBuffer);
+
+    pBuffer->pSourceGC =
+        pBuffer->pMaskGC =
+        pBuffer->pSaveGC =
+        pBuffer->pRestoreGC =
+        pBuffer->pMoveGC =
+        pBuffer->pPixSourceGC =
+        pBuffer->pPixMaskGC = NULL;
 #ifdef ARGB_CURSOR
-        miDCMakePicture(&pBuffer->pRootPicture, &pWin->drawable, pWin);
-        if (!pBuffer->pRootPicture)
-            goto failure;
-
-        pBuffer->pTempPicture = NULL;
+    pBuffer->pRootPicture = NULL;
+    pBuffer->pTempPicture = NULL;
 #endif
-
-        // these get (re)allocated lazily depending on the cursor size
-        pBuffer->pSave = pBuffer->pTemp = NULL;
-    }
+    pBuffer->pSave = pBuffer->pTemp = NULL;
 
     return TRUE;
-
-failure:
-
-    miDCDeviceCleanup(pDev, pScreen);
-
-    return FALSE;
 }
 
 static void
 miDCDeviceCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
 {
     miDCBufferPtr   pBuffer;
-    int             i;
 
     if (DevHasCursor(pDev))
     {
-        for (i = 0; i < screenInfo.numScreens; i++)
-        {
-            pScreen = screenInfo.screens[i];
-
-            pBuffer = MIDCBUFFER(pDev, pScreen);
-
-            if (pBuffer)
-            {
-                if (pBuffer->pSourceGC) FreeGC(pBuffer->pSourceGC, (GContext) 0);
-                if (pBuffer->pMaskGC) FreeGC(pBuffer->pMaskGC, (GContext) 0);
-                if (pBuffer->pSaveGC) FreeGC(pBuffer->pSaveGC, (GContext) 0);
-                if (pBuffer->pRestoreGC) FreeGC(pBuffer->pRestoreGC, (GContext) 0);
-                if (pBuffer->pMoveGC) FreeGC(pBuffer->pMoveGC, (GContext) 0);
-                if (pBuffer->pPixSourceGC) FreeGC(pBuffer->pPixSourceGC, (GContext) 0);
-                if (pBuffer->pPixMaskGC) FreeGC(pBuffer->pPixMaskGC, (GContext) 0);
-
+        pBuffer = MIDCBUFFER(pDev);
+        tossGC (pBuffer->pSourceGC);
+        tossGC (pBuffer->pMaskGC);
+        tossGC (pBuffer->pSaveGC);
+        tossGC (pBuffer->pRestoreGC);
+        tossGC (pBuffer->pMoveGC);
+        tossGC (pBuffer->pPixSourceGC);
+        tossGC (pBuffer->pPixMaskGC);
+        tossPix (pBuffer->pSave);
+        tossPix (pBuffer->pTemp);
 #ifdef ARGB_CURSOR
-                if (pBuffer->pRootPicture) FreePicture(pBuffer->pRootPicture, 0);
-                if (pBuffer->pTempPicture) FreePicture(pBuffer->pTempPicture, 0);
+#if 0				/* This has been free()d before */
+        tossPict (pScreenPriv->pRootPicture);
+#endif 
+        tossPict (pBuffer->pTempPicture);
 #endif
-
-                if (pBuffer->pSave) (*pScreen->DestroyPixmap)(pBuffer->pSave);
-                if (pBuffer->pTemp) (*pScreen->DestroyPixmap)(pBuffer->pTemp);
-
-                xfree(pBuffer);
-                dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, NULL);
-            }
-        }
+        xfree(pBuffer);
+        dixSetPrivate(&pDev->devPrivates, miDCSpriteKey, NULL);
     }
 }
commit f7ef6fd9a1a1f48603df2796fe7c904c25a81077
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Apr 20 15:56:58 2010 +0300

    xfree86: fix not reached code in tty code
    
    CLEARRTS_SUPPORT cannot be triggered at all. Notice that mouse driver manual
    page states the support for it though.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c
index 4ba8599..da57939 100644
--- a/hw/xfree86/os-support/shared/posix_tty.c
+++ b/hw/xfree86/os-support/shared/posix_tty.c
@@ -340,14 +340,9 @@ xf86SetSerial (int fd, pointer options)
 
 	if ((xf86SetBoolOption (options, "ClearRTS", FALSE)))
 	{
-#ifdef CLEARRTS_SUPPORT
-		val = TIOCM_RTS;
-		SYSCALL (ioctl(fd, TIOCMBIC, &val));
-#else
 		xf86Msg (X_WARNING,
 			 "Option ClearRTS not supported on this OS\n");
 			return (-1);
-#endif
 		xf86MarkOptionUsedByName (options, "ClearRTS");
 	}
 
commit b36eeb713a349961a6be8a6dd183ded6d27f9974
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Apr 20 16:26:02 2010 +0300

    xkb: check for NULL pointer before dereferences it in XkbWriteXKBSymbols
    
    move srv assignment to before it's being used. Also, check for xkb being nil.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbout.c b/xkb/xkbout.c
index 68ede90..082c85e 100644
--- a/xkb/xkbout.c
+++ b/xkb/xkbout.c
@@ -353,9 +353,13 @@ XkbClientMapPtr		map;
 XkbServerMapPtr		srv;
 Bool			showActions;
 
+    if (!xkb) {
+	_XkbLibError(_XkbErrMissingSymbols,"XkbWriteXKBSymbols",0);
+	return FALSE;
+    }
+
     map= xkb->map;
-    srv= xkb->server;
-    if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map)) {
+    if ((!map)||(!map->syms)||(!map->key_sym_map)) {
 	_XkbLibError(_XkbErrMissingSymbols,"XkbWriteXKBSymbols",0);
 	return FALSE;
     }
@@ -376,6 +380,7 @@ Bool			showActions;
     }
     if (tmp>0)
 	fprintf(file,"\n");
+    srv= xkb->server;
     for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
 	Bool	simple;
 	if ((int)XkbKeyNumSyms(xkb,i)<1)
commit 471f350c99b2e7c5a9045eef5ebff65cd2ddb7c5
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Apr 19 20:34:30 2010 +0300

    exa: don't need to check for NULL pointer if we already assumed it has a value
    
    the alternative would be to check ps in the beginning of the function.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Acked-by: Michel Dänzer <michel at daenzer.net>

diff --git a/exa/exa.c b/exa/exa.c
index 590d9a5..b2bd1c5 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -779,14 +779,12 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     unwrap(pExaScr, pScreen, BitmapToRegion);
     unwrap(pExaScr, pScreen, CreateScreenResources);
 #ifdef RENDER
-    if (ps) {
-	unwrap(pExaScr, ps, Composite);
-	if (pExaScr->SavedGlyphs)
-	    unwrap(pExaScr, ps, Glyphs);
-	unwrap(pExaScr, ps, Trapezoids);
-	unwrap(pExaScr, ps, Triangles);
-	unwrap(pExaScr, ps, AddTraps);
-    }
+    unwrap(pExaScr, ps, Composite);
+    if (pExaScr->SavedGlyphs)
+	unwrap(pExaScr, ps, Glyphs);
+    unwrap(pExaScr, ps, Trapezoids);
+    unwrap(pExaScr, ps, Triangles);
+    unwrap(pExaScr, ps, AddTraps);
 #endif
 
     xfree (pExaScr);
commit 96784f4fcb6c2fb82f6d1abbd28ea1e189e4e6f5
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Apr 19 20:46:12 2010 +0300

    xkb: check for NULL pointer before dereferences it in XkbAddClientResource
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 33741e9..9755f98 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -1041,8 +1041,7 @@ XkbInterestPtr	interest;
 	    return ((interest->resource==id)?interest:NULL);
 	interest = interest->next;
     }
-    interest = xalloc(sizeof(XkbInterestRec));
-    bzero(interest,sizeof(XkbInterestRec));
+    interest = xcalloc(1, sizeof(XkbInterestRec));
     if (interest) {
 	interest->dev = dev;
 	interest->client = client;
commit 057c147541bde6f0cbe22ca069b43a97ddc95baf
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Apr 16 18:01:41 2010 +0300

    Xi: check for NULL pointer before dereferences it in ListButtonInfo
    
    Both dev and dev->button are already used before their checking were being
    performed. So check on the beginning.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/Xi/xiquerydevice.c b/Xi/xiquerydevice.c
index 435868d..47ab688 100644
--- a/Xi/xiquerydevice.c
+++ b/Xi/xiquerydevice.c
@@ -247,6 +247,9 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState)
     int mask_len;
     int i;
 
+    if (!dev || !dev->button)
+	return 0;
+
     mask_len = bytes_to_int32(bits_to_bytes(dev->button->numButtons));
 
     info->type = ButtonClass;
@@ -259,7 +262,7 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState)
     memset(bits, 0, mask_len * 4);
 
     if (reportState)
-	for (i = 0; dev && dev->button && i < dev->button->numButtons; i++)
+	for (i = 0; i < dev->button->numButtons; i++)
 	    if (BitIsOn(dev->button->down, i))
 		SetBit(bits, i);
 
commit 7f457351d2a09013cd57fcb2f95c0d6f56bfaccb
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon Apr 19 20:18:51 2010 +0300

    xfree86: check for NULL pointer before dereferences it in parser code
    
    Seems to be harmless. Meh.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 8aab0cf..06710d5 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -845,10 +845,13 @@ static int
 ConfigFilter(const struct dirent *de)
 {
 	const char *name = de->d_name;
-	size_t len = strlen(name);
+	size_t len;
 	size_t suflen = strlen(XCONFIGSUFFIX);
 
-	if (!name || name[0] == '.' || len <= suflen)
+	if (!name || name[0] == '.')
+		return 0;
+	len = strlen(name);
+	if(len <= suflen)
 		return 0;
 	if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
 		return 0;
commit d948dcd9555c81ccb378054383ef8da464202bdf
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Apr 16 17:08:09 2010 +0300

    Xi: fix not reached code in XSendExtensionEvent
    
    Error was introduced in 31a7994a. I.e., broken since 2007. I guess nobody uses
    XSendExtensionEvent.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/Xi/sendexev.c b/Xi/sendexev.c
index 8629dd2..bd96d74 100644
--- a/Xi/sendexev.c
+++ b/Xi/sendexev.c
@@ -138,9 +138,10 @@ ProcXSendExtensionEvent(ClientPtr client)
 
     first = ((xEvent *) & stuff[1]);
     if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
-	  (first->u.u.type < lastEvent)))
+	  (first->u.u.type < lastEvent))) {
 	client->errorValue = first->u.u.type;
 	return BadValue;
+    }
 
     list = (XEventClass *) (first + stuff->num_events);
     if ((ret = CreateMaskFromList(client, list, stuff->count, tmp, dev,
commit f491b0aa5b86a5242fc4e04218202bbb52d0af39
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Apr 16 16:47:33 2010 +0300

    xfree86: fix not reached code in parser
    
    ...because Error is a macro that returns NULL.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 1091be5..4e42b24 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -219,15 +219,15 @@ xf86readConfigFile (void)
 			}
 			else
 			{
-				Error (INVALID_SECTION_MSG, xf86tokenString ());
 				free(val.str);
 				val.str = NULL;
+				Error (INVALID_SECTION_MSG, xf86tokenString ());
 			}
 			break;
 		default:
-			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
 			free(val.str);
 			val.str = NULL;
+			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
 		}
 	}
 
commit 099946a3ac94ff5e575e9edcecd26cf9f346b241
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Apr 16 18:35:55 2010 +0300

    mi: check for NULL pointer before dereferences it in miPointerSetPosition
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/mi/mipointer.c b/mi/mipointer.c
index e1f63be..1b33f82 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -497,14 +497,14 @@ miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y)
 
     miPointerPtr        pPointer; 
 
+    if (!pDev || !pDev->coreEvents)
+        return;
+
     pPointer = MIPOINTER(pDev);
     pScreen = pPointer->pScreen;
     if (!pScreen)
 	return;	    /* called before ready */
 
-    if (!pDev || !pDev->coreEvents)
-        return;
-
     if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
     {
 	pScreenPriv = GetScreenPrivate (pScreen);
commit 49835eec0c996ad95a01f0fe340336b6b60e51aa
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Fri Apr 16 17:50:43 2010 +0300

    exa: check for NULL pointer before dereferences it
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Acked-by: Michel Dänzer <michel at daenzer.net>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/exa/exa_classic.c b/exa/exa_classic.c
index c31e2d4..e1ead6c 100644
--- a/exa/exa_classic.c
+++ b/exa/exa_classic.c
@@ -148,7 +148,7 @@ Bool
 exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int depth,
 		      int bitsPerPixel, int devKind, pointer pPixData)
 {
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
+    ScreenPtr pScreen;
     ExaScreenPrivPtr pExaScr;
     ExaPixmapPrivPtr pExaPixmap;
     Bool ret;
@@ -156,6 +156,7 @@ exaModifyPixmapHeader_classic(PixmapPtr pPixmap, int width, int height, int dept
     if (!pPixmap)
         return FALSE;
 
+    pScreen = pPixmap->drawable.pScreen;
     pExaScr = ExaGetScreenPriv(pScreen);
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
 
diff --git a/exa/exa_driver.c b/exa/exa_driver.c
index dcf1a98..abe79ba 100644
--- a/exa/exa_driver.c
+++ b/exa/exa_driver.c
@@ -126,7 +126,7 @@ Bool
 exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth,
 		      int bitsPerPixel, int devKind, pointer pPixData)
 {
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
+    ScreenPtr pScreen;
     ExaScreenPrivPtr pExaScr;
     ExaPixmapPrivPtr pExaPixmap;
     Bool ret;
@@ -134,6 +134,7 @@ exaModifyPixmapHeader_driver(PixmapPtr pPixmap, int width, int height, int depth
     if (!pPixmap)
         return FALSE;
 
+    pScreen = pPixmap->drawable.pScreen;
     pExaScr = ExaGetScreenPriv(pScreen);
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
 
diff --git a/exa/exa_mixed.c b/exa/exa_mixed.c
index 21cc3bd..49e04f2 100644
--- a/exa/exa_mixed.c
+++ b/exa/exa_mixed.c
@@ -124,7 +124,7 @@ Bool
 exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
 		      int bitsPerPixel, int devKind, pointer pPixData)
 {
-    ScreenPtr pScreen = pPixmap->drawable.pScreen;
+    ScreenPtr pScreen;
     ExaScreenPrivPtr pExaScr;
     ExaPixmapPrivPtr pExaPixmap;
     Bool ret, has_gpu_copy;
@@ -132,6 +132,7 @@ exaModifyPixmapHeader_mixed(PixmapPtr pPixmap, int width, int height, int depth,
     if (!pPixmap)
         return FALSE;
 
+    pScreen = pPixmap->drawable.pScreen;
     pExaScr = ExaGetScreenPriv(pScreen);
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
 
commit 996c115deb558e8e9490ea773528b8e96650df53
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Thu Mar 25 18:17:54 2010 +0200

    configure: remove unused builtin font macro from autoconf file
    
    This should be removed together with 49b93df8.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 9aff613..7759aac 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -408,9 +408,6 @@
 /* Support HAL for hotplug */
 #undef CONFIG_HAL
 
-/* Use only built-in fonts */
-#undef BUILTIN_FONTS
-
 /* Have a monotonic clock from clock_gettime() */
 #undef MONOTONIC_CLOCK
 
commit 0ba82562eeba8bf3bcd00b6e3ff28ce5b2c8df3c
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Mar 30 19:10:36 2010 +0300

    Death to Multibuffer extension
    
    The rationale behind is because no sane application will use this when we have
    modern APIs such DRI2. Besides, as a fact, xfree86 server has already
    deprecated this extension in 1998:
    
        http://www.xfree86.org/3.3.6/isc7.html
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index 53cbc1f..fa007aa 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -99,13 +99,6 @@ BUILTIN_SRCS += $(XCALIBRATE_SRCS)
 # XCalibrate needs tslib
 endif
 
-# Multi-buffering extension
-MULTIBUFFER_SRCS = mbuf.c
-EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c
-if MULTIBUFFER
-MODULE_SRCS  += $(MULTIBUFFER_SRCS)
-endif
-
 # XF86 Big Font extension
 BIGFONT_SRCS = xf86bigfont.c xf86bigfontsrv.h
 if XF86BIGFONT
@@ -140,8 +133,6 @@ EXTRA_DIST = \
 	$(XSELINUX_SRCS) \
 	$(XCALIBRATE_SRCS) \
 	$(XINERAMA_SRCS) \
-	$(MULTIBUFFER_SRCS) \
-	$(EXTRA_MULTIBUFFER_SRCS) \
 	$(FONTCACHE_SRCS) \
 	$(BIGFONT_SRCS) \
 	$(DPMS_SRCS) \
diff --git a/Xext/mbuf.c b/Xext/mbuf.c
deleted file mode 100644
index aacb9cf..0000000
--- a/Xext/mbuf.c
+++ /dev/null
@@ -1,2014 +0,0 @@
-/************************************************************
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "window.h"
-#include "os.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "resource.h"
-#include "opaque.h"
-#include "sleepuntil.h"
-#include "inputstr.h"
-#include <X11/extensions/multibufconst.h>
-#include <X11/extensions/multibufproto.h>
-
-#include <stdio.h>
-#if !defined(WIN32)
-#include <sys/time.h>
-#endif
-
-/* given an OtherClientPtr obj, get the ClientPtr */
-#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
-
-/* given a MultibufferPtr b, get the ClientPtr */
-#define bClient(b)   (clients[CLIENT_ID(b->pPixmap->drawable.id)])
-
-#define ValidEventMasks (ExposureMask|MultibufferClobberNotifyMask|MultibufferUpdateNotifyMask)
-
-/* The _Multibuffer and _Multibuffers structures below refer to each other,
- * so we need this forward declaration
- */
-typedef struct _Multibuffers	*MultibuffersPtr;
-
-/*
- * per-Multibuffer data
- */
-typedef struct _Multibuffer {
-    MultibuffersPtr pMultibuffers;  /* associated window data */
-    Mask	    eventMask;	    /* MultibufferClobberNotifyMask|ExposureMask|MultibufferUpdateNotifyMask */
-    Mask	    otherEventMask; /* mask of all other clients event masks */
-    OtherClients    *otherClients;  /* other clients that want events */
-    int		    number;	    /* index of this buffer into array */
-    int		    side;	    /* always Mono */
-    int		    clobber;	    /* Unclobbered, PartiallyClobbered, FullClobbered */
-    PixmapPtr	    pPixmap;	    /* associated pixmap */
-} MultibufferRec, *MultibufferPtr;
-
-/*
- * per-window data
- */
-
-typedef struct _Multibuffers {
-    WindowPtr	pWindow;		/* associated window */
-    int		numMultibuffer;		/* count of buffers */
-    int		refcnt;			/* ref count for delete */
-    int		displayedMultibuffer;	/* currently active buffer */
-    int		updateAction;		/* Undefined, Background, Untouched, Copied */
-    int		updateHint;		/* Frequent, Intermittent, Static */
-    int		windowMode;		/* always Mono */
-
-    TimeStamp	lastUpdate;		/* time of last update */
-
-    unsigned short	width, height;	/* last known window size */
-    short		x, y;		/* for static gravity */
-
-    MultibufferPtr	buffers;        /* array of numMultibuffer buffers */
-} MultibuffersRec;
-
-/*
- * per-screen data
- */
-typedef struct _MultibufferScreen {
-    PositionWindowProcPtr PositionWindow;		/* pWin, x,y */
-} MultibufferScreenRec, *MultibufferScreenPtr;
-
-/*
- * per display-image-buffers request data.
- */
-
-typedef struct _DisplayRequest {
-    struct _DisplayRequest	*next;
-    TimeStamp			activateTime;
-    ClientPtr			pClient;
-    XID				id;
-} DisplayRequestRec, *DisplayRequestPtr;
-
-#define DestroyWindowMask		(1L<<0)
-#define PositionWindowMask		(1L<<1)
-#define PostValidateTreeMask		(1L<<2)
-#define ClipNotifyMask			(1L<<3)
-#define WindowExposuresMask		(1L<<4)
-#define CopyWindowMask			(1L<<5)
-#define ClearToBackgroundMask		(1L<<6)
-#define ChangeWindowAttributesMask	(1L<<7)
-
-extern int		MultibufferScreenIndex;
-extern int		MultibufferWindowIndex;
-
-extern RESTYPE		MultibufferDrawableResType;
-
-extern void		MultibufferUpdate(	/* pMbuffer, time */
-				MultibufferPtr /* pMultibuffer */,
-				CARD32 /* time */
-				);
-extern void		MultibufferExpose(	/* pMbuffer, pRegion */
-				MultibufferPtr /* pMultibuffer */,
-				RegionPtr /* pRegion */
-				);
-extern void		MultibufferClobber(	/* pMbuffer */
-				MultibufferPtr /* pMultibuffer */
-				);
-
-typedef struct _mbufWindow	*mbufWindowPtr;
-
-void DestroyImageBuffers (WindowPtr	pWin);
-
-/*
- * per-buffer data
- */
-
-#define MB_DISPLAYED_BUFFER(pMBWindow) \
-    ((pMBWindow)->buffers + (pMBWindow)->displayedMultibuffer)
-
-typedef struct _mbufBuffer {
-    mbufWindowPtr   pMBWindow;	    /* associated window data */
-    Mask	    eventMask;	    /* client event mask */
-    Mask	    otherEventMask; /* union of other clients' event masks */
-    OtherClientsPtr otherClients;   /* other clients that want events */
-    int		    number;	    /* index of this buffer into array */
-    int		    side;	    /* stero side: always Mono */
-    int		    clobber;	    /* clober state */
-    DrawablePtr	    pDrawable;	    /* associated drawable */
-} mbufBufferRec, *mbufBufferPtr;
-
-
-/*
- * per-window data
- */
-
-#define MB_WINDOW_PRIV(pWin) \
-    ((mbufWindowPtr)((pWin)->devPrivates[MultibufferWindowIndex].ptr))
-
-typedef struct _mbufWindow {
-    WindowPtr	pWindow;		/* associated window */
-    int		numMultibuffer;		/* count of buffers */
-    mbufBufferPtr buffers;		/* array of (numMultibuffer) buffers */
-    int		displayedMultibuffer;	/* currently active buffer */
-    int		updateAction;		/* Undefined, Background,
-					   Untouched, Copied */
-    int		updateHint;		/* Frequent, Intermittent, Static */
-    int		windowMode;		/* always Mono */
-    TimeStamp	lastUpdate;		/* time of last update */
-    short		x, y;		/* for static gravity */
-    unsigned short	width, height;	/* last known window size */
-    DevUnion		devPrivate;
-} mbufWindowRec;
-
-
-/*
- * per-screen data
- */
-
-#define MB_SCREEN_PRIV(pScreen) \
-    ((mbufScreenPtr)((pScreen)->devPrivates[MultibufferScreenIndex].ptr))
-
-typedef struct _mbufScreen {
-    long mbufWindowCount;		/* count of multibuffered windows */
-
-    /* Wrap pScreen->DestroyWindow */
-    DestroyWindowProcPtr DestroyWindow;
-    long funcsWrapped;			/* flags which functions are wrapped */
-
-    /* Initialized by device-dependent section */
-    int  nInfo;				/* number of buffer info rec's */
-    xMbufBufferInfo *pInfo;		/* buffer info (for Normal buffers) */
-
-    int  (* CreateImageBuffers)(
-		WindowPtr		/* pWin */,
-		int			/* nbuf */,
-		XID *			/* ids */,
-		int			/* action */,
-		int			/* hint */
-		);
-    void (* DestroyImageBuffers)(
-		WindowPtr		/* pWin */
-		);
-    void (* DisplayImageBuffers)(
-		ScreenPtr		/* pScreen */,
-		mbufBufferPtr *		/* ppMBBuffer */,
-		mbufWindowPtr *		/* ppMBWindow */,
-		int			/* nbuf */
-		);
-    void (* ClearImageBufferArea)(
-		mbufBufferPtr		/* pMBBuffer */,
-		short			/* x */,
-		short			/* y */,
-		unsigned short		/* width */,
-		unsigned short		/* height */,
-		Bool			/* exposures */
-		);
-    Bool (* ChangeMBufferAttributes)(	/* pMBWindow, vmask */
-		/* FIXME */
-		);
-    Bool (* ChangeBufferAttributes)(	/* pMBBuffer, vmask */
-		/* FIXME */
-		);
-    void (* DeleteBufferDrawable)(
-		DrawablePtr		/* pDrawable */
-		);
-    void (* WrapScreenFuncs)(
-		ScreenPtr		/* pScreen */
-		);
-    void (* ResetProc)(
-		ScreenPtr		/* pScreen */
-		);
-    DevUnion	devPrivate;
-} mbufScreenRec, *mbufScreenPtr;
-
-
-/* Privates to mbufScreenRec */
-
-#ifdef _MULTIBUF_PIXMAP_
-#define MB_SCREEN_PRIV_PIXMAP(pScreen) \
-    ((mbufPixmapPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
-
-typedef struct _mbufPixmapPriv
-{
-    /* Pointers to wrapped functions */
-    PositionWindowProcPtr PositionWindow;		/* pWin, x,y */
-    long funcsWrapped;			/* flags which functions are wrapped */
-} mbufPixmapPrivRec, *mbufPixmapPrivPtr;
-#endif /* _MULTIBUF_PIXMAP_ */
-
-
-#ifdef _MULTIBUF_BUFFER_
-
-extern int frameWindowPrivateIndex;
-
-#define MB_SCREEN_PRIV_BUFFER(pScreen) \
-    ((mbufBufferPrivPtr) MB_SCREEN_PRIV((pScreen))->devPrivate.ptr)
-
-typedef struct _mbufBufferPriv
-{
-    DevUnion	*frameBuffer;	/* Array of screen framebuffers */
-    DevUnion	selectPlane;	/* Plane(s) that select displayed buffer */
-
-    /*
-     * Note: subtractRgn and unionRgn may overlap. subtractRgn is a union
-     * of all the old clipLists of the windows that are displaying
-     * the backbuffer. unionRgn is the union of all the new clipLists
-     * of the same windows.
-     */
-
-    RegionRec	backBuffer;	/* Area of screen displaying back buffer */
-    RegionRec   subtractRgn;	/* Regions lost to backBuffer   */
-    RegionRec   unionRgn;	/* Regions gained by backBuffer */
-    Bool	rgnChanged;	/* TRUE if "backBuffer" needs to be updated */
-
-    void (* CopyBufferBits)();	/* pMBWindow, srcBufferNum, dstBufferNum */
-    void (* DrawSelectPlane)();	/* pScreen, selectPlane, pRegion, bufferNum */
-
-    /* Pointers to wrapped functions */
-    PostValidateTreeProcPtr	PostValidateTree; /* pParent, pChild, kind */
-    ClipNotifyProcPtr		ClipNotify;       /* pWin, dx, dy */
-    WindowExposuresProcPtr	WindowExposures;  /* pWin, pRegion */
-    CopyWindowProcPtr		CopyWindow;       /* pWin, oldPt, pOldRegion */
-    ClearToBackgroundProcPtr	ClearToBackground; /* pWin, x,y,w,h, sendExpose */
-    ChangeWindowAttributesProcPtr ChangeWindowAttributes; /* pWin, vmask */
-    long funcsWrapped;			/* flags which functions are wrapped */
-    unsigned  inClearToBackground:1;	/* used by WindowExposure */
-} mbufBufferPrivRec, *mbufBufferPrivPtr;
-#endif /* _MULTIBUF_BUFFER_ */
-
-static int		MultibufferEventBase;
-static int		MultibufferErrorBase;
-static int MultibufferScreenPrivKeyIndex;
-static DevPrivateKey MultibufferScreenPrivKey = &MultibufferScreenPrivKeyIndex;
-static int MultibufferWindowPrivKeyIndex;
-static DevPrivateKey MultibufferWindowPrivKey = &MultibufferWindowPrivKeyIndex;
-
-static void		PerformDisplayRequest (
-				MultibuffersPtr * /* ppMultibuffers */,
-				MultibufferPtr * /* pMultibuffer */,
-				int /* nbuf */
-				);
-static Bool		QueueDisplayRequest (
-				ClientPtr /* client */,
-				TimeStamp /* activateTime */
-				);
-
-static void		BumpTimeStamp (
-				TimeStamp * /* ts */,
-				CARD32 /* inc */
-				);
-
-static void		AliasMultibuffer (
-				MultibuffersPtr /* pMultibuffers */,
-				int /* i */
-				);
-static void		RecalculateMultibufferOtherEvents (
-				MultibufferPtr /* pMultibuffer */
-				);
-static int		EventSelectForMultibuffer(
-				MultibufferPtr /* pMultibuffer */,
-				ClientPtr /* client */,
-				Mask /* mask */
-				);
-
-/*
- * The Pixmap associated with a buffer can be found as a resource
- * with this type
- */
-RESTYPE			MultibufferDrawableResType;
-static int		MultibufferDrawableDelete (
-				pointer /* value */,
-				XID /* id */
-				);
-/*
- * The per-buffer data can be found as a resource with this type.
- * the resource id of the per-buffer data is the same as the resource
- * id of the pixmap
- */
-static RESTYPE		MultibufferResType;
-static int		MultibufferDelete (
-				pointer /* value */,
-				XID /* id */
-				);
-
-/*
- * The per-window data can be found as a resource with this type,
- * using the window resource id
- */
-static RESTYPE		MultibuffersResType;
-static int		MultibuffersDelete (
-				pointer /* value */,
-				XID /* id */
-				);
-
-/*
- * Clients other than the buffer creator attach event masks in
- * OtherClient structures; each has a resource of this type.
- */
-static RESTYPE		OtherClientResType;
-static int		OtherClientDelete (
-				pointer /* value */,
-				XID /* id */
-				);
-
-/****************
- * MultibufferExtensionInit
- *
- * Called from InitExtensions in main()
- *
- ****************/
-
-extern DISPATCH_PROC(ProcGetBufferAttributes);
-
-static DISPATCH_PROC(ProcClearImageBufferArea);
-static DISPATCH_PROC(ProcCreateImageBuffers);
-static DISPATCH_PROC(ProcDestroyImageBuffers);
-static DISPATCH_PROC(ProcDisplayImageBuffers);
-static DISPATCH_PROC(ProcGetBufferInfo);
-static DISPATCH_PROC(ProcGetBufferVersion);
-static DISPATCH_PROC(ProcGetMBufferAttributes);
-static DISPATCH_PROC(ProcMultibufferDispatch);
-static DISPATCH_PROC(ProcSetBufferAttributes);
-static DISPATCH_PROC(ProcSetMBufferAttributes);
-static DISPATCH_PROC(SProcClearImageBufferArea);
-static DISPATCH_PROC(SProcCreateImageBuffers);
-static DISPATCH_PROC(SProcDestroyImageBuffers);
-static DISPATCH_PROC(SProcDisplayImageBuffers);
-static DISPATCH_PROC(SProcGetBufferAttributes);
-static DISPATCH_PROC(SProcGetBufferInfo);
-static DISPATCH_PROC(SProcGetBufferVersion);
-static DISPATCH_PROC(SProcGetMBufferAttributes);
-static DISPATCH_PROC(SProcMultibufferDispatch);
-static DISPATCH_PROC(SProcSetBufferAttributes);
-static DISPATCH_PROC(SProcSetMBufferAttributes);
-
-static void		MultibufferResetProc(
-				ExtensionEntry * /* extEntry */
-				);
-static void		SClobberNotifyEvent(
-				xMbufClobberNotifyEvent * /* from */,
-				xMbufClobberNotifyEvent	* /* to */
-				);
-static void		SUpdateNotifyEvent(
-				xMbufUpdateNotifyEvent * /* from */,
-				xMbufUpdateNotifyEvent * /* to */
-				);
-static Bool		MultibufferPositionWindow(
-				WindowPtr /* pWin */,
-				int /* x */,
-				int /* y */
-				);
-
-static void		SetupBackgroundPainter (
-				WindowPtr /* pWin */,
-				GCPtr /* pGC */
-				);
-
-static int		DeliverEventsToMultibuffer (
-				MultibufferPtr /* pMultibuffer */,
-				xEvent * /* pEvents */,
-				int /* count */,
-				Mask /* filter */
-				);
-
-void
-MultibufferExtensionInit()
-{
-    ExtensionEntry	    *extEntry;
-    int			    i, j;
-    ScreenPtr		    pScreen;
-    MultibufferScreenPtr    pMultibufferScreen;
-
-    for (i = 0; i < screenInfo.numScreens; i++)
-    {
-	pScreen = screenInfo.screens[i];
-	if (!(pMultibufferScreen = xalloc (sizeof (MultibufferScreenRec))))
-	{
-	    for (j = 0; j < i; j++)
-		xfree (dixLookupPrivate(&screenInfo.screens[j]->devPrivates, MultibufferScreenPrivKey));
-	    return;
-	}
-	dixSetPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey, pMultibufferScreen);
-	/*
- 	 * wrap PositionWindow to resize the pixmap when the window
-	 * changes size
- 	 */
-	pMultibufferScreen->PositionWindow = pScreen->PositionWindow;
-	pScreen->PositionWindow = MultibufferPositionWindow;
-    }
-    /*
-     * create the resource types
-     */
-    MultibufferDrawableResType =
-	CreateNewResourceType(MultibufferDrawableDelete, "MultibufferDrawable");
-    if (MultiBufferDrawableResType)
-	MultibufferDrawableResType |= RC_DRAWABLE;
-    MultibufferResType = CreateNewResourceType(MultibufferDelete,
-					       "MultibufferBuffer");
-    MultibuffersResType = CreateNewResourceType(MultibuffersDelete,
-						"MultibufferWindow");
-    OtherClientResType = CreateNewResourceType(OtherClientDelete,
-					       "MultibufferOtherClient");
-    if (MultibufferDrawableResType && MultibufferResType &&
-	MultibuffersResType && 	OtherClientResType &&
-	(extEntry = AddExtension(MULTIBUFFER_PROTOCOL_NAME,
-				 MultibufferNumberEvents, 
-				 MultibufferNumberErrors,
-				 ProcMultibufferDispatch, SProcMultibufferDispatch,
-				 MultibufferResetProc, StandardMinorOpcode)))
-    {
-	MultibufferEventBase = extEntry->eventBase;
-	MultibufferErrorBase = extEntry->errorBase;
-	EventSwapVector[MultibufferEventBase + MultibufferClobberNotify] = (EventSwapPtr) SClobberNotifyEvent;
-	EventSwapVector[MultibufferEventBase + MultibufferUpdateNotify] = (EventSwapPtr) SUpdateNotifyEvent;
-    }
-}
-
-/*ARGSUSED*/
-static void
-MultibufferResetProc (extEntry)
-ExtensionEntry	*extEntry;
-{
-    int			    i;
-    ScreenPtr		    pScreen;
-    MultibufferScreenPtr    pMultibufferScreen;
-    
-    for (i = 0; i < screenInfo.numScreens; i++)
-    {
-	pScreen = screenInfo.screens[i];
-	if ((pMultibufferScreen = (MultibufferScreenPtr)dixLookupPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey)))
-	{
-	    pScreen->PositionWindow = pMultibufferScreen->PositionWindow;
-	    xfree (pMultibufferScreen);
-	}
-    }
-}
-
-static int
-ProcGetBufferVersion (client)
-    ClientPtr	client;
-{
-    xMbufGetBufferVersionReply	rep;
-    int		n;
-
-    REQUEST_SIZE_MATCH (xMbufGetBufferVersionReq);
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.majorVersion = MULTIBUFFER_MAJOR_VERSION;
-    rep.minorVersion = MULTIBUFFER_MINOR_VERSION;
-    if (client->swapped) {
-    	swaps(&rep.sequenceNumber, n);
-    	swapl(&rep.length, n);
-    }
-    WriteToClient(client, sizeof (xMbufGetBufferVersionReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static void
-SetupBackgroundPainter (pWin, pGC)
-    WindowPtr	pWin;
-    GCPtr	pGC;
-{
-    pointer	    gcvalues[4];
-    int		    ts_x_origin, ts_y_origin;
-    PixUnion	    background;
-    int		    backgroundState;
-    Mask	    gcmask;
-
-    /*
-     * First take care of any ParentRelative stuff by altering the
-     * tile/stipple origin to match the coordinates of the upper-left
-     * corner of the first ancestor without a ParentRelative background.
-     * This coordinate is, of course, negative.
-     */
-
-    ts_x_origin = ts_y_origin = 0;
-    while (pWin->backgroundState == ParentRelative) {
-	ts_x_origin -= pWin->origin.x;
-	ts_y_origin -= pWin->origin.y;
-	pWin = pWin->parent;
-    }
-    backgroundState = pWin->backgroundState;
-    background = pWin->background;
-
-    switch (backgroundState)
-    {
-    case BackgroundPixel:
-	gcvalues[0] = (pointer) background.pixel;
-	gcvalues[1] = (pointer) FillSolid;
-	gcmask = GCForeground|GCFillStyle;
-	break;
-
-    case BackgroundPixmap:
-	gcvalues[0] = (pointer) FillTiled;
-	gcvalues[1] = (pointer) background.pixmap;
-	gcvalues[2] = (pointer)(long) ts_x_origin;
-	gcvalues[3] = (pointer)(long) ts_y_origin;
-	gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
-	break;
-
-    default:
-	gcvalues[0] = (pointer) GXnoop;
-	gcmask = GCFunction;
-    }
-    DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE);
-}
-
-int
-CreateImageBuffers (pWin, nbuf, ids, action, hint)
-    WindowPtr	pWin;
-    int		nbuf;
-    XID		*ids;
-    int		action;
-    int		hint;
-{
-    MultibuffersPtr	pMultibuffers;
-    MultibufferPtr	pMultibuffer;
-    ScreenPtr		pScreen;
-    int			width, height, depth;
-    int			i;
-    GCPtr		pClearGC = NULL;
-    xRectangle		clearRect;
-
-    DestroyImageBuffers(pWin);
-    pMultibuffers = xalloc (sizeof (MultibuffersRec) + nbuf * sizeof (MultibufferRec));
-    if (!pMultibuffers)
-	return BadAlloc;
-    pMultibuffers->pWindow = pWin;
-    pMultibuffers->buffers = (MultibufferPtr) (pMultibuffers + 1);
-    pMultibuffers->refcnt = pMultibuffers->numMultibuffer = 0;
-    if (!AddResource (pWin->drawable.id, MultibuffersResType, (pointer) pMultibuffers))
-	return BadAlloc;
-    width = pWin->drawable.width;
-    height = pWin->drawable.height;
-    depth = pWin->drawable.depth;
-    pScreen = pWin->drawable.pScreen;
-
-    if (pWin->backgroundState != None)
-    {
-	pClearGC = GetScratchGC (pWin->drawable.depth, pScreen);
-	SetupBackgroundPainter (pWin, pClearGC);
-	clearRect.x = clearRect.y = 0;
-	clearRect.width = width;
-	clearRect.height = height;
-    }
-
-    for (i = 0; i < nbuf; i++)
-    {
-	pMultibuffer = &pMultibuffers->buffers[i];
-	pMultibuffer->eventMask = 0L;
-	pMultibuffer->otherEventMask = 0L;
-	pMultibuffer->otherClients = (OtherClientsPtr) NULL;
-	pMultibuffer->number = i;
-	pMultibuffer->side = MultibufferSideMono;
-	pMultibuffer->clobber = MultibufferUnclobbered;
-	pMultibuffer->pMultibuffers = pMultibuffers;
-	if (!AddResource (ids[i], MultibufferResType, (pointer) pMultibuffer))
-	    break;
-	pMultibuffer->pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, depth, 0);
-	if (!pMultibuffer->pPixmap)
-	    break;
-	if (!AddResource (ids[i], MultibufferDrawableResType, (pointer) pMultibuffer->pPixmap))
-	{
-	    FreeResource (ids[i], MultibufferResType);
-	    (*pScreen->DestroyPixmap) (pMultibuffer->pPixmap);
-	    break;
-	}
-	pMultibuffer->pPixmap->drawable.id = ids[i];
-
-	if (i > 0 && pClearGC)
-	{
-	    ValidateGC((DrawablePtr)pMultibuffer->pPixmap, pClearGC);
-	    (*pClearGC->ops->PolyFillRect)((DrawablePtr)pMultibuffer->pPixmap,
-					   pClearGC, 1, &clearRect);
-	}
-    }
-    pMultibuffers->numMultibuffer = i;
-    pMultibuffers->refcnt = i;
-    pMultibuffers->displayedMultibuffer = -1;
-    if (i > 0)
-	AliasMultibuffer (pMultibuffers, 0);
-    pMultibuffers->updateAction = action;
-    pMultibuffers->updateHint = hint;
-    pMultibuffers->windowMode = MultibufferModeMono;
-    pMultibuffers->lastUpdate.months = 0;
-    pMultibuffers->lastUpdate.milliseconds = 0;
-    pMultibuffers->width = width;
-    pMultibuffers->height = height;
-    dixSetPrivate(&pWin->devPrivates, MultibufferWindowPrivKey, pMultibuffers);
-    if (pClearGC) FreeScratchGC(pClearGC);
-    return Success;
-}
-
-
-static int
-ProcCreateImageBuffers (client)
-    ClientPtr	client;
-{
-    REQUEST(xMbufCreateImageBuffersReq);
-    xMbufCreateImageBuffersReply	rep;
-    int		n;
-    WindowPtr			pWin;
-    XID				*ids;
-    int				len, nbuf, i, err, rc;
-
-    REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
-    len = stuff->length - bytes_to_int32(sizeof(xMbufCreateImageBuffersReq));
-    if (len == 0)
-	return BadLength;
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-    if (pWin->drawable.class == InputOnly)
-	return BadMatch;
-    switch (stuff->updateAction)
-    {
-    case MultibufferUpdateActionUndefined:
-    case MultibufferUpdateActionBackground:
-    case MultibufferUpdateActionUntouched:
-    case MultibufferUpdateActionCopied:
-	break;
-    default:
-	client->errorValue = stuff->updateAction;
-	return BadValue;
-    }
-    switch (stuff->updateHint)
-    {
-    case MultibufferUpdateHintFrequent:
-    case MultibufferUpdateHintIntermittent:
-    case MultibufferUpdateHintStatic:
-	break;
-    default:
-	client->errorValue = stuff->updateHint;
-	return BadValue;
-    }
-    nbuf = len;
-    ids = (XID *) &stuff[1];
-    for (i = 0; i < nbuf; i++)
-    {
-	LEGAL_NEW_RESOURCE(ids[i], client);
-    }
-    err = CreateImageBuffers (pWin, nbuf, ids,
-			      stuff->updateAction, stuff->updateHint);
-    if (err != Success)
-	return err;
-    rep.type = X_Reply;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-    rep.numberBuffer = ((MultibuffersPtr) (dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey)))->numMultibuffer;
-    if (client->swapped)
-    {
-    	swaps(&rep.sequenceNumber, n);
-    	swapl(&rep.length, n);
-	swaps(&rep.numberBuffer, n);
-    }
-    WriteToClient(client, sizeof (xMbufCreateImageBuffersReply), (char*)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcDisplayImageBuffers (client)
-    ClientPtr	client;
-{
-    REQUEST(xMbufDisplayImageBuffersReq);
-    MultibufferPtr	    *pMultibuffer;
-    MultibuffersPtr	    *ppMultibuffers;
-    int		    nbuf;
-    XID		    *ids;
-    int		    i, j;
-    CARD32	    minDelay;
-    TimeStamp	    activateTime, bufferTime;
-    int		    rc;
-    
-
-    REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
-    nbuf = stuff->length - bytes_to_int32(sizeof (xMbufDisplayImageBuffersReq));
-    if (!nbuf)
-	return Success;
-    minDelay = stuff->minDelay;
-    ids = (XID *) &stuff[1];
-    ppMultibuffers = xalloc(nbuf * sizeof (MultibuffersPtr));
-    pMultibuffer = xalloc(nbuf * sizeof (MultibufferPtr));
-    if (!ppMultibuffers || !pMultibuffer)
-    {
-	if (ppMultibuffers) xfree(ppMultibuffers);
-	if (pMultibuffer)   xfree(pMultibuffer);
-	client->errorValue = 0;
-	return BadAlloc;
-    }
-    activateTime.months = 0;
-    activateTime.milliseconds = 0;
-    for (i = 0; i < nbuf; i++)
-    {
-	rc = dixLookupResourceByType(&pMultibuffer[i], ids[i],
-		MultibufferResType, client, DixUseAccess);
-	if (rc != Success)
-	{
-	    xfree(ppMultibuffers);
-	    xfree(pMultibuffer);
-	    client->errorValue = ids[i];
-	    return MultibufferErrorBase + MultibufferBadBuffer;
-	}
-	ppMultibuffers[i] = pMultibuffer[i]->pMultibuffers;
-	for (j = 0; j < i; j++)
-	{
-	    if (ppMultibuffers[i] == ppMultibuffers[j])
-	    {
-	    	xfree(ppMultibuffers);
-	    	xfree(pMultibuffer);
-		client->errorValue = ids[i];
-	    	return BadMatch;
-	    }
-	}
-	bufferTime = ppMultibuffers[i]->lastUpdate;
-	BumpTimeStamp (&bufferTime, minDelay);
-	if (CompareTimeStamps (bufferTime, activateTime) == LATER)
-	    activateTime = bufferTime;
-    }
-    UpdateCurrentTime ();
-    if (CompareTimeStamps (activateTime, currentTime) == LATER &&
-	QueueDisplayRequest (client, activateTime))
-    {
-	;
-    }
-    else
-	PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf);
-
-    xfree(ppMultibuffers);
-    xfree(pMultibuffer);
-    return Success;
-}
-
-
-static int
-ProcDestroyImageBuffers (client)
-    ClientPtr	client;
-{
-    REQUEST (xMbufDestroyImageBuffersReq);
-    WindowPtr	pWin;
-    int rc;
-
-    REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-    DestroyImageBuffers (pWin);
-    return Success;
-}
-
-static int
-ProcSetMBufferAttributes (client)
-    ClientPtr	client;
-{
-    REQUEST (xMbufSetMBufferAttributesReq);
-    WindowPtr	pWin;
-    MultibuffersPtr	pMultibuffers;
-    int		len, rc;
-    Mask	vmask;
-    Mask	index2;
-    CARD32	updateHint;
-    XID		*vlist;
-
-    REQUEST_AT_LEAST_SIZE (xMbufSetMBufferAttributesReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-    rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id,
-	    MultibufferResType, client, DixSetAttrAccess);
-    if (rc != Success)
-	return BadMatch;
-    len = stuff->length - bytes_to_int32(sizeof (xMbufSetMBufferAttributesReq));
-    vmask = stuff->valueMask;
-    if (len != Ones (vmask))
-	return BadLength;
-    vlist = (XID *) &stuff[1];
-    while (vmask)
-    {
-	index2 = (Mask) lowbit (vmask);
-	vmask &= ~index2;
-	switch (index2)
-	{
-	case MultibufferWindowUpdateHint:
-	    updateHint = (CARD32) *vlist;
-	    switch (updateHint)
-	    {
-	    case MultibufferUpdateHintFrequent:
-	    case MultibufferUpdateHintIntermittent:
-	    case MultibufferUpdateHintStatic:
-		pMultibuffers->updateHint = updateHint;
-		break;
-	    default:
-		client->errorValue = updateHint;
-		return BadValue;
-	    }
-	    vlist++;
-	    break;
-	default:
-	    client->errorValue = stuff->valueMask;
-	    return BadValue;
-	}
-    }
-    return Success;
-}
-
-static int
-ProcGetMBufferAttributes (client)
-    ClientPtr	client;
-{
-    REQUEST (xMbufGetMBufferAttributesReq);
-    WindowPtr	pWin;
-    MultibuffersPtr	pMultibuffers;
-    XID		*ids;
-    xMbufGetMBufferAttributesReply  rep;
-    int		i, n, rc;
-
-    REQUEST_SIZE_MATCH (xMbufGetMBufferAttributesReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-    rc = dixLookupResourceByType(&pMultibuffers, pWin->drawable.id,
-	    MultibufferResType, client, DixGetAttrAccess);
-    if (rc != Success)
-	return BadAccess;
-    ids = xalloc (pMultibuffers->numMultibuffer * sizeof (XID));
-    if (!ids)
-	return BadAlloc;
-    for (i = 0; i < pMultibuffers->numMultibuffer; i++)
-	ids[i] = pMultibuffers->buffers[i].pPixmap->drawable.id;
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = pMultibuffers->numMultibuffer;
-    rep.displayedBuffer = pMultibuffers->displayedMultibuffer;
-    rep.updateAction = pMultibuffers->updateAction;
-    rep.updateHint = pMultibuffers->updateHint;
-    rep.windowMode = pMultibuffers->windowMode;
-    if (client->swapped)
-    {
-    	swaps(&rep.sequenceNumber, n);
-    	swapl(&rep.length, n);
-	swaps(&rep.displayedBuffer, n);
-	SwapLongs (ids, pMultibuffers->numMultibuffer);
-    }
-    WriteToClient (client, sizeof(xMbufGetMBufferAttributesReply),
-		   (char *)&rep);
-    WriteToClient (client, (int)(pMultibuffers->numMultibuffer * sizeof (XID)),
-		   (char *)ids);
-    xfree((pointer) ids);
-    return client->noClientException;
-}
-
-static int
-ProcSetBufferAttributes (client)
-    ClientPtr	client;
-{
-    REQUEST(xMbufSetBufferAttributesReq);
-    MultibufferPtr	pMultibuffer;
-    int		len;
-    Mask	vmask, index2;
-    XID		*vlist;
-    Mask	eventMask;
-    int		result;
-    int		rc;
-
-    REQUEST_AT_LEAST_SIZE (xMbufSetBufferAttributesReq);
-
-    rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
-	    MultibufferResType, client, DixSetAttrAccess);
-    if (rc != Success)
-	return MultibufferErrorBase + MultibufferBadBuffer;
-    len = stuff->length - bytes_to_int32(sizeof (xMbufSetBufferAttributesReq));
-    vmask = stuff->valueMask;
-    if (len != Ones (vmask))
-	return BadLength;
-    vlist = (XID *) &stuff[1];
-    while (vmask)
-    {
-	index2 = (Mask) lowbit (vmask);
-	vmask &= ~index2;
-	switch (index2)
-	{
-	case MultibufferBufferEventMask:
-	    eventMask = (Mask) *vlist;
-	    vlist++;
-	    result = EventSelectForMultibuffer (pMultibuffer, client, eventMask);
-	    if (result != Success)
-		return result;
-	    break;
-	default:
-	    client->errorValue = stuff->valueMask;
-	    return BadValue;
-	}
-    }
-    return Success;
-}
-
-int
-ProcGetBufferAttributes (client)
-    ClientPtr	client;
-{
-    REQUEST(xMbufGetBufferAttributesReq);
-    MultibufferPtr	pMultibuffer;
-    xMbufGetBufferAttributesReply	rep;
-    OtherClientsPtr		other;
-    int				n;
-    int				rc;
-
-    REQUEST_SIZE_MATCH (xMbufGetBufferAttributesReq);
-    rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
-	    MultibufferResType, client, DixGetAttrAccess);
-    if (rc != Success)
-	return MultibufferErrorBase + MultibufferBadBuffer;
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = 0;
-    rep.window = pMultibuffer->pMultibuffers->pWindow->drawable.id;
-    if (bClient (pMultibuffer) == client)
-	rep.eventMask = pMultibuffer->eventMask;
-    else
-    {
-	rep.eventMask = (Mask) 0L;
-	for (other = pMultibuffer->otherClients; other; other = other->next)
-	    if (SameClient (other, client))
-	    {
-		rep.eventMask = other->mask;
-		break;
-	    }
-    }
-    rep.bufferIndex = pMultibuffer->number;
-    rep.side = pMultibuffer->side;
-    if (client->swapped)
-    {
-    	swaps(&rep.sequenceNumber, n);
-    	swapl(&rep.length, n);
-	swapl(&rep.window, n);
-	swapl(&rep.eventMask, n);
-	swaps(&rep.bufferIndex, n);
-    }
-    WriteToClient(client, sizeof (xMbufGetBufferAttributesReply), (char *)&rep);
-    return (client->noClientException);
-}
-
-static int
-ProcGetBufferInfo (client)
-    ClientPtr	client;
-{
-    REQUEST (xMbufGetBufferInfoReq);
-    DrawablePtr		    pDrawable;
-    xMbufGetBufferInfoReply rep;
-    ScreenPtr		    pScreen;
-    int			    i, j, k, n, rc;
-    xMbufBufferInfo	    *pInfo;
-    int			    nInfo;
-    DepthPtr		    pDepth;
-
-    rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0,
-			   DixUnknownAccess);
-    if (rc != Success)
-	return rc;
-    pScreen = pDrawable->pScreen;
-    nInfo = 0;
-    for (i = 0; i < pScreen->numDepths; i++)
-    {
-	pDepth = &pScreen->allowedDepths[i];
-	nInfo += pDepth->numVids;
-    }
-    pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo));
-    if (!pInfo)
-	return BadAlloc;
-
-    rep.type = X_Reply;
-    rep.sequenceNumber = client->sequence;
-    rep.length = nInfo * bytes_to_int32(sizeof (xMbufBufferInfo));
-    rep.normalInfo = nInfo;
-    rep.stereoInfo = 0;
-    if (client->swapped)
-    {
-	swaps(&rep.sequenceNumber, n);
-	swapl(&rep.length, n);
-	swaps(&rep.normalInfo, n);
-	swaps(&rep.stereoInfo, n);
-    }
-
-    k = 0;
-    for (i = 0; i < pScreen->numDepths; i++)
-    {
-	pDepth = &pScreen->allowedDepths[i];
-	for (j = 0; j < pDepth->numVids; j++)
-	{
-	    pInfo[k].visualID = pDepth->vids[j];
-	    pInfo[k].maxBuffers = 0;
-	    pInfo[k].depth = pDepth->depth;
-	    if (client->swapped)
-	    {
-		swapl (&pInfo[k].visualID, n);
-		swaps (&pInfo[k].maxBuffers, n);
-	    }
-	    k++;
-	}
-    }
-    WriteToClient (client, sizeof (xMbufGetBufferInfoReply), (pointer) &rep);
-    WriteToClient (client, (int) nInfo * sizeof (xMbufBufferInfo), (pointer) pInfo);
-    xfree ((pointer) pInfo);
-    return client->noClientException;
-}
-
-static int
-ProcClearImageBufferArea (client)
-    ClientPtr	client;
-{
-    REQUEST (xMbufClearImageBufferAreaReq);
-    MultibufferPtr	pMultibuffer;
-    WindowPtr pWin;
-    xRectangle clearRect;
-    int width, height;
-    DrawablePtr pDrawable;
-    ScreenPtr pScreen;
-    int rc;
-
-    REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq);
-    rc = dixLookupResourceByType(&pMultibuffer, stuff->buffer,
-	    MultibufferResType, client, DixWriteAccess);
-    if (rc != Success)
-	return MultibufferErrorBase + MultibufferBadBuffer;
-    if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse))
-    {
-	client->errorValue = stuff->exposures;
-        return(BadValue);
-    }
-    pWin = pMultibuffer->pMultibuffers->pWindow;
-    width  = pWin->drawable.width;
-    height = pWin->drawable.height;
-    pScreen = pWin->drawable.pScreen;
-
-    clearRect.x = stuff->x;
-    clearRect.y = stuff->y;
-    clearRect.width  = stuff->width  ? stuff->width  : width;
-    clearRect.height = stuff->height ? stuff->height : height;
-
-    if (pWin->backgroundState != None)
-    {
-	GCPtr pClearGC;
-	pClearGC = GetScratchGC (pWin->drawable.depth, pScreen);
-	SetupBackgroundPainter (pWin, pClearGC);
-
-	if (pMultibuffer->number == pMultibuffer->pMultibuffers->displayedMultibuffer)
-	    pDrawable = (DrawablePtr)pWin;
-	else
-	    pDrawable = (DrawablePtr)pMultibuffer->pPixmap;
-
-	ValidateGC(pDrawable, pClearGC);
-	(*pClearGC->ops->PolyFillRect) (pDrawable, pClearGC, 1, &clearRect);
-	FreeScratchGC(pClearGC);
-    }
-
-    if (stuff->exposures)
-    {
-	RegionRec region;
-	BoxRec box;
-	box.x1 = clearRect.x;
-	box.y1 = clearRect.y;
-	box.x2 = clearRect.x + clearRect.width;
-	box.y2 = clearRect.y + clearRect.height;
-	REGION_INIT(pScreen, &region, &box, 1);
-	MultibufferExpose(pMultibuffer, &region);
-	REGION_UNINIT(pScreen, &region);
-    }
-    return Success;
-}
-
-static int
-ProcMultibufferDispatch (client)
-    ClientPtr	client;
-{
-    REQUEST(xReq);
-    switch (stuff->data) {
-    case X_MbufGetBufferVersion:
-	return ProcGetBufferVersion (client);
-    case X_MbufCreateImageBuffers:
-	return ProcCreateImageBuffers (client);
-    case X_MbufDisplayImageBuffers:
-	return ProcDisplayImageBuffers (client);
-    case X_MbufDestroyImageBuffers:
-	return ProcDestroyImageBuffers (client);
-    case X_MbufSetMBufferAttributes:
-	return ProcSetMBufferAttributes (client);
-    case X_MbufGetMBufferAttributes:
-	return ProcGetMBufferAttributes (client);
-    case X_MbufSetBufferAttributes:
-	return ProcSetBufferAttributes (client);
-    case X_MbufGetBufferAttributes:
-	return ProcGetBufferAttributes (client);
-    case X_MbufGetBufferInfo:
-	return ProcGetBufferInfo (client);
-    case X_MbufClearImageBufferArea:
-	return ProcClearImageBufferArea (client);
-    default:
-	return BadRequest;
-    }
-}
-
-static int
-SProcGetBufferVersion (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufGetBufferVersionReq);
-
-    swaps (&stuff->length, n);
-    return ProcGetBufferVersion (client);
-}
-
-static int
-SProcCreateImageBuffers (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufCreateImageBuffersReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE (xMbufCreateImageBuffersReq);
-    swapl (&stuff->window, n);
-    SwapRestL(stuff);
-    return ProcCreateImageBuffers (client);
-}
-
-static int
-SProcDisplayImageBuffers (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufDisplayImageBuffersReq);
-    
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE (xMbufDisplayImageBuffersReq);
-    swaps (&stuff->minDelay, n);
-    swaps (&stuff->maxDelay, n);
-    SwapRestL(stuff);
-    return ProcDisplayImageBuffers (client);
-}
-
-static int
-SProcDestroyImageBuffers (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufDestroyImageBuffersReq);
-    
-    swaps (&stuff->length, n);
-    REQUEST_SIZE_MATCH (xMbufDestroyImageBuffersReq);
-    swapl (&stuff->window, n);
-    return ProcDestroyImageBuffers (client);
-}
-
-static int
-SProcSetMBufferAttributes (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufSetMBufferAttributesReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE(xMbufSetMBufferAttributesReq);
-    swapl (&stuff->window, n);
-    swapl (&stuff->valueMask, n);
-    SwapRestL(stuff);
-    return ProcSetMBufferAttributes (client);
-}
-
-static int
-SProcGetMBufferAttributes (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufGetMBufferAttributesReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE(xMbufGetMBufferAttributesReq);
-    swapl (&stuff->window, n);
-    return ProcGetMBufferAttributes (client);
-}
-
-static int
-SProcSetBufferAttributes (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufSetBufferAttributesReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE(xMbufSetBufferAttributesReq);
-    swapl (&stuff->buffer, n);
-    swapl (&stuff->valueMask, n);
-    SwapRestL(stuff);
-    return ProcSetBufferAttributes (client);
-}
-
-static int
-SProcGetBufferAttributes (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufGetBufferAttributesReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_AT_LEAST_SIZE(xMbufGetBufferAttributesReq);
-    swapl (&stuff->buffer, n);
-    return ProcGetBufferAttributes (client);
-}
-
-static int
-SProcGetBufferInfo (client)
-    ClientPtr	client;
-{
-    int    n;
-    REQUEST (xMbufGetBufferInfoReq);
-
-    swaps (&stuff->length, n);
-    REQUEST_SIZE_MATCH (xMbufGetBufferInfoReq);
-    swapl (&stuff->drawable, n);
-    return ProcGetBufferInfo (client);
-}
-
-static int
-SProcClearImageBufferArea(client)
-    ClientPtr client;
-{
-    char n;
-    REQUEST(xMbufClearImageBufferAreaReq);
-
-    swaps(&stuff->length, n);
-    REQUEST_SIZE_MATCH (xMbufClearImageBufferAreaReq);
-    swapl(&stuff->buffer, n);
-    swaps(&stuff->x, n);
-    swaps(&stuff->y, n);
-    swaps(&stuff->width, n);
-    swaps(&stuff->height, n);
-    return ProcClearImageBufferArea(client);
-}
-
-static int
-SProcMultibufferDispatch (client)
-    ClientPtr	client;
-{
-    REQUEST(xReq);
-    switch (stuff->data) {
-    case X_MbufGetBufferVersion:
-	return SProcGetBufferVersion (client);
-    case X_MbufCreateImageBuffers:
-	return SProcCreateImageBuffers (client);
-    case X_MbufDisplayImageBuffers:
-	return SProcDisplayImageBuffers (client);
-    case X_MbufDestroyImageBuffers:
-	return SProcDestroyImageBuffers (client);
-    case X_MbufSetMBufferAttributes:
-	return SProcSetMBufferAttributes (client);
-    case X_MbufGetMBufferAttributes:
-	return SProcGetMBufferAttributes (client);
-    case X_MbufSetBufferAttributes:
-	return SProcSetBufferAttributes (client);
-    case X_MbufGetBufferAttributes:
-	return SProcGetBufferAttributes (client);
-    case X_MbufGetBufferInfo:
-	return SProcGetBufferInfo (client);
-    case X_MbufClearImageBufferArea:
-	return SProcClearImageBufferArea (client);
-    default:
-	return BadRequest;
-    }
-}
-
-static void
-SUpdateNotifyEvent (from, to)
-    xMbufUpdateNotifyEvent	*from, *to;
-{
-    to->type = from->type;
-    cpswaps (from->sequenceNumber, to->sequenceNumber);
-    cpswapl (from->buffer, to->buffer);
-    cpswapl (from->timeStamp, to->timeStamp);
-}
-
-static void
-SClobberNotifyEvent (from, to)
-    xMbufClobberNotifyEvent	*from, *to;
-{
-    to->type = from->type;
-    cpswaps (from->sequenceNumber, to->sequenceNumber);
-    cpswapl (from->buffer, to->buffer);
-    to->state = from->state;
-}
-
-RegionPtr CreateUnclippedWinSize(WindowPtr pWin);
-
-RegionPtr
-CreateUnclippedWinSize (WindowPtr pWin)
-{
-    RegionPtr	pRgn;
-    BoxRec	box;
-
-    box.x1 = pWin->drawable.x;
-    box.y1 = pWin->drawable.y;
-    box.x2 = pWin->drawable.x + (int) pWin->drawable.width;
-    box.y2 = pWin->drawable.y + (int) pWin->drawable.height;
-    pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
-    if (wBoundingShape (pWin) || wClipShape (pWin)) {
-	ScreenPtr pScreen;
-        pScreen = pWin->drawable.pScreen;
-
-	REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x,
-			 - pWin->drawable.y);
-	if (wBoundingShape (pWin))
-	    REGION_INTERSECT(pScreen, pRgn, pRgn, wBoundingShape (pWin));
-	if (wClipShape (pWin))
-	    REGION_INTERSECT(pScreen, pRgn, pRgn, wClipShape (pWin));
-	REGION_TRANSLATE(pScreen, pRgn, pWin->drawable.x, pWin->drawable.y);
-    }
-    return pRgn;
-}
-
-static void
-PerformDisplayRequest (ppMultibuffers, pMultibuffer, nbuf)
-    MultibufferPtr	    *pMultibuffer;
-    MultibuffersPtr	    *ppMultibuffers;
-    int		    nbuf;
-{
-    GCPtr	    pGC;
-    PixmapPtr	    pPrevPixmap, pNewPixmap;
-    xRectangle	    clearRect;
-    WindowPtr	    pWin;
-    RegionPtr	    pExposed;
-    int		    i;
-    MultibufferPtr  pPrevMultibuffer;
-    XID		    graphicsExpose;
-
-    UpdateCurrentTime ();
-    for (i = 0; i < nbuf; i++)
-    {
-	pWin = ppMultibuffers[i]->pWindow;
-	pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
-	pPrevMultibuffer =
-	   &ppMultibuffers[i]->buffers[ppMultibuffers[i]->displayedMultibuffer];
-	pPrevPixmap = pPrevMultibuffer->pPixmap;
-	pNewPixmap = pMultibuffer[i]->pPixmap;
-	switch (ppMultibuffers[i]->updateAction)
-	{
-	case MultibufferUpdateActionUndefined:
-	    break;
-	case MultibufferUpdateActionBackground:
-	    SetupBackgroundPainter (pWin, pGC);
-	    ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
-	    clearRect.x = 0;
-	    clearRect.y = 0;
-	    clearRect.width = pPrevPixmap->drawable.width;
-	    clearRect.height = pPrevPixmap->drawable.height;
-	    (*pGC->ops->PolyFillRect) ((DrawablePtr)pPrevPixmap, pGC,
-				       1, &clearRect);
-	    break;
-	case MultibufferUpdateActionUntouched:
-	    /* copy the window to the pixmap that represents the
-	     * currently displayed buffer
-	     */
-	    if (pPrevMultibuffer->eventMask & ExposureMask)
-	    {
-	    	graphicsExpose = TRUE;
-	    	DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE);
-	    }
-	    ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
-	    pExposed = (*pGC->ops->CopyArea)
-			    ((DrawablePtr) pWin,
-			     (DrawablePtr) pPrevPixmap,
-			     pGC,
-			     0, 0,
-			     pWin->drawable.width, pWin->drawable.height,
-			     0, 0);
-
-	    /* if we couldn't copy the whole window to the buffer,
-	     * send expose events (if any client wants them)
-	     */
-	    if (pPrevMultibuffer->eventMask & ExposureMask)
-	    { /* some client wants expose events */
-	    	if (pExposed)
-	    	{
-		    RegionPtr	pWinSize;
-
-		    pWinSize = CreateUnclippedWinSize (pWin);
-		    /* pExposed is window-relative, but at this point
-		     * pWinSize is screen-relative.  Make pWinSize be
-		     * window-relative so that region ops involving
-		     * pExposed and pWinSize behave sensibly.
-		     */
-		    REGION_TRANSLATE(pWin->drawable.pScreen, pWinSize,
-				     -pWin->drawable.x, -pWin->drawable.y);
-		    REGION_INTERSECT(pWin->drawable.pScreen, pExposed,
-				     pExposed, pWinSize);
-		    REGION_DESTROY(pWin->drawable.pScreen, pWinSize);
-	    	    MultibufferExpose (pPrevMultibuffer, pExposed);
-	    	    REGION_DESTROY(pWin->drawable.pScreen, pExposed);
-	    	}
-	    	graphicsExpose = FALSE;
-	    	DoChangeGC (pGC, GCGraphicsExposures, &graphicsExpose, FALSE);
-	    }
-	    break; /* end case MultibufferUpdateActionUntouched */
-
-	case MultibufferUpdateActionCopied:
-	    ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
-	    (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap,
-				   (DrawablePtr)pPrevPixmap, pGC,
-				   0, 0,
-				   pWin->drawable.width, pWin->drawable.height,
-				   0, 0);
-	    break;
-	} /* end switch on update action */
-
-	/* display the new buffer */
-	ValidateGC ((DrawablePtr)pWin, pGC);
-	(*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin, pGC,
-			       0, 0,
-			       pWin->drawable.width, pWin->drawable.height,
-			       0, 0);
-	ppMultibuffers[i]->lastUpdate = currentTime;
-	MultibufferUpdate (pMultibuffer[i],
-			   ppMultibuffers[i]->lastUpdate.milliseconds);
-	AliasMultibuffer (ppMultibuffers[i],
-			  pMultibuffer[i] - ppMultibuffers[i]->buffers);
-	FreeScratchGC (pGC);
-    }
-}
-
-DrawablePtr
-GetBufferPointer (pWin, i)
-    WindowPtr	pWin;
-    int		i;
-{
-    MultibuffersPtr pMultibuffers;
-
-    if (!(pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey)))
-	return NULL;
-    return (DrawablePtr) pMultibuffers->buffers[i].pPixmap;
-}
-
-static Bool
-QueueDisplayRequest (client, activateTime)
-    ClientPtr	    client;
-    TimeStamp	    activateTime;
-{
-    /* see xtest.c:ProcXTestFakeInput for code similar to this */
-
-    if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
-    {
-	return FALSE;
-    }
-    /* swap the request back so we can simply re-execute it */
-    if (client->swapped)
-    {
-    	int    n;
-    	REQUEST (xMbufDisplayImageBuffersReq);
-    	
-    	SwapRestL(stuff);
-    	swaps (&stuff->length, n);
-    	swaps (&stuff->minDelay, n);
-    	swaps (&stuff->maxDelay, n);
-    }
-    ResetCurrentRequest (client);
-    client->sequence--;
-    return TRUE;
-}
-
-
-/*
- * Deliver events to a buffer
- */
-
-static int
-DeliverEventsToMultibuffer (pMultibuffer, pEvents, count, filter)
-    MultibufferPtr	pMultibuffer;
-    xEvent	*pEvents;
-    int		count;
-    Mask	filter;
-{
-    int deliveries = 0, nondeliveries = 0;
-    int attempt;
-    OtherClients *other;
-
-    /* if nobody wants the event, we're done */
-    if (!((pMultibuffer->otherEventMask|pMultibuffer->eventMask) & filter))
-	return 0;
-
-    /* maybe send event to owner */
-    if ((attempt = TryClientEvents(
-	bClient(pMultibuffer), NULL, pEvents, count, pMultibuffer->eventMask, filter, (GrabPtr) 0)) != 0)
-    {
-	if (attempt > 0)
-	    deliveries++;
-	else
-	    nondeliveries--;
-    }
-
-    /* maybe send event to other clients */
-    for (other = pMultibuffer->otherClients; other; other=other->next)
-    {
-	if ((attempt = TryClientEvents(
-	      rClient(other), NULL, pEvents, count, other->mask, filter, (GrabPtr) 0)) != 0)
-	{
-	    if (attempt > 0)
-		deliveries++;
-	    else
-		nondeliveries--;
-	}
-    }
-    if (deliveries)
-	return deliveries;
-    return nondeliveries;
-}
-
-/*
- * Send Expose events to interested clients
- */
-
-void
-MultibufferExpose (pMultibuffer, pRegion)
-    MultibufferPtr	pMultibuffer;
-    RegionPtr	pRegion;
-{
-    if (pRegion && !REGION_NIL(pRegion))
-    {
-	xEvent *pEvent;
-	PixmapPtr   pPixmap;
-	xEvent *pe;
-	BoxPtr pBox;
-	int i;
-	int numRects;
-
-	pPixmap = pMultibuffer->pPixmap;
-	REGION_TRANSLATE(pPixmap->drawable.pScreen, pRegion,
-		    -pPixmap->drawable.x, -pPixmap->drawable.y);
-	/* XXX MultibufferExpose "knows" the region representation */
-	numRects = REGION_NUM_RECTS(pRegion);
-	pBox = REGION_RECTS(pRegion);
-
-	pEvent = xalloc(numRects * sizeof(xEvent));
-	if (pEvent) {
-	    pe = pEvent;
-
-	    for (i=1; i<=numRects; i++, pe++, pBox++)
-	    {
-		pe->u.u.type = Expose;
-		pe->u.expose.window = pPixmap->drawable.id;
-		pe->u.expose.x = pBox->x1;
-		pe->u.expose.y = pBox->y1;
-		pe->u.expose.width = pBox->x2 - pBox->x1;
-		pe->u.expose.height = pBox->y2 - pBox->y1;
-		pe->u.expose.count = (numRects - i);
-	    }
-	    (void) DeliverEventsToMultibuffer (pMultibuffer, pEvent, numRects,
-					       ExposureMask);
-	    xfree(pEvent);
-	}
-    }
-}
-
-/* send UpdateNotify event */
-void
-MultibufferUpdate (pMultibuffer, time2)
-    MultibufferPtr	pMultibuffer;
-    CARD32	time2;
-{
-    xMbufUpdateNotifyEvent	event;
-
-    event.type = MultibufferEventBase + MultibufferUpdateNotify;
-    event.buffer = pMultibuffer->pPixmap->drawable.id;
-    event.timeStamp = time2;
-    (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event,
-				1, (Mask)MultibufferUpdateNotifyMask);
-}
-
-/*
- * The sample implementation will never generate MultibufferClobberNotify
- * events
- */
-
-void
-MultibufferClobber (pMultibuffer)
-    MultibufferPtr	pMultibuffer;
-{
-    xMbufClobberNotifyEvent	event;
-
-    event.type = MultibufferEventBase + MultibufferClobberNotify;
-    event.buffer = pMultibuffer->pPixmap->drawable.id;
-    event.state = pMultibuffer->clobber;
-    (void) DeliverEventsToMultibuffer (pMultibuffer, (xEvent *)&event,
-				1, (Mask)MultibufferClobberNotifyMask);
-}
-
-/*
- * make the resource id for buffer i refer to the window
- * drawable instead of the pixmap;
- */
-
-static void
-AliasMultibuffer (pMultibuffers, i)
-    MultibuffersPtr	pMultibuffers;
-    int		i;
-{
-    MultibufferPtr	pMultibuffer;
-
-    if (i == pMultibuffers->displayedMultibuffer)
-	return;
-    /*
-     * remove the old association
-     */
-    if (pMultibuffers->displayedMultibuffer >= 0)
-    {
-	pMultibuffer = &pMultibuffers->buffers[pMultibuffers->displayedMultibuffer];
-	ChangeResourceValue (pMultibuffer->pPixmap->drawable.id,
-			     MultibufferDrawableResType,
- 			     (pointer) pMultibuffer->pPixmap);
-    }
-    /*
-     * make the new association
-     */
-    pMultibuffer = &pMultibuffers->buffers[i];
-    ChangeResourceValue (pMultibuffer->pPixmap->drawable.id,
-			 MultibufferDrawableResType,
-			 (pointer) pMultibuffers->pWindow);
-    pMultibuffers->displayedMultibuffer = i;
-}
-
-/*
- * free everything associated with multibuffering for this
- * window
- */
-
-void
-DestroyImageBuffers (pWin)
-    WindowPtr	pWin;
-{
-    FreeResourceByType (pWin->drawable.id, MultibuffersResType, FALSE);
-    /* Zero out the window's pointer to the buffers so they won't be reused */
-    dixSetPrivate(&pWin->devPrivates, MultibufferWindowPrivKey, NULL);
-}
-
-/*
- * resize the buffers when the window is resized
- */ 
-
-static Bool
-MultibufferPositionWindow (pWin, x, y)
-    WindowPtr	pWin;
-    int		x, y;
-{
-    ScreenPtr	    pScreen;
-    MultibufferScreenPtr pMultibufferScreen;
-    MultibuffersPtr	    pMultibuffers;
-    MultibufferPtr	    pMultibuffer;
-    int		    width, height;
-    int		    i;
-    int		    dx, dy, dw, dh;
-    int		    sourcex, sourcey;
-    int		    destx, desty;
-    PixmapPtr	    pPixmap;
-    GCPtr	    pGC;
-    int		    savewidth, saveheight;
-    xRectangle	    clearRect;
-    Bool	    clear;
-
-    pScreen = pWin->drawable.pScreen;
-    pMultibufferScreen = (MultibufferScreenPtr) dixLookupPrivate(&pScreen->devPrivates, MultibufferScreenPrivKey);
-    (*pMultibufferScreen->PositionWindow) (pWin, x, y);
-
-    /* if this window is not multibuffered, we're done */
-    if (!(pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey)))
-	return TRUE;
-
-    /* if new size is same as old, we're done */
-    if (pMultibuffers->width == pWin->drawable.width &&
-        pMultibuffers->height == pWin->drawable.height)
-	return TRUE;
-
-    width = pWin->drawable.width;
-    height = pWin->drawable.height;
-    dx = pWin->drawable.x - pMultibuffers->x;
-    dy = pWin->drawable.x - pMultibuffers->y;
-    dw = width - pMultibuffers->width;
-    dh = height - pMultibuffers->height;
-    GravityTranslate (0, 0, -dx, -dy, dw, dh,
-		      pWin->bitGravity, &destx, &desty);
-
-    /* if the window grew, remember to paint the window background,
-     * and maybe send expose events, for the new areas of the buffers
-     */
-    clear = pMultibuffers->width < width || pMultibuffers->height < height ||
-		pWin->bitGravity == ForgetGravity;
-
-    sourcex = 0;
-    sourcey = 0;
-    savewidth = pMultibuffers->width;
-    saveheight = pMultibuffers->height;
-    /* clip rectangle to source and destination */
-    if (destx < 0)
-    {
-	savewidth += destx;
-	sourcex -= destx;
-	destx = 0;
-    }
-    if (destx + savewidth > width)
-	savewidth = width - destx;
-    if (desty < 0)
-    {
-	saveheight += desty;
-	sourcey -= desty;
-	desty = 0;
-    }
-    if (desty + saveheight > height)
-	saveheight = height - desty;
-
-    pMultibuffers->width = width;
-    pMultibuffers->height = height;
-    pMultibuffers->x = pWin->drawable.x;
-    pMultibuffers->y = pWin->drawable.y;
-
-    pGC = GetScratchGC (pWin->drawable.depth, pScreen);
-    if (clear)
-    {
-	SetupBackgroundPainter (pWin, pGC);
-	clearRect.x = 0;
-	clearRect.y = 0;
-	clearRect.width = width;
-	clearRect.height = height;
-    }
-    for (i = 0; i < pMultibuffers->numMultibuffer; i++)
-    {
-	pMultibuffer = &pMultibuffers->buffers[i];
-	pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
-					    pWin->drawable.depth,
-					    CREATE_PIXMAP_USAGE_SCRATCH);
-	if (!pPixmap)
-	{
-	    DestroyImageBuffers (pWin);
-	    break;
-	}
-	ValidateGC ((DrawablePtr)pPixmap, pGC);
-	/*
-	 * I suppose this could avoid quite a bit of work if
-	 * it computed the minimal area required.
-	 */
-	if (clear)
-	    (*pGC->ops->PolyFillRect) ((DrawablePtr)pPixmap, pGC, 1, &clearRect);
-	if (pWin->bitGravity != ForgetGravity)
-	{
-	    (*pGC->ops->CopyArea) ((DrawablePtr)pMultibuffer->pPixmap,
-				   (DrawablePtr)pPixmap, pGC,
-				    sourcex, sourcey, savewidth, saveheight,
-				    destx, desty);
-	}
-	pPixmap->drawable.id = pMultibuffer->pPixmap->drawable.id;
-	(*pScreen->DestroyPixmap) (pMultibuffer->pPixmap);
-	pMultibuffer->pPixmap = pPixmap;
-	if (i != pMultibuffers->displayedMultibuffer)
-	{
-	    ChangeResourceValue (pPixmap->drawable.id,
-				 MultibufferDrawableResType,
-				 (pointer) pPixmap);
-	}
-    }
-    FreeScratchGC (pGC);
-    return TRUE;
-}
-
-/* Resource delete func for MultibufferDrawableResType */
-/*ARGSUSED*/
-static int
-MultibufferDrawableDelete (value, id)
-    pointer	value;
-    XID		id;
-{
-    DrawablePtr	pDrawable = (DrawablePtr)value;
-    WindowPtr	pWin;
-    MultibuffersPtr	pMultibuffers;
-    PixmapPtr	pPixmap;
-
-    if (pDrawable->type == DRAWABLE_WINDOW)
-    {
-	pWin = (WindowPtr) pDrawable;
-	pMultibuffers = (MultibuffersPtr) dixLookupPrivate(&pWin->devPrivates, MultibufferWindowPrivKey);
-	pPixmap = pMultibuffers->buffers[pMultibuffers->displayedMultibuffer].pPixmap;
-    }
-    else
-    {
-	pPixmap = (PixmapPtr) pDrawable;
-    }
-    (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap);
-    return Success;
-}
-
-/* Resource delete func for MultibufferResType */
-/*ARGSUSED*/
-static int
-MultibufferDelete (value, id)
-    pointer	value;
-    XID		id;
-{
-    MultibufferPtr	pMultibuffer = (MultibufferPtr)value;
-    MultibuffersPtr	pMultibuffers;
-
-    pMultibuffers = pMultibuffer->pMultibuffers;
-    if (--pMultibuffers->refcnt == 0)
-    {
-	FreeResourceByType (pMultibuffers->pWindow->drawable.id,
-			    MultibuffersResType, TRUE);
-	xfree (pMultibuffers);
-    }
-    return Success;
-}
-
-/* Resource delete func for MultibuffersResType */
-/*ARGSUSED*/
-static int
-MultibuffersDelete (value, id)
-    pointer	value;
-    XID		id;
-{
-    MultibuffersPtr	pMultibuffers = (MultibuffersPtr)value;
-    int	i;
-
-    if (pMultibuffers->refcnt == pMultibuffers->numMultibuffer)
-    {
-	for (i = pMultibuffers->numMultibuffer; --i >= 0; )
-	    FreeResource (pMultibuffers->buffers[i].pPixmap->drawable.id, 0);
-    }
-    return Success;
-}
-
-/* Resource delete func for OtherClientResType */
-static int
-OtherClientDelete (value, id)
-    pointer	value;
-    XID		id;
-{
-    MultibufferPtr	pMultibuffer = (MultibufferPtr)value;
-    OtherClientsPtr	other, prev;
-
-    prev = 0;
-    for (other = pMultibuffer->otherClients; other; other = other->next)
-    {
-	if (other->resource == id)
-	{
-	    if (prev)
-		prev->next = other->next;
-	    else
-		pMultibuffer->otherClients = other->next;
-	    xfree (other);
-	    RecalculateMultibufferOtherEvents (pMultibuffer);
-	    break;
-	}
-	prev = other;
-    }
-    return Success;
-}
-
-static int
-EventSelectForMultibuffer (pMultibuffer, client, mask)
-    MultibufferPtr	pMultibuffer;
-    ClientPtr	client;
-    Mask	mask;
-{
-    OtherClientsPtr	other;
-
-    if (mask & ~ValidEventMasks)
-    {
-	client->errorValue = mask;
-	return BadValue;
-    }
-    if (bClient (pMultibuffer) == client)
-    {
-	pMultibuffer->eventMask = mask;
-    }
-    else /* some other client besides the creator wants events */
-    {
-	for (other = pMultibuffer->otherClients; other; other = other->next)
-	{
-	    if (SameClient (other, client))
-	    {
-		if (mask == 0)
-		{
-		    FreeResource (other->resource, RT_NONE);
-		    break;
-		}
-		other->mask = mask;
-		break;
-	    }
-	}
-	if (!other)
-	{ /* new client that never selected events on this buffer before */
-	    other = xalloc (sizeof (OtherClients));
-	    if (!other)
-		return BadAlloc;
-	    other->mask = mask;
-	    other->resource = FakeClientID (client->index);
-	    if (!AddResource (other->resource, OtherClientResType, (pointer) pMultibuffer))
-	    {
-		xfree (other);
-		return BadAlloc;
-	    }
-	    other->next = pMultibuffer->otherClients;
-	    pMultibuffer->otherClients = other;
-	}
-	RecalculateMultibufferOtherEvents (pMultibuffer);
-    }
-    return (client->noClientException);
-}
-
-/* or together all the otherClients event masks */
-static void
-RecalculateMultibufferOtherEvents (pMultibuffer)
-    MultibufferPtr	pMultibuffer;
-{
-    Mask	    otherEventMask;
-    OtherClients    *other;
-
-    otherEventMask = 0L;
-    for (other = pMultibuffer->otherClients; other; other = other->next)
-	otherEventMask |= other->mask;
-    pMultibuffer->otherEventMask = otherEventMask;
-}
-
-/* add milliseconds to a timestamp, handling overflow */
-static void
-BumpTimeStamp (ts, inc)
-TimeStamp   *ts;
-CARD32	    inc;
-{
-    CARD32  newms;
-
-    newms = ts->milliseconds + inc;
-    if (newms < ts->milliseconds)
-	ts->months++;
-    ts->milliseconds = newms;
-}
diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c
deleted file mode 100644
index 7d9d60a..0000000
--- a/Xext/mbufbf.c
+++ /dev/null
@@ -1,1007 +0,0 @@
-/*
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "os.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "resource.h"
-#include "opaque.h"
-#include "regionstr.h"
-#include "gcstruct.h"
-#include "inputstr.h"
-#include "validate.h"
-#include "globals.h"
-#include <sys/time.h>
-
-#define _MULTIBUF_SERVER_	/* don't want Xlib structures */
-#define _MULTIBUF_BUFFER_
-#include <X11/extensions/multibufst.h>
-
-/* 
-Support for doublebuffer hardare
-
-This code is designed to support doublebuffer hardware where the
-displayed buffer is selected on a per-pixel basis by an additional bit
-plane, called the select plane. It could probably be easily modified
-to work with systems that use window-id planes.
-
-This is done by creating a new drawable type, DRAWABLE_BUFFER. The
-type has the same exact layout as a window drawable. Your code should
-treat a DRAWABLE_BUFFER the same as it would tread a DRAWABLE_WINDOW
-when handling the gc drawing functions. In addition, PaintWindowBackground,
-CopyWindow, and all of the gc drawing functions to be able to draw into both
-framebuffers. Which framebuffer to draw into is selected by the contents of
-	pWin->devPrivates[frameWindowPrivateIndex].
-The content of the devPrivate is either from frameBuffer[0] or
-frameBuffer[1], depending on which buffer is being drawn into. When
-	pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[0],
-the functions should draw into the front framebuffer. When
-	pWin->devPrivates[frameWindowPrivateIndex] == frameBuffer[1],
-the functions should draw into the back framebuffer.
-
-In addition, you need to provide a function that allows you to copy
-bits between the buffers (optional since CopyArea can be used) and a
-function that draws into the select plane. Then, you need to register
-your functions and other information, by calling:
-
-void
-RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane,
-			     CopyBufferBitsFunc, DrawSelectPlaneFunc)
-    int			nInfo;
-    xMbufBufferInfo	*pInfo;
-    DevUnion		*frameBuffer;
-    DevUnion		selectPlane;
-
-"pInfo" is an array indicating which visuals and depths that double
-buffering is supported on. "nInfo" is the length of the array.
-
-"frameBuffer" is array of length 2. The contents of the array element
-is ddx-specific. The content of frameBuffer[0] should, when placed in
-the window private, indicate that framebuffer 0 should be drawn into.
-The contents of frameBuffer[1], when placed into the window private,
-should indicate that framebuffer 1 should be drawn into.
-
-"selectPlane" is ddx-specific. It should contain information
-neccessary for your displayProc to access the select plane.
-It is passed to DrawSelectPlaneFunc.
-
-"CopyBufferBitsFunc" is a ddx-specific function that copies from one
-buffer of a multibuffered window to another buffer. If the CopyBufferBitsFunc
-is NULL, a default function will be used that calls pScreen->CopyArea.
-
-    void CopyBufferBitsFunc(pMBWindow, srcBufferNum, dstBufferNum)
-        mbufWindowPtr pMBWindow;
-        int srcBufferNum, dstBufferNum;
-
-"DrawSelectPlaneFunc" is a ddx-specific function that fills the
-regions "prgn" of select plane with the value "bufferNum". If 
-selectPlane is a DrawablePtr (such as a PixmapPtr), you can pass
-NULL for DrawSelectPlaneFunc, a default function will be used that
-calls FillRectangle on the selectPlane.
-
-    void DrawSelectPlaneFunc(pScreen, selectPlane, prgn, bufferNum)
-        ScreenPtr	pScreen;
-        DevUnion	selectPlane;
-        RegionPtr	prgn;
-        long		bufferNum;
-
-...
-...
-...
-
-*/
-
-#define MAX_BUFFERS  2	/* Only supports 2 buffers */
-#define FRONT_BUFFER 0
-#define BACK_BUFFER  1
-
-
-/* Buffer drawables have the same structure as window drawables */
-typedef WindowRec BufferRec;
-typedef WindowPtr BufferPtr;
-
-
-/*
- * Call RegisterHdwrBuffer for every screen that has doublebuffer hardware. 
- */
-
-static int		bufNumInfo[MAXSCREENS];
-static xMbufBufferInfo	*bufInfo[MAXSCREENS];
-static DevUnion		*bufFrameBuffer[MAXSCREENS];
-static DevUnion		bufselectPlane[MAXSCREENS];
-static void		(* bufCopyBufferBitsFunc[MAXSCREENS])();
-static void		(* bufDrawSelectPlaneFunc[MAXSCREENS])();
-
-static Bool bufMultibufferInit();
-
-
-void
-RegisterDoubleBufferHardware(pScreen, nInfo, pInfo, frameBuffer, selectPlane,
-			     CopyBufferBitsFunc, DrawSelectPlaneFunc)
-    ScreenPtr		pScreen;
-    int			nInfo;
-    xMbufBufferInfo	*pInfo;
-    DevUnion		*frameBuffer;
-    DevUnion		selectPlane;
-    void		(* CopyBufferBitsFunc)();
-    void		(* DrawSelectPlaneFunc)();
-{
-    bufNumInfo[pScreen->myNum]     = nInfo;
-    bufInfo[pScreen->myNum]        = pInfo;
-    bufFrameBuffer[pScreen->myNum] = frameBuffer;
-    bufselectPlane[pScreen->myNum] = selectPlane;
-
-    bufCopyBufferBitsFunc[pScreen->myNum]  = CopyBufferBitsFunc;
-    bufDrawSelectPlaneFunc[pScreen->myNum] = DrawSelectPlaneFunc;
-
-    /* Register ourselves with device-independent multibuffers code */
-    RegisterMultibufferInit(pScreen, bufMultibufferInit);
-}
-
-
-/*
- * Called by Multibuffer extension initialization.
- * Initializes mbufScreenRec and its devPrivate.
- */
-    
-static Bool NoopDDA_True() { return TRUE; }
-static Bool bufPositionWindow();
-static int  bufCreateImageBuffers();
-static void bufDestroyImageBuffers();
-static void bufDisplayImageBuffers();
-static void bufClearImageBufferArea();
-static void bufDestroyBuffer();
-static void bufCopyBufferBits();
-static void bufDrawSelectPlane();
-static void bufWrapScreenFuncs();
-static void bufResetProc();
-
-static void bufPostValidateTree();
-static void bufClipNotify();
-static void bufWindowExposures();
-static Bool bufChangeWindowAttributes();
-static void bufClearToBackground();
-static void bufCopyWindow();
-
-static Bool
-bufMultibufferInit(pScreen, pMBScreen)
-    ScreenPtr pScreen;
-    mbufScreenPtr pMBScreen;
-{
-    mbufBufferPrivPtr	pMBPriv;
-    BoxRec		box;
-
-    /* Multibuffer info */
-    pMBScreen->nInfo = bufNumInfo[pScreen->myNum];
-    pMBScreen->pInfo = bufInfo[pScreen->myNum];
-
-    /* Hooks */
-    pMBScreen->CreateImageBuffers = bufCreateImageBuffers;
-    pMBScreen->DestroyImageBuffers = bufDestroyImageBuffers;
-    pMBScreen->DisplayImageBuffers = bufDisplayImageBuffers;
-    pMBScreen->ClearImageBufferArea = bufClearImageBufferArea;
-    pMBScreen->ChangeMBufferAttributes = NoopDDA_True;
-    pMBScreen->ChangeBufferAttributes = NoopDDA_True;
-    pMBScreen->DeleteBufferDrawable = bufDestroyBuffer;
-    pMBScreen->WrapScreenFuncs = bufWrapScreenFuncs;
-    pMBScreen->ResetProc = bufResetProc;
-    /* Create devPrivate part */
-    pMBPriv = xalloc(sizeof *pMBPriv);
-    if (!pMBPriv)
-	return (FALSE);
-
-    pMBScreen->devPrivate.ptr = (pointer) pMBPriv;
-    pMBPriv->frameBuffer  = bufFrameBuffer[pScreen->myNum];
-    pMBPriv->selectPlane = bufselectPlane[pScreen->myNum];
-
-    /*
-     * Initializing the subtractRgn to the screen area will ensure that
-     * the selectPlane will get cleared on the first PostValidateTree.
-     */
-
-    box.x1 = 0;
-    box.y1 = 0;
-    box.x2 = pScreen->width;
-    box.y2 = pScreen->height;
-
-    pMBPriv->rgnChanged = TRUE;
-    REGION_INIT(pScreen, &pMBPriv->backBuffer, &box, 1);
-    REGION_INIT(pScreen, &pMBPriv->subtractRgn, &box, 1);
-    REGION_NULL(pScreen, &pMBPriv->unionRgn);
-
-    /* Misc functions */
-    pMBPriv->CopyBufferBits  = bufCopyBufferBitsFunc[pScreen->myNum];
-    pMBPriv->DrawSelectPlane = bufDrawSelectPlaneFunc[pScreen->myNum];
-
-    if (!pMBPriv->CopyBufferBits)
-	pMBPriv->CopyBufferBits = bufCopyBufferBits;
-
-    if (!pMBPriv->DrawSelectPlane)
-	pMBPriv->DrawSelectPlane = bufDrawSelectPlane;
-
-    /* screen functions */
-    pMBPriv->funcsWrapped = 0;
-    pMBPriv->inClearToBackground = FALSE;
-    pMBPriv->WindowExposures = NULL;
-    pMBPriv->CopyWindow = NULL;
-    pMBPriv->ClearToBackground = NULL;
-    pMBPriv->ClipNotify = NULL;
-    pMBPriv->ChangeWindowAttributes = NULL;
-
-    /* Start out wrapped to clear select plane */
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree);
-    return TRUE;
-}
-
-static void
-UpdateBufferFromWindow(pBuffer, pWin)
-    BufferPtr	pBuffer;
-    WindowPtr	pWin;
-{
-    pBuffer->drawable.x      = pWin->drawable.x;
-    pBuffer->drawable.y      = pWin->drawable.y;
-    pBuffer->drawable.width  = pWin->drawable.width;
-    pBuffer->drawable.height = pWin->drawable.height;
-
-    pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
-    /* Update for PaintWindowBackground */
-    pBuffer->parent = pWin->parent;
-
-    /*
-     * Make the borderClip the same as the clipList so
-     * NotClippedByChildren comes out with just clipList.
-     */
-
-    pBuffer->clipList   = pWin->clipList;
-    pBuffer->borderClip = pWin->clipList;
-    pBuffer->winSize    = pWin->winSize;
-    pBuffer->borderSize = pWin->borderSize;
-
-    pBuffer->origin = pWin->origin;
-}
-
-static BufferPtr
-bufCreateBuffer(pScreen, pWin, bufferNum)
-    ScreenPtr	pScreen;
-    WindowPtr	pWin;
-    int		bufferNum;
-{
-    mbufBufferPrivPtr	pMBPriv;
-    DevUnion	*devPrivates;
-    BufferPtr	pBuffer;
-    int		i;
-
-    pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    pBuffer = AllocateWindow(pWin->drawable.pScreen);
-    if (!pBuffer)
-	return (NULL);
-
-    /* XXX- Until we know what is needed, copy everything. */
-    devPrivates = pBuffer->devPrivates;
-    *pBuffer = *pWin;
-    pBuffer->devPrivates   = devPrivates;
-
-    pBuffer->drawable.type = DRAWABLE_BUFFER;
-    pBuffer->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-
-    pBuffer->nextSib    = NULL;
-    pBuffer->prevSib    = NULL;
-    pBuffer->firstChild = NULL;
-    pBuffer->lastChild  = NULL;
-
-    /* XXX - Need to call pScreen->CreateWindow for tile/stipples
-     *       or should I just copy the devPrivates?
-     */
-    
-    for (i=0; i < pScreen->WindowPrivateLen; i++)
-	pBuffer->devPrivates[i] = pWin->devPrivates[i];
-
-    pBuffer->devPrivates[frameWindowPrivateIndex] =
-	pMBPriv->frameBuffer[bufferNum];
-
-    return pBuffer;
-}
-
-static void
-bufDestroyBuffer(pDrawable)
-    DrawablePtr	pDrawable;
-{
-    xfree(pDrawable);
-}
-
-/*ARGSUSED*/
-static int
-bufCreateImageBuffers (pWin, nbuf, ids, action, hint)
-    WindowPtr	pWin;
-    int		nbuf;
-    XID		*ids;
-    int		action;
-    int		hint;
-{
-    ScreenPtr		pScreen;
-    mbufScreenPtr	pMBScreen;
-    mbufWindowPtr	pMBWindow;
-    mbufBufferPtr	pMBBuffer;
-    int			i;
-
-    pScreen   = pWin->drawable.pScreen;
-    pMBScreen = MB_SCREEN_PRIV(pScreen);
-    pMBWindow = MB_WINDOW_PRIV(pWin);
-
-    pMBWindow->devPrivate.ptr = (pointer) REGION_CREATE(pScreen, 0,0);
-    if (!pMBWindow->devPrivate.ptr)
-	return(0);
-    REGION_COPY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr,
-			    &pWin->clipList);
-
-    for (i = 0; i < nbuf; i++)
-    {
-	pMBBuffer = pMBWindow->buffers + i;
-	pMBBuffer->pDrawable = (DrawablePtr) bufCreateBuffer(pScreen,pWin,i);
-
-	if (!pMBBuffer->pDrawable)
-	    break;
-
-	if (!AddResource (ids[i], MultibufferDrawableResType,
-			  (pointer) pMBBuffer->pDrawable))
-	{
-	    bufDestroyBuffer((BufferPtr) pMBBuffer->pDrawable);
-	    break;
-	}
-	pMBBuffer->pDrawable->id = ids[i];
-
-	/*
-	 * If window is already mapped, generate exposures and
-	 * clear the area of the newly buffers.
-	 */
-
-	if ((pWin->realized) && (i != pMBWindow->displayedMultibuffer))
-	    (* pMBScreen->ClearImageBufferArea)(pMBBuffer, 0,0, 0,0, TRUE);
-    }
-
-    return i;
-}
-
-static void
-bufDestroyImageBuffers(pWin)
-    WindowPtr	pWin;
-{
-    ScreenPtr		pScreen;
-    mbufWindowPtr	pMBWindow;
-
-    pScreen   = pWin->drawable.pScreen;
-
-    if (pMBWindow = MB_WINDOW_PRIV(pWin))
-    {
-	mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-	/*
-	 * if the backbuffer is currently being displayed, move the bits
-	 * to the frontbuffer and display it instead.
-	 */
-
-	if (pWin->realized && (pMBWindow->displayedMultibuffer == BACK_BUFFER))
-	{
-	    (* pMBPriv->CopyBufferBits)(pMBWindow, BACK_BUFFER, FRONT_BUFFER);
-	    REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer,
-				  &pMBPriv->backBuffer, &pWin->clipList);
-	    (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
-			    &pWin->clipList, FRONT_BUFFER);
-	}
-
-	/* Switch window rendering to front buffer */
-	pWin->devPrivates[frameWindowPrivateIndex] =
-	    pMBPriv->frameBuffer[FRONT_BUFFER];
-
-	REGION_DESTROY(pScreen, (RegionPtr) pMBWindow->devPrivate.ptr);
-	pMBWindow->devPrivate.ptr = NULL;
-    }
-}
-
-/*
- * Can be replaced by pScreen->ClearToBackground if pBuffer->eventMask
- * and wOtherEventsMasks(pBuffer) were setup.
- */
-
-static void
-bufClearImageBufferArea(pMBBuffer, x,y, w,h, generateExposures)
-    mbufBufferPtr	pMBBuffer;
-    short		x,y;
-    unsigned short	w,h;
-    Bool		generateExposures;
-{
-    BoxRec box;
-    RegionRec	reg;
-    RegionPtr pBSReg = NullRegion;
-    ScreenPtr	pScreen;
-    BoxPtr  extents;
-    int	    x1, y1, x2, y2;
-    BufferPtr pBuffer;
-
-    pBuffer = (BufferPtr) pMBBuffer->pDrawable;
-    /* compute everything using ints to avoid overflow */
-
-    x1 = pBuffer->drawable.x + x;
-    y1 = pBuffer->drawable.y + y;
-    if (w)
-        x2 = x1 + (int) w;
-    else
-        x2 = x1 + (int) pBuffer->drawable.width - (int) x;
-    if (h)
-        y2 = y1 + h;	
-    else
-        y2 = y1 + (int) pBuffer->drawable.height - (int) y;
-
-    extents = &pBuffer->clipList.extents;
-    
-    /* clip the resulting rectangle to the window clipList extents.  This
-     * makes sure that the result will fit in a box, given that the
-     * screen is < 32768 on a side.
-     */
-
-    if (x1 < extents->x1)
-	x1 = extents->x1;
-    if (x2 > extents->x2)
-	x2 = extents->x2;
-    if (y1 < extents->y1)
-	y1 = extents->y1;
-    if (y2 > extents->y2)
-	y2 = extents->y2;
-
-    if (x2 <= x1 || y2 <= y1)
-    {
-	x2 = x1 = 0;
-	y2 = y1 = 0;
-    }
-
-    box.x1 = x1;
-    box.x2 = x2;
-    box.y1 = y1;
-    box.y2 = y2;
-
-    pScreen = pBuffer->drawable.pScreen;
-    REGION_INIT(pScreen, &reg, &box, 1);
-
-    REGION_INTERSECT(pScreen, &reg, &reg, &pBuffer->clipList);
-    if (pBuffer->backgroundState != None)
-	miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
-    if (generateExposures)
-	MultibufferExpose(pMBBuffer, &reg);
-#ifdef _notdef
-    /* XXBS - This is the original miClearToBackground code.
-     * WindowExposures needs to be called (or the functionality emulated)
-     * in order for backingStore to work, but first, pBuffer->eventMask
-     * and wOtherEventsMasks(pBuffer) need to be setup correctly.
-     */
-
-    if (generateExposures)
-	(*pScreen->WindowExposures)(pBuffer, &reg, pBSReg);
-    else if (pBuffer->backgroundState != None)
-        miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
-#endif
-    REGION_UNINIT(pScreen, &reg);
-    if (pBSReg)
-	REGION_DESTROY(pScreen, pBSReg);
-}
-
-static void
-bufWrapScreenFuncs(pScreen)
-    ScreenPtr pScreen;
-{
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,PostValidateTree, bufPostValidateTree);
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClipNotify, bufClipNotify);
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,WindowExposures,bufWindowExposures);
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,ChangeWindowAttributes, bufChangeWindowAttributes);
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,ClearToBackground,bufClearToBackground);
-    WRAP_SCREEN_FUNC(pScreen,pMBPriv,CopyWindow,bufCopyWindow);
-}
-
-static void
-bufResetProc(pScreen)
-    ScreenPtr pScreen;
-{
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    /*
-     * frameBuffer, selectPlane, and pInfo should be freed by
-     * whoever called RegisterDoubleBufferHardware
-     */
-
-    REGION_UNINIT(pScreen, &pMBPriv->backBuffer);
-    REGION_UNINIT(pScreen, &pMBPriv->subtractRgn);
-    REGION_UNINIT(pScreen, &pMBPriv->unionRgn);
-    xfree(pMBPriv);
-}
-
-/*---------------------------------------------------------------------------*/
-
-/* 
- * Used if CopyBufferBitsFunc is not provided when registering.
- * This should work for everybody since CopyArea needs to support
- * copying between buffers anyway.
- */
-
-static void
-bufCopyBufferBits(pMBWindow, srcBufferNum, dstBufferNum)
-    mbufWindowPtr pMBWindow;
-    int srcBufferNum, dstBufferNum;
-{
-    DrawablePtr pSrcBuffer, pDstBuffer;
-    GCPtr pGC;
-
-    pSrcBuffer = pMBWindow->buffers[srcBufferNum].pDrawable;
-    pDstBuffer = pMBWindow->buffers[dstBufferNum].pDrawable;
-
-    pGC = GetScratchGC (pDstBuffer->depth, pDstBuffer->pScreen);
-    if (!pGC)
-	return;
-
-    ValidateGC (pDstBuffer, pGC);
-    (* pGC->ops->CopyArea) (pSrcBuffer, pDstBuffer, pGC,
-		    0,0, pDstBuffer->width, pDstBuffer->height, 0,0);
-    FreeScratchGC (pGC);
-}
-
-/*
- * Used if DrawSelectPlanFunc is not provided for when registering.
- * However, it only works if selectPlane.ptr is a drawable. Also
- * assumes that painting with color 0 selects the front buffer,
- * while color 1 selects the back buffer.
- */
-
-static void
-bufDrawSelectPlane(pScreen, selectPlane, prgn, bufferNum)
-    ScreenPtr	pScreen;
-    DevUnion	selectPlane;
-    RegionPtr	prgn;
-    long	bufferNum;
-{
-    DrawablePtr pDrawable;
-    GCPtr pGC;
-    int i;
-    BoxPtr pbox;
-    xRectangle *prect;
-    int numRects;
-    XID	value;
-
-    if (REGION_NUM_RECTS(prgn) == 0)
-	return;
-
-    pDrawable = (DrawablePtr) selectPlane.ptr;
-    pGC = GetScratchGC (pDrawable->depth, pScreen);
-    if (!pGC)
-	return;
-
-    prect = xalloc(REGION_NUM_RECTS(prgn) * sizeof(xRectangle));
-    if (!prect)
-    {
-	FreeScratchGC(pGC);
-	return;
-    }
-
-    value = (XID) bufferNum;
-    DoChangeGC(pGC, GCForeground, &value, 0);
-    ValidateGC(pDrawable, pGC);
-
-    numRects = REGION_NUM_RECTS(prgn);
-    pbox = REGION_RECTS(prgn);
-    for (i= numRects; --i >= 0; pbox++, prect++)
-    {
-	prect->x = pbox->x1;
-	prect->y = pbox->y1;
-	prect->width = pbox->x2 - pbox->x1;
-	prect->height = pbox->y2 - pbox->y1;
-    }
-    prect -= numRects;
-    (* pGC->ops->PolyFillRect)(pDrawable, pGC, numRects, prect);
-
-    xfree(prect);
-    FreeScratchGC (pGC);
-}
-
-
-static void
-bufDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf)
-    ScreenPtr		pScreen;
-    mbufBufferPtr	*ppMBBuffer;
-    mbufWindowPtr	*ppMBWindow;
-    int			nbuf;
-{
-    WindowPtr       pWin;
-    BufferPtr	    pPrevBuffer, pNewBuffer;
-    int		    i, number;
-    mbufBufferPrivPtr pMBPriv;
-    mbufBufferPtr   pPrevMBBuffer;
-
-    pMBPriv   = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    for (i = 0; i < nbuf; i++)
-    {
-	number = ppMBBuffer[i]->number; /* 0=frontbuffer, 1=backbuffer */
-	pWin = ppMBWindow[i]->pWindow;
-	pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]);
-
-	pPrevBuffer = (BufferPtr) pPrevMBBuffer->pDrawable;
-	pNewBuffer  = (BufferPtr) ppMBBuffer[i]->pDrawable;
-
-	if (pPrevBuffer != pNewBuffer)
-	{
-	    RegionPtr backBuffer = &pMBPriv->backBuffer;
-
-	    /*
-	     * Update the select plane and the backBuffer region.
-	     */
-
-	    (* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
-			    &pWin->clipList, number);
-
-	    if (number == BACK_BUFFER)
-		REGION_UNION(pScreen, backBuffer, backBuffer,
-				   &pWin->clipList);
-	    else
-		REGION_SUBTRACT(pScreen, backBuffer, backBuffer,
-				   &pWin->clipList);
-
-	    /* Switch which framebuffer the window draws into */
-	    pWin->devPrivates[frameWindowPrivateIndex] =
-		pMBPriv->frameBuffer[number];
-	}
-
-	switch (ppMBWindow[i]->updateAction)
-	{
-	case MultibufferUpdateActionUndefined:
-	    break;
-	case MultibufferUpdateActionBackground:
-	    (* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea)
-		(pPrevMBBuffer, 0,0, 0,0, FALSE);
-	    break;
-	case MultibufferUpdateActionUntouched:
-	    break;
-	case MultibufferUpdateActionCopied:
-	    if (pPrevBuffer != pNewBuffer)
-	    {
-		(* pMBPriv->CopyBufferBits) (ppMBWindow[i],
-			ppMBBuffer[i]->number, pPrevMBBuffer->number);
-	    }
-	    break;
-	}
-    }
-}
-
-/* Updates the backBuffer region and paints the selectPlane. */
-
-static void
-bufPostValidateTree(pParent, pChild, kind)
-    WindowPtr	pParent, pChild;
-    VTKind	kind;
-{
-    ScreenPtr pScreen;
-    mbufBufferPrivPtr pMBPriv;
-
-    if (pParent)
-	pScreen = pParent->drawable.pScreen;
-    else if (pChild)
-	pScreen = pChild->drawable.pScreen;
-    else
-	return; /* Hopeless */
-
-    pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree);
-    if (pScreen->PostValidateTree)
-	(* pScreen->PostValidateTree)(pParent, pChild, kind);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, PostValidateTree);
-
-    /* Does backBuffer need to change? */
-    if (pMBPriv->rgnChanged)
-    {
-	RegionRec exposed;
-	RegionPtr pSubtractRgn, pUnionRgn;
-	Bool overlap;
-
-	pMBPriv->rgnChanged = FALSE;
-
-	pSubtractRgn = &pMBPriv->subtractRgn;
-	pUnionRgn    = &pMBPriv->unionRgn;
-	REGION_VALIDATE(pScreen, pSubtractRgn, &overlap);
-#ifdef DEBUG
-	if (overlap)
-	    FatalError("bufPostValidateTree: subtractRgn overlaps");
-#endif
-	REGION_VALIDATE(pScreen, pUnionRgn, &overlap);
-#ifdef DEBUG
-	if (overlap)
-	    FatalError("bufPostValidateTree: unionRgn overlaps");
-#endif
-
-	/* Update backBuffer: subtract must come before union */
-	REGION_SUBTRACT(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer,
-			      pSubtractRgn);
-	REGION_UNION(pScreen, &pMBPriv->backBuffer, &pMBPriv->backBuffer,
-			      pUnionRgn);
-
-	/* Paint gained and lost backbuffer areas in select plane */
-	REGION_NULL(pScreen, &exposed);
-	REGION_SUBTRACT(pScreen, &exposed, pSubtractRgn, pUnionRgn);
-	(* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
-				     &exposed, FRONT_BUFFER);
-
-	REGION_SUBTRACT(pScreen, &exposed, pUnionRgn, pSubtractRgn);
-	(* pMBPriv->DrawSelectPlane)(pScreen, pMBPriv->selectPlane,
-				    &exposed, BACK_BUFFER);
-	
-	REGION_UNINIT(pScreen, &exposed);
-	REGION_EMPTY(pScreen, pSubtractRgn);
-	REGION_EMPTY(pScreen, pUnionRgn);
-    }
-}
-
-/*
- * If the window is multibuffered and displaying the backbuffer,
- * add the old clipList to the subtractRgn and add the new clipList
- * to the unionRgn. PostValidateTree will use subtractRgn and unionRgn
- * to update the backBuffer region and the selectPlane.
- *
- * Copy changes to the window structure into the buffers.
- * Send ClobberNotify events.
- */
-
-static void
-bufClipNotify(pWin, dx,dy)
-    WindowPtr pWin;
-    int       dx,dy;
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-    mbufWindowPtr	pMBWindow;
-    int i;
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify);
-    if (pScreen->ClipNotify)
-	(* pScreen->ClipNotify)(pWin, dx,dy);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClipNotify);
-
-    if (pMBWindow = MB_WINDOW_PRIV(pWin))
-    {
-	RegionPtr pOldClipList = (RegionPtr) pMBWindow->devPrivate.ptr;
-
-	if (! REGION_EQUAL(pScreen, pOldClipList, &pWin->clipList))
-	{
-	    if (pMBWindow->displayedMultibuffer == BACK_BUFFER)
-	    {
-		pMBPriv->rgnChanged = TRUE;
-		REGION_APPEND(pScreen, &pMBPriv->subtractRgn, pOldClipList);
-		REGION_APPEND(pScreen, &pMBPriv->unionRgn, &pWin->clipList);
-	    }
-
-	    REGION_COPY(pScreen, pOldClipList,&pWin->clipList);
-	}
-
-	/* Update buffer x,y,w,h, and clipList */
-	for (i=0; i<pMBWindow->numMultibuffer; i++)
-	{
-	    mbufBufferPtr pMBBuffer = pMBWindow->buffers + i;
-	    if (pMBBuffer->clobber != pWin->visibility)
-	    {
-		pMBBuffer->clobber = pWin->visibility;
-		MultibufferClobber(pMBBuffer);
-	    }
-	    UpdateBufferFromWindow(pMBBuffer->pDrawable, pWin);
-	}
-    }
-}
-
-/*
- * Updates buffer's background fields when the window's changes.
- * This is necessary because miPaintWindow is used to paint the buffer.
- *
- * XXBS - Backingstore state will have be tracked too if it is supported.
- */
-
-static Bool
-bufChangeWindowAttributes(pWin, mask)
-    WindowPtr pWin;
-    unsigned long mask;
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-    mbufWindowPtr pMBWindow;
-    Bool ret;
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes);
-    ret = (* pScreen->ChangeWindowAttributes)(pWin, mask);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, ChangeWindowAttributes);
-
-    if (pMBWindow = MB_WINDOW_PRIV(pWin))
-    {
-	if (mask & (CWBackPixmap | CWBackPixel))
-	{
-	    BufferPtr pBuffer;
-	    int i;
-
-	    for (i=0; i<pMBWindow->displayedMultibuffer; i++)
-	    {
-		pBuffer = (BufferPtr) pMBWindow->buffers[i].pDrawable;
-		pBuffer->backgroundState = pWin->backgroundState;
-		pBuffer->background = pWin->background;
-	    }
-	}
-    }
-    return ret;
-}
-
-/*
- * Send exposures and clear the background for a buffer whenever
- * its corresponding window is exposed, except when called by
- * ClearToBackground.
- */
-
-static void 
-bufWindowExposures(pWin, prgn, other_exposed)
-    WindowPtr pWin;
-    RegionPtr prgn, other_exposed;
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    mbufWindowPtr pMBWindow = MB_WINDOW_PRIV(pWin);
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-    RegionRec tmp_rgn;
-    int i;
-    Bool handleBuffers;
-
-    handleBuffers = (!pMBPriv->inClearToBackground) &&
-	(pWin->drawable.type == DRAWABLE_WINDOW) &&
-	pMBWindow && (prgn && !REGION_NIL(prgn));
-
-    /* miWindowExposures munges prgn and other_exposed. */
-    if (handleBuffers)
-    {
-	REGION_NULL(pScreen, &tmp_rgn);
-	REGION_COPY(pScreen, &tmp_rgn, prgn);
-    }
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures);
-    (* pScreen->WindowExposures) (pWin, prgn, other_exposed);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, WindowExposures);
-
-    if (!handleBuffers)
-	return;
-
-    /*
-     * Send expose events to all clients. Paint the exposed region for all
-     * buffers except the displayed buffer since it is handled when the
-     * window is painted.
-     *
-     * XXBS - Will have to be re-written to handle BackingStore on buffers.
-     */
-
-    for (i=0; i<pMBWindow->numMultibuffer; i++)
-    {
-	mbufBufferPtr pMBBuffer;
-	BufferPtr pBuffer;
-
-	pMBBuffer = pMBWindow->buffers + i;
-	pBuffer = (BufferPtr) pMBBuffer->pDrawable;
-
-	if (i != pMBWindow->displayedMultibuffer)
-	    miPaintWindow(pBuffer, &tmp_rgn, PW_BACKGROUND);
-	if ((pMBBuffer->otherEventMask | pMBBuffer->eventMask) & ExposureMask)
-	    MultibufferExpose(pMBBuffer, &tmp_rgn);
-    }
-
-    REGION_UNINIT(pScreen, &tmp_rgn);
-}
-
-/*
- * Set ``inClearToBackground'' so that WindowExposures does not attempt
- * to send expose events or clear the background on the buffers.
- */
-
-static void
-bufClearToBackground(pWin, x,y,w,h, sendExpose)
-    WindowPtr pWin;
-    int x,y, w,h;
-    Bool sendExpose;
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-
-    pMBPriv->inClearToBackground = TRUE;
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground);
-    (* pScreen->ClearToBackground)(pWin, x,y,w,h, sendExpose);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, ClearToBackground);
-
-    pMBPriv->inClearToBackground = FALSE;
-}
-
-/*
- * Move bits in both buffers. It does this by calling pScreen->CopyWindow
- * twice, once with the root window's devPrivate[frameWindowPrivateIndex]
- * pointing to the frontbuffer pixmap and once with it pointed to the
- * backbuffer pixmap. It does this if there are *any* existing multibuffered
- * window... a possible optimization is to copy the backbuffer only if this
- * window or its inferiors are multibuffered. May be faster, maybe not.
- *
- * XXX - Only works if your CopyWindow checks the root window's devPrivate
- *       to see which buffer to draw into. Works for cfbPaintWindow.
- */
-
-/*ARGSUSED*/
-static void 
-bufCopyWindow(pWin, ptOldOrg, prgnSrc)
-    WindowPtr pWin;
-    DDXPointRec ptOldOrg;
-    RegionPtr prgnSrc;
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    mbufBufferPrivPtr pMBPriv = MB_SCREEN_PRIV_BUFFER(pScreen);
-    WindowPtr pwinroot;
-    DevUnion save;
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow);
-
-    pwinroot = WindowTable[pScreen->myNum];
-    save = pwinroot->devPrivates[frameWindowPrivateIndex];
-
-    /*
-     * Copy front buffer
-     */
-
-    pwinroot->devPrivates[frameWindowPrivateIndex] =
-	pMBPriv->frameBuffer[FRONT_BUFFER];
-    (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
-    /*
-     * Copy back buffer
-     */
-
-    /* CopyWindow translates prgnSrc... translate it back for 2nd call. */
-    REGION_TRANSLATE(pScreen, prgnSrc,
-				  ptOldOrg.x - pWin->drawable.x,
-				  ptOldOrg.y - pWin->drawable.y);
-    pwinroot->devPrivates[frameWindowPrivateIndex] =
-	pMBPriv->frameBuffer[BACK_BUFFER];
-    (* pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc);
-
-    pwinroot->devPrivates[frameWindowPrivateIndex] = save;
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, void, CopyWindow);
-}
diff --git a/Xext/mbufpx.c b/Xext/mbufpx.c
deleted file mode 100644
index 8421ba9..0000000
--- a/Xext/mbufpx.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/************************************************************
-
-Copyright 1989, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "os.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "resource.h"
-#include "opaque.h"
-#include "regionstr.h"
-#include "gcstruct.h"
-#include "inputstr.h"
-#include <sys/time.h>
-
-#define _MULTIBUF_SERVER_	/* don't want Xlib structures */
-#define _MULTIBUF_PIXMAP_
-#include <X11/extensions/multibufst.h>
-
-
-static Bool NoopDDA_True() { return TRUE; }
-
-static Bool pixPositionWindow();
-static int  pixCreateImageBuffers();
-static void pixDisplayImageBuffers();
-static void pixClearImageBufferArea();
-static void pixDeleteBufferDrawable();
-static void pixWrapScreenFuncs();
-static void pixResetProc();
-
-Bool
-pixMultibufferInit(pScreen, pMBScreen)
-    ScreenPtr pScreen;
-    mbufScreenPtr pMBScreen;
-{
-    int			i, j, k;
-    xMbufBufferInfo	*pInfo;
-    int			nInfo;
-    DepthPtr		pDepth;
-    mbufPixmapPrivPtr	pMBPriv;
-
-    pMBScreen->CreateImageBuffers = pixCreateImageBuffers;
-    pMBScreen->DestroyImageBuffers = (void (*)())NoopDDA;
-    pMBScreen->DisplayImageBuffers = pixDisplayImageBuffers;
-    pMBScreen->ClearImageBufferArea = pixClearImageBufferArea;
-    pMBScreen->ChangeMBufferAttributes = NoopDDA_True;
-    pMBScreen->ChangeBufferAttributes = NoopDDA_True;
-    pMBScreen->DeleteBufferDrawable = pixDeleteBufferDrawable;
-    pMBScreen->WrapScreenFuncs = pixWrapScreenFuncs;
-    pMBScreen->ResetProc = pixResetProc;
-
-    /* Support every depth and visual combination that the screen does */
-
-    nInfo = 0;
-    for (i = 0; i < pScreen->numDepths; i++)
-    {
-	pDepth = &pScreen->allowedDepths[i];
-	nInfo += pDepth->numVids;
-    }
-
-    pInfo = xalloc (nInfo * sizeof (xMbufBufferInfo));
-    if (!pInfo)
-	return FALSE;
-
-    k = 0;
-    for (i = 0; i < pScreen->numDepths; i++)
-    {
-	pDepth = &pScreen->allowedDepths[i];
-	for (j = 0; j < pDepth->numVids; j++)
-	{
-	    pInfo[k].visualID = pDepth->vids[j];
-	    pInfo[k].maxBuffers = 0;
-	    pInfo[k].depth = pDepth->depth;
-	    k++;
-	}
-    }
-
-    pMBScreen->nInfo = nInfo;
-    pMBScreen->pInfo = pInfo;
-
-    /*
-     * Setup the devPrivate to mbufScreenRec
-     */
-
-    pMBPriv = xalloc(sizeof(* pMBPriv));
-    if (!pMBPriv)
-    {
-	xfree(pInfo);
-	return (FALSE);
-    }
-    pMBScreen->devPrivate.ptr = (pointer) pMBPriv;
-    pMBPriv->PositionWindow = NULL;
-    pMBPriv->funcsWrapped = 0;
-
-    return TRUE;
-}
-
-/*ARGSUSED*/
-static int
-pixCreateImageBuffers (pWin, nbuf, ids, action, hint)
-    WindowPtr	pWin;
-    int		nbuf;
-    XID		*ids;
-    int		action;
-    int		hint;
-{
-    mbufWindowPtr	pMBWindow;
-    mbufBufferPtr	pMBBuffer;
-    ScreenPtr		pScreen;
-    int			width, height, depth;
-    int			i;
-
-    pMBWindow = MB_WINDOW_PRIV(pWin);
-
-    width = pWin->drawable.width;
-    height = pWin->drawable.height;
-    depth = pWin->drawable.depth;
-    pScreen = pWin->drawable.pScreen;
-
-    for (i = 0; i < nbuf; i++)
-    {
-	pMBBuffer = &pMBWindow->buffers[i];
-	pMBBuffer->pDrawable = (DrawablePtr)
-	    (*pScreen->CreatePixmap) (pScreen, width, height, depth, 0);
-	if (!pMBBuffer->pDrawable)
-	    break;
-
-	if (!AddResource (ids[i], MultibufferDrawableResType,
-			  (pointer) pMBBuffer->pDrawable))
-	{
-	    (*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable);
-	    break;
-	}
-	pMBBuffer->pDrawable->id = ids[i];
-
-	/*
-	 * In the description of the CreateImageBuffers request:
-         * "If the window is mapped, or if these image buffers have
-         *  backing store, their contents will be tiled with the window
-         *  background, and zero or more expose events will be generated
-         *  for each of these buffers."
-	 */
-
-	(* MB_SCREEN_PRIV(pScreen)->ClearImageBufferArea)
-	    (pMBBuffer, 0,0, 0,0, TRUE);
-    }
-
-    return i;
-}
-
-/*
- * set up the gc to clear the pixmaps;
- */
-static Bool
-SetupBackgroundPainter (pWin, pGC)
-    WindowPtr	pWin;
-    GCPtr	pGC;
-{
-    XID		    gcvalues[4];
-    int		    ts_x_origin, ts_y_origin;
-    PixUnion	    background;
-    int		    backgroundState;
-    Mask	    gcmask;
-
-    /*
-     * First take care of any ParentRelative stuff by altering the
-     * tile/stipple origin to match the coordinates of the upper-left
-     * corner of the first ancestor without a ParentRelative background.
-     * This coordinate is, of course, negative.
-     */
-
-    ts_x_origin = ts_y_origin = 0;
-    while (pWin->backgroundState == ParentRelative) {
-	ts_x_origin -= pWin->origin.x;
-	ts_y_origin -= pWin->origin.y;
-	pWin = pWin->parent;
-    }
-    backgroundState = pWin->backgroundState;
-    background = pWin->background;
-
-    switch (backgroundState)
-    {
-    case BackgroundPixel:
-	gcvalues[0] = (XID) background.pixel;
-	gcvalues[1] = FillSolid;
-	gcmask = GCForeground|GCFillStyle;
-	break;
-
-    case BackgroundPixmap:
-	gcvalues[0] = FillTiled;
-	gcvalues[1] = (XID) background.pixmap;
-	gcvalues[2] = ts_x_origin;
-	gcvalues[3] = ts_y_origin;
-	gcmask = GCFillStyle|GCTile|GCTileStipXOrigin|GCTileStipYOrigin;
-	break;
-
-    default:
-	return FALSE;
-    }
-    DoChangeGC(pGC, gcmask, gcvalues, TRUE);
-    return TRUE;
-}
-
-static void
-MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects)
-    WindowPtr pWin;
-    DrawablePtr pDrawable;
-    int nrects;
-    xRectangle *pRects;
-{
-    GCPtr      pGC;
-
-    pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
-    if (SetupBackgroundPainter(pWin, pGC))
-    {
-	ValidateGC(pDrawable, pGC);
-	(*pGC->ops->PolyFillRect) (pDrawable, pGC, nrects, pRects);
-    }
-    FreeScratchGC(pGC);
-}
-
-static void
-MultibufferPaintBackgroundRegion(pWin, pDrawable, pRegion)
-    WindowPtr pWin;
-    DrawablePtr pDrawable;
-    RegionPtr pRegion;
-{
-    xRectangle *pRects;
-    int nrects  = REGION_NUM_RECTS(pRegion);
-    BoxPtr pbox = REGION_RECTS(pRegion);
-
-    pRects = xalloc(nrects * sizeof(xRectangle));
-    if (pRects)
-    {
-	int i;
-	for (i = 0; i < nrects; i++)
-	{
-	    pRects[i].x = pbox->x1;
-	    pRects[i].y = pbox->y1;
-	    pRects[i].width  = pbox->x2 - pbox->x1;
-	    pRects[i].height = pbox->y2 - pbox->y1;
-	}
-	MultibufferPaintBackgroundRectangles(pWin, pDrawable, nrects, pRects);
-	xfree(pRects);
-    }
-}
-
-static void
-pixDisplayImageBuffers(pScreen, ppMBWindow, ppMBBuffer, nbuf)
-    mbufBufferPtr	    *ppMBBuffer;
-    mbufWindowPtr	    *ppMBWindow;
-    int		    nbuf;
-{
-    GCPtr	    pGC = NULL;
-    PixmapPtr	    pPrevPixmap, pNewPixmap;
-    WindowPtr	    pWin;
-    RegionPtr	    pExposed;
-    int		    i;
-    mbufBufferPtr  pPrevMBBuffer;
-    XID		    bool;
-    xRectangle      r;
-
-    UpdateCurrentTime ();
-    for (i = 0; i < nbuf; i++)
-    {
-	pWin = ppMBWindow[i]->pWindow;
-
-	/* Time to get a different scratch GC? */
-
-	if (!pGC
-	    || pGC->depth   != pWin->drawable.depth
-	    || pGC->pScreen != pWin->drawable.pScreen)
-	{
-	    if (pGC) FreeScratchGC(pGC);
-	    pGC = GetScratchGC (pWin->drawable.depth, pWin->drawable.pScreen);
-	}
-	pPrevMBBuffer = MB_DISPLAYED_BUFFER(ppMBWindow[i]);
-	pPrevPixmap = (PixmapPtr) pPrevMBBuffer->pDrawable;
-	pNewPixmap = (PixmapPtr) ppMBBuffer[i]->pDrawable;
-
-	if (pPrevPixmap == pNewPixmap)
-	{
-	  /* "If a specified buffer is already displayed, any delays and
-	   *  update action will still be performed for that buffer."
-	   *
-	   *  We special-case this because applications do occasionally
-	   *  request a redundant DisplayImageBuffers, and we can save
-	   *  strokes by recognizing that the only update action that will
-	   *  change the buffer contents in this case is Background.
-	   */
-	    if (ppMBWindow[i]->updateAction == MultibufferUpdateActionBackground)
-	    {
-		r.x = r.y = 0;
-		r.width  = pWin->drawable.width;
-		r.height = pWin->drawable.height;
-		MultibufferPaintBackgroundRectangles(pWin, (DrawablePtr)pWin,
-						     1, &r);
-	    }
-	}
-	else /* different buffer is being displayed */
-	{
-	    /* perform update action */
-
-	    switch (ppMBWindow[i]->updateAction)
-	    {
-	    case MultibufferUpdateActionUndefined:
-		break;
-
-	    case MultibufferUpdateActionBackground:
-
-		r.x = r.y = 0;
-		r.width  = pPrevPixmap->drawable.width;
-		r.height = pPrevPixmap->drawable.height;
-		MultibufferPaintBackgroundRectangles(pWin,
-						     (DrawablePtr)pPrevPixmap,
-						     1, &r);
-		break;
-
-	    case MultibufferUpdateActionUntouched:
-		
-		/* copy the window to the pixmap that represents the
-		 * currently displayed buffer
-		 */
-
-		if (pPrevMBBuffer->eventMask & ExposureMask)
-		{
-		    bool = TRUE;
-		    DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE);
-		}
-		ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
-		pExposed = (*pGC->ops->CopyArea)((DrawablePtr) pWin,
-						 (DrawablePtr) pPrevPixmap,
-						 pGC,
-						 0, 0,
-						 pWin->drawable.width,
-						 pWin->drawable.height,
-						 0, 0);
-
-		/* if we couldn't copy the whole window to the buffer,
-		 * send expose events (if any client wants them)
-		 */
-
-		if (pPrevMBBuffer->eventMask & ExposureMask)
-		{ /* some client wants expose events */
-		    if (pExposed)
-		    {
-			RegionPtr	 pWinSize;
-			extern RegionPtr CreateUnclippedWinSize();
-			ScreenPtr pScreen = pWin->drawable.pScreen;
-			pWinSize = CreateUnclippedWinSize (pWin);
-			/*
-			 * pExposed is window-relative, but at this point
-			 * pWinSize is screen-relative.  Make pWinSize be
-			 * window-relative so that region ops involving
-			 * pExposed and pWinSize behave sensibly.
-			 */
-			REGION_TRANSLATE(pScreen, pWinSize,
-						     -pWin->drawable.x,
-						     -pWin->drawable.y);
-			REGION_INTERSECT(pScreen, pExposed, pExposed, pWinSize);
-			REGION_DESTROY(pScreen, pWinSize);
-			MultibufferExpose (pPrevMBBuffer, pExposed);
-			REGION_DESTROY(pScreen, pExposed);
-		    }
-		    bool = FALSE;
-		    DoChangeGC (pGC, GCGraphicsExposures, &bool, FALSE);
-		} /* end some client wants expose events */
-
-		break; /* end case MultibufferUpdateActionUntouched */
-
-	    case MultibufferUpdateActionCopied:
-
-		ValidateGC ((DrawablePtr)pPrevPixmap, pGC);
-		(*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap,
-				       (DrawablePtr)pPrevPixmap, pGC,
-				       0, 0, pWin->drawable.width,
-				       pWin->drawable.height, 0, 0);
-		break;
-
-	    } /* end switch on update action */
-
-	    /* display the new buffer */
-
-	    ValidateGC ((DrawablePtr)pWin, pGC);
-	    (*pGC->ops->CopyArea) ((DrawablePtr)pNewPixmap, (DrawablePtr)pWin,
-				   pGC, 0, 0,
-				   pWin->drawable.width, pWin->drawable.height,
-				   0, 0);
-	}
-
-	ppMBWindow[i]->lastUpdate = currentTime;
-    }
-
-    if (pGC) FreeScratchGC (pGC);
-    return;
-}
-
-/*
- * resize the buffers when the window is resized
- */ 
-
-static Bool
-pixPositionWindow (pWin, x, y)
-    WindowPtr	pWin;
-    int		x, y;
-{
-    ScreenPtr	    pScreen;
-    mbufPixmapPrivPtr pMBPriv;
-    mbufWindowPtr   pMBWindow;
-    mbufBufferPtr   pMBBuffer;
-    int		    width, height;
-    int		    i;
-    int		    dx, dy, dw, dh;
-    int		    sourcex, sourcey;
-    int		    destx, desty;
-    PixmapPtr	    pPixmap;
-    GCPtr	    pGC;
-    int		    savewidth, saveheight;
-    Bool	    clear;
-    RegionRec       exposedRegion;
-    Bool	    ret;
-
-    pScreen = pWin->drawable.pScreen;
-    pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
-
-    UNWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow);
-    ret = (* pScreen->PositionWindow) (pWin, x, y);
-    REWRAP_SCREEN_FUNC(pScreen, pMBPriv, Bool, PositionWindow);
-
-    if (!(pMBWindow = MB_WINDOW_PRIV(pWin)))
-	return ret;
-
-    /* if new size is same as old, we're done */
-
-    if (pMBWindow->width == pWin->drawable.width &&
-        pMBWindow->height == pWin->drawable.height)
-	return ret;
-
-    width = pWin->drawable.width;
-    height = pWin->drawable.height;
-    dx = pWin->drawable.x - pMBWindow->x;
-    dy = pWin->drawable.x - pMBWindow->y;
-    dw = width - pMBWindow->width;
-    dh = height - pMBWindow->height;
-    GravityTranslate (0, 0, -dx, -dy, dw, dh,
-		      pWin->bitGravity, &destx, &desty);
-
-    /* if the window grew, remember to paint the window background,
-     * and maybe send expose events, for the new areas of the buffers
-     */
-
-    clear = pMBWindow->width < width || pMBWindow->height < height ||
-	    pWin->bitGravity == ForgetGravity;
-
-    sourcex = 0;
-    sourcey = 0;
-    savewidth = pMBWindow->width;
-    saveheight = pMBWindow->height;
-    /* clip rectangle to source and destination */
-    if (destx < 0)
-    {
-	savewidth += destx;
-	sourcex -= destx;
-	destx = 0;
-    }
-    if (destx + savewidth > width)
-	savewidth = width - destx;
-    if (desty < 0)
-    {
-	saveheight += desty;
-	sourcey -= desty;
-	desty = 0;
-    }
-    if (desty + saveheight > height)
-	saveheight = height - desty;
-
-    pMBWindow->width = width;
-    pMBWindow->height = height;
-    pMBWindow->x = pWin->drawable.x;
-    pMBWindow->y = pWin->drawable.y;
-
-    if (clear)
-    {
-	BoxRec box;
-
-	box.x1 = box.y1 = 0;
-	box.x2 = width;
-	box.y2 = height;
-	REGION_INIT(pScreen, &exposedRegion, &box, 1);
-	if (pWin->bitGravity != ForgetGravity)
-	{
-	    RegionRec preservedRegion;
-	    box.x1 = destx;
-	    box.y1 = desty;
-	    box.x2 = destx + savewidth;
-	    box.y2 = desty + saveheight;
-	    REGION_INIT(pScreen, &preservedRegion, &box, 1);
-	    REGION_SUBTRACT(pScreen, &exposedRegion, &exposedRegion, &preservedRegion);
-	    REGION_UNINIT(pScreen, &preservedRegion);
-	}
-
-    } /* end if (clear) */
-
-    pGC = GetScratchGC (pWin->drawable.depth, pScreen);
-
-    /* create buffers with new window size */
-
-    for (i = 0; i < pMBWindow->numMultibuffer; i++)
-    {
-	pMBBuffer = &pMBWindow->buffers[i];
-	pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, pWin->drawable.depth,
-					    CREATE_PIXMAP_USAGE_SCRATCH);
-	if (!pPixmap)
-	{
-	    (* MB_SCREEN_PRIV(pScreen)->DestroyImageBuffers)(pWin);
-	    break;
-	}
-	if (clear)
-	{
-	    MultibufferPaintBackgroundRegion(pWin, (DrawablePtr)pPixmap, &exposedRegion);
-	    MultibufferExpose(pMBBuffer, &exposedRegion);
-	}
-	if (pWin->bitGravity != ForgetGravity)
-	{
-	    ValidateGC ((DrawablePtr)pPixmap, pGC);
-	    (*pGC->ops->CopyArea) (pMBBuffer->pDrawable, (DrawablePtr)pPixmap,
-				   pGC,
-				   sourcex, sourcey, savewidth, saveheight,
-				   destx, desty);
-	}
-	pPixmap->drawable.id = pMBBuffer->pDrawable->id;
-	(*pScreen->DestroyPixmap) ((PixmapPtr) pMBBuffer->pDrawable);
-	pMBBuffer->pDrawable = (DrawablePtr) pPixmap;
-	if (i != pMBWindow->displayedMultibuffer)
-	{
-	    ChangeResourceValue (pPixmap->drawable.id,
-				 MultibufferDrawableResType,
-				 (pointer) pPixmap);
-	}
-    }
-    FreeScratchGC (pGC);
-    if (clear)
-	REGION_UNINIT(pScreen, &exposedRegion);
-    return TRUE;
-}
-
-static void
-pixWrapScreenFuncs(pScreen)
-    ScreenPtr pScreen;
-{
-    mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
-    WRAP_SCREEN_FUNC(pScreen, pMBPriv, PositionWindow, pixPositionWindow);
-}
-
-static void
-pixResetProc(pScreen)
-    ScreenPtr pScreen;
-{
-    mbufScreenPtr pMBScreen = MB_SCREEN_PRIV(pScreen);
-    mbufPixmapPrivPtr pMBPriv = MB_SCREEN_PRIV_PIXMAP(pScreen);
-
-    xfree(pMBScreen->pInfo);
-    xfree(pMBPriv);
-}
-
-static void
-pixClearImageBufferArea(pMBBuffer, x,y, width,height, exposures)
-    mbufBufferPtr	pMBBuffer;
-    short		x, y;
-    unsigned short	width, height;
-    Bool		exposures;
-{
-    WindowPtr pWin;
-    ScreenPtr pScreen;
-    BoxRec box;
-    RegionRec region;
-    int w_width, w_height;
-    DrawablePtr pDrawable;
-
-    pWin = pMBBuffer->pMBWindow->pWindow;
-    pScreen = pWin->drawable.pScreen;
-
-    w_width  = pWin->drawable.width;
-    w_height = pWin->drawable.height;
-
-    box.x1 = x;
-    box.y1 = y;
-    box.x2 = width  ? (box.x1 + width)  : w_width;
-    box.y2 = height ? (box.y1 + height) : w_height;
-
-    if (box.x1 < 0)        box.x1 = 0;
-    if (box.y1 < 0)        box.y1 = 0;
-    if (box.x2 > w_width)  box.x2 = w_width;
-    if (box.y2 > w_height) box.y2 = w_height;
-
-    REGION_INIT(pScreen, &region, &box, 1);
-
-    if (pMBBuffer->number == pMBBuffer->pMBWindow->displayedMultibuffer)
-      pDrawable = (DrawablePtr) pWin;
-    else
-      pDrawable = pMBBuffer->pDrawable;
-
-    MultibufferPaintBackgroundRegion(pWin, pDrawable, &region);
-
-    if (exposures)
-	MultibufferExpose(pMBBuffer, &region);
-
-    REGION_UNINIT(pScreen, &region);
-}
-
-static void
-pixDeleteBufferDrawable(pDrawable)
-    DrawablePtr	pDrawable;
-{
-    (* pDrawable->pScreen->DestroyPixmap)((PixmapPtr) pDrawable);
-}
diff --git a/Xext/sync.c b/Xext/sync.c
index ce65314..990cb67 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2174,7 +2174,7 @@ static XSyncValue *pnext_time;
 
 /*
 *** Server Block Handler
-*** code inspired by multibuffer extension
+*** code inspired by multibuffer extension (now deprecated)
  */
 /*ARGSUSED*/
 static void
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 5af2b5c..a1aacc4 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -357,7 +357,8 @@ ProcXTestFakeInput(ClientPtr client)
         activateTime.milliseconds = ms;
         ev->u.keyButtonPointer.time = 0;
 
-        /* see mbuf.c:QueueDisplayRequest for code similar to this */
+        /* see mbuf.c:QueueDisplayRequest (from the deprecated Multibuffer
+         * extension) for code similar to this */
 
         if (!ClientSleepUntil(client, &activateTime, NULL, NULL))
         {
diff --git a/configure.ac b/configure.ac
index b1d5119..b48d3a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -632,7 +632,6 @@ AC_ARG_ENABLE(xselinux,       AS_HELP_STRING([--disable-xselinux], [Build SELinu
 AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
 AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
 AC_ARG_ENABLE(tslib,          AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
-AC_ARG_ENABLE(multibuffer,    AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no])
 AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
 AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
 AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
@@ -1095,12 +1094,6 @@ if test "x$XCSECURITY" = xyes; then
 	AC_DEFINE(XCSECURITY, 1, [Build Security extension])
 fi
 
-AM_CONDITIONAL(MULTIBUFFER, [test "x$MULTIBUFFER" = xyes])
-if test "x$MULTIBUFFER" = xyes; then
-	AC_DEFINE(MULTIBUFFER, 1, [Build Multibuffer extension])
-	# Requires xextproto which is always required
-fi
-
 AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
 if test "x$DBE" = xyes; then
 	AC_DEFINE(DBE, 1, [Support DBE extension])
diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c
index 2995625..7d20868 100644
--- a/hw/xfree86/dixmods/extmod/modinit.c
+++ b/hw/xfree86/dixmods/extmod/modinit.c
@@ -47,15 +47,6 @@ static ExtensionModule extensionModules[] = {
 	NULL
     },
 #endif
-#ifdef MULTIBUFFER
-    {
-	MultibufferExtensionInit,
-	MULTIBUFFER_PROTOCOL_NAME,
-	&noMultibufferExtension,
-	NULL,
-	NULL
-    },
-#endif
 #ifdef SCREENSAVER
     {
 	ScreenSaverExtensionInit,
diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
index 6210526..1154e46 100644
--- a/hw/xfree86/dixmods/extmod/modinit.h
+++ b/hw/xfree86/dixmods/extmod/modinit.h
@@ -9,11 +9,6 @@
 
 #include <X11/extensions/shapeproto.h>
 
-#ifdef MULTIBUFFER
-extern void MultibufferExtensionInit(INITARGS);
-#include <X11/extensions/multibufproto.h>
-#endif
-
 #ifdef XTEST
 extern void XTestExtensionInit(INITARGS);
 #include <X11/extensions/xtestproto.h>
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 058c8fd..9aff613 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -360,9 +360,6 @@
 /* Support Xv extension */
 #undef XV
 
-/* Build Multibuffer extension */
-#undef MULTIBUFFER
-
 /* Support DRI extension */
 #undef XF86DRI
 
diff --git a/include/globals.h b/include/globals.h
index 52c19a4..82e86c3 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -69,10 +69,6 @@ extern _X_EXPORT Bool noScreenSaverExtension;
 extern _X_EXPORT Bool noMITShmExtension;
 #endif
 
-#ifdef MULTIBUFFER
-extern _X_EXPORT Bool noMultibufferExtension;
-#endif
-
 #ifdef RANDR
 extern _X_EXPORT Bool noRRExtension;
 #endif
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 692be86..a8674a0 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -55,7 +55,6 @@ SOFTWARE.
 
 #ifdef HAVE_DMX_CONFIG_H
 #include <dmx-config.h>
-#undef MULTIBUFFER
 #undef XV
 #undef DBE
 #undef XF86VIDMODE
@@ -116,9 +115,6 @@ extern Bool noScreenSaverExtension;
 #ifdef MITSHM
 extern Bool noMITShmExtension;
 #endif
-#ifdef MULTIBUFFER
-extern Bool noMultibufferExtension;
-#endif
 #ifdef RANDR
 extern Bool noRRExtension;
 #endif
@@ -195,9 +191,6 @@ typedef void (*InitExtension)(INITARGS);
 #ifdef MITSHM
 extern void ShmExtensionInit(INITARGS);
 #endif
-#ifdef MULTIBUFFER
-extern void MultibufferExtensionInit(INITARGS);
-#endif
 #ifdef PANORAMIX
 extern void PanoramiXExtensionInit(INITARGS);
 #endif
@@ -308,9 +301,6 @@ static ExtensionToggle ExtensionToggleList[] =
 #ifdef MITSHM
     { SHMNAME, &noMITShmExtension },
 #endif
-#ifdef MULTIBUFFER
-    { "Multi-Buffering", &noMultibufferExtension },
-#endif
 #ifdef RANDR
     { "RANDR", &noRRExtension },
 #endif
@@ -416,9 +406,6 @@ InitExtensions(int argc, char *argv[])
 #ifdef MITSHM
     if (!noMITShmExtension) ShmExtensionInit();
 #endif
-#ifdef MULTIBUFFER
-    if (!noMultibufferExtension) MultibufferExtensionInit();
-#endif
     XInputExtensionInit();
 #ifdef XTEST
     if (!noTestExtensions) XTestExtensionInit();
diff --git a/os/utils.c b/os/utils.c
index 13d3b3f..127b47b 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -148,9 +148,6 @@ Bool noScreenSaverExtension = FALSE;
 #ifdef MITSHM
 Bool noMITShmExtension = FALSE;
 #endif
-#ifdef MULTIBUFFER
-Bool noMultibufferExtension = FALSE;
-#endif
 #ifdef RANDR
 Bool noRRExtension = FALSE;
 #endif
commit 28b7b2b8d02d975480080865f0dddebcaa2f7968
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Apr 19 09:26:10 2010 -0700

    unifdef -B -DRENDER to always include RENDER code
    
    This patch was created with:
    
    git ls-files '*.[ch]' | while read f; do unifdef -B -DRENDER -o $f $f; done
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index cfeba01..96eb8f9 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -52,9 +52,7 @@ Equipment Corporation.
 #include "globals.h"
 #include "servermd.h"
 #include "resource.h"
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 #include "modinit.h"
 #include "protocol-versions.h"
 
@@ -589,9 +587,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
     ProcVector[X_StoreColors] = PanoramiXStoreColors;
     ProcVector[X_StoreNamedColor] = PanoramiXStoreNamedColor;
 
-#ifdef RENDER
     PanoramiXRenderInit ();
-#endif
 }
 
 extern Bool CreateConnectionBlock(void);
@@ -891,9 +887,7 @@ static void PanoramiXResetProc(ExtensionEntry* extEntry)
 {
     int		i;
 
-#ifdef RENDER
     PanoramiXRenderReset ();
-#endif
     screenInfo.numScreens = PanoramiXNumScreens;
     for (i = 256; i--; )
 	ProcVector[i] = SavedProcVector[i];
diff --git a/Xext/panoramiX.h b/Xext/panoramiX.h
index cca4c52..463a994 100644
--- a/Xext/panoramiX.h
+++ b/Xext/panoramiX.h
@@ -69,11 +69,9 @@ typedef struct {
 	struct {
 	    Bool shared;
 	} pix;
-#ifdef RENDER
 	struct {
 	    Bool root;
 	} pict;
-#endif
 	char raw_data[4];
     } u;
 } PanoramiXRes;
diff --git a/exa/exa.c b/exa/exa.c
index 590d9a5..dcfa4b3 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -753,9 +753,7 @@ static Bool
 exaCloseScreen(int i, ScreenPtr pScreen)
 {
     ExaScreenPriv(pScreen);
-#ifdef RENDER
     PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     if (ps->Glyphs == exaGlyphs)
 	exaGlyphsFini(pScreen);
@@ -778,7 +776,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     unwrap(pExaScr, pScreen, ChangeWindowAttributes);
     unwrap(pExaScr, pScreen, BitmapToRegion);
     unwrap(pExaScr, pScreen, CreateScreenResources);
-#ifdef RENDER
     if (ps) {
 	unwrap(pExaScr, ps, Composite);
 	if (pExaScr->SavedGlyphs)
@@ -787,7 +784,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
 	unwrap(pExaScr, ps, Triangles);
 	unwrap(pExaScr, ps, AddTraps);
     }
-#endif
 
     xfree (pExaScr);
 
@@ -825,9 +821,7 @@ exaDriverInit (ScreenPtr		pScreen,
                ExaDriverPtr	pScreenInfo)
 {
     ExaScreenPrivPtr pExaScr;
-#ifdef RENDER
     PictureScreenPtr ps;
-#endif
 
     if (!pScreenInfo)
 	return FALSE;
@@ -895,9 +889,7 @@ exaDriverInit (ScreenPtr		pScreen,
         pScreenInfo->maxPitchPixels = pScreenInfo->maxX;
     }
 
-#ifdef RENDER
     ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
     if (!pExaScr) {
@@ -940,7 +932,6 @@ exaDriverInit (ScreenPtr		pScreen,
     wrap(pExaScr, pScreen, BitmapToRegion, exaBitmapToRegion);
     wrap(pExaScr, pScreen, CreateScreenResources, exaCreateScreenResources);
 
-#ifdef RENDER
     if (ps) {
 	wrap(pExaScr, ps, Composite, exaComposite);
 	if (pScreenInfo->PrepareComposite)
@@ -949,7 +940,6 @@ exaDriverInit (ScreenPtr		pScreen,
 	wrap(pExaScr, ps, Triangles, exaTriangles);
 	wrap(pExaScr, ps, AddTraps, ExaCheckAddTraps);
     }
-#endif
 
 #ifdef MITSHM
     /*
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 21d9646..ed8be31 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -50,10 +50,8 @@
 #include "dix.h"
 #include "fb.h"
 #include "fboverlay.h"
-#ifdef RENDER
 #include "fbpict.h"
 #include "glyphstr.h"
-#endif
 #include "damage.h"
 
 #define DEBUG_TRACE_FALL	0
@@ -166,13 +164,11 @@ typedef struct {
     CreateScreenResourcesProcPtr SavedCreateScreenResources;
     ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
     SourceValidateProcPtr        SavedSourceValidate;
-#ifdef RENDER
     CompositeProcPtr             SavedComposite;
     TrianglesProcPtr		 SavedTriangles;
     GlyphsProcPtr                SavedGlyphs;
     TrapezoidsProcPtr            SavedTrapezoids;
     AddTrapsProcPtr		 SavedAddTraps;
-#endif
     void (*do_migration) (ExaMigrationPtr pixmaps, int npixmaps, Bool can_accel);
     Bool (*pixmap_has_gpu_copy) (PixmapPtr pPixmap);
     void (*do_move_in_pixmap) (PixmapPtr pPixmap);
@@ -499,7 +495,6 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable,
 
 extern const GCOps exaOps;
 
-#ifdef RENDER
 void
 ExaCheckComposite (CARD8      op,
 		  PicturePtr pSrc,
@@ -513,7 +508,6 @@ ExaCheckComposite (CARD8      op,
 		  INT16      yDst,
 		  CARD16     width,
 		  CARD16     height);
-#endif
 
 /* exa_offscreen.c */
 void
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 1b68e1c..b7f383f 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -30,7 +30,6 @@
 
 #include "exa_priv.h"
 
-#ifdef RENDER
 #include "mipict.h"
 
 #if DEBUG_TRACE_FALL
@@ -1072,7 +1071,6 @@ done:
     if (pMask)
 	pMask->repeat = saveMaskRepeat;
 }
-#endif
 
 /**
  * Same as miCreateAlphaPicture, except it uses ExaCheckPolyFillRect instead
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index b4ead7f..db9ce9f 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -23,9 +23,7 @@
 
 #include "exa_priv.h"
 
-#ifdef RENDER
 #include "mipict.h"
-#endif
 
 /*
  * These functions wrap the low-level fb rendering functions and
@@ -617,9 +615,7 @@ ExaCheckComposite (CARD8      op,
                    CARD16     height)
 {
     ScreenPtr pScreen = pDst->pDrawable->pScreen;
-#ifdef RENDER
     PictureScreenPtr	ps = GetPictureScreen(pScreen);
-#endif /* RENDER */
     EXA_PRE_FALLBACK(pScreen);
 
     if (pExaScr->prepare_access_reg) {
@@ -652,7 +648,6 @@ ExaCheckComposite (CARD8      op,
 	    exaPrepareAccess (pMask->pDrawable, EXA_PREPARE_MASK);
     }
 
-#ifdef RENDER
     swap(pExaScr, ps, Composite);
     ps->Composite (op,
                  pSrc,
@@ -667,7 +662,6 @@ ExaCheckComposite (CARD8      op,
                  width,
                  height);
     swap(pExaScr, ps, Composite);
-#endif /* RENDER */
     if (pMask && pMask->pDrawable != NULL)
 	exaFinishAccess (pMask->pDrawable, EXA_PREPARE_MASK);
     if (pSrc->pDrawable != NULL)
@@ -692,19 +686,15 @@ ExaCheckAddTraps (PicturePtr	pPicture,
 		  xTrap		*traps)
 {
     ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-#ifdef RENDER
     PictureScreenPtr	ps = GetPictureScreen(pScreen);
-#endif /* RENDER */
     EXA_PRE_FALLBACK(pScreen);
 
     EXA_FALLBACK(("to pict %p (%c)\n",
 		  exaDrawableLocation(pPicture->pDrawable)));
     exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
-#ifdef RENDER
     swap(pExaScr, ps, AddTraps);
     ps->AddTraps (pPicture, x_off, y_off, ntrap, traps);
     swap(pExaScr, ps, AddTraps);
-#endif /* RENDER */
     exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
     EXA_POST_FALLBACK(pScreen);
 }
diff --git a/fb/fb.h b/fb/fb.h
index 02d6c03..91c91ee 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -41,11 +41,7 @@
 #include "mi.h"
 #include "migc.h"
 #include "mibstore.h"
-#ifdef RENDER
 #include "picturestr.h"
-#else
-#include "picture.h"
-#endif
 
 #ifdef FB_ACCESS_WRAPPER
 
diff --git a/fb/fbpict.c b/fb/fbpict.c
index dddfce8..896d33e 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -31,8 +31,6 @@
 
 #include "fb.h"
 
-#ifdef RENDER
-
 #include "picturestr.h"
 #include "mipict.h"
 #include "fbpict.h"
@@ -203,8 +201,6 @@ fbCompositeGeneral (CARD8	op,
 			width, height);
 }
 
-#endif /* RENDER */
-
 static pixman_image_t *
 create_solid_fill_image (PicturePtr pict)
 {
@@ -472,8 +468,6 @@ Bool
 fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
 {
 
-#ifdef RENDER
-
     PictureScreenPtr    ps;
 
     if (!miPictureInit (pScreen, formats, nformats))
@@ -486,7 +480,5 @@ fbPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     ps->AddTraps = fbAddTraps;
     ps->AddTriangles = fbAddTriangles;
 
-#endif /* RENDER */
-
     return TRUE;
 }
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index 515e2e1..9f5c39f 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -26,8 +26,6 @@
 
 #include "fb.h"
 
-#ifdef RENDER
-
 #include "picturestr.h"
 #include "mipict.h"
 #include "renderedge.h"
@@ -160,4 +158,3 @@ fbAddTriangles (PicturePtr  pPicture,
     }
 }
 
-#endif /* RENDER */
diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index 6ebd00e..fbb8b96 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -62,9 +62,7 @@
 #include "globals.h"
 #include "scrnintstr.h"
 
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 #ifdef GLXEXT
 #include <GL/glx.h>
@@ -233,7 +231,6 @@ typedef struct _DMXScreenInfo {
 
     SetShapeProcPtr                SetShape;
 
-#ifdef RENDER
     CreatePictureProcPtr           CreatePicture;
     DestroyPictureProcPtr          DestroyPicture;
     ChangePictureClipProcPtr       ChangePictureClip;
@@ -254,7 +251,6 @@ typedef struct _DMXScreenInfo {
     TrianglesProcPtr               Triangles;
     TriStripProcPtr                TriStrip;
     TriFanProcPtr                  TriFan;
-#endif
 } DMXScreenInfo;
 
 /* Global variables available to all Xserver/hw/dmx routines. */
diff --git a/hw/dmx/dmxclient.h b/hw/dmx/dmxclient.h
index 147d14e..c45f71f 100644
--- a/hw/dmx/dmxclient.h
+++ b/hw/dmx/dmxclient.h
@@ -86,10 +86,8 @@ typedef XID           KeySym64;
 
 #include <X11/extensions/shape.h>
 
-#ifdef RENDER
 #include <X11/extensions/Xrender.h>
 #undef PictFormatType
-#endif
 
 #include <X11/extensions/XKB.h>
 #include "xkbstr.h"
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 2266041..4e55533 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -53,9 +53,7 @@
 #include "dmxgc.h"
 #include "dmxfont.h"
 #include "dmxcmap.h"
-#ifdef RENDER
 #include "dmxpict.h"
-#endif
 #include "dmxinput.h"
 #include "dmxsync.h"
 #include "dmxscrinit.h"
@@ -896,14 +894,12 @@ static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
 	if (pCmap->pScreen->myNum == scrnNum)
 	    (void)dmxBECreateColormap((ColormapPtr)value);
 #if 0
-#ifdef RENDER
     /* TODO: Recreate Picture and GlyphSet resources */
     } else if ((type & TypeMask) == (PictureType & TypeMask)) {
 	/* Picture resources are created when windows are created */
     } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
 	dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
 #endif
-#endif
     } else {
 	/* Other resource types??? */
     }
@@ -1057,7 +1053,6 @@ static Bool dmxCompareScreens(DMXScreenInfo *new, DMXScreenInfo *old)
     return TRUE;
 }
 
-#ifdef RENDER
 /** Restore Render's picture */
 static void dmxBERestoreRenderPict(pointer value, XID id, pointer n)
 {
@@ -1164,7 +1159,6 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n)
     free(gids);
     free(glyphs);    
 }
-#endif
 
 /** Reattach previously detached back-end screen. */
 int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
@@ -1284,7 +1278,6 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
     /* Create window hierarchy (top down) */
     dmxBECreateWindowTree(idx);
 
-#ifdef RENDER
     /* Restore the picture state for RENDER */
     for (i = currentMaxClients; --i >= 0; )
 	if (clients[i])
@@ -1296,7 +1289,6 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr)
 	if (clients[i])
 	    FindClientResourcesByType(clients[i],GlyphSetType, 
 				      dmxBERestoreRenderGlyph,(pointer)idx);
-#endif
 
     /* Refresh screen by generating exposure events for all windows */
     dmxForceExposures(idx);
@@ -1482,7 +1474,6 @@ static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
 	ColormapPtr  pCmap = value;
 	if (pCmap->pScreen->myNum == scrnNum)
 	    dmxBEFreeColormap((ColormapPtr)value);
-#ifdef RENDER
     } else if ((type & TypeMask) == (PictureType & TypeMask)) {
 	PicturePtr  pPict = value;
 	if (pPict->pDrawable->pScreen->myNum == scrnNum) {
@@ -1496,7 +1487,6 @@ static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type,
 	}
     } else if ((type & TypeMask) == (GlyphSetType & TypeMask)) {
 	dmxBEFreeGlyphSet(pScreen, (GlyphSetPtr)value);
-#endif
     } else {
 	/* Other resource types??? */
     }
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index f481cf5..cc9ea0b 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -53,9 +53,7 @@
 #include "dmxcb.h"
 #include "dmxprop.h"
 #include "dmxstat.h"
-#ifdef RENDER
 #include "dmxpict.h"
-#endif
 
 #include <X11/Xos.h>                /* For gettimeofday */
 #include "dixstruct.h"
@@ -795,11 +793,9 @@ void InitOutput(ScreenInfo *pScreenInfo, int argc, char *argv[])
      */
     dmxInitFonts();
 
-#ifdef RENDER
     /* Initialize the render extension */
     if (!noRenderExtension)
 	dmxInitRender();
-#endif
 
     /* Initialized things that need timer hooks */
     dmxStatInit();
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index 09734f5..c1beb9b 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -53,9 +53,7 @@
 #include "dmxprop.h"
 #include "dmxdpms.h"
 
-#ifdef RENDER
 #include "dmxpict.h"
-#endif
 
 #include "fb.h"
 #include "mipointer.h"
@@ -78,12 +76,10 @@ static int dmxScreenPrivateKeyIndex;
 DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKeyIndex; /**< Private index for Screens   */
 static int dmxColormapPrivateKeyIndex;
 DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKeyIndex; /**< Private index for Colormaps */
-#ifdef RENDER
 static int dmxPictPrivateKeyIndex;
 DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts     */
 static int dmxGlyphSetPrivateKeyIndex;
 DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */
-#endif
 
 /** Initialize the parts of screen \a idx that require access to the
  *  back-end server. */
@@ -278,9 +274,7 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
 		 dmxScreen->beXDPI,
 		 dmxScreen->scrnWidth,
 		 dmxScreen->beBPP);
-#ifdef RENDER
     (void)dmxPictureInit(pScreen, 0, 0);
-#endif
 
     /* Not yet... */
     pScreen->GetWindowPixmap = NULL;
@@ -435,9 +429,7 @@ Bool dmxCloseScreen(int idx, ScreenPtr pScreen)
 
     /* Reset the proc vectors */
     if (idx == 0) {
-#ifdef RENDER
 	dmxResetRender();
-#endif
 	dmxResetFonts();
     }
 
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index f9e46db..ea2f2c5 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -46,9 +46,7 @@
 #include "dmxvisual.h"
 #include "dmxinput.h"
 #include "dmxextension.h"
-#ifdef RENDER
 #include "dmxpict.h"
-#endif
 
 #include "windowstr.h"
 
@@ -288,9 +286,7 @@ void dmxCreateAndRealizeWindow(WindowPtr pWindow, Bool doSync)
     pWinPriv->window = dmxCreateNonRootWindow(pWindow);
     if (pWinPriv->restacked) dmxDoRestackWindow(pWindow);
     if (pWinPriv->isShaped) dmxDoSetShape(pWindow);
-#ifdef RENDER
     if (pWinPriv->hasPict) dmxCreatePictureList(pWindow);
-#endif
     if (pWinPriv->mapped) XMapWindow(dmxScreen->beDisplay,
 				      pWinPriv->window);
     if (doSync) dmxSync(dmxScreen, False);
@@ -320,9 +316,7 @@ Bool dmxCreateWindow(WindowPtr pWindow)
     pWinPriv->restacked  = FALSE;
     pWinPriv->attribMask = 0;
     pWinPriv->isShaped   = FALSE;
-#ifdef RENDER
     pWinPriv->hasPict    = FALSE;
-#endif
 #ifdef GLXEXT
     pWinPriv->swapGroup  = NULL;
     pWinPriv->barrier    = 0;
@@ -405,10 +399,8 @@ Bool dmxDestroyWindow(WindowPtr pWindow)
 
     DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
 
-#ifdef RENDER
     /* Destroy any picture list associated with this window */
     needSync |= dmxDestroyPictureList(pWindow);
-#endif
 
     /* Destroy window on back-end server */
     needSync |= dmxBEDestroyWindow(pWindow);
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index 353d0a3..740a21f 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -49,9 +49,7 @@ typedef struct _dmxWinPriv {
     Colormap       cmap;
     Visual        *visual;
     Bool           isShaped;
-#ifdef RENDER
     Bool           hasPict;
-#endif
 #ifdef GLXEXT
     void          *swapGroup;
     int            barrier;
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 1902ab8..765bd0e 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -1003,10 +1003,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
     pScreen->BlockHandler	= KdBlockHandler;
     pScreen->WakeupHandler	= KdWakeupHandler;
 
-#ifdef RENDER
     if (!fbPictureInit (pScreen, 0, 0))
 	return FALSE;
-#endif
     if (card->cfuncs->initScreen)
 	if (!(*card->cfuncs->initScreen) (pScreen))
 	    return FALSE;
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index e7dd1d9..0428f0a 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -248,10 +248,8 @@ ddxUseMsg(void)
 {
     ErrorF("-screen scrn WxHxD     set screen's width, height, depth\n");
     ErrorF("-pixdepths list-of-int support given pixmap depths\n");
-#ifdef RENDER
     ErrorF("+/-render		   turn on/of RENDER extension support"
 	   "(default on)\n");
-#endif
     ErrorF("-linebias n            adjust thin line pixelization\n");
     ErrorF("-blackpixel n          pixel value for black\n");
     ErrorF("-whitepixel n          pixel value for white\n");
@@ -904,10 +902,8 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
 
     ret = fbScreenInit(pScreen, pbits, pvfb->width, pvfb->height,
 		       dpix, dpiy, pvfb->paddedWidth,pvfb->bitsPerPixel);
-#ifdef RENDER
     if (ret && Render) 
 	fbPictureInit (pScreen, 0, 0);
-#endif
 
     if (!ret) return FALSE;
 
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 1e9543f..9a2837e 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -67,9 +67,7 @@ extern DeviceAssocRec mouse_assoc;
 
 #include "xkbsrv.h"
 
-#ifdef RENDER
 #include "picture.h"
-#endif
 
 /*
  * These paths define the way the config file search is done.  The escape
@@ -925,7 +923,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
         }
     }
     
-#ifdef RENDER
     {
 	if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
 	    int policy = PictureParseCmapPolicy (s);
@@ -938,7 +935,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
 	    }
 	}
     }
-#endif
 
 #ifdef RANDR
     xf86Info.disableRandR = FALSE;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 71ac9a9..03a29ea 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -74,9 +74,7 @@
 #include "xf86DDC.h"
 #include "xf86Xinput.h"
 #include "xf86InPriv.h"
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 #include "xf86VGAarbiter.h"
 #include "globals.h"
@@ -110,15 +108,9 @@ static PixmapFormatRec formats[MAXFORMATS] = {
 	{ 15,	16,	BITMAP_SCANLINE_PAD },
 	{ 16,	16,	BITMAP_SCANLINE_PAD },
 	{ 24,	32,	BITMAP_SCANLINE_PAD },
-#ifdef RENDER
 	{ 32,	32,	BITMAP_SCANLINE_PAD },
-#endif
 };
-#ifdef RENDER
 static int numFormats = 7;
-#else
-static int numFormats = 6;
-#endif
 static Bool formatsDone = FALSE;
 
 #ifndef OSNAME
@@ -1082,7 +1074,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 		    xf86Screens[i]->pScreen->CreateWindow);
       xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
 
-#ifdef RENDER
     if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
     {
 	xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
@@ -1092,7 +1083,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 				  SubPixelHorizontalRGB : SubPixelNone) :
 				 SubPixelUnknown);
     }
-#endif
 #ifdef RANDR
     if (!xf86Info.disableRandR)
 	xf86RandRInit (screenInfo.screens[scr_index]);
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index cd45cd1..52a8b9a 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -151,9 +151,7 @@ xf86VGAarbiterWrapFunctions(void)
     ScrnInfoPtr pScrn;
     VGAarbiterScreenPtr pScreenPriv;
     miPointerScreenPtr PointPriv;
-#ifdef RENDER
     PictureScreenPtr    ps;
-#endif
     ScreenPtr pScreen;
     int vga_count, i;
 
@@ -173,9 +171,7 @@ xf86VGAarbiterWrapFunctions(void)
 
     for (i = 0; i < xf86NumScreens; i++) {
         pScreen = xf86Screens[i]->pScreen;
-#ifdef RENDER
         ps = GetPictureScreenIfSet(pScreen);
-#endif
         pScrn = xf86Screens[pScreen->myNum];
         PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
 
@@ -204,11 +200,9 @@ xf86VGAarbiterWrapFunctions(void)
         WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor);
         WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor);
         WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition);
-#ifdef RENDER
         WRAP_PICT(Composite,VGAarbiterComposite);
         WRAP_PICT(Glyphs,VGAarbiterGlyphs);
         WRAP_PICT(CompositeRects,VGAarbiterCompositeRects);
-#endif
         WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame);
         WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode);
         WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT);
@@ -230,9 +224,7 @@ VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
         &pScreen->devPrivates, VGAarbiterScreenKey);
     miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
         &pScreen->devPrivates, miPointerScreenKey);
-#ifdef RENDER
     PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     UNWRAP_SCREEN(CreateGC);
     UNWRAP_SCREEN(CloseScreen);
@@ -248,11 +240,9 @@ VGAarbiterCloseScreen (int i, ScreenPtr pScreen)
     UNWRAP_SCREEN(UnrealizeCursor);
     UNWRAP_SCREEN(RecolorCursor);
     UNWRAP_SCREEN(SetCursorPosition);
-#ifdef RENDER
     UNWRAP_PICT(Composite);
     UNWRAP_PICT(Glyphs);
     UNWRAP_PICT(CompositeRects);
-#endif
     UNWRAP_SCREEN_INFO(AdjustFrame);
     UNWRAP_SCREEN_INFO(SwitchMode);
     UNWRAP_SCREEN_INFO(EnterVT);
@@ -1048,7 +1038,6 @@ VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
     SPRITE_EPILOG;
 }
 
-#ifdef RENDER
 static void
 VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
          PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask,
@@ -1097,7 +1086,6 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe
     VGAPut();
     PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
 }
-#endif
 #else
 /* dummy functions */
 void xf86VGAarbiterInit(void) {}
diff --git a/hw/xfree86/common/xf86VGAarbiterPriv.h b/hw/xfree86/common/xf86VGAarbiterPriv.h
index 40d4368..9b4a597 100644
--- a/hw/xfree86/common/xf86VGAarbiterPriv.h
+++ b/hw/xfree86/common/xf86VGAarbiterPriv.h
@@ -43,9 +43,7 @@
 #include "xf86str.h"
 #include "mipointer.h"
 #include "mipointrst.h"
-#ifdef RENDER
 # include "picturestr.h"
-#endif
 
 
 #define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
@@ -139,11 +137,9 @@ typedef struct _VGAarbiterScreen {
     void                        (*LeaveVT)(int, int);
     void                        (*FreeScreen)(int, int);
     miPointerSpriteFuncPtr      miSprite;
-#ifdef RENDER
     CompositeProcPtr            Composite;
     GlyphsProcPtr               Glyphs;
     CompositeRectsProcPtr       CompositeRects;
-#endif
 } VGAarbiterScreenRec, *VGAarbiterScreenPtr;
 
 typedef struct _VGAarbiterGC {
@@ -254,7 +250,6 @@ static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScree
 static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
 
 
-#ifdef RENDER
 static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
     PicturePtr pDst, INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
     INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
@@ -263,4 +258,3 @@ static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
     list, GlyphPtr *glyphs);
 static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor
     *color, int nRect, xRectangle *rects);
-#endif
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 860e520..1ccaffc 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -42,9 +42,7 @@
 #include "X11/extensions/render.h"
 #include "X11/extensions/dpmsconst.h"
 #include "X11/Xatom.h"
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 #include "xf86xv.h"
 
@@ -184,7 +182,6 @@ xf86CrtcInUse (xf86CrtcPtr crtc)
 void
 xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
 {
-#ifdef RENDER
     int			subpixel_order = SubPixelUnknown;
     Bool		has_none = FALSE;
     ScrnInfoPtr		scrn = xf86Screens[pScreen->myNum];
@@ -243,7 +240,6 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
     if (subpixel_order == SubPixelUnknown && has_none)
 	subpixel_order = SubPixelNone;
     PictureSetSubpixelOrder (pScreen, subpixel_order);
-#endif
 }
 
 /**
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index e2e174e..f90ecc2 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -41,9 +41,7 @@
 #include "X11/extensions/render.h"
 #include "X11/extensions/dpmsconst.h"
 #include "X11/Xatom.h"
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 #include "cursorstr.h"
 #include "inputstr.h"
 
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index 9c9aa0d..1c81701 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -27,9 +27,7 @@
 #include "xf86str.h"
 #include "shadowfb.h"
 
-#ifdef RENDER
 # include "picturestr.h"
-#endif
 
 static Bool ShadowCloseScreen (int i, ScreenPtr pScreen);
 static void ShadowCopyWindow(
@@ -51,7 +49,6 @@ static Bool ShadowModifyPixmapHeader(
 static Bool ShadowEnterVT(int index, int flags);
 static void ShadowLeaveVT(int index, int flags);
 
-#ifdef RENDER
 static void ShadowComposite(
     CARD8 op,
     PicturePtr pSrc,
@@ -66,7 +63,6 @@ static void ShadowComposite(
     CARD16 width,
     CARD16 height
 );
-#endif /* RENDER */
 
 
 typedef struct {
@@ -77,9 +73,7 @@ typedef struct {
   CopyWindowProcPtr			CopyWindow;
   CreateGCProcPtr			CreateGC;
   ModifyPixmapHeaderProcPtr		ModifyPixmapHeader;
-#ifdef RENDER
   CompositeProcPtr Composite;
-#endif /* RENDER */
   Bool				(*EnterVT)(int, int);
   void				(*LeaveVT)(int, int);
   Bool				vtSema;
@@ -164,9 +158,7 @@ ShadowFBInit2 (
 ){
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     ShadowScreenPtr pPriv;
-#ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-#endif /* RENDER */
 
     if(!preRefreshArea && !postRefreshArea) return FALSE;
     
@@ -199,12 +191,10 @@ ShadowFBInit2 (
     pScrn->EnterVT = ShadowEnterVT;
     pScrn->LeaveVT = ShadowLeaveVT;
 
-#ifdef RENDER
     if(ps) {
       pPriv->Composite = ps->Composite;
       ps->Composite = ShadowComposite;
     }
-#endif /* RENDER */
 
     return TRUE;
 }
@@ -251,9 +241,7 @@ ShadowCloseScreen (int i, ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
-#ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-#endif /* RENDER */
 
     pScreen->CloseScreen = pPriv->CloseScreen;
     pScreen->CopyWindow = pPriv->CopyWindow;
@@ -263,11 +251,9 @@ ShadowCloseScreen (int i, ScreenPtr pScreen)
     pScrn->EnterVT = pPriv->EnterVT;
     pScrn->LeaveVT = pPriv->LeaveVT;
 
-#ifdef RENDER
     if(ps) {
         ps->Composite = pPriv->Composite;
     }
-#endif /* RENDER */
 
     xfree((pointer)pPriv);
 
@@ -355,7 +341,6 @@ ShadowModifyPixmapHeader(
     return retval;
 }
 
-#ifdef RENDER
 static void
 ShadowComposite(
     CARD8 op,
@@ -408,7 +393,6 @@ ShadowComposite(
         (*pPriv->postRefresh)(pPriv->pScrn, 1, &box);
     }
 }
-#endif /* RENDER */
 
 /**********************************************************/
 
diff --git a/hw/xfree86/xaa/xaa.h b/hw/xfree86/xaa/xaa.h
index 7db6b95..2af954f 100644
--- a/hw/xfree86/xaa/xaa.h
+++ b/hw/xfree86/xaa/xaa.h
@@ -108,9 +108,7 @@
 #include "regionstr.h"
 #include "xf86fbman.h"
 
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 /* Flags */
 #define PIXMAP_CACHE			0x00000001
@@ -1251,7 +1249,6 @@ typedef struct _XAAInfoRec {
 
    CARD32 FullPlanemasks[32];
 
-#ifdef RENDER
    Bool (*Composite) (
    	CARD8      op,
         PicturePtr pSrc,
@@ -1336,13 +1333,10 @@ typedef struct _XAAInfoRec {
    CARD32 * CPUToScreenTextureFormats;
 
 
-#endif
-
    /* these were added for 4.3.0 */
    BoxRec SolidLineLimits;
    BoxRec DashedLineLimits;
 
-#ifdef RENDER
    /* These were added for X.Org 6.8.0 */
    Bool (*SetupForCPUToScreenAlphaTexture2) (
 	ScrnInfoPtr	pScrn,
@@ -1373,7 +1367,6 @@ typedef struct _XAAInfoRec {
 	int		flags
    );
    CARD32 *CPUToScreenTextureDstFormats;
-#endif /* RENDER */
 } XAAInfoRec, *XAAInfoRecPtr;
 
 #define SET_SYNC_FLAG(infoRec)	(infoRec)->NeedToSync = TRUE
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 2ce2d90..7d4583d 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -100,9 +100,7 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     XAAScreenPtr pScreenPriv;
     int i;
-#ifdef RENDER
     PictureScreenPtr    ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     /* Return successfully if no acceleration wanted */
     if (!infoRec)
@@ -173,7 +171,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
     pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess;
 
     pScreenPriv->WindowExposures = pScreen->WindowExposures;
-#ifdef RENDER
     if (ps)
     {
 	pScreenPriv->Composite = ps->Composite;
@@ -181,7 +178,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 	pScreenPriv->Glyphs = ps->Glyphs;
 	ps->Glyphs = XAAGlyphs;
     }
-#endif    
     if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)
         XAASetupOverlay8_32Planar(pScreen);
 
diff --git a/hw/xfree86/xaa/xaaInitAccel.c b/hw/xfree86/xaa/xaaInitAccel.c
index 157325e..6f3d622 100644
--- a/hw/xfree86/xaa/xaaInitAccel.c
+++ b/hw/xfree86/xaa/xaaInitAccel.c
@@ -1251,7 +1251,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
 	   infoRec->ComputeDash = XAAComputeDash;
     }
 
-#ifdef RENDER
     {
 	Bool haveTexture = infoRec->CPUToScreenTextureFormats &&
 			   infoRec->CPUToScreenTextureDstFormats &&
@@ -1271,7 +1270,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
             infoRec->Glyphs = XAADoGlyphs;
         }	
     }
-#endif
 
     /************  Validation Functions **************/
 
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 57d8aa3..f332614 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -260,7 +260,6 @@ typedef struct _XAAStateWrapRec {
    GetImageProcPtr GetImage;
    GetSpansProcPtr GetSpans;
    CopyWindowProcPtr CopyWindow;
-#ifdef RENDER
    Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op,
                                            CARD16 red, CARD16 green,
                                            CARD16 blue, CARD16 alpha,
@@ -271,7 +270,6 @@ typedef struct _XAAStateWrapRec {
                                       CARD32 srcFormat, CARD32 dstFormat,
                                       CARD8 *texPtr, int texPitch,
                                       int width, int height, int flags);
-#endif
 } XAAStateWrapRec, *XAAStateWrapPtr;
 
 static int XAAStateKeyIndex;
@@ -1457,7 +1455,6 @@ static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
 			     prgnSrc);
 }
 
-#ifdef RENDER
 static Bool XAAStateWrapSetupForCPUToScreenAlphaTexture2(ScrnInfoPtr pScrn,
                                                          int op, CARD16 red,
                                                          CARD16 green,
@@ -1494,7 +1491,6 @@ static Bool XAAStateWrapSetupForCPUToScreenTexture2(ScrnInfoPtr pScrn, int op,
                                                     dstFormat, texPtr, texPitch,
 						    width, height, flags);
 }
-#endif
 
 /* Setup Function */
 Bool
@@ -1624,9 +1620,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
    XAA_STATE_WRAP(GetImage);
    XAA_STATE_WRAP(GetSpans);
    XAA_STATE_WRAP(CopyWindow);
-#ifdef RENDER
    XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
    XAA_STATE_WRAP(SetupForCPUToScreenTexture2);
-#endif
    return TRUE;
 }
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index 8841894..d640988 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -62,10 +62,8 @@ typedef struct {
     UninstallColormapProcPtr	UninstallColormap;
     ListInstalledColormapsProcPtr ListInstalledColormaps;
     StoreColorsProcPtr		StoreColors;
-#ifdef RENDER
     CompositeProcPtr		Composite;
     GlyphsProcPtr		Glyphs;
-#endif    
 
     CloseScreenProcPtr		wrapCloseScreen;
     CreateScreenResourcesProcPtr wrapCreateScreenResources;
@@ -79,10 +77,8 @@ typedef struct {
     UninstallColormapProcPtr	wrapUninstallColormap;
     ListInstalledColormapsProcPtr wrapListInstalledColormaps;
     StoreColorsProcPtr		wrapStoreColors;
-#ifdef RENDER
     CompositeProcPtr		wrapComposite;
     GlyphsProcPtr		wrapGlyphs;
-#endif    
     int depth;
 } xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr;
 
@@ -270,9 +266,7 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
 {
     Bool ret;
     xaaWrapperScrPrivPtr pScrPriv;
-#ifdef RENDER
     PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
 	return FALSE;
@@ -293,12 +287,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
     get (pScrPriv, pScreen, UninstallColormap, wrapUninstallColormap);
     get (pScrPriv, pScreen, ListInstalledColormaps, wrapListInstalledColormaps);
     get (pScrPriv, pScreen, StoreColors, wrapStoreColors);
-#ifdef RENDER
     if (ps) {
 	get (pScrPriv, ps, Glyphs, wrapGlyphs);
 	get (pScrPriv, ps, Composite, wrapComposite);
     }
-#endif
     if (!(ret = XAAInit(pScreen,infoPtr)))
 	return FALSE;
     
@@ -317,12 +309,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
 	  xaaWrapperListInstalledColormaps);
     wrap (pScrPriv, pScreen, StoreColors, xaaWrapperStoreColors);
 
-#ifdef RENDER
     if (ps) {
 	wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs);
 	wrap (pScrPriv, ps, Composite, xaaWrapperComposite);
     }
-#endif
     pScrPriv->depth = depth;
     dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv);
 
@@ -438,7 +428,6 @@ xaaWrapperDestroyClip(GCPtr pGC)
     XAAWRAPPER_GC_FUNC_EPILOGUE (pGC);
 }
 
-#ifdef RENDER
 static void
 xaaWrapperComposite (CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
 	     INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask,
@@ -470,7 +459,6 @@ xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
     wrap (pScrPriv, ps, Glyphs, xaaWrapperGlyphs);
 
 }
-#endif
 
 void
 XAASync(ScreenPtr pScreen)
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 5e3d373..129c1d6 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -10,9 +10,7 @@
 #include "xf86fbman.h"
 #include "xaa.h"
 #include "mi.h"
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 #define GCWhenForced		(GCArcMode << 1)
 
@@ -55,10 +53,8 @@ typedef struct _XAAScreen {
    void                		(*LeaveVT)(int, int);
    int				(*SetDGAMode)(int, int, DGADevicePtr);
    void				(*EnableDisableFBAccess)(int, Bool);
-#ifdef RENDER
     CompositeProcPtr            Composite;
     GlyphsProcPtr               Glyphs;
-#endif
 } XAAScreenRec, *XAAScreenPtr;
 
 #define	OPS_ARE_PIXMAP		0x00000001
@@ -1539,7 +1535,6 @@ extern _X_EXPORT void XAARemoveAreaCallback(FBAreaPtr area);
 extern _X_EXPORT void XAAMoveOutOffscreenPixmap(PixmapPtr pPix);
 extern _X_EXPORT Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
 
-#ifdef RENDER
 extern _X_EXPORT void
 XAAComposite (CARD8      op,
 	      PicturePtr pSrc,
@@ -1627,8 +1622,6 @@ XAAGetPixelFromRGBA (
     CARD32 format
 );
 
-#endif
-
 /* XXX should be static */
 extern _X_EXPORT GCOps XAAFallbackOps;
 extern _X_EXPORT GCOps *XAAGetFallbackOps(void);
diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h
index 857dbc3..86ba003 100644
--- a/hw/xfree86/xaa/xaawrap.h
+++ b/hw/xfree86/xaa/xaawrap.h
@@ -61,14 +61,12 @@
 #include <xorg-config.h>
 #endif
 
-#ifdef RENDER
 #define XAA_RENDER_PROLOGUE(pScreen,field)\
     (GetPictureScreen(pScreen)->field = \
      ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
 
 #define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
     (GetPictureScreen(pScreen)->field = wrapper)
-#endif
 
 /* This also works fine for drawables */
 
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index d3f4488..1fb158b 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -240,11 +240,9 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv
         return FALSE;
     }
 
-#ifdef RENDER
     if (! fbPictureInit(pScreen, 0, 0)) {
         return FALSE;
     }
-#endif
 
 #ifdef MITSHM
     ShmRegisterFbFuncs(pScreen);
diff --git a/hw/xquartz/mach-startup/launchd_fd.h b/hw/xquartz/mach-startup/launchd_fd.h
index 5083fae..12caf71 100644
--- a/hw/xquartz/mach-startup/launchd_fd.h
+++ b/hw/xquartz/mach-startup/launchd_fd.h
@@ -33,4 +33,4 @@
 
 int launchd_display_fd(void);
 
-#endif /* _XQUARTZ_LAUNCHD_FD_H_ */
\ No newline at end of file
+#endif /* _XQUARTZ_LAUNCHD_FD_H_ */
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 175cd9d..fd286de 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -155,9 +155,7 @@ static PixmapFormatRec g_PixmapFormats[] = {
   { 15,   16,     BITMAP_SCANLINE_PAD },
   { 16,   16,     BITMAP_SCANLINE_PAD },
   { 24,   32,     BITMAP_SCANLINE_PAD },
-#ifdef RENDER
   { 32,   32,     BITMAP_SCANLINE_PAD }
-#endif
 };
 
 const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]);
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 5cda970..b1acd3e 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -183,10 +183,8 @@
 #include "fb.h"
 #include "rootless.h"
 
-#ifdef RENDER
 #include "mipict.h"
 #include "picturestr.h"
-#endif
 
 #ifdef RANDR
 #include "randrstr.h"
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index c8cd646..953548e 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -390,14 +390,12 @@ winFinishScreenInitFB (int index,
   pScreen->blockData = pScreen;
   pScreen->wakeupData = pScreen;
 
-#ifdef RENDER
   /* Render extension initialization, calls miPictureInit */
   if (!fbPictureInit (pScreen, NULL, 0))
     {
       ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n");
       return FALSE;
     }
-#endif
 
 #ifdef RANDR
   /* Initialize resize and rotate support */
diff --git a/hw/xwin/winwin32rootless.c b/hw/xwin/winwin32rootless.c
index c225a44..ac30621 100755
--- a/hw/xwin/winwin32rootless.c
+++ b/hw/xwin/winwin32rootless.c
@@ -894,9 +894,6 @@ winMWExtWMUpdateRegion (RootlessFrameID wid, RegionPtr pDamage)
   SIZE szWin;
   POINT ptSrc;
 #endif
-#if CYGMULTIWINDOW_DEBUG && 0
-  winDebug ("winMWExtWMUpdateRegion (%08x)\n", pRLWinPriv);
-#endif
 #if 0
   szWin.cx = pRLWinPriv->dwWidth;
   szWin.cy = pRLWinPriv->dwHeight;
@@ -938,10 +935,6 @@ winMWExtWMDamageRects (RootlessFrameID wid, int nCount, const BoxRec *pRects,
 {
   win32RootlessWindowPtr pRLWinPriv = (win32RootlessWindowPtr) wid;
   const BoxRec *pEnd;
-#if CYGMULTIWINDOW_DEBUG && 0
-  winDebug ("winMWExtWMDamageRects (%08x, %d, %08x, %d, %d)\n",
-	    pRLWinPriv, nCount, pRects, shift_x, shift_y);
-#endif
 
   for (pEnd = pRects + nCount; pRects < pEnd; pRects++) {
         RECT rcDmg;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 4d7afee..a985c20 100755
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -519,9 +519,6 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
       break;
 
     case WM_MOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
-      winDebug ("winMWExtWMWindowProc - WM_MOUSEMOVE\n");
-#endif
       /* Unpack the client area mouse coordinates */
       ptMouse.x = GET_X_LPARAM(lParam);
       ptMouse.y = GET_Y_LPARAM(lParam);
@@ -576,9 +573,6 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
       return 0;
       
     case WM_NCMOUSEMOVE:
-#if CYGMULTIWINDOW_DEBUG && 0
-      winDebug ("winMWExtWMWindowProc - WM_NCMOUSEMOVE\n");
-#endif
       /*
        * We break instead of returning 0 since we need to call
        * DefWindowProc to get the mouse cursor changes
diff --git a/include/cursor.h b/include/cursor.h
index acc95c3..dadedfd 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -55,9 +55,7 @@ SOFTWARE.
 #define NullCursor ((CursorPtr)NULL)
 
 /* Provide support for alpha composited cursors */
-#ifdef RENDER
 #define ARGB_CURSOR
-#endif
 
 struct _DeviceIntRec;
 
diff --git a/include/globals.h b/include/globals.h
index 52c19a4..c8d79c1 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -77,9 +77,7 @@ extern _X_EXPORT Bool noMultibufferExtension;
 extern _X_EXPORT Bool noRRExtension;
 #endif
 
-#ifdef RENDER
 extern _X_EXPORT Bool noRenderExtension;
-#endif
 
 #ifdef XCSECURITY
 extern _X_EXPORT Bool noSecurityExtension;
diff --git a/mi/miinitext.c b/mi/miinitext.c
index 692be86..1da31eb 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -122,9 +122,7 @@ extern Bool noMultibufferExtension;
 #ifdef RANDR
 extern Bool noRRExtension;
 #endif
-#ifdef RENDER
 extern Bool noRenderExtension;
-#endif
 #ifdef XCSECURITY
 extern Bool noSecurityExtension;
 #endif
@@ -252,9 +250,7 @@ extern void XFree86DRIExtensionInit(INITARGS);
 #ifdef DPMSExtension
 extern void DPMSExtensionInit(INITARGS);
 #endif
-#ifdef RENDER
 extern void RenderExtensionInit(INITARGS);
-#endif
 #ifdef RANDR
 extern void RRExtensionInit(INITARGS);
 #endif
@@ -314,9 +310,7 @@ static ExtensionToggle ExtensionToggleList[] =
 #ifdef RANDR
     { "RANDR", &noRRExtension },
 #endif
-#ifdef RENDER
     { "RENDER", &noRenderExtension },
-#endif
 #ifdef XCSECURITY
     { "SECURITY", &noSecurityExtension },
 #endif
@@ -469,9 +463,7 @@ InitExtensions(int argc, char *argv[])
     /* must be before Render to layer DisplayCursor correctly */
     if (!noXFixesExtension) XFixesExtensionInit();
 #endif
-#ifdef RENDER
     if (!noRenderExtension) RenderExtensionInit();
-#endif
 #ifdef RANDR
     if (!noRRExtension) RRExtensionInit();
 #endif
@@ -524,9 +516,7 @@ static ExtensionModule staticExtensions[] = {
 #ifdef XF86BIGFONT
     { XFree86BigfontExtensionInit, XF86BIGFONTNAME, &noXFree86BigfontExtension, NULL, NULL },
 #endif
-#ifdef RENDER
     { RenderExtensionInit, "RENDER", &noRenderExtension, NULL, NULL },
-#endif
 #ifdef RANDR
     { RRExtensionInit, "RANDR", &noRRExtension, NULL, NULL },
 #endif
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index 74000ff..247cb83 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -49,10 +49,8 @@ static int cwScreenKeyIndex;
 DevPrivateKey cwScreenKey = &cwScreenKeyIndex;
 static int cwWindowKeyIndex;
 DevPrivateKey cwWindowKey = &cwWindowKeyIndex;
-#ifdef RENDER
 static int cwPictureKeyIndex;
 DevPrivateKey cwPictureKey = &cwPictureKeyIndex;
-#endif
 extern GCOps cwGCOps;
 
 static Bool
@@ -477,9 +475,7 @@ void
 miInitializeCompositeWrapper(ScreenPtr pScreen)
 {
     cwScreenPtr pScreenPriv;
-#ifdef RENDER
     Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
-#endif
 
     if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec)))
 	return;
@@ -499,19 +495,15 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
     SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
     SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
 
-#ifdef RENDER
     if (has_render)
 	cwInitializeRender(pScreen);
-#endif
 }
 
 static Bool
 cwCloseScreen (int i, ScreenPtr pScreen)
 {
     cwScreenPtr   pScreenPriv;
-#ifdef RENDER
     PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-#endif
 
     pScreenPriv = (cwScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
 						cwScreenKey);
@@ -521,10 +513,8 @@ cwCloseScreen (int i, ScreenPtr pScreen)
     pScreen->CreateGC = pScreenPriv->CreateGC;
     pScreen->CopyWindow = pScreenPriv->CopyWindow;
 
-#ifdef RENDER
     if (ps)
 	cwFiniRender(pScreen);
-#endif
 
     xfree((pointer)pScreenPriv);
 
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index ae65503..79051df 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -90,7 +90,6 @@ typedef struct {
     GetWindowPixmapProcPtr	GetWindowPixmap;
     SetWindowPixmapProcPtr	SetWindowPixmap;
     
-#ifdef RENDER
     DestroyPictureProcPtr	DestroyPicture;
     ChangePictureClipProcPtr	ChangePictureClip;
     DestroyPictureClipProcPtr	DestroyPictureClip;
@@ -107,7 +106,6 @@ typedef struct {
     TriFanProcPtr		TriFan;
 
     RasterizeTrapezoidProcPtr	RasterizeTrapezoid;
-#endif
 } cwScreenRec, *cwScreenPtr;
 
 extern _X_EXPORT DevPrivateKey cwScreenKey;
diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c
index 6e0c727..dfe2681 100644
--- a/miext/cw/cw_render.c
+++ b/miext/cw/cw_render.c
@@ -30,8 +30,6 @@
 #include "windowstr.h"
 #include "cw.h"
 
-#ifdef RENDER
-
 #define cwPsDecl(pScreen)	\
     PictureScreenPtr	ps = GetPictureScreen (pScreen);	\
     cwScreenPtr		pCwScreen = getCwScreen (pScreen)
@@ -469,4 +467,3 @@ cwFiniRender (ScreenPtr pScreen)
     cwPsUnwrap(TriFan);
 }
 
-#endif /* RENDER */
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 2851aed..de18573 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -596,8 +596,6 @@ damageDestroyClip(GCPtr pGC)
 				  REGION_NOTEMPTY(d->pScreen, \
 						  g->pCompositeClip)))
 
-#ifdef RENDER
-
 #define TRIM_PICTURE_BOX(box, pDst) { \
     BoxPtr extents = &pDst->pCompositeClip->extents;\
     if(box.x1 < extents->x1) box.x1 = extents->x1; \
@@ -774,7 +772,6 @@ damageAddTraps (PicturePtr  pPicture,
     damageRegionProcessPending (pPicture->pDrawable);
     wrap (pScrPriv, ps, AddTraps, damageAddTraps);
 }
-#endif
 
 /**********************************************************/
 
@@ -1882,9 +1879,7 @@ Bool
 DamageSetup (ScreenPtr pScreen)
 {
     DamageScrPrivPtr	pScrPriv;
-#ifdef RENDER
     PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
-#endif
     const DamageScreenFuncsRec miFuncs = {
 	miDamageCreate, miDamageRegister, miDamageUnregister, miDamageDestroy
     };
@@ -1908,13 +1903,11 @@ DamageSetup (ScreenPtr pScreen)
     wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
     wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen);
-#ifdef RENDER
     if (ps) {
 	wrap (pScrPriv, ps, Glyphs, damageGlyphs);
 	wrap (pScrPriv, ps, Composite, damageComposite);
 	wrap (pScrPriv, ps, AddTraps, damageAddTraps);
     }
-#endif
 
     pScrPriv->funcs = miFuncs;
 
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index d7435b2..b224958 100644
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -30,9 +30,7 @@
 #include "damage.h"
 #include "gcstruct.h"
 #include "privates.h"
-#ifdef RENDER
 # include "picturestr.h"
-#endif
 
 typedef struct _damage {
     DamagePtr		pNext;
@@ -72,11 +70,9 @@ typedef struct _damageScrPriv {
     DestroyPixmapProcPtr	DestroyPixmap;
     SetWindowPixmapProcPtr	SetWindowPixmap;
     DestroyWindowProcPtr	DestroyWindow;
-#ifdef RENDER
     CompositeProcPtr		Composite;
     GlyphsProcPtr		Glyphs;
     AddTrapsProcPtr		AddTraps;
-#endif
 
     /* Table of wrappable function pointers */
     DamageScreenFuncsRec	funcs;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index d4a94f8..f44c4e8 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -42,9 +42,7 @@
 
 #include "scrnintstr.h"
 
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 
 // Debug output, or not.
@@ -100,10 +98,8 @@ typedef struct _RootlessScreenRec {
 
     SetShapeProcPtr SetShape;
 
-#ifdef RENDER
     CompositeProcPtr Composite;
     GlyphsProcPtr Glyphs;
-#endif
 
     InstallColormapProcPtr InstallColormap;
     UninstallColormapProcPtr UninstallColormap;
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 7a799d9..5f24946 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -242,8 +242,6 @@ RootlessSourceValidate(DrawablePtr pDrawable, int x, int y, int w, int h)
     SCREEN_WRAP(pDrawable->pScreen, SourceValidate);
 }
 
-#ifdef RENDER
-
 static void
 RootlessComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
                   INT16 xSrc, INT16 ySrc, INT16  xMask, INT16  yMask,
@@ -363,8 +361,6 @@ RootlessGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
     }
 }
 
-#endif // RENDER
-
 
 /*
  * RootlessValidateTree
@@ -698,7 +694,6 @@ RootlessWrap(ScreenPtr pScreen)
 
     WRAP(SetShape);
 
-#ifdef RENDER
     {
         // Composite and Glyphs don't use normal screen wrapping
         PictureScreenPtr ps = GetPictureScreen(pScreen);
@@ -707,7 +702,6 @@ RootlessWrap(ScreenPtr pScreen)
         s->Glyphs = ps->Glyphs;
         ps->Glyphs = RootlessGlyphs;
     }
-#endif
 
     // WRAP(ClearToBackground); fixme put this back? useful for shaped wins?
 
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index ef85c0b..f447305 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -26,9 +26,7 @@
 
 #include "scrnintstr.h"
 
-#ifdef RENDER
 #include "picturestr.h"
-#endif
 
 #include "damage.h"
 #include "damagestr.h"
diff --git a/os/utils.c b/os/utils.c
index 13d3b3f..e622e53 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -120,9 +120,7 @@ __stdcall unsigned long GetTickCount(void);
 
 #include "xkbsrv.h"
 
-#ifdef RENDER
 #include "picture.h"
-#endif
 
 Bool noTestExtensions;
 #ifdef COMPOSITE
@@ -154,9 +152,7 @@ Bool noMultibufferExtension = FALSE;
 #ifdef RANDR
 Bool noRRExtension = FALSE;
 #endif
-#ifdef RENDER
 Bool noRenderExtension = FALSE;
-#endif
 #ifdef XCSECURITY
 Bool noSecurityExtension = FALSE;
 #endif
@@ -517,9 +513,7 @@ void UseMsg(void)
     ErrorF("-nopn                  reject failure to listen on all ports\n");
     ErrorF("-r                     turns off auto-repeat\n");
     ErrorF("r                      turns on auto-repeat \n");
-#ifdef RENDER
     ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
-#endif
     ErrorF("-retro                 start with classic stipple and cursor\n");
     ErrorF("-s #                   screen-saver timeout (minutes)\n");
     ErrorF("-t #                   default pointer threshold (pixels/t)\n");
@@ -920,7 +914,6 @@ ProcessCommandLine(int argc, char *argv[])
 	    else
 		UseMsg();
 	}
-#ifdef RENDER
 	else if ( strcmp( argv[i], "-render" ) == 0)
 	{
 	    if (++i < argc)
@@ -935,7 +928,6 @@ ProcessCommandLine(int argc, char *argv[])
 	    else
 		UseMsg ();
 	}
-#endif
 	else if ( strcmp( argv[i], "+extension") == 0)
 	{
 	    if (++i < argc)
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 975fe33..b163a73 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -47,10 +47,8 @@
 #include "rrtransform.h"
 #include <X11/extensions/randr.h>
 #include <X11/extensions/randrproto.h>
-#ifdef RENDER
 #include <X11/extensions/render.h> 	/* we share subpixel order information */
 #include "picturestr.h"
-#endif
 #include <X11/Xfuncproto.h>
 
 /* required for ABI compatibility for now */
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index 12b9a4a..20066d5 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -99,9 +99,7 @@ RRScanOldConfig (ScreenPtr pScreen, Rotation rotations)
 	    return;
 	RROutputSetCrtcs (output, &crtc, 1);
 	RROutputSetConnection (output, RR_Connected);
-#ifdef RENDER
 	RROutputSetSubpixelOrder (output, PictureGetSubpixelOrder (pScreen));
-#endif
     }
 
     output = pScrPriv->outputs[0];
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 630ff57..26de1e2 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -106,11 +106,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
     se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
     se.root =  pRoot->drawable.id;
     se.window = pWin->drawable.id;
-#ifdef RENDER
     se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
-#else
-    se.subpixelOrder = SubPixelUnknown;
-#endif
 
     se.sequenceNumber = client->sequence;
     se.sizeID = RR10CurrentSizeID (pScreen);
diff --git a/xfixes/region.c b/xfixes/region.c
index 1b4accb..795caf0 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -26,10 +26,8 @@
 
 #include "xfixesint.h"
 #include "scrnintstr.h"
-#ifdef RENDER
 #include <picturestr.h>
 extern int RenderErrBase;
-#endif
 #include <regionstr.h>
 #include <gcstruct.h>
 #include <window.h>
@@ -265,7 +263,6 @@ SProcXFixesCreateRegionFromGC (ClientPtr client)
 int
 ProcXFixesCreateRegionFromPicture (ClientPtr client)
 {
-#ifdef RENDER
     RegionPtr	pRegion;
     PicturePtr	pPicture;
     REQUEST (xXFixesCreateRegionFromPictureReq);
@@ -296,9 +293,6 @@ ProcXFixesCreateRegionFromPicture (ClientPtr client)
 	return BadAlloc;
     
     return(client->noClientException);
-#else
-    return BadRequest;
-#endif
 }
 
 int
@@ -769,7 +763,6 @@ SProcXFixesSetWindowShapeRegion (ClientPtr client)
 int
 ProcXFixesSetPictureClipRegion (ClientPtr client)
 {
-#ifdef RENDER
     PicturePtr		pPicture;
     RegionPtr		pRegion;
     ScreenPtr		pScreen;
@@ -785,9 +778,6 @@ ProcXFixesSetPictureClipRegion (ClientPtr client)
     
     return SetPictureClipRegion (pPicture, stuff->xOrigin, stuff->yOrigin,
 				 pRegion);
-#else
-    return BadRequest;
-#endif
 }
 
 int
commit b3ab978df861c08298f57529e3db980489055c35
Merge: a92b2c2... 0ad022a...
Author: Keith Packard <keithp at keithp.com>
Date:   Sun Apr 18 22:01:40 2010 -0700

    Merge remote branch 'whot/for-keith'

commit 0ad022a729bafa56cc7b5d241f567444a34514ad
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 14 10:54:29 2010 +1000

    xkb: rename XkbFakeDeviceButton and XkbFakeDeviceMotion, move into xkbActions.c
    
    The name XkbDDXFakeDeviceButton and XkbDDXFakeDeviceMotion is somewhat
    misleading, there's no DDX involved in the game at all anymore.
    
    This removes XkbFakeDeviceMotion and XkbFakeDeviceButton from the API where
    it arguably shouldn't have been in the first place.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 239b7a1..a5d25d0 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -768,19 +768,6 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators(
 	CARD32			/* newState */
 );
 
-extern _X_EXPORT void XkbDDXFakePointerMotion(
-	DeviceIntPtr	/* dev */,
- 	unsigned int	/* flags */,
-	int		/* x */,
-	int		/* y */
-);
-
-extern _X_EXPORT void XkbDDXFakeDeviceButton(
-	DeviceIntPtr	/* dev */,
-	Bool		/* press */,
-	int		/* button */
-);
-
 extern _X_EXPORT int XkbDDXTerminateServer(
 	DeviceIntPtr	/* dev */,
 	KeyCode		/* key */,
diff --git a/xkb/Makefile.am b/xkb/Makefile.am
index e54ce59..fb3ccbf 100644
--- a/xkb/Makefile.am
+++ b/xkb/Makefile.am
@@ -5,11 +5,9 @@ AM_CFLAGS = $(DIX_CFLAGS)
 DDX_SRCS = \
         ddxBeep.c \
         ddxCtrls.c \
-        ddxFakeMtn.c \
         ddxLEDs.c \
         ddxLoad.c \
-        ddxList.c \
-        ddxDevBtn.c
+        ddxList.c
 
 DIX_SRCS = \
         xkb.c \
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
deleted file mode 100644
index b8a1255..0000000
--- a/xkb/ddxDevBtn.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/************************************************************
-Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, provided that the above copyright
-notice appear in all copies and that both that copyright
-notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "inputstr.h"
-#include <xkbsrv.h>
-#include "mi.h"
-
-void
-XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
-{
-    EventListPtr        events;
-    int                 nevents, i;
-    DeviceIntPtr        ptr;
-
-    /* If dev is a slave device, and the SD is attached, do nothing. If we'd
-     * post through the attached master pointer we'd get duplicate events.
-     *
-     * if dev is a master keyboard, post through the XTEST device
-     *
-     * if dev is a floating slave, post through the device itself.
-     */
-
-    if (IsMaster(dev))
-        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-    else if (!dev->u.master)
-        ptr = dev;
-    else
-        return;
-
-    events = InitEventList(GetMaximumEventsNum());
-    OsBlockSignals();
-    nevents = GetPointerEvents(events, ptr,
-                               press ? ButtonPress : ButtonRelease, button,
-                               0 /* flags */, 0 /* first */,
-                               0 /* num_val */, NULL);
-    OsReleaseSignals();
-
-    for (i = 0; i < nevents; i++)
-        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
-
-    FreeEventList(events, GetMaximumEventsNum());
-}
diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
deleted file mode 100644
index b383716..0000000
--- a/xkb/ddxFakeMtn.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/************************************************************
-Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, provided that the above copyright
-notice appear in all copies and that both that copyright
-notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be 
-used in advertising or publicity pertaining to distribution 
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability 
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
-THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "inputstr.h"
-#include <xkbsrv.h>
-#include "mi.h"
-
-void
-XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
-{
-    EventListPtr        events;
-    int                 nevents, i;
-    DeviceIntPtr        ptr;
-    int                 gpe_flags = 0;
-
-    if (!dev->u.master)
-        ptr = dev;
-    else
-        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
-
-    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
-        gpe_flags = POINTER_ABSOLUTE;
-    else
-        gpe_flags = POINTER_RELATIVE;
-
-    events = InitEventList(GetMaximumEventsNum());
-    OsBlockSignals();
-    nevents = GetPointerEvents(events, ptr,
-                               MotionNotify, 0,
-                               gpe_flags, 0, 2, (int[]){x, y});
-    OsReleaseSignals();
-
-    for (i = 0; i < nevents; i++)
-        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
-
-    FreeEventList(events, GetMaximumEventsNum());
-}
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 4c7bce2..6a9943f 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -40,11 +40,15 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <xkbsrv.h>
 #include "xkb.h"
 #include <ctype.h>
+#include "mi.h"
 #define EXTENSION_EVENT_BASE 64
 
 static int xkbDevicePrivateKeyIndex;
 DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKeyIndex;
 
+static void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
+static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
+
 void
 xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
                    pointer data)
@@ -479,7 +483,7 @@ int		dx,dy;
 	dx= xkbi->mouseKeysDX;
 	dy= xkbi->mouseKeysDY;
     }
-    XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
+    XkbFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
     return xkbi->desc->ctrls->mk_interval;
 }
 
@@ -507,7 +511,7 @@ Bool	accel;
 	accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
 	x= XkbPtrActionX(&pAction->ptr);
 	y= XkbPtrActionY(&pAction->ptr);
-	XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
+	XkbFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
 	AccessXCancelRepeatKey(xkbi,keycode);
 	xkbi->mouseKeysAccel= accel&&
 		(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
@@ -554,7 +558,7 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
 			((pAction->btn.flags&XkbSA_LockNoLock)==0)) {
 		    xkbi->lockedPtrButtons|= (1<<button);
 		    AccessXCancelRepeatKey(xkbi,keycode);
-		    XkbDDXFakeDeviceButton(xkbi->device, 1, button);
+		    XkbFakeDeviceButton(xkbi->device, 1, button);
 		    filter->upAction.type= XkbSA_NoAction;
 		}
 		break;
@@ -565,12 +569,12 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
 		    if (pAction->btn.count>0) {
 			nClicks= pAction->btn.count;
 			for (i=0;i<nClicks;i++) {
-			    XkbDDXFakeDeviceButton(xkbi->device, 1, button);
-			    XkbDDXFakeDeviceButton(xkbi->device, 0, button);
+			    XkbFakeDeviceButton(xkbi->device, 1, button);
+			    XkbFakeDeviceButton(xkbi->device, 0, button);
 			}
 			filter->upAction.type= XkbSA_NoAction;
 		    }
-		    else XkbDDXFakeDeviceButton(xkbi->device, 1, button);
+		    else XkbFakeDeviceButton(xkbi->device, 1, button);
 		}
 		break;
 	    case XkbSA_SetPtrDflt:
@@ -626,7 +630,7 @@ _XkbFilterPointerBtn(	XkbSrvInfoPtr	xkbi,
 		}
 		xkbi->lockedPtrButtons&= ~(1<<button);
 	    case XkbSA_PtrBtn:
-		XkbDDXFakeDeviceButton(xkbi->device, 0, button);
+		XkbFakeDeviceButton(xkbi->device, 0, button);
 		break;
 	}
 	filter->active = 0;
@@ -964,7 +968,7 @@ int		button;
 		if ((pAction->devbtn.flags&XkbSA_LockNoLock)||
 		    BitIsOn(dev->button->down, button))
 		    return 0;
-		XkbDDXFakeDeviceButton(dev,TRUE,button);
+		XkbFakeDeviceButton(dev,TRUE,button);
 		filter->upAction.type= XkbSA_NoAction;
 		break;
 	    case XkbSA_DeviceBtn:
@@ -972,12 +976,12 @@ int		button;
 		    int nClicks,i;
 		    nClicks= pAction->btn.count;
 		    for (i=0;i<nClicks;i++) {
-			XkbDDXFakeDeviceButton(dev,TRUE,button);
-			XkbDDXFakeDeviceButton(dev,FALSE,button);
+			XkbFakeDeviceButton(dev,TRUE,button);
+			XkbFakeDeviceButton(dev,FALSE,button);
 		    }
 		    filter->upAction.type= XkbSA_NoAction;
 		}
-		else XkbDDXFakeDeviceButton(dev,TRUE,button);
+		else XkbFakeDeviceButton(dev,TRUE,button);
 		break;
 	}
     }
@@ -996,10 +1000,10 @@ int		button;
 		if ((filter->upAction.devbtn.flags&XkbSA_LockNoUnlock)||
 		    !BitIsOn(dev->button->down, button))
 		    return 0;
-		XkbDDXFakeDeviceButton(dev,FALSE,button);
+		XkbFakeDeviceButton(dev,FALSE,button);
 		break;
 	    case XkbSA_DeviceBtn:
-		XkbDDXFakeDeviceButton(dev,FALSE,button);
+		XkbFakeDeviceButton(dev,FALSE,button);
 		break;
 	}
 	filter->active = 0;
@@ -1316,3 +1320,70 @@ xkbStateNotify	sn;
     return;
 }
 
+static void
+XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
+{
+    EventListPtr        events;
+    int                 nevents, i;
+    DeviceIntPtr        ptr;
+    int                 gpe_flags = 0;
+
+    if (!dev->u.master)
+        ptr = dev;
+    else
+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
+
+    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
+        gpe_flags = POINTER_ABSOLUTE;
+    else
+        gpe_flags = POINTER_RELATIVE;
+
+    events = InitEventList(GetMaximumEventsNum());
+    OsBlockSignals();
+    nevents = GetPointerEvents(events, ptr,
+                               MotionNotify, 0,
+                               gpe_flags, 0, 2, (int[]){x, y});
+    OsReleaseSignals();
+
+    for (i = 0; i < nevents; i++)
+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
+
+    FreeEventList(events, GetMaximumEventsNum());
+}
+
+static void
+XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
+{
+    EventListPtr        events;
+    int                 nevents, i;
+    DeviceIntPtr        ptr;
+
+    /* If dev is a slave device, and the SD is attached, do nothing. If we'd
+     * post through the attached master pointer we'd get duplicate events.
+     *
+     * if dev is a master keyboard, post through the XTEST device
+     *
+     * if dev is a floating slave, post through the device itself.
+     */
+
+    if (IsMaster(dev))
+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
+    else if (!dev->u.master)
+        ptr = dev;
+    else
+        return;
+
+    events = InitEventList(GetMaximumEventsNum());
+    OsBlockSignals();
+    nevents = GetPointerEvents(events, ptr,
+                               press ? ButtonPress : ButtonRelease, button,
+                               0 /* flags */, 0 /* first */,
+                               0 /* num_val */, NULL);
+    OsReleaseSignals();
+
+
+    for (i = 0; i < nevents; i++)
+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
+
+    FreeEventList(events, GetMaximumEventsNum());
+}
commit da4e2e382828d7ba460766709368ec6214b286dd
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 14 09:48:53 2010 +1000

    xkb: purge unneeded includes from ddxDevBtn.c
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index b8a222d..b8a1255 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -28,18 +28,9 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <dix-config.h>
 #endif
 
-#include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
 #include "inputstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "eventstr.h"
 #include <xkbsrv.h>
 #include "mi.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
 
 void
 XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
commit f4106c02318fcc4b534224df5b95a58aff555fb4
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Apr 13 14:44:59 2010 +1000

    xkb: use GPE for XKB fake motion events.
    
    Section 4.6.1 of the XKB spec says that "the initial event always moves the
    cursor the distance specified in the action [...]", so skip the
    POINTER_ACCELERATE flag for GPE, it would cause double-acceleration.
    
    Potential regression - GPE expects the coordinates to be either relative or
    both. XKB in theory allows for x to be relative and y to be absolute (or
    vice versa). Let's pretend that scenario has no users.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Simon Thum <simon.thum at gmx.de>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 278ff76..239b7a1 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -769,6 +769,7 @@ extern _X_EXPORT void XkbDDXUpdateDeviceIndicators(
 );
 
 extern _X_EXPORT void XkbDDXFakePointerMotion(
+	DeviceIntPtr	/* dev */,
  	unsigned int	/* flags */,
 	int		/* x */,
 	int		/* y */
diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
index f90d209..b383716 100644
--- a/xkb/ddxFakeMtn.c
+++ b/xkb/ddxFakeMtn.c
@@ -28,91 +28,37 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <dix-config.h>
 #endif
 
-#include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
 #include "inputstr.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
 #include <xkbsrv.h>
-#include <X11/extensions/XI.h>
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-#include "mipointer.h"
-#include "mipointrst.h"
+#include "mi.h"
 
 void
-XkbDDXFakePointerMotion(unsigned flags,int x,int y)
+XkbDDXFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
 {
-int 		   oldX,oldY;
-ScreenPtr	   pScreen, oldScreen;
-
-    GetSpritePosition(inputInfo.pointer, &oldX, &oldY);
-    pScreen = oldScreen = GetSpriteWindow(inputInfo.pointer)->drawable.pScreen;
-
-#ifdef PANORAMIX
-    if (!noPanoramiXExtension) {
-	BoxRec box;
-	int i;
+    EventListPtr        events;
+    int                 nevents, i;
+    DeviceIntPtr        ptr;
+    int                 gpe_flags = 0;
 
-	if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
-							    oldX, oldY, &box)) {
-	    FOR_NSCREENS(i) {
-		if(i == pScreen->myNum)
-		    continue;
-		if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
-				   oldX, oldY, &box)) {
-		    pScreen = screenInfo.screens[i];
-		    break;
-		}
-	    }
-	}
-	oldScreen = pScreen;
-
-	if (flags&XkbSA_MoveAbsoluteX)
-	     oldX=  x;
-	else oldX+= x;
-	if (flags&XkbSA_MoveAbsoluteY)
-	     oldY=  y;
-	else oldY+= y;
+    if (!dev->u.master)
+        ptr = dev;
+    else
+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
 
-	if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
-							    oldX, oldY, &box)) {
-	    FOR_NSCREENS(i) {
-		if(i == pScreen->myNum)
-		    continue;
-		if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
-				   oldX, oldY, &box)) {
-		    pScreen = screenInfo.screens[i];
-		    break;
-		}
-	    }
-	}
-	oldX -= panoramiXdataPtr[pScreen->myNum].x;
-	oldY -= panoramiXdataPtr[pScreen->myNum].y;
-    }
+    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
+        gpe_flags = POINTER_ABSOLUTE;
     else
-#endif
-    {
-	if (flags&XkbSA_MoveAbsoluteX)
-	     oldX=  x;
-	else oldX+= x;
-	if (flags&XkbSA_MoveAbsoluteY)
-	     oldY=  y;
-	else oldY+= y;
+        gpe_flags = POINTER_RELATIVE;
+
+    events = InitEventList(GetMaximumEventsNum());
+    OsBlockSignals();
+    nevents = GetPointerEvents(events, ptr,
+                               MotionNotify, 0,
+                               gpe_flags, 0, 2, (int[]){x, y});
+    OsReleaseSignals();
 
-#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
-	(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
-	    (&pScreen, &oldX, &oldY);
-    }
+    for (i = 0; i < nevents; i++)
+        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
 
-    if (pScreen != oldScreen)
-	NewCurrentScreen(inputInfo.pointer, pScreen, oldX, oldY);
-    if (pScreen->SetCursorPosition)
-	(*pScreen->SetCursorPosition)(inputInfo.pointer, pScreen, oldX, oldY, TRUE);
+    FreeEventList(events, GetMaximumEventsNum());
 }
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 2cdb6fc..4c7bce2 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -479,7 +479,7 @@ int		dx,dy;
 	dx= xkbi->mouseKeysDX;
 	dy= xkbi->mouseKeysDY;
     }
-    XkbDDXFakePointerMotion(xkbi->mouseKeysFlags,dx,dy);
+    XkbDDXFakePointerMotion(xkbi->device, xkbi->mouseKeysFlags,dx,dy);
     return xkbi->desc->ctrls->mk_interval;
 }
 
@@ -507,7 +507,7 @@ Bool	accel;
 	accel= ((pAction->ptr.flags&XkbSA_NoAcceleration)==0);
 	x= XkbPtrActionX(&pAction->ptr);
 	y= XkbPtrActionY(&pAction->ptr);
-	XkbDDXFakePointerMotion(pAction->ptr.flags,x,y);
+	XkbDDXFakePointerMotion(xkbi->device, pAction->ptr.flags,x,y);
 	AccessXCancelRepeatKey(xkbi,keycode);
 	xkbi->mouseKeysAccel= accel&&
 		(xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask);
commit 6c42c8c356be305dc7f3f92ad8d58675da8c2f07
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed Apr 14 10:51:41 2010 +1000

    xkb: Guard against SIGIO updates during PointerKeys.
    
    In theory, an event coming in during GPE could reset our lastSlave, leading
    to rather interesting events lateron.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Simon Thum <simon.thum at gmx.de>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 3bee84b..b8a222d 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -64,11 +64,12 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
         return;
 
     events = InitEventList(GetMaximumEventsNum());
+    OsBlockSignals();
     nevents = GetPointerEvents(events, ptr,
                                press ? ButtonPress : ButtonRelease, button,
                                0 /* flags */, 0 /* first */,
                                0 /* num_val */, NULL);
-
+    OsReleaseSignals();
 
     for (i = 0; i < nevents; i++)
         mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
commit 108457dff816569453a2d88cd72595fa7eb02479
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Apr 13 14:41:07 2010 +1000

    xkb: Post PointerKeys through the XTEST device.
    
    Posting an event through a master device may cause pointer jumps once
    lastSlave == master, caused by double scaling. To avoid this, post the fake
    event generated by XKB through the XTEST device instead.
    
    Fedora bug #560356 <https://bugzilla.redhat.com/560356>
    Tested-by: Andrew McNabb
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 94630d1..3bee84b 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -51,13 +51,13 @@ XkbDDXFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
     /* If dev is a slave device, and the SD is attached, do nothing. If we'd
      * post through the attached master pointer we'd get duplicate events.
      *
-     * if dev is a master keyboard, post through the master pointer.
+     * if dev is a master keyboard, post through the XTEST device
      *
      * if dev is a floating slave, post through the device itself.
      */
 
     if (IsMaster(dev))
-        ptr = GetMaster(dev, MASTER_POINTER);
+        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
     else if (!dev->u.master)
         ptr = dev;
     else
commit a780e5b3638a0ff81301fc68aca15b47ba0befb7
Author: Benjamin Tissoires <tissoire at cena.fr>
Date:   Wed Apr 14 17:27:51 2010 +0200

    xf86ScaleAxis: support for high resolution devices
    
    High resolution devices was generating integer overflow.
    For instance the wacom Cintiq 21UX has an axis value up to
    87000. Thus the term (dSx * (Cx - Rxlow)) is greater than
    MAX_INT32.
    
    Using 64bits integer avoids such problem.
    
    Signed-off-by: Philippe Ribet <ribet at cena.fr>
    Signed-off-by: Benjamin Tissoires <tissoire at cena.fr>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 7723ba6..dba3370 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -86,6 +86,7 @@
 #include "windowstr.h"	/* screenIsSaved */
 
 #include <stdarg.h>
+#include <stdint.h>          /* for int64_t */
 
 #include <X11/Xpoll.h>
 
@@ -1177,12 +1178,11 @@ xf86ScaleAxis(int	Cx,
               int	Rxlow )
 {
     int X;
-    int dSx = Sxhigh - Sxlow;
-    int dRx = Rxhigh - Rxlow;
+    int64_t dSx = Sxhigh - Sxlow;
+    int64_t dRx = Rxhigh - Rxlow;
 
-    dSx = Sxhigh - Sxlow;
     if (dRx) {
-	X = ((dSx * (Cx - Rxlow)) / dRx) + Sxlow;
+	X = (int)(((dSx * (Cx - Rxlow)) / dRx) + Sxlow);
     }
     else {
 	X = 0;


More information about the Xquartz-changes mailing list