xserver: Branch 'XACE-SELINUX' - 88 commits

Eamon Walsh ewalsh at kemper.freedesktop.org
Wed Sep 19 15:19:48 PDT 2007


 .gitignore                                 |   30 +
 GL/Makefile.am                             |    6 
 Xext/Makefile.am                           |    2 
 Xext/mbufbf.c                              |    9 
 afb/Makefile.am                            |    2 
 afb/afb.h                                  |   15 
 afb/afbpntwin.c                            |  128 ----
 afb/afbscrinit.c                           |   13 
 afb/afbwindow.c                            |  167 ------
 cfb/Makefile.am.inc                        |    2 
 cfb/cfb.h                                  |   39 -
 cfb/cfballpriv.c                           |   19 
 cfb/cfbmap.h                               |    6 
 cfb/cfbpntwin.c                            |  768 -----------------------------
 cfb/cfbscrinit.c                           |    4 
 cfb/cfbtile32.c                            |    2 
 cfb/cfbunmap.h                             |    3 
 cfb/cfbwindow.c                            |  185 ------
 composite/compalloc.c                      |   73 ++
 composite/compinit.c                       |    4 
 composite/compint.h                        |    7 
 composite/compwindow.c                     |   19 
 config/dbus.c                              |   18 
 configure.ac                               |  472 ++++++++---------
 dix/Makefile.am                            |    2 
 dix/devices.c                              |    1 
 dix/dispatch.c                             |    8 
 dix/events.c                               |    2 
 dix/getevents.c                            |   37 +
 dix/main.c                                 |    2 
 dix/window.c                               |    2 
 doc/Xserver.man.pre                        |   40 +
 exa/exa.c                                  |  214 +++++---
 exa/exa_accel.c                            |  665 +++++++++++--------------
 exa/exa_migration.c                        |  360 +++++++------
 exa/exa_priv.h                             |   69 +-
 exa/exa_render.c                           |  320 +++++++-----
 exa/exa_unaccel.c                          |  111 ++--
 fb/fb.h                                    |    4 
 fb/fboverlay.c                             |   11 
 fb/fboverlay.h                             |    4 
 fb/fbpseudocolor.c                         |   68 --
 fb/fbscreen.c                              |    2 
 fb/fbwindow.c                              |   55 --
 fb/wfbrename.h                             |    2 
 hw/Makefile.am                             |   12 
 hw/darwin/Makefile.am                      |   81 +--
 hw/darwin/apple/X11Application.m           |    2 
 hw/darwin/darwin.c                         |  123 ----
 hw/darwin/darwin.h                         |    2 
 hw/darwin/iokit/xfIOKit.c                  |    2 
 hw/darwin/quartz/Makefile.am               |    2 
 hw/darwin/quartz/Preferences.m             |    2 
 hw/darwin/quartz/pseudoramiX.c             |    3 
 hw/darwin/quartz/quartz.c                  |    2 
 hw/darwin/quartz/quartzCocoa.m             |    2 
 hw/darwin/quartz/xpr/xprScreen.c           |    3 
 hw/darwin/utils/dumpkeymap.c               |    2 
 hw/dmx/Makefile.am                         |   15 
 hw/dmx/dmx.h                               |    2 
 hw/dmx/dmxinput.c                          |   11 
 hw/dmx/dmxscrinit.c                        |    5 
 hw/dmx/dmxwindow.c                         |   51 -
 hw/dmx/dmxwindow.h                         |    4 
 hw/kdrive/Makefile.am                      |    2 
 hw/kdrive/ati/ChangeLog                    |  622 -----------------------
 hw/kdrive/ati/Makefile.am                  |    3 
 hw/kdrive/chips/Makefile.am                |    3 
 hw/kdrive/ephyr/ephyr_draw.c               |    1 
 hw/kdrive/epson/Makefile.am                |    3 
 hw/kdrive/fbdev/Makefile.am                |    3 
 hw/kdrive/i810/Makefile.am                 |    3 
 hw/kdrive/igs/igsdraw.c                    |   72 --
 hw/kdrive/mach64/Makefile.am               |    3 
 hw/kdrive/mga/Makefile.am                  |    3 
 hw/kdrive/neomagic/ChangeLog               |   98 ---
 hw/kdrive/neomagic/Makefile.am             |    2 
 hw/kdrive/neomagic/backend.c               |   86 ---
 hw/kdrive/neomagic/backend.h               |   70 --
 hw/kdrive/nvidia/Makefile.am               |    3 
 hw/kdrive/pm2/Makefile.am                  |    3 
 hw/kdrive/r128/Makefile.am                 |    3 
 hw/kdrive/savage/s3.h                      |    1 
 hw/kdrive/savage/s3draw.c                  |  118 ----
 hw/kdrive/sdl/Makefile.am                  |    3 
 hw/kdrive/sis530/sisdraw.c                 |   73 --
 hw/kdrive/smi/Makefile.am                  |    3 
 hw/kdrive/src/kaa.c                        |   48 -
 hw/kdrive/src/kasync.c                     |   10 
 hw/kdrive/src/kdrive.h                     |    3 
 hw/kdrive/vesa/Makefile.am                 |    3 
 hw/kdrive/via/Makefile.am                  |    3 
 hw/vfb/Makefile.am                         |   13 
 hw/xfree86/Makefile.am                     |   16 
 hw/xfree86/common/atKeynames.h             |    2 
 hw/xfree86/common/xf86.h                   |    6 
 hw/xfree86/common/xf86Bus.c                |  215 --------
 hw/xfree86/common/xf86Events.c             |    4 
 hw/xfree86/common/xf86Init.c               |    6 
 hw/xfree86/common/xf86Resources.h          |    2 
 hw/xfree86/doc/man/xorg.conf.man.pre       |   46 +
 hw/xfree86/exa/exa.man.pre                 |    2 
 hw/xfree86/fbdevhw/fbdevhw.c               |    2 
 hw/xfree86/fbdevhw/fbdevhwstub.c           |    5 
 hw/xfree86/i2c/xf86i2c.c                   |    2 
 hw/xfree86/int10/helper_exec.c             |    4 
 hw/xfree86/loader/xf86sym.c                |    3 
 hw/xfree86/os-support/bsd/Makefile.am      |    1 
 hw/xfree86/os-support/bsd/bsdResource.c    |  101 ---
 hw/xfree86/os-support/bus/Makefile.am      |    8 
 hw/xfree86/os-support/bus/Pci.c            |   18 
 hw/xfree86/os-support/bus/Pci.h            |   41 -
 hw/xfree86/os-support/bus/axpPci.c         |   28 -
 hw/xfree86/os-support/bus/bsd_pci.c        |   84 +++
 hw/xfree86/os-support/bus/freebsdPci.c     |  164 ------
 hw/xfree86/os-support/bus/linuxPci.c       |   43 -
 hw/xfree86/os-support/bus/netbsdPci.c      |  129 ----
 hw/xfree86/os-support/bus/sparcPci.c       |   48 -
 hw/xfree86/os-support/hurd/Makefile.am     |    1 
 hw/xfree86/os-support/linux/lnxResource.c  |  186 -------
 hw/xfree86/os-support/linux/lnx_pci.c      |   63 --
 hw/xfree86/os-support/shared/stdPci.c      |   48 -
 hw/xfree86/os-support/shared/stdResource.c |   64 --
 hw/xfree86/os-support/solaris/Makefile.am  |    2 
 hw/xfree86/os-support/xf86_OSproc.h        |   10 
 hw/xfree86/rac/xf86RAC.c                   |   40 -
 hw/xfree86/shadowfb/shadow.c               |   42 -
 hw/xfree86/xaa/Makefile.am                 |    2 
 hw/xfree86/xaa/xaa.h                       |    2 
 hw/xfree86/xaa/xaaGC.c                     |    9 
 hw/xfree86/xaa/xaaInit.c                   |   10 
 hw/xfree86/xaa/xaaOverlay.c                |  179 ------
 hw/xfree86/xaa/xaaOverlayDF.c              |   53 --
 hw/xfree86/xaa/xaaPaintWin.c               |  200 -------
 hw/xfree86/xaa/xaaStateChange.c            |   24 
 hw/xfree86/xaa/xaaWrapper.c                |   35 -
 hw/xfree86/xaa/xaalocal.h                  |   10 
 hw/xfree86/xf1bpp/Makefile.am              |    1 
 hw/xfree86/xf1bpp/mfbmap.h                 |    1 
 hw/xfree86/xf1bpp/mfbunmap.h               |    1 
 hw/xfree86/xf4bpp/Makefile.am              |    1 
 hw/xfree86/xf4bpp/ppcGC.c                  |    9 
 hw/xfree86/xf4bpp/ppcIO.c                  |    4 
 hw/xfree86/xf4bpp/ppcPntWin.c              |  216 --------
 hw/xfree86/xf4bpp/ppcWindow.c              |    8 
 hw/xfree86/xf4bpp/xf4bpp.h                 |    7 
 hw/xfree86/xf8_32bpp/cfb8_32.h             |   16 
 hw/xfree86/xf8_32bpp/cfbpntwin.c           |  129 ----
 hw/xfree86/xf8_32bpp/cfbscrinit.c          |    8 
 hw/xfree86/xf8_32bpp/cfbwindow.c           |    5 
 hw/xfree86/xf8_32bpp/xf86overlay.c         |   65 --
 hw/xgl/Makefile.am                         |   12 
 hw/xgl/egl/Makefile.am                     |   21 
 hw/xgl/glx/xglx.c                          |    2 
 hw/xgl/xgl.h                               |   12 
 hw/xgl/xglscreen.c                         |    2 
 hw/xgl/xglwindow.c                         |  175 ------
 hw/xnest/Makefile.am                       |   11 
 hw/xnest/Screen.c                          |    2 
 hw/xnest/Window.c                          |   24 
 hw/xnest/XNWindow.h                        |    2 
 hw/xprint/Makefile.am                      |   20 
 hw/xprint/ddxInit.c                        |   11 
 hw/xprint/pcl/Pcl.h                        |    4 
 hw/xprint/pcl/PclInit.c                    |    2 
 hw/xprint/pcl/PclWindow.c                  |  226 --------
 hw/xprint/pcl/Pclmap.h                     |    1 
 hw/xprint/ps/Ps.h                          |    1 
 hw/xprint/ps/PsInit.c                      |    2 
 hw/xprint/ps/PsWindow.c                    |  224 --------
 hw/xwin/Makefile.am                        |   11 
 hw/xwin/win.h                              |   13 
 hw/xwin/winpntwin.c                        |   47 -
 hw/xwin/winscrinit.c                       |    2 
 include/inputstr.h                         |    1 
 include/scrnintstr.h                       |    4 
 mfb/Makefile.am                            |    2 
 mfb/mfb.h                                  |   21 
 mfb/mfbpntwin.c                            |  127 ----
 mfb/mfbscrinit.c                           |   20 
 mfb/mfbwindow.c                            |  179 ------
 mi/mibank.c                                |   71 --
 mi/miexpose.c                              |  341 +++---------
 mi/mioverlay.c                             |   20 
 mi/miscrinit.c                             |    2 
 mi/miwindow.c                              |    6 
 miext/cw/cw.c                              |  147 -----
 miext/cw/cw.h                              |    2 
 miext/damage/damage.c                      |   39 -
 miext/damage/damage.h                      |    3 
 miext/damage/damagestr.h                   |    2 
 miext/rootless/rootlessCommon.h            |    2 
 miext/rootless/rootlessScreen.c            |    2 
 miext/rootless/rootlessWindow.c            |   98 ---
 miext/rootless/rootlessWindow.h            |    4 
 miext/rootless/safeAlpha/Makefile.am       |    3 
 miext/rootless/safeAlpha/safeAlpha.h       |    2 
 miext/rootless/safeAlpha/safeAlphaWindow.c |  177 ------
 os/connection.c                            |   15 
 os/io.c                                    |    4 
 os/osdep.h                                 |    3 
 os/utils.c                                 |    8 
 randr/rroutput.c                           |    1 
 randr/rrscreen.c                           |   11 
 randr/rrxinerama.c                         |   14 
 render/picturestr.h                        |    2 
 xorg-server.pc.in                          |    3 
 207 files changed, 1903 insertions(+), 8250 deletions(-)

New commits:
diff-tree 5b36b64192517e2470766ce7ff1d4dc04c936fad (from 963e69b8efc39369915e7f0c6f370ac0d5d2b60f)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Sep 19 11:11:54 2007 -0400

    xace: add missing argument to hook call.

diff --git a/dix/events.c b/dix/events.c
index 42c3ba1..0d82d19 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2892,7 +2892,7 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIn
     if (!deliveries)
     {
 	FixUpEventFromWindow(xE, grab->window, None, TRUE);
-	if (!XaceHook(XACE_SEND_ACCESS, thisDev, grab->window, xE, count) &&
+	if (!XaceHook(XACE_SEND_ACCESS, 0, thisDev, grab->window, xE, count) &&
 	    !XaceHook(XACE_RECEIVE_ACCESS, rClient(grab), grab->window, xE,
 		      count))
 	    deliveries = TryClientEvents(rClient(grab), xE, count,
diff-tree 963e69b8efc39369915e7f0c6f370ac0d5d2b60f (from 97c150b61bbe436453b05d3c07cd2173870aac40)
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Sep 19 11:11:41 2007 -0400

    xace: add special-case for just setting the event mask on a window,
    this should only check "receive" permission, not "setattr" permission.

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 507854e..8c68e55 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -570,11 +570,13 @@ ProcChangeWindowAttributes(ClientPtr cli
 {
     WindowPtr pWin;
     REQUEST(xChangeWindowAttributesReq);
-    int result;
-    int len, rc;
+    int result, len, rc;
+    Mask access_mode = DixSetAttrAccess;
 
     REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
-    rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess);
+    if (stuff->valueMask == CWEventMask)
+	access_mode = DixReceiveAccess;
+    rc = dixLookupWindow(&pWin, stuff->window, client, access_mode);
     if (rc != Success)
         return rc;
     len = client->req_len - (sizeof(xChangeWindowAttributesReq) >> 2);
diff-tree 97c150b61bbe436453b05d3c07cd2173870aac40 (from parents)
Merge: 57907e0943da0c3fd3bf6c128d210b544629ce72 547ad2125ece93bbe01f6d09a3baf176ebd16bb3
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Sep 19 07:25:55 2007 -0400

    Merge branch 'master' into XACE-SELINUX
    
    Conflicts:
    
    	afb/afbpntwin.c
    	afb/afbscrinit.c
    	afb/afbwindow.c
    	cfb/cfb.h
    	cfb/cfballpriv.c
    	cfb/cfbscrinit.c
    	cfb/cfbwindow.c
    	configure.ac
    	fb/wfbrename.h
    	hw/xfree86/xf4bpp/ppcIO.c
    	hw/xfree86/xf4bpp/ppcPntWin.c
    	hw/xfree86/xf4bpp/ppcWindow.c
    	hw/xfree86/xf8_32bpp/cfbscrinit.c
    	mfb/mfb.h
    	mfb/mfbpntwin.c
    	mfb/mfbscrinit.c
    	mfb/mfbwindow.c
    	mi/miexpose.c
    
    Note: conflicts caused by devPrivates rework vs. paintwindow changes.

diff --cc afb/afb.h
index 5cfbddf,943c2c6..2111030
@@@ -743,18 -737,8 +738,8 @@@
  #endif
  
  #define afbGetGCPrivate(pGC) \
 -	((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
 +    ((afbPrivGC *)dixLookupPrivate(&(pGC)->devPrivates, afbGCPrivateKey))
  
- /* private field of window */
- typedef struct {
- 	unsigned char fastBorder;	/* non-zero if border tile is 32 bits wide */
- 	unsigned char fastBackground;
- 	unsigned short unused; /* pad for alignment with Sun compiler */
- 	DDXPointRec oldRotate;
- 	PixmapPtr pRotatedBackground;
- 	PixmapPtr pRotatedBorder;
- } afbPrivWin;
- 
  /* Common macros for extracting drawing information */
  
  #define afbGetTypedWidth(pDrawable,wtype)( \
diff --cc afb/afbscrinit.c
index 8615d93,f3a0542..cbabb89
@@@ -69,11 -69,12 +69,10 @@@
  #include "servermd.h"
  
  #ifdef PIXMAP_PER_WINDOW
 -int frameWindowPrivateIndex;
 +DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
  #endif
- DevPrivateKey afbWindowPrivateKey = &afbWindowPrivateKey;
 -int afbGCPrivateIndex;
 -int afbScreenPrivateIndex;
 -
 -static unsigned long afbGeneration = 0;
 +DevPrivateKey afbGCPrivateKey = &afbGCPrivateKey;
 +DevPrivateKey afbScreenPrivateKey = &afbScreenPrivateKey;
  
  static Bool
  afbCloseScreen(int index, ScreenPtr pScreen)
@@@ -135,18 -133,22 +134,14 @@@
  }
  
  static Bool
- afbAllocatePrivates(ScreenPtr pScreen,
- 		    DevPrivateKey *pWinKey, DevPrivateKey *pGCKey)
 -afbAllocatePrivates(ScreenPtr pScreen, int *pWinIndex, int *pGCIndex)
++afbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
  {
- 	if (pWinKey)
- 		*pWinKey = afbWindowPrivateKey;
 -	if (afbGeneration != serverGeneration) {
 -#ifdef PIXMAP_PER_WINDOW
 -		frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 -#endif
 -		afbGCPrivateIndex = AllocateGCPrivateIndex();
 -		afbGeneration = serverGeneration;
 -	}
 -	if (pGCIndex)
 -		*pGCIndex = afbGCPrivateIndex;
 +	if (pGCKey)
 +		*pGCKey = afbGCPrivateKey;
  
 -	afbScreenPrivateIndex = AllocateScreenPrivateIndex();
  	pScreen->GetWindowPixmap = afbGetWindowPixmap;
  	pScreen->SetWindowPixmap = afbSetWindowPixmap;
- 	return(dixRequestPrivate(afbWindowPrivateKey, sizeof(afbPrivWin)) &&
- 	       dixRequestPrivate(afbGCPrivateKey, sizeof(afbPrivGC)));
 -	return(AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
++	return dixRequestPrivate(afbGCPrivateKey, sizeof(afbPrivGC));
  }
  
  /* dts * (inch/dot) * (25.4 mm / inch) = mm */
@@@ -172,7 -174,7 +167,7 @@@
  		ErrorF("afbInitVisuals: FALSE\n");
  		return FALSE;
  	}
- 	if (!afbAllocatePrivates(pScreen, NULL, NULL)) {
 -	if (!afbAllocatePrivates(pScreen,(int *)NULL, (int *)NULL)) {
++	if (!afbAllocatePrivates(pScreen, NULL)) {
  		ErrorF("afbAllocatePrivates: FALSE\n");
  		return FALSE;
  	}
diff --cc cfb/cfb.h
index 44d4ad0,c9ceda9..b74a82f
@@@ -56,8 -55,7 +56,7 @@@
     pixmap.devKind = width_of_pixmap_in_bytes
  */
  
 -extern int  cfbGCPrivateIndex;
 +extern DevPrivateKey cfbGCPrivateKey;
- extern DevPrivateKey cfbWindowPrivateKey;
  
  /* private field of GC */
  typedef struct {
@@@ -82,22 -80,8 +81,6 @@@
      CfbBits	xor, and;
  } cfbRRopRec, *cfbRRopPtr;
  
- /* private field of window */
- typedef struct {
-     unsigned	char fastBorder; /* non-zero if border is 32 bits wide */
-     unsigned	char fastBackground;
-     unsigned short unused; /* pad for alignment with Sun compiler */
-     DDXPointRec	oldRotate;
-     PixmapPtr	pRotatedBackground;
-     PixmapPtr	pRotatedBorder;
-     } cfbPrivWin;
- 
- #define cfbGetWindowPrivate(_pWin) ((cfbPrivWin *)\
-     dixLookupPrivate(&(_pWin)->devPrivates, cfbWindowPrivateKey))
- 
- 
--/* cfb8bit.c */
--
  extern int cfbSetStipple(
      int /*alu*/,
      CfbBits /*fg*/,
@@@ -314,8 -298,7 +297,7 @@@
  
  extern Bool cfbAllocatePrivates(
      ScreenPtr /*pScreen*/,
-     DevPrivateKey * /*window_key*/,
 -    int * /*gc_index*/
 +    DevPrivateKey * /*gc_key*/
  );
  /* cfbbitblt.c */
  
diff --cc cfb/cfballpriv.c
index e6ab93a,858ff60..3b58266
@@@ -45,37 -45,38 +45,26 @@@
  #include "mibstore.h"
  
  #if 1 || PSZ==8
- DevPrivateKey cfbWindowPrivateKey = &cfbWindowPrivateKey;
 -int cfbGCPrivateIndex = -1;
 +DevPrivateKey cfbGCPrivateKey = &cfbGCPrivateKey;
  #endif
  #ifdef CFB_NEED_SCREEN_PRIVATE
 -int cfbScreenPrivateIndex = -1;
 -static unsigned long cfbGeneration = 0;
 +DevPrivateKey cfbScreenPrivateKey = &cfbScreenPrivateKey;
  #endif
  
  
  Bool
- cfbAllocatePrivates(pScreen, window_key, gc_key)
-     ScreenPtr	pScreen;
-     DevPrivateKey *window_key, *gc_key;
 -cfbAllocatePrivates(ScreenPtr pScreen, int *gc_index)
++cfbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *gc_key)
  {
-     if (!window_key || !gc_key || (!*window_key && !*gc_key))
 -    if (!gc_index || *gc_index == -1)
++    if (!gc_key || !*gc_key)
      {
-     	if (!mfbAllocatePrivates(pScreen,
- 			     	 &cfbWindowPrivateKey, &cfbGCPrivateKey))
 -    	if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
++    	if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey))
  	    return FALSE;
-     	if (window_key)
- 	    *window_key = cfbWindowPrivateKey;
 -    	if (gc_index)
 -	    *gc_index = cfbGCPrivateIndex;
 +    	if (gc_key)
 +	    *gc_key = cfbGCPrivateKey;
      }
      else
      {
- 	cfbWindowPrivateKey = *window_key;
 -	cfbGCPrivateIndex = *gc_index;
 +	cfbGCPrivateKey = *gc_key;
      }
-     if (!dixRequestPrivate(cfbWindowPrivateKey, sizeof(cfbPrivWin)))
- 	return FALSE;
-     if (!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC)))
- 	return FALSE;
-     return TRUE;
 -    if (!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
 -	return FALSE;
 -#ifdef CFB_NEED_SCREEN_PRIVATE
 -    if (cfbGeneration != serverGeneration)
 -    {
 -      cfbScreenPrivateIndex = AllocateScreenPrivateIndex ();
 -      cfbGeneration = serverGeneration;
 -    }
 -    if (cfbScreenPrivateIndex == -1)
 -	return FALSE;
 -#endif
 -    return TRUE;
++    return dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC));
  }
diff --cc cfb/cfbwindow.c
index 49cc6f0,c4f027b..2b582d4
@@@ -60,23 -60,12 +60,12 @@@
  #include "cfbmskbits.h"
  
  Bool
- cfbCreateWindow(pWin)
-     WindowPtr pWin;
+ cfbCreateWindow(WindowPtr pWin)
  {
-     cfbPrivWin *pPrivWin;
- 
-     pPrivWin = cfbGetWindowPrivate(pWin);
-     pPrivWin->pRotatedBorder = NullPixmap;
-     pPrivWin->pRotatedBackground = NullPixmap;
-     pPrivWin->fastBackground = FALSE;
-     pPrivWin->fastBorder = FALSE;
-     pPrivWin->oldRotate.x = 0;
-     pPrivWin->oldRotate.y = 0;
- 
  #ifdef PIXMAP_PER_WINDOW
      /* Setup pointer to Screen pixmap */
 -    pWin->devPrivates[frameWindowPrivateIndex].ptr =
 -	(pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
 +    dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey,
 +		  cfbGetScreenPixmap(pWin->drawable.pScreen));
  #endif
  
      return TRUE;
diff --cc configure.ac
index 43bc357,24b12df..dd9d500
@@@ -1312,7 -1301,7 +1314,7 @@@
  	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
  	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
  	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
- 	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB $OS_LIB"
 -	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB"
++	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB"
  
  dnl Check to see if dlopen is in default libraries (like Solaris, which
  dnl has it in libc), or if libdl is needed to get it.
diff --cc exa/exa.c
index 4260cba,eac2d91..8f219fb
@@@ -40,9 -40,21 +40,20 @@@
  #include "exa.h"
  #include "cw.h"
  
 -static int exaGeneration;
 -int exaScreenPrivateIndex;
 -int exaPixmapPrivateIndex;
 +DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKey;
 +DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKey;
  
+ static _X_INLINE void*
+ ExaGetPixmapAddress(PixmapPtr p)
+ {
+     ExaPixmapPriv(p);
+ 
+     if (pExaPixmap->offscreen && pExaPixmap->fb_ptr)
+ 	return pExaPixmap->fb_ptr;
+     else
+ 	return pExaPixmap->sys_ptr;
+ }
+ 
  /**
   * exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of
   * the beginning of the given pixmap.
diff --cc fb/wfbrename.h
index a6296fb,93ce41b..9382244
@@@ -117,10 -117,9 +117,9 @@@
  #define fbOverlayCreateWindow wfbOverlayCreateWindow
  #define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit
  #define fbOverlayGeneration wfbOverlayGeneration
 -#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
 +#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
  #define fbOverlayPaintKey wfbOverlayPaintKey
- #define fbOverlayPaintWindow wfbOverlayPaintWindow
 -#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
 +#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
  #define fbOverlaySetupScreen wfbOverlaySetupScreen
  #define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
  #define fbOverlayWindowExposures wfbOverlayWindowExposures
diff --cc hw/xfree86/xf8_32bpp/cfbscrinit.c
index fffd8d3,5e2657f..c3432b8
@@@ -55,17 -56,13 +55,13 @@@
     
     
     /* All cfb will have the same GC and Window private indicies */
-    if(!mfbAllocatePrivates(pScreen, &cfbWindowPrivateKey, &cfbGCPrivateKey))
- 	return FALSE;
- 
-    /* The cfb indicies are the mfb indicies. Reallocating them resizes them */ 
-    if(!dixRequestPrivate(cfbWindowPrivateKey, sizeof(cfbPrivWin)))
 -   if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
++   if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateKey))
  	return FALSE;
  
 -   if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
 +   if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC)))
          return FALSE;
  
 -   if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec)))
 +   if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec)))
          return FALSE;
  
     return TRUE;
diff --cc mfb/mfb.h
index 42f3002,69d2d69..4d503f9
@@@ -705,8 -697,7 +698,7 @@@
  
  extern Bool mfbAllocatePrivates(
      ScreenPtr /*pScreen*/,
-     DevPrivateKey *pWinKey,
-     DevPrivateKey *pGCIndex
 -    int * /*pGCIndex*/
++    DevPrivateKey * /*pGCKey*/
  );
  
  extern Bool mfbScreenInit(
@@@ -891,10 -882,12 +883,9 @@@
  typedef mfbPrivGC	*mfbPrivGCPtr;
  #endif
  
 -/* XXX these should be static, but it breaks the ABI */
 -extern int  mfbGCPrivateIndex;		/* index into GC private array */
 -extern int  mfbGetGCPrivateIndex(void);
 +extern DevPrivateKey mfbGetGCPrivateKey(void);
- extern DevPrivateKey mfbGetWindowPrivateKey(void);
  #ifdef PIXMAP_PER_WINDOW
 -extern int  frameWindowPrivateIndex;	/* index into Window private array */
 -extern int  frameGetWindowPrivateIndex(void);
 +extern DevPrivateKey frameGetWindowPrivateKey(void);
  #endif
  
  #ifndef MFB_PROTOTYPES_ONLY
diff --cc mfb/mfbscrinit.c
index 515e9e3,6d364b7..8873a1b
@@@ -68,13 -68,11 +68,11 @@@
  #include "servermd.h"
  
  #ifdef PIXMAP_PER_WINDOW
 -int frameWindowPrivateIndex;
 -int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
 +static DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
 +DevPrivateKey frameGetWindowPrivateKey(void) { return frameWindowPrivateKey; }
  #endif
- static DevPrivateKey mfbWindowPrivateKey = &mfbWindowPrivateKey;
- DevPrivateKey mfbGetWindowPrivateKey(void) { return mfbWindowPrivateKey; }
 -int mfbGCPrivateIndex;
 -int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
 +static DevPrivateKey mfbGCPrivateKey = &mfbGCPrivateKey;
 +DevPrivateKey mfbGetGCPrivateKey(void) { return mfbGCPrivateKey; }
  static unsigned long mfbGeneration = 0;
  
  static VisualRec visual = {
@@@ -90,8 -88,7 +88,7 @@@
  };
  
  Bool
- mfbAllocatePrivates(ScreenPtr pScreen,
- 		    DevPrivateKey *pWinIndex, DevPrivateKey *pGCIndex)
 -mfbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
++mfbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
  {
      if (mfbGeneration != serverGeneration)
      {
@@@ -99,14 -100,11 +96,11 @@@
  	VID = visual.vid;
  	mfbGeneration = serverGeneration;
      }
-     if (pWinIndex)
- 	*pWinIndex = mfbWindowPrivateKey;
--    if (pGCIndex)
- 	*pGCIndex = mfbGCPrivateKey;
 -	*pGCIndex = mfbGCPrivateIndex;
++    if (pGCKey)
++	*pGCKey = mfbGCPrivateKey;
      pScreen->GetWindowPixmap = mfbGetWindowPixmap;
      pScreen->SetWindowPixmap = mfbSetWindowPixmap;
-     return (dixRequestPrivate(mfbWindowPrivateKey, sizeof(mfbPrivWin)) &&
- 	    dixRequestPrivate(mfbGCPrivateKey, sizeof(mfbPrivGC)));
 -    return AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC));
++    return dixRequestPrivate(mfbGCPrivateKey, sizeof(mfbPrivGC));
  }
  
  
diff --cc mi/mibank.c
index b52399c,3492f1e..05813e5
@@@ -2263,11 -2200,9 +2194,9 @@@
      SCREEN_WRAP(GetImage,              miBankGetImage);
      SCREEN_WRAP(GetSpans,              miBankGetSpans);
      SCREEN_WRAP(CreateGC,              miBankCreateGC);
-     SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
-     SCREEN_WRAP(PaintWindowBorder,     miBankPaintWindow);
      SCREEN_WRAP(CopyWindow,            miBankCopyWindow);
  
 -    BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
 +    dixSetPrivate(&pScreen->devPrivates, miBankScreenKey, pScreenPriv);
  
      return TRUE;
  }
diff --cc render/picturestr.h
index fad9741,09a7131..5444e51
@@@ -24,10 -24,9 +24,10 @@@
  #ifndef _PICTURESTR_H_
  #define _PICTURESTR_H_
  
- #include "glyphstr.h"
  #include "scrnintstr.h"
+ #include "glyphstr.h"
  #include "resource.h"
 +#include "privates.h"
  
  typedef struct _DirectFormat {
      CARD16	    red, redMask;
diff-tree 547ad2125ece93bbe01f6d09a3baf176ebd16bb3 (from 56cc24ffb21f7fd41f9ea9e8f969aa85021b9f53)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 17 20:33:56 2007 +0200

    EXA: Make sure driver hooks get correct offscreen offsets from exaCopyDirty.
    
    This should ensure the driver UploadTo/DownloadFromScreen hooks can always
    work as intended.

diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index ace9076..c0e022c 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -127,7 +127,7 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     ExaPixmapPriv (pPixmap);
     RegionPtr damage = DamageRegion (pExaPixmap->pDamage);
     RegionRec CopyReg;
-    CARD8 *save_ptr;
+    Bool save_offscreen;
     int save_pitch;
     BoxPtr pBox;
     int nbox;
@@ -176,9 +176,9 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     pBox = REGION_RECTS(&CopyReg);
     nbox = REGION_NUM_RECTS(&CopyReg);
 
-    save_ptr = pPixmap->devPrivate.ptr;
+    save_offscreen = pExaPixmap->offscreen;
     save_pitch = pPixmap->devKind;
-    pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+    pExaPixmap->offscreen = TRUE;
     pPixmap->devKind = pExaPixmap->fb_pitch;
 
     while (nbox--) {
@@ -216,7 +216,7 @@ exaCopyDirty(ExaMigrationPtr migrate, Re
     else
 	sync (pPixmap->drawable.pScreen);
 
-    pPixmap->devPrivate.ptr = save_ptr;
+    pExaPixmap->offscreen = save_offscreen;
     pPixmap->devKind = save_pitch;
 
     /* The copied bits are now valid in destination */
diff-tree 56cc24ffb21f7fd41f9ea9e8f969aa85021b9f53 (from 7ac89060e02c7a803018afd580720f8326561fd8)
Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Mon Sep 17 20:33:56 2007 +0200

    EXA: Don't crash in ExaCheckPolyArc.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=12286 .

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index fcd4af9..c55ef03 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -196,6 +196,12 @@ ExaCheckPolyArc (DrawablePtr pDrawable, 
 		int narcs, xArc *pArcs)
 {
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
+
+    /* Disable this as fbPolyArc can call miZeroPolyArc which in turn
+     * can call accelerated functions, that as yet, haven't been notified
+     * with exaFinishAccess().
+     */
+#if 0
     if (pGC->lineWidth == 0)
     {
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
@@ -205,6 +211,7 @@ ExaCheckPolyArc (DrawablePtr pDrawable, 
 	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 	return;
     }
+#endif
     miPolyArc (pDrawable, pGC, narcs, pArcs);
 }
 
diff-tree 7ac89060e02c7a803018afd580720f8326561fd8 (from 3876c6c80534a6f7412ec806a2ba9ada22c5e505)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 17 20:33:55 2007 +0200

    EXA: Don't crash in exaGetImage when swapped out.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 8500c5b..2acade2 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1324,9 +1324,6 @@ exaGetImage (DrawablePtr pDrawable, int 
     int xoff, yoff;
     Bool ok;
 
-    if (pExaScr->swappedOut)
-	goto fallback;
-
     pixmaps[0].as_dst = FALSE;
     pixmaps[0].as_src = TRUE;
     pixmaps[0].pPix = pPix = exaGetDrawablePixmap (pDrawable);
@@ -1341,6 +1338,9 @@ exaGetImage (DrawablePtr pDrawable, int 
 
     REGION_INIT(pScreen, &Reg, &Box, 1);
 
+    if (pExaScr->swappedOut)
+	goto fallback;
+
     exaDoMigration(pixmaps, 1, FALSE);
 
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
diff-tree 3876c6c80534a6f7412ec806a2ba9ada22c5e505 (from d5738ff2e0f93df4729c075ce31a1041d580e50e)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 18:47:45 2007 +0200

    EXA: Fixed compiler warnings.

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index aecbfeb..fcd4af9 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -258,11 +258,11 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 		  exaDrawableLocation(&pBitmap->drawable),
 		  exaDrawableLocation(pDrawable)));
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
-    exaPrepareAccess (pBitmap, EXA_PREPARE_SRC);
+    exaPrepareAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
     exaPrepareAccessGC (pGC);
     fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
     exaFinishAccessGC (pGC);
-    exaFinishAccess (pBitmap, EXA_PREPARE_SRC);
+    exaFinishAccess (&pBitmap->drawable, EXA_PREPARE_SRC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 }
 
diff-tree d5738ff2e0f93df4729c075ce31a1041d580e50e (from a0dafd95e1e13a2f1b77ab9f82fd365a7be19de5)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 16:59:03 2007 +0200

    EXA: Added missing exaPrepare/FinishAccess calls in ExaCheckPushPixels.

diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index d487dc5..aecbfeb 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -258,9 +258,11 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 		  exaDrawableLocation(&pBitmap->drawable),
 		  exaDrawableLocation(pDrawable)));
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    exaPrepareAccess (pBitmap, EXA_PREPARE_SRC);
     exaPrepareAccessGC (pGC);
     fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
     exaFinishAccessGC (pGC);
+    exaFinishAccess (pBitmap, EXA_PREPARE_SRC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 }
 
diff-tree a0dafd95e1e13a2f1b77ab9f82fd365a7be19de5 (from 7bd65577018a574970b767b67967b65fcd5c2bf0)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Mon Sep 17 16:45:20 2007 +0200

    Removed hw/xwin/winpntwin.c from Makefile.am.
    
    winpntwin.c was removed in e4d11e58ce349dfe6af2f73ff341317f9b39684c.

diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 8aaed8c..5ffba12 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -45,7 +45,6 @@ SRCS_NATIVEGDI = \
 	wingetsp.c \
 	winnativegdi.c \
 	winpixmap.c \
-	winpntwin.c \
 	winpolyline.c \
 	winpushpxl.c \
 	winrop.c \
diff-tree 7bd65577018a574970b767b67967b65fcd5c2bf0 (from b9f7aeb20015290a8acf938a11bf9272bf3527cf)
Author: Tilman Sauerbeck <tilman at code-monkey.de>
Date:   Sat Sep 15 14:01:57 2007 +0200

    Initialize output->pendingProperties.

diff --git a/randr/rroutput.c b/randr/rroutput.c
index a67e493..c1e971d 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -95,6 +95,7 @@ RROutputCreate (ScreenPtr   pScreen,
     output->numUserModes = 0;
     output->userModes = NULL;
     output->properties = NULL;
+    output->pendingProperties = FALSE;
     output->changed = FALSE;
     output->devPrivate = devPrivate;
     
diff-tree b9f7aeb20015290a8acf938a11bf9272bf3527cf (from parents)
Merge: e4d11e58ce349dfe6af2f73ff341317f9b39684c 06d27f8045966c1fb154eafaff308a01b93f265b
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Sep 13 00:15:45 2007 +0000

    Merge remote branch 'origin/master' into paint-window
    
    Conflicts:
    
    	mi/miexpose.c

diff --cc mi/miexpose.c
index 03d4c27,2dc8f15..6ace9f5
@@@ -545,25 -592,31 +544,31 @@@
      BoxPtr	pbox;
      xRectangle	*prect;
      int		numRects;
-     int		xoff, yoff;
- 
-     pPixmap = (*pScreen->GetWindowPixmap) (pWin);
- 
- #ifdef COMPOSITE
-     xoff = -pPixmap->screen_x;
-     yoff = -pPixmap->screen_y;
- #else
-     xoff = 0;
-     yoff = 0;
- #endif
-     gcval[0].val = GXcopy;
-     gcmask = GCFunction;
+     /*
+      * Distance from screen to destination drawable, use this
+      * to adjust rendering coordinates which come in in screen space
+      */
+     int		draw_x_off, draw_y_off;
+     /*
+      * Tile offset for drawing; these need to align the tile
+      * to the appropriate window origin
+      */
+     int		tile_x_off, tile_y_off;
+     PixUnion	fill;
+     Bool	solid = TRUE;
+     DrawablePtr	drawable = &pWin->drawable;
  
 -    while (pWin->backgroundState == ParentRelative)
 -        pWin = pWin->parent;
 -
      if (what == PW_BACKGROUND)
      {
 +	while (pWin->backgroundState == ParentRelative)
 +	    pWin = pWin->parent;
 +
+ 	draw_x_off = drawable->x;
+ 	draw_y_off = drawable->y;
+ 
+ 	tile_x_off = 0;
+ 	tile_y_off = 0;
+ 	fill = pWin->background;
  	switch (pWin->backgroundState) {
  	case None:
  	    return;
diff-tree e4d11e58ce349dfe6af2f73ff341317f9b39684c (from 6da39c67905500ab2db00a45cda4a9f756cdde96)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 12 13:58:46 2007 +0000

    Remove the PaintWindow optimization.
    
    This was an attempt to avoid scratch gc creation and validation for paintwin
    because that was expensive.  This is not the case in current servers, and the
    danger of failure to implement it correctly (as seen in all previous
    implementations) is high enough to justify removing it.  No performance
    difference detected with x11perf -create -move -resize -circulate on Xvfb.
    Leave the screen hooks for PaintWindow* in for now to avoid ABI change.

diff --git a/Xext/mbufbf.c b/Xext/mbufbf.c
index e29c974..b879abc 100644
--- a/Xext/mbufbf.c
+++ b/Xext/mbufbf.c
@@ -504,7 +504,7 @@ bufClearImageBufferArea(pMBBuffer, x,y, 
 
     REGION_INTERSECT(pScreen, &reg, &reg, &pBuffer->clipList);
     if (pBuffer->backgroundState != None)
-	(*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+	miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
     if (generateExposures)
 	MultibufferExpose(pMBBuffer, &reg);
 #ifdef _notdef
@@ -517,7 +517,7 @@ bufClearImageBufferArea(pMBBuffer, x,y, 
     if (generateExposures)
 	(*pScreen->WindowExposures)(pBuffer, &reg, pBSReg);
     else if (pBuffer->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pBuffer, &reg, PW_BACKGROUND);
+        miPaintWindow(pBuffer, &reg, PW_BACKGROUND);
 #endif
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
@@ -836,8 +836,7 @@ bufClipNotify(pWin, dx,dy)
 
 /*
  * Updates buffer's background fields when the window's changes.
- * This is necessary because pScreen->PaintWindowBackground
- * is used to paint the buffer.
+ * This is necessary because miPaintWindow is used to paint the buffer.
  *
  * XXBS - Backingstore state will have be tracked too if it is supported.
  */
@@ -927,7 +926,7 @@ bufWindowExposures(pWin, prgn, other_exp
 	pBuffer = (BufferPtr) pMBBuffer->pDrawable;
 
 	if (i != pMBWindow->displayedMultibuffer)
-	    (* pScreen->PaintWindowBackground)(pBuffer,&tmp_rgn,PW_BACKGROUND);
+	    miPaintWindow(pBuffer, &tmp_rgn, PW_BACKGROUND);
 	if ((pMBBuffer->otherEventMask | pMBBuffer->eventMask) & ExposureMask)
 	    MultibufferExpose(pMBBuffer, &tmp_rgn);
     }
diff --git a/afb/Makefile.am b/afb/Makefile.am
index d6b8901..9fc22ca 100644
--- a/afb/Makefile.am
+++ b/afb/Makefile.am
@@ -6,7 +6,7 @@ libafb_gen_sources = afbbltC.c afbbltX.c
 
 DISTCLEANFILES = $(libafb_gen_sources)
 
-libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpntwin.c afbpixmap.c \
+libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpixmap.c \
 	 afbimage.c afbline.c afbbres.c afbhrzvert.c afbbresd.c afbpushpxl.c afbply1rct.c \
 	 afbzerarc.c afbfillarc.c afbfillsp.c afbsetsp.c afbscrinit.c afbplygblt.c \
 	 afbclip.c afbgetsp.c afbpolypnt.c afbbitblt.c afbcmap.c afbimggblt.c afbpntarea.c \
diff --git a/afb/afb.h b/afb/afb.h
index 9125951..943c2c6 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -506,11 +506,6 @@ extern void afbCopyRotatePixmap(
 	int /*xrot*/,
 	int /*yrot*/
 );
-extern void afbPaintWindow(
-	WindowPtr /*pWin*/,
-	RegionPtr /*pRegion*/,
-	int /*what*/
-);
 /* afbpolypnt.c */
 
 extern void afbPolyPoint(
@@ -744,16 +739,6 @@ extern int frameWindowPrivateIndex;		/* 
 #define afbGetGCPrivate(pGC) \
 	((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
 
-/* private field of window */
-typedef struct {
-	unsigned char fastBorder;	/* non-zero if border tile is 32 bits wide */
-	unsigned char fastBackground;
-	unsigned short unused; /* pad for alignment with Sun compiler */
-	DDXPointRec oldRotate;
-	PixmapPtr pRotatedBackground;
-	PixmapPtr pRotatedBorder;
-} afbPrivWin;
-
 /* Common macros for extracting drawing information */
 
 #define afbGetTypedWidth(pDrawable,wtype)( \
diff --git a/afb/afbpntwin.c b/afb/afbpntwin.c
deleted file mode 100644
index 6082f7c..0000000
--- a/afb/afbpntwin.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/***********************************************************
-
-Copyright (c) 1987  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-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
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "afb.h"
-#include "maskbits.h"
-#include "mi.h"
-
-void
-afbPaintWindow(pWin, pRegion, what)
-	WindowPtr		pWin;
-	RegionPtr		pRegion;
-	int				what;
-{
-	register afbPrivWin		*pPrivWin;
-	unsigned char rrops[AFB_MAX_DEPTH];
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-
-	switch (what) {
-		case PW_BACKGROUND:
-			switch (pWin->backgroundState) {
-				case None:
-					return;
-				case ParentRelative:
-					do {
-						pWin = pWin->parent;
-					} while (pWin->backgroundState == ParentRelative);
-					(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-																					 what);
-					return;
-				case BackgroundPixmap:
-					if (pPrivWin->fastBackground) {
-						afbTileAreaPPWCopy((DrawablePtr)pWin,
-												  REGION_NUM_RECTS(pRegion),
-												  REGION_RECTS(pRegion), GXcopy,
-												  pPrivWin->pRotatedBackground, ~0);
-						return;
-					} else {
-						afbTileAreaCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-											  REGION_RECTS(pRegion), GXcopy,
-											  pWin->background.pixmap, 0, 0, ~0);
-						return;
-					}
-					break;
-				case BackgroundPixel:
-					afbReduceRop(GXcopy, pWin->background.pixel, ~0,
-									  pWin->drawable.depth, rrops);
-					afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-											REGION_RECTS(pRegion), rrops);
-					return;
-			}
-			break;
-		case PW_BORDER:
-			if (pWin->borderIsPixel) {
-				afbReduceRop(GXcopy, pWin->border.pixel, ~0, pWin->drawable.depth,
-								  rrops);
-				afbSolidFillArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-										REGION_RECTS(pRegion), rrops);
-				return;
-			} else if (pPrivWin->fastBorder) {
-				afbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-										  REGION_RECTS(pRegion), GXcopy,
-										  pPrivWin->pRotatedBorder, ~0);
-				return;
-			}
-			break;
-	}
-	miPaintWindow(pWin, pRegion, what);
-}
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index 71e8d4c..f3a0542 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -71,7 +71,6 @@ SOFTWARE.
 #ifdef PIXMAP_PER_WINDOW
 int frameWindowPrivateIndex;
 #endif
-int afbWindowPrivateIndex;
 int afbGCPrivateIndex;
 int afbScreenPrivateIndex;
 
@@ -140,20 +139,16 @@ afbAllocatePrivates(ScreenPtr pScreen, i
 #ifdef PIXMAP_PER_WINDOW
 		frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 #endif
-		afbWindowPrivateIndex = AllocateWindowPrivateIndex();
 		afbGCPrivateIndex = AllocateGCPrivateIndex();
 		afbGeneration = serverGeneration;
 	}
-	if (pWinIndex)
-		*pWinIndex = afbWindowPrivateIndex;
 	if (pGCIndex)
 		*pGCIndex = afbGCPrivateIndex;
 
 	afbScreenPrivateIndex = AllocateScreenPrivateIndex();
 	pScreen->GetWindowPixmap = afbGetWindowPixmap;
 	pScreen->SetWindowPixmap = afbSetWindowPixmap;
-	return(AllocateWindowPrivate(pScreen, afbWindowPrivateIndex, sizeof(afbPrivWin)) &&
-	       AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
+	return(AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
 }
 
 /* dts * (inch/dot) * (25.4 mm / inch) = mm */
@@ -198,8 +193,6 @@ afbScreenInit(register ScreenPtr pScreen
 	pScreen->ChangeWindowAttributes = afbChangeWindowAttributes;
 	pScreen->RealizeWindow = afbMapWindow;
 	pScreen->UnrealizeWindow = afbUnmapWindow;
-	pScreen->PaintWindowBackground = afbPaintWindow;
-	pScreen->PaintWindowBorder = afbPaintWindow;
 	pScreen->CopyWindow = afbCopyWindow;
 	pScreen->CreatePixmap = afbCreatePixmap;
 	pScreen->DestroyPixmap = afbDestroyPixmap;
diff --git a/afb/afbwindow.c b/afb/afbwindow.c
index a4a1602..5c2f18a 100644
--- a/afb/afbwindow.c
+++ b/afb/afbwindow.c
@@ -62,39 +62,16 @@ SOFTWARE.
 #include "maskbits.h"
 
 Bool
-afbCreateWindow(pWin)
-	register WindowPtr pWin;
+afbCreateWindow(WindowPtr pWin)
 {
-	register afbPrivWin *pPrivWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	pPrivWin->pRotatedBorder = NullPixmap;
-	pPrivWin->pRotatedBackground = NullPixmap;
-	pPrivWin->fastBackground = FALSE;
-	pPrivWin->fastBorder = FALSE;
-#ifdef PIXMAP_PER_WINDOW
-	pWin->devPrivates[frameWindowPrivateIndex].ptr =
-			pWin->pDrawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr;
-#endif
-
 	return (TRUE);
 }
 
 /* This always returns true, because Xfree can't fail.  It might be possible
  * on some devices for Destroy to fail */
 Bool
-afbDestroyWindow(pWin)
-	WindowPtr pWin;
+afbDestroyWindow(WindowPtr pWin)
 {
-	register afbPrivWin *pPrivWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-
-	if (pPrivWin->pRotatedBorder)
-		(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-	if (pPrivWin->pRotatedBackground)
-		(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
-
 	return (TRUE);
 }
 
@@ -106,46 +83,10 @@ afbMapWindow(pWindow)
 	return (TRUE);
 }
 
-/* (x, y) is the upper left corner of the window on the screen
-   do we really need to pass this?  (is it a;ready in pWin->absCorner?)
-   we only do the rotation for pixmaps that are 32 bits wide (padded
-or otherwise.)
-   afbChangeWindowAttributes() has already put a copy of the pixmap
-in pPrivWin->pRotated*
-*/
-
 /*ARGSUSED*/
 Bool
-afbPositionWindow(pWin, x, y)
-	WindowPtr pWin;
-	int x, y;
+afbPositionWindow(WindowPtr pWin, int x, int y)
 {
-	register afbPrivWin *pPrivWin;
-	int		reset = 0;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground) {
-		afbXRotatePixmap(pPrivWin->pRotatedBackground,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBackground,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		reset = 1;
-	}
-
-	if (!pWin->borderIsPixel && pPrivWin->fastBorder) {
-		while (pWin->backgroundState == ParentRelative)
-			pWin = pWin->parent;
-		afbXRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		reset = 1;
-	}
-	if (reset) {
-		pPrivWin->oldRotate.x = pWin->drawable.x;
-		pPrivWin->oldRotate.y = pWin->drawable.y;
-	}
-
 	/* This is the "wrong" fix to the right problem, but it doesn't really
 	 * cost very much.  When the window is moved, we need to invalidate any
 	 * RotatedPixmap that exists in any GC currently validated against this
@@ -215,104 +156,8 @@ afbCopyWindow(pWin, ptOldOrg, prgnSrc)
 	REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 }
 
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivate.
-*/
 Bool
-afbChangeWindowAttributes(pWin, mask)
-	register WindowPtr pWin;
-	register unsigned long mask;
+afbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
 {
-	register unsigned long index;
-	register afbPrivWin *pPrivWin;
-	WindowPtr		pBgWin;
-
-	pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-	/*
-	 * When background state changes from ParentRelative and
-	 * we had previously rotated the fast border pixmap to match
-	 * the parent relative origin, rerotate to match window
-	 */
-	if (mask & (CWBackPixmap | CWBackPixel) &&
-		 pWin->backgroundState != ParentRelative && pPrivWin->fastBorder &&
-		 (pPrivWin->oldRotate.x != pWin->drawable.x ||
-		  pPrivWin->oldRotate.y != pWin->drawable.y)) {
-		afbXRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.x - pPrivWin->oldRotate.x);
-		afbYRotatePixmap(pPrivWin->pRotatedBorder,
-								pWin->drawable.y - pPrivWin->oldRotate.y);
-		pPrivWin->oldRotate.x = pWin->drawable.x;
-		pPrivWin->oldRotate.y = pWin->drawable.y;
-	}
-	while(mask) {
-		index = lowbit (mask);
-		mask &= ~index;
-		switch(index) {
-			case CWBackPixmap:
-				if (pWin->backgroundState == None)
-					pPrivWin->fastBackground = FALSE;
-				else if (pWin->backgroundState == ParentRelative) {
-					pPrivWin->fastBackground = FALSE;
-					/* Rotate border to match parent origin */
-					if (pPrivWin->pRotatedBorder) {
-						for (pBgWin = pWin->parent;
-							  pBgWin->backgroundState == ParentRelative;
-							  pBgWin = pBgWin->parent);
-						afbXRotatePixmap(pPrivWin->pRotatedBorder,
-												pBgWin->drawable.x - pPrivWin->oldRotate.x);
-						afbYRotatePixmap(pPrivWin->pRotatedBorder,
-												pBgWin->drawable.y - pPrivWin->oldRotate.y);
-						pPrivWin->oldRotate.x = pBgWin->drawable.x;
-						pPrivWin->oldRotate.y = pBgWin->drawable.y;
-					}
-				} else if ((pWin->background.pixmap->drawable.width <= PPW) &&
-							  !(pWin->background.pixmap->drawable.width &
-								 (pWin->background.pixmap->drawable.width - 1))) {
-					afbCopyRotatePixmap(pWin->background.pixmap,
-												&pPrivWin->pRotatedBackground,
-												pWin->drawable.x, pWin->drawable.y);
-					if (pPrivWin->pRotatedBackground) {
-						pPrivWin->fastBackground = TRUE;
-						pPrivWin->oldRotate.x = pWin->drawable.x;
-						pPrivWin->oldRotate.y = pWin->drawable.y;
-					} else
-						pPrivWin->fastBackground = FALSE;
-				} else
-					pPrivWin->fastBackground = FALSE;
-					break;
-
-			case CWBackPixel:
-				pPrivWin->fastBackground = FALSE;
-				break;
-
-			case CWBorderPixmap:
-				if ((pWin->border.pixmap->drawable.width <= PPW) &&
-					 !(pWin->border.pixmap->drawable.width &
-						(pWin->border.pixmap->drawable.width - 1))) {
-					for (pBgWin = pWin;
-						  pBgWin->backgroundState == ParentRelative;
-						  pBgWin = pBgWin->parent);
-					afbCopyRotatePixmap(pWin->border.pixmap,
-												&pPrivWin->pRotatedBorder,
-												pBgWin->drawable.x, pBgWin->drawable.y);
-					if (pPrivWin->pRotatedBorder) {
-						pPrivWin->fastBorder = TRUE;
-						pPrivWin->oldRotate.x = pBgWin->drawable.x;
-						pPrivWin->oldRotate.y = pBgWin->drawable.y;
-					} else
-						pPrivWin->fastBorder = FALSE;
-				} else
-					pPrivWin->fastBorder = FALSE;
-				break;
-			case CWBorderPixel:
-				pPrivWin->fastBorder = FALSE;
-				break;
-		}
-	}
-	/* Again, we have no failure modes indicated by any of the routines
-	 * we've called, so we have to assume it worked */
 	return (TRUE);
 }
diff --git a/cfb/Makefile.am.inc b/cfb/Makefile.am.inc
index 5aa913a..a2ee143 100644
--- a/cfb/Makefile.am.inc
+++ b/cfb/Makefile.am.inc
@@ -8,7 +8,7 @@ DISTCLEANFILES = $(libcfb_gen_sources)
 CFB_INCLUDES = -I$(top_srcdir)/mfb -I$(top_srcdir)/cfb
 
 libcfb_common_sources =  $(top_srcdir)/cfb/cfbgc.c $(top_srcdir)/cfb/cfbrrop.c \
-	$(top_srcdir)/cfb/cfbwindow.c $(top_srcdir)/cfb/cfbpntwin.c \
+	$(top_srcdir)/cfb/cfbwindow.c \
 	$(top_srcdir)/cfb/cfbmskbits.c $(top_srcdir)/cfb/cfbpixmap.c \
 	$(top_srcdir)/cfb/cfbbitblt.c $(top_srcdir)/cfb/cfbfillsp.c \
 	$(top_srcdir)/cfb/cfbsetsp.c $(top_srcdir)/cfb/cfbscrinit.c \
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 5614f4f..c9ceda9 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -56,7 +56,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
 
 extern int  cfbGCPrivateIndex;
-extern int  cfbWindowPrivateIndex;
 
 /* private field of GC */
 typedef struct {
@@ -81,20 +80,6 @@ typedef struct {
     CfbBits	xor, and;
 } cfbRRopRec, *cfbRRopPtr;
 
-/* private field of window */
-typedef struct {
-    unsigned	char fastBorder; /* non-zero if border is 32 bits wide */
-    unsigned	char fastBackground;
-    unsigned short unused; /* pad for alignment with Sun compiler */
-    DDXPointRec	oldRotate;
-    PixmapPtr	pRotatedBackground;
-    PixmapPtr	pRotatedBorder;
-    } cfbPrivWin;
-
-#define cfbGetWindowPrivate(_pWin) ((cfbPrivWin *)\
-	(_pWin)->devPrivates[cfbWindowPrivateIndex].ptr)
-
-
 /* cfb8bit.c */
 
 extern int cfbSetStipple(
@@ -313,7 +298,6 @@ extern int cfb8SegmentSS1RectXor(
 
 extern Bool cfbAllocatePrivates(
     ScreenPtr /*pScreen*/,
-    int * /*window_index*/,
     int * /*gc_index*/
 );
 /* cfbbitblt.c */
@@ -806,27 +790,6 @@ extern void cfbFillPoly1RectGeneral(
     int /*count*/,
     DDXPointPtr /*ptsIn*/
 );
-/* cfbpntwin.c */
-
-extern void cfbPaintWindow(
-    WindowPtr /*pWin*/,
-    RegionPtr /*pRegion*/,
-    int /*what*/
-);
-
-extern void cfbFillBoxSolid(
-    DrawablePtr /*pDrawable*/,
-    int /*nBox*/,
-    BoxPtr /*pBox*/,
-    unsigned long /*pixel*/
-);
-
-extern void cfbFillBoxTile32(
-    DrawablePtr /*pDrawable*/,
-    int /*nBox*/,
-    BoxPtr /*pBox*/,
-    PixmapPtr /*tile*/
-);
 /* cfbpolypnt.c */
 
 extern void cfbPolyPoint(
diff --git a/cfb/cfballpriv.c b/cfb/cfballpriv.c
index e0ccdf4..858ff60 100644
--- a/cfb/cfballpriv.c
+++ b/cfb/cfballpriv.c
@@ -45,7 +45,6 @@ in this Software without prior written a
 #include "mibstore.h"
 
 #if 1 || PSZ==8
-int cfbWindowPrivateIndex = -1;
 int cfbGCPrivateIndex = -1;
 #endif
 #ifdef CFB_NEED_SCREEN_PRIVATE
@@ -55,29 +54,20 @@ static unsigned long cfbGeneration = 0;
 
 
 Bool
-cfbAllocatePrivates(pScreen, window_index, gc_index)
-    ScreenPtr	pScreen;
-    int		*window_index, *gc_index;
+cfbAllocatePrivates(ScreenPtr pScreen, int *gc_index)
 {
-    if (!window_index || !gc_index ||
-	(*window_index == -1 && *gc_index == -1))
+    if (!gc_index || *gc_index == -1)
     {
-    	if (!mfbAllocatePrivates(pScreen,
-			     	 &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+    	if (!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
 	    return FALSE;
-    	if (window_index)
-	    *window_index = cfbWindowPrivateIndex;
     	if (gc_index)
 	    *gc_index = cfbGCPrivateIndex;
     }
     else
     {
-	cfbWindowPrivateIndex = *window_index;
 	cfbGCPrivateIndex = *gc_index;
     }
-    if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex,
-			       sizeof(cfbPrivWin)) ||
-	!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+    if (!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
 	return FALSE;
 #ifdef CFB_NEED_SCREEN_PRIVATE
     if (cfbGeneration != serverGeneration)
diff --git a/cfb/cfbmap.h b/cfb/cfbmap.h
index 1d6a3f8..2e709b1 100644
--- a/cfb/cfbmap.h
+++ b/cfb/cfbmap.h
@@ -71,8 +71,6 @@ in this Software without prior written a
 #undef cfbDoBitbltGeneral
 #undef cfbDoBitbltOr
 #undef cfbDoBitbltXor
-#undef cfbFillBoxSolid
-#undef cfbFillBoxTile32
 #undef cfbFillBoxTile32sCopy
 #undef cfbFillBoxTile32sGeneral
 #undef cfbFillBoxTileOdd
@@ -108,7 +106,6 @@ in this Software without prior written a
 #undef cfbNonTEOps
 #undef cfbNonTEOps1Rect
 #undef cfbPadPixmap
-#undef cfbPaintWindow
 #undef cfbPolyFillArcSolidCopy
 #undef cfbPolyFillArcSolidGeneral
 #undef cfbPolyFillRect
@@ -250,8 +247,6 @@ cfb can not hack PSZ yet
 #define cfbDoBitbltOr CFBNAME(DoBitbltOr)
 #define cfbDoBitbltXor CFBNAME(DoBitbltXor)
 #define cfbExpandDirectColors CFBNAME(cfbExpandDirectColors)
-#define cfbFillBoxSolid CFBNAME(FillBoxSolid)
-#define cfbFillBoxTile32 CFBNAME(FillBoxTile32)
 #define cfbFillBoxTile32sCopy CFBNAME(FillBoxTile32sCopy)
 #define cfbFillBoxTile32sGeneral CFBNAME(FillBoxTile32sGeneral)
 #define cfbFillBoxTileOdd CFBNAME(FillBoxTileOdd)
@@ -288,7 +283,6 @@ cfb can not hack PSZ yet
 #define cfbNonTEOps CFBNAME(NonTEOps)
 #define cfbNonTEOps1Rect CFBNAME(NonTEOps1Rect)
 #define cfbPadPixmap CFBNAME(PadPixmap)
-#define cfbPaintWindow CFBNAME(PaintWindow)
 #define cfbPolyFillArcSolidCopy CFBNAME(PolyFillArcSolidCopy)
 #define cfbPolyFillArcSolidGeneral CFBNAME(PolyFillArcSolidGeneral)
 #define cfbPolyFillRect CFBNAME(PolyFillRect)
diff --git a/cfb/cfbpntwin.c b/cfb/cfbpntwin.c
deleted file mode 100644
index 32f011e..0000000
--- a/cfb/cfbpntwin.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 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.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "cfb.h"
-#include "cfbmskbits.h"
-#include "mi.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-void
-cfbPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-    register cfbPrivWin	*pPrivWin;
-    WindowPtr	pBgWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    break;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		cfbFillBoxTile32 ((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  pPrivWin->pRotatedBackground);
-	    }
-	    else
-	    {
-		int xorg = pWin->drawable.x;
-		int yorg = pWin->drawable.y;
-#ifdef PANORAMIX
-		if(!noPanoramiXExtension) {
-		    int index = pWin->drawable.pScreen->myNum;
-		    if(WindowTable[index] == pWin) {
-			xorg -= panoramiXdataPtr[index].x;
-			yorg -= panoramiXdataPtr[index].y;
-		    }
-		}
-#endif
-		cfbFillBoxTileOdd ((DrawablePtr)pWin,
-				   (int)REGION_NUM_RECTS(pRegion),
-				   REGION_RECTS(pRegion),
-				   pWin->background.pixmap,
-				   xorg, yorg);
-	    }
-	    break;
-	case BackgroundPixel:
-	    cfbFillBoxSolid ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    cfbFillBoxSolid ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	}
-	else if (pPrivWin->fastBorder)
-	{
-	    cfbFillBoxTile32 ((DrawablePtr)pWin,
-			      (int)REGION_NUM_RECTS(pRegion),
-			      REGION_RECTS(pRegion),
-			      pPrivWin->pRotatedBorder);
-	}
-	else
-	{
-	    int xorg, yorg;
-
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    xorg = pBgWin->drawable.x;
-	    yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pBgWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-
-	    cfbFillBoxTileOdd ((DrawablePtr)pWin,
-			       (int)REGION_NUM_RECTS(pRegion),
-			       REGION_RECTS(pRegion),
-			       pWin->border.pixmap,
-			       xorg, yorg);
-	}
-	break;
-    }
-}
-
-/*
- * Use the RROP macros in copy mode
- */
-
-#define RROP GXcopy
-#include "cfbrrop.h"
-
-#ifdef RROP_UNROLL
-# define Expand(left,right,leftAdjust) {\
-    int part = nmiddle & RROP_UNROLL_MASK; \
-    int widthStep; \
-    widthStep = widthDst - nmiddle - leftAdjust; \
-    nmiddle >>= RROP_UNROLL_SHIFT; \
-    while (h--) { \
-	left \
-	pdst += part; \
-	switch (part) { \
-	    RROP_UNROLL_CASE(pdst) \
-	} \
-	m = nmiddle; \
-	while (m) { \
-	    pdst += RROP_UNROLL; \
-	    RROP_UNROLL_LOOP(pdst) \
-	    m--; \
-	} \
-	right \
-	pdst += widthStep; \
-    } \
-}
-
-#else
-# define Expand(left, right, leftAdjust) { \
-    int widthStep; \
-    widthStep = widthDst - nmiddle - leftAdjust; \
-    while (h--) { \
-	left \
-	m = nmiddle; \
-	while (m--) {\
-	    RROP_SOLID(pdst); \
-	    pdst++; \
-	} \
-	right \
-	pdst += widthStep; \
-    } \
-}
-#endif
-
-void
-cfbFillBoxSolid (pDrawable, nBox, pBox, pixel)
-    DrawablePtr	    pDrawable;
-    int		    nBox;
-    BoxPtr	    pBox;
-    unsigned long   pixel;
-{
-    CfbBits   *pdstBase;
-    int		    widthDst;
-    register int    h;
-    register CfbBits   *pdst;
-    int		    nmiddle;
-    int		    w;
-#if PSZ == 24
-    int leftIndex, rightIndex;
-    CfbBits piQxelArray[3], *pdstULC; /*upper left corner*/
-
-    piQxelArray[0] = (pixel&0xFFFFFF) | ((pixel&0xFF)<<24);
-    piQxelArray[1] = ((pixel&0xFFFF00)>>8) | ((pixel&0xFFFF)<<16);
-    piQxelArray[2] = ((pixel&0xFFFFFF)<<8) | ((pixel&0xFF0000)>>16);
-#else
-    register CfbBits   rrop_xor;
-    register CfbBits   leftMask, rightMask;
-    register int    m;
-#endif
-
-    cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase);
-
-#if PSZ != 24
-    rrop_xor = PFILL(pixel);
-#endif
-    for (; nBox; nBox--, pBox++)
-    {
-    	pdst = pdstBase + pBox->y1 * widthDst;
-    	h = pBox->y2 - pBox->y1;
-	w = pBox->x2 - pBox->x1;
-#if PSZ == 8
-	if (w == 1)
-	{
-	    register char    *pdstb = ((char *) pdst) + pBox->x1;
-	    int	    incr = widthDst * PGSZB;
-
-	    while (h--)
-	    {
-		*pdstb = rrop_xor;
-		pdstb += incr;
-	    }
-	}
-	else
-	{
-#endif
-#if PSZ == 24
-/* _Box has x1, y1, x2, y2*/
-	  leftIndex = pBox->x1 & 3;
-	  rightIndex = ((leftIndex+w)<5)?0:(pBox->x2 &3);
-	  nmiddle = w - rightIndex;
-	  if(leftIndex){
-	      nmiddle -= (4 - leftIndex);
-	  }
-	  nmiddle >>= 2;
-	  if(nmiddle < 0)
-	    nmiddle = 0;
-
-	  pdst = pdstBase + pBox->y1 * widthDst + ((pBox->x1*3) >> 2);
-
-	  switch(leftIndex+w){
-	  case 4:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst -=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst -=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst-- = piQxelArray[2];
-		pdst += widthDst;
-	      }
-	      break;
-	    case 3:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 3:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 2:
-	    while(h--){
-	      if(leftIndex){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-	      }
-	      else{
-		*pdst++ = piQxelArray[0];
-	      }
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		pdst--;
-		pdst += widthDst;
-	    }
-	    break;
-	  case 1: /*only if leftIndex = 0 and w = 1*/
-	    while(h--){
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		pdst += widthDst;
-	      }
-	    break;
-	  case 0: /*never*/
-	    break;
-	  default:
-	  {
-	    w = nmiddle;
-	    pdstULC = pdst;
-/*	    maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);*/
-	    while(h--){
-	      nmiddle = w;
-	      pdst = pdstULC;
-	      switch(leftIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 2:
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 3:
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst++;
-	        break;
-	      }
-	      while(nmiddle--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	      }
-	      switch(rightIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-	        break;
-	      case 2:
-		*pdst++ = piQxelArray[0];
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-	        break;
-	      case 3:
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-	        break;
-	    }
-	    pdstULC += widthDst;
-	    }
-
-	  }
-	}
-#else
-	pdst += (pBox->x1 >> PWSH);
-	if ((pBox->x1 & PIM) + w <= PPW)
-	{
-	    maskpartialbits(pBox->x1, w, leftMask);
-	    while (h--) {
-		*pdst = (*pdst & ~leftMask) | (rrop_xor & leftMask);
-		pdst += widthDst;
-	    }
-	}
-	else
-	{
-	    maskbits (pBox->x1, w, leftMask, rightMask, nmiddle);
-	    if (leftMask)
-	    {
-		if (rightMask)
-		{
-		    Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++; ,
-			    RROP_SOLID_MASK (pdst, rightMask); ,
-			    1)
-		}
-		else
-		{
-		    Expand (RROP_SOLID_MASK (pdst, leftMask); pdst++;,
-			    ;,
-			    1)
-		}
-	    }
-	    else
-	    {
-		if (rightMask)
-		{
-		    Expand (;,
-			    RROP_SOLID_MASK (pdst, rightMask);,
-			    0)
-		}
-		else
-		{
-		    Expand (;,
-			    ;,
-			    0)
-		}
-	    }
-	}
-#endif
-#if PSZ == 8
-	}
-#endif
-    }
-}
-
-void
-cfbFillBoxTile32 (pDrawable, nBox, pBox, tile)
-    DrawablePtr	    pDrawable;
-    int		    nBox;	/* number of boxes to fill */
-    BoxPtr 	    pBox;	/* pointer to list of boxes to fill */
-    PixmapPtr	    tile;	/* rotated, expanded tile */
-{
-    register CfbBits  *pdst;
-    CfbBits	    *psrc;
-    int			    tileHeight;
-
-    int			    widthDst;
-    int			    w;
-    int			    h;
-    int			    nmiddle;
-    int			    y;
-    int			    srcy;
-
-    CfbBits	    *pdstBase;
-#if PSZ == 24
-    int			    leftIndex, rightIndex;
-    CfbBits piQxelArray[3], *pdstULC;
-#else
-    register CfbBits  rrop_xor;	
-    register CfbBits  leftMask;
-    register CfbBits  rightMask;
-    register int      m;
-#endif
-
-    tileHeight = tile->drawable.height;
-    psrc = (CfbBits *)tile->devPrivate.ptr;
-
-    cfbGetLongWidthAndPointer (pDrawable, widthDst, pdstBase);
-
-    while (nBox--)
-    {
-#if PSZ == 24
-	w = pBox->x2 - pBox->x1;
-	h = pBox->y2 - pBox->y1;
-	y = pBox->y1;
-	leftIndex = pBox->x1 & 3;
-/*	rightIndex = ((leftIndex+w)<5)?0:pBox->x2 &3;*/
-	rightIndex = pBox->x2 &3;
-	nmiddle = w - rightIndex;
-	if(leftIndex){
-	  nmiddle -= (4 - leftIndex);
-	}
-	nmiddle >>= 2;
-	if(nmiddle < 0)
-	  nmiddle = 0;
-
-	pdst = pdstBase + ((pBox->x1 *3)>> 2) +  pBox->y1 * widthDst;
-	srcy = y % tileHeight;
-
-#define StepTile    piQxelArray[0] = (psrc[srcy] & 0xFFFFFF) | ((psrc[srcy] & 0xFF)<<24); \
-		    piQxelArray[1] = (psrc[srcy] & 0xFFFF00) | ((psrc[srcy] & 0xFFFF)<<16); \
-		    piQxelArray[2] = ((psrc[srcy] & 0xFF0000)>>16) | \
-		    		     ((psrc[srcy] & 0xFFFFFF)<<8); \
-		    /*rrop_xor = psrc[srcy];*/ \
-		    ++srcy; \
-		    if (srcy == tileHeight) \
-		        srcy = 0;
-
-	  switch(leftIndex+w){
-	  case 4:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		  StepTile
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst-=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst   = piQxelArray[2];
-		pdst-=2;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst--   = piQxelArray[2];
-		pdst += widthDst;
-	      }
-	      break;
-	    case 3:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 3:
-	    switch(leftIndex){
-	    case 0:
-	      while(h--){
-		  StepTile
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 1:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    case 2:
-	      while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		pdst--;
-		pdst += widthDst;
-	      }
-	      break;
-	    }
-	    break;
-	  case 2:
-	    while(h--){
-		  StepTile
-	      if(leftIndex){
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-	      }
-	      else{
-		*pdst++ = piQxelArray[0];
-	      }
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		pdst--;
-		pdst += widthDst;
-	    }
-	    break;
-	  case 1: /*only if leftIndex = 0 and w = 1*/
-	    while(h--){
-		  StepTile
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		pdst += widthDst;
-	      }
-	    break;
-	  case 0: /*never*/
-	    break;
-	  default:
-	  {
-	    w = nmiddle;
-	    pdstULC = pdst;
-
-	    while(h--){
-	      StepTile
-	      nmiddle = w;
-	      pdst = pdstULC;
-	      switch(leftIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFFFFFF) | (piQxelArray[0] & 0xFF000000);
-		pdst++;
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 2:
-		*pdst = ((*pdst) & 0xFFFF) | (piQxelArray[1] & 0xFFFF0000);
-		pdst++;
-		*pdst++ = piQxelArray[2];
-	        break;
-	      case 3:
-		*pdst = ((*pdst) & 0xFF) | (piQxelArray[2] & 0xFFFFFF00);
-		pdst++;
-	        break;
-	      }
-	      while(nmiddle--){
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst++ = piQxelArray[2];
-	      }
-	      switch(rightIndex){
-	      case 0:
-		break;
-	      case 1:
-		*pdst = ((*pdst) & 0xFF000000) | (piQxelArray[0] & 0xFFFFFF);
-		break;
-	      case 2:
-		*pdst++ = piQxelArray[0];
-		*pdst = ((*pdst) & 0xFFFF0000) | (piQxelArray[1] & 0xFFFF);
-		break;
-	      case 3:
-		*pdst++ = piQxelArray[0];
-		*pdst++ = piQxelArray[1];
-		*pdst = ((*pdst) & 0xFFFFFF00) | (piQxelArray[2] & 0xFF);
-		break;
-	      }
-	      pdstULC += widthDst;
-	    }
-	  }
-	  }
-#else
-	w = pBox->x2 - pBox->x1;
-	h = pBox->y2 - pBox->y1;
-	y = pBox->y1;
-	pdst = pdstBase + (pBox->y1 * widthDst) + (pBox->x1 >> PWSH);
-	srcy = y % tileHeight;
-
-#define StepTile    rrop_xor = psrc[srcy]; \
-		    ++srcy; \
-		    if (srcy == tileHeight) \
-		        srcy = 0;
-
-	if ( ((pBox->x1 & PIM) + w) < PPW)
-	{
-	    maskpartialbits(pBox->x1, w, leftMask);
-	    rightMask = ~leftMask;
-	    while (h--)
-	    {
-		StepTile
-		*pdst = (*pdst & rightMask) | (rrop_xor & leftMask);
-		pdst += widthDst;
-	    }
-	}
-	else
-	{
-	    maskbits(pBox->x1, w, leftMask, rightMask, nmiddle);
-
-	    if (leftMask)
-	    {
-		if (rightMask)
-		{
-		    Expand (StepTile
-			    RROP_SOLID_MASK(pdst, leftMask); pdst++;,
-			    RROP_SOLID_MASK(pdst, rightMask);,
-			    1)
-		}
-		else
-		{
-		    Expand (StepTile
-			    RROP_SOLID_MASK(pdst, leftMask); pdst++;,
-			    ;,
-			    1)
-		}
-	    }
-	    else
-	    {
-		if (rightMask)
-		{
-		    Expand (StepTile
-			    ,
-			    RROP_SOLID_MASK(pdst, rightMask);,
-			    0)
-		}
-		else
-		{
-		    Expand (StepTile
-			    ,
-			    ;,
-			    0)
-		}
-	    }
-	}
-#endif
-        pBox++;
-    }
-}
diff --git a/cfb/cfbscrinit.c b/cfb/cfbscrinit.c
index 83f5cf0..ddfb41e 100644
--- a/cfb/cfbscrinit.c
+++ b/cfb/cfbscrinit.c
@@ -88,7 +88,7 @@ cfbSetupScreen(pScreen, pbits, xsize, ys
     int dpix, dpiy;		/* dots per inch */
     int width;			/* pixel width of frame buffer */
 {
-    if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
+    if (!cfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
     pScreen->defColormap = FakeClientID(0);
     /* let CreateDefColormap do whatever it wants for pixels */ 
@@ -103,8 +103,6 @@ cfbSetupScreen(pScreen, pbits, xsize, ys
     pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
     pScreen->RealizeWindow = cfbMapWindow;
     pScreen->UnrealizeWindow = cfbUnmapWindow;
-    pScreen->PaintWindowBackground = cfbPaintWindow;
-    pScreen->PaintWindowBorder = cfbPaintWindow;
     pScreen->CopyWindow = cfbCopyWindow;
     pScreen->CreatePixmap = cfbCreatePixmap;
     pScreen->DestroyPixmap = cfbDestroyPixmap;
diff --git a/cfb/cfbtile32.c b/cfb/cfbtile32.c
index fb6a106..90439ad 100644
--- a/cfb/cfbtile32.c
+++ b/cfb/cfbtile32.c
@@ -1,5 +1,5 @@
 /*
- * Fill 32 bit tiled rectangles.  Used by both PolyFillRect and PaintWindow.
+ * Fill 32 bit tiled rectangles.  Used by PolyFillRect.
  * no depth dependencies.
  */
 
diff --git a/cfb/cfbunmap.h b/cfb/cfbunmap.h
index 61c7fc9..d15c23e 100644
--- a/cfb/cfbunmap.h
+++ b/cfb/cfbunmap.h
@@ -74,8 +74,6 @@
 #undef cfbDoBitbltOr
 #undef cfbDoBitbltXor
 #undef cfbExpandDirectColors
-#undef cfbFillBoxSolid
-#undef cfbFillBoxTile32
 #undef cfbFillBoxTile32sCopy
 #undef cfbFillBoxTile32sGeneral
 #undef cfbFillBoxTileOdd
@@ -112,7 +110,6 @@
 #undef cfbNonTEOps
 #undef cfbNonTEOps1Rect
 #undef cfbPadPixmap
-#undef cfbPaintWindow
 #undef cfbPolyFillArcSolidCopy
 #undef cfbPolyFillArcSolidGeneral
 #undef cfbPolyFillRect
diff --git a/cfb/cfbwindow.c b/cfb/cfbwindow.c
index e04b73d..c4f027b 100644
--- a/cfb/cfbwindow.c
+++ b/cfb/cfbwindow.c
@@ -60,19 +60,8 @@ SOFTWARE.
 #include "cfbmskbits.h"
 
 Bool
-cfbCreateWindow(pWin)
-    WindowPtr pWin;
+cfbCreateWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-    pPrivWin->oldRotate.x = 0;
-    pPrivWin->oldRotate.y = 0;
-
 #ifdef PIXMAP_PER_WINDOW
     /* Setup pointer to Screen pixmap */
     pWin->devPrivates[frameWindowPrivateIndex].ptr =
@@ -83,17 +72,8 @@ cfbCreateWindow(pWin)
 }
 
 Bool
-cfbDestroyWindow(pWin)
-    WindowPtr pWin;
+cfbDestroyWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-    if (pPrivWin->pRotatedBorder)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-    if (pPrivWin->pRotatedBackground)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
     return(TRUE);
 }
 
@@ -105,47 +85,10 @@ cfbMapWindow(pWindow)
     return(TRUE);
 }
 
-/* (x, y) is the upper left corner of the window on the screen 
-   do we really need to pass this?  (is it a;ready in pWin->absCorner?)
-   we only do the rotation for pixmaps that are 32 bits wide (padded
-or otherwise.)
-   cfbChangeWindowAttributes() has already put a copy of the pixmap
-in pPrivWin->pRotated*
-*/
 /*ARGSUSED*/
 Bool
-cfbPositionWindow(pWin, x, y)
-    WindowPtr pWin;
-    int x, y;
+cfbPositionWindow(WindowPtr pWin, int x, int y)
 {
-    cfbPrivWin *pPrivWin;
-    int setxy = 0;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-    if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
-    {
-	cfbXRotatePixmap(pPrivWin->pRotatedBackground,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBackground,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	setxy = 1;
-    }
-
-    if (!pWin->borderIsPixel &&	pPrivWin->fastBorder)
-    {
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-	cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	setxy = 1;
-    }
-    if (setxy)
-    {
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
     return (TRUE);
 }
 
@@ -209,129 +152,9 @@ cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivates[cfbWindowPrivateIndex].ptr.
-*/
 Bool
-cfbChangeWindowAttributes(pWin, mask)
-    WindowPtr pWin;
-    unsigned long mask;
+cfbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
 {
-    register unsigned long index;
-    register cfbPrivWin *pPrivWin;
-    int width;
-    WindowPtr	pBgWin;
-
-    pPrivWin = cfbGetWindowPrivate(pWin);
-
-    /*
-     * When background state changes from ParentRelative and
-     * we had previously rotated the fast border pixmap to match
-     * the parent relative origin, rerotate to match window
-     */
-    if (mask & (CWBackPixmap | CWBackPixel) &&
-	pWin->backgroundState != ParentRelative &&
-	pPrivWin->fastBorder &&
-	(pPrivWin->oldRotate.x != pWin->drawable.x ||
-	 pPrivWin->oldRotate.y != pWin->drawable.y))
-    {
-	cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-    while(mask)
-    {
-	index = lowbit (mask);
-	mask &= ~index;
-	switch(index)
-	{
-	case CWBackPixmap:
-	    if (pWin->backgroundState == None)
-	    {
-		pPrivWin->fastBackground = FALSE;
-	    }
-	    else if (pWin->backgroundState == ParentRelative)
-	    {
-		pPrivWin->fastBackground = FALSE;
-		/* Rotate border to match parent origin */
-		if (pPrivWin->pRotatedBorder) {
-		    for (pBgWin = pWin->parent;
-			 pBgWin->backgroundState == ParentRelative;
-			 pBgWin = pBgWin->parent);
-		    cfbXRotatePixmap(pPrivWin->pRotatedBorder,
-				  pBgWin->drawable.x - pPrivWin->oldRotate.x);
-		    cfbYRotatePixmap(pPrivWin->pRotatedBorder,
-				  pBgWin->drawable.y - pPrivWin->oldRotate.y);
-		    pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		    pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		}
-	    }
-	    else if (((width = (pWin->background.pixmap->drawable.width * PSZ))
-		      <= PGSZ) && !(width & (width - 1)))
-	    {
-		cfbCopyRotatePixmap(pWin->background.pixmap,
-				    &pPrivWin->pRotatedBackground,
-				    pWin->drawable.x,
-				    pWin->drawable.y);
-		if (pPrivWin->pRotatedBackground)
-		{
-		    pPrivWin->fastBackground = TRUE;
-		    pPrivWin->oldRotate.x = pWin->drawable.x;
-		    pPrivWin->oldRotate.y = pWin->drawable.y;
-		}
-		else
-		{
-		    pPrivWin->fastBackground = FALSE;
-		}
-	    }
-	    else
-	    {
-		pPrivWin->fastBackground = FALSE;
-	    }
-	    break;
-
-	case CWBackPixel:
-	    pPrivWin->fastBackground = FALSE;
-	    break;
-
-	case CWBorderPixmap:
-	    if (((width = (pWin->border.pixmap->drawable.width * PSZ)) <= PGSZ) &&
-		!(width & (width - 1)))
-	    {
-		for (pBgWin = pWin;
-		     pBgWin->backgroundState == ParentRelative;
-		     pBgWin = pBgWin->parent);
-		cfbCopyRotatePixmap(pWin->border.pixmap,
-				    &pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.x,
-				    pBgWin->drawable.y);
-		if (pPrivWin->pRotatedBorder)
-		{
-		    pPrivWin->fastBorder = TRUE;
-		    pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		    pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		}
-		else
-		{
-		    pPrivWin->fastBorder = FALSE;
-		}
-	    }
-	    else
-	    {
-		pPrivWin->fastBorder = FALSE;
-	    }
-	    break;
-	 case CWBorderPixel:
-	    pPrivWin->fastBorder = FALSE;
-	    break;
-	}
-    }
     return (TRUE);
 }
 
diff --git a/composite/compinit.c b/composite/compinit.c
index c557eeb..5f09fe2 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -70,7 +70,6 @@ compCloseScreen (int index, ScreenPtr pS
     pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
     
     pScreen->ClipNotify = cs->ClipNotify;
-    pScreen->PaintWindowBackground = cs->PaintWindowBackground;
     pScreen->UnrealizeWindow = cs->UnrealizeWindow;
     pScreen->RealizeWindow = cs->RealizeWindow;
     pScreen->DestroyWindow = cs->DestroyWindow;
@@ -431,9 +430,6 @@ compScreenInit (ScreenPtr pScreen)
     cs->UnrealizeWindow = pScreen->UnrealizeWindow;
     pScreen->UnrealizeWindow = compUnrealizeWindow;
 
-    cs->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = compPaintWindowBackground;
-
     cs->ClipNotify = pScreen->ClipNotify;
     pScreen->ClipNotify = compClipNotify;
 
diff --git a/composite/compint.h b/composite/compint.h
index f69595c..535e1a4 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -123,7 +123,6 @@ typedef struct _CompScreen {
     DestroyWindowProcPtr	DestroyWindow;
     RealizeWindowProcPtr	RealizeWindow;
     UnrealizeWindowProcPtr	UnrealizeWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
     ClipNotifyProcPtr		ClipNotify;
     /*
      * Called from ConfigureWindow, these
@@ -256,9 +255,6 @@ Bool
 compUnrealizeWindow (WindowPtr pWin);
 
 void
-compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 compClipNotify (WindowPtr pWin, int dx, int dy);
 
 void
diff --git a/composite/compwindow.c b/composite/compwindow.c
index bfd2946..5792367 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -99,7 +99,7 @@ compRepaintBorder (ClientPtr pClient, po
 
 	REGION_NULL(pScreen, &exposed);
 	REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
-	(*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER);
+	miPaintWindow(pWindow, &exposed, PW_BORDER);
 	REGION_UNINIT(pScreen, &exposed);
     }
     return TRUE;
@@ -240,21 +240,6 @@ compUnrealizeWindow (WindowPtr pWin)
     return ret;
 }
 
-void
-compPaintWindowBackground (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr		pScreen = pWin->drawable.pScreen;
-    CompSubwindowsPtr	csw = GetCompSubwindows (pWin);
-    CompScreenPtr	cs = GetCompScreen (pScreen);
-    
-    if (csw && csw->update == CompositeRedirectManual)
-	return;
-    pScreen->PaintWindowBackground = cs->PaintWindowBackground;
-    (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-    cs->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = compPaintWindowBackground;
-}
-
 /*
  * Called after the borderClip for the window has settled down
  * We use this to make sure our extra borderClip has the right origin
diff --git a/dix/window.c b/dix/window.c
index ca4335c..717c5a7 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -1522,7 +1522,7 @@ PatchUp:
 
 	REGION_NULL(pScreen, &exposed);
 	REGION_SUBTRACT(pScreen, &exposed, &pWin->borderClip, &pWin->winSize);
-	(*pWin->drawable.pScreen->PaintWindowBorder)(pWin, &exposed, PW_BORDER);
+	miPaintWindow(pWin, &exposed, PW_BORDER);
 	REGION_UNINIT(pScreen, &exposed);
     }
     return error;
diff --git a/exa/exa.c b/exa/exa.c
index 458272d..eac2d91 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -604,8 +604,6 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     pScreen->CloseScreen = pExaScr->SavedCloseScreen;
     pScreen->GetImage = pExaScr->SavedGetImage;
     pScreen->GetSpans = pExaScr->SavedGetSpans;
-    pScreen->PaintWindowBackground = pExaScr->SavedPaintWindowBackground;
-    pScreen->PaintWindowBorder = pExaScr->SavedPaintWindowBorder;
     pScreen->CreatePixmap = pExaScr->SavedCreatePixmap;
     pScreen->DestroyPixmap = pExaScr->SavedDestroyPixmap;
     pScreen->CopyWindow = pExaScr->SavedCopyWindow;
@@ -759,12 +757,6 @@ exaDriverInit (ScreenPtr		pScreen,
     pExaScr->SavedBitmapToRegion = pScreen->BitmapToRegion;
     pScreen->BitmapToRegion = exaBitmapToRegion;
 
-    pExaScr->SavedPaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = exaPaintWindow;
-
-    pExaScr->SavedPaintWindowBorder = pScreen->PaintWindowBorder;
-    pScreen->PaintWindowBorder = exaPaintWindow;
-
 #ifdef RENDER
     if (ps) {
         pExaScr->SavedComposite = ps->Composite;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 232ec99..8500c5b 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1304,54 +1304,6 @@ fallback:
     return TRUE;
 }
 
-void
-exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ExaScreenPriv (pWin->drawable.pScreen);
-
-    if (REGION_NIL(pRegion))
-	return;
-
-    if (!pExaScr->swappedOut) {
-	DDXPointRec zeros = { 0, 0 };
-
-        switch (what) {
-        case PW_BACKGROUND:
-            switch (pWin->backgroundState) {
-            case None:
-                return;
-            case ParentRelative:
-                do {
-                    pWin = pWin->parent;
-                } while (pWin->backgroundState == ParentRelative);
-                (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-                                                                 what);
-                return;
-            case BackgroundPixel:
-		exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel,
-				   FB_ALLONES, GXcopy);
-                return;
-            case BackgroundPixmap:
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap,
-				   &zeros, FB_ALLONES, GXcopy);
-                return;
-            }
-            break;
-        case PW_BORDER:
-            if (pWin->borderIsPixel) {
-                exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel,
-				   FB_ALLONES, GXcopy);
-                return;
-            } else {
-                exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap,
-				   &zeros, FB_ALLONES, GXcopy);
-                return;
-            }
-            break;
-        }
-    }
-    ExaCheckPaintWindow (pWin, pRegion, what);
-}
 
 /**
  * Accelerates GetImage for solid ZPixmap downloads from framebuffer memory.
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 02371d7..9e4f8bc 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -101,10 +101,8 @@ typedef struct {
     CloseScreenProcPtr 		 SavedCloseScreen;
     GetImageProcPtr 		 SavedGetImage;
     GetSpansProcPtr 		 SavedGetSpans;
-    PaintWindowBackgroundProcPtr SavedPaintWindowBackground;
     CreatePixmapProcPtr 	 SavedCreatePixmap;
     DestroyPixmapProcPtr 	 SavedDestroyPixmap;
-    PaintWindowBorderProcPtr 	 SavedPaintWindowBorder;
     CopyWindowProcPtr 		 SavedCopyWindow;
     ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
     BitmapToRegionProcPtr        SavedBitmapToRegion;
@@ -272,9 +270,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
 		 int nspans,
 		 char *pdstStart);
 
-void
-ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
-
 CARD32
 exaGetPixmapFirstPixel (PixmapPtr pPixmap); 
 
@@ -297,9 +292,6 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 		    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu);
 
 void
-exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 exaShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int format,
 	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
 	       char *data);
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index f4d453e..d487dc5 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -278,23 +278,6 @@ ExaCheckGetSpans (DrawablePtr pDrawable,
     exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
 }
 
-/* XXX: Note the lack of a prepare on the tile, if the window has a tiled
- * background.  This function happens to only be called if pExaScr->swappedOut,
- * so we actually end up not having to do it since the tile won't be in fb.
- * That doesn't make this not dirty, though.
- */
-void
-ExaCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    EXA_FALLBACK(("from %p (%c)\n", pWin,
-		  exaDrawableLocation(&pWin->drawable)));
-    exaPrepareAccess (&pWin->drawable, EXA_PREPARE_DEST);
-    exaPrepareAccessWindow(pWin);
-    fbPaintWindow (pWin, pRegion, what);
-    exaFinishAccessWindow(pWin);
-    exaFinishAccess (&pWin->drawable, EXA_PREPARE_DEST);
-}
-
 void
 ExaCheckComposite (CARD8      op,
                    PicturePtr pSrc,
diff --git a/fb/fb.h b/fb/fb.h
index a924f49..379a00a 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2094,10 +2094,6 @@ fbFillRegionTiled (DrawablePtr	pDrawable
 		   RegionPtr	pRegion,
 		   PixmapPtr	pTile);
 
-void
-fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-
 pixman_image_t *image_from_pict (PicturePtr pict,
 				 Bool       has_clip);
 void free_pixman_pict (PicturePtr, pixman_image_t *);
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 5d7481e..0d1eb88 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -278,16 +278,6 @@ fbOverlayWindowExposures (WindowPtr	pWin
     miWindowExposures(pWin, prgn, other_exposed);
 }
 
-void
-fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    if (what == PW_BORDER)
-	fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
-				    fbOverlayWindowLayer (pWin),
-				    pRegion);
-    fbPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 fbOverlaySetupScreen(ScreenPtr	pScreen,
 		     pointer	pbits1,
@@ -441,7 +431,6 @@ fbOverlayFinishScreenInit(ScreenPtr	pScr
     pScreen->CreateWindow = fbOverlayCreateWindow;
     pScreen->WindowExposures = fbOverlayWindowExposures;
     pScreen->CopyWindow = fbOverlayCopyWindow;
-    pScreen->PaintWindowBorder = fbOverlayPaintWindow;
 #ifdef FB_24_32BIT
     if (bpp == 24 && imagebpp == 32)
     {
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index af0acb8..55135ea 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -93,10 +93,6 @@ fbOverlayWindowExposures (WindowPtr	pWin
 			  RegionPtr	prgn,
 			  RegionPtr	other_exposed);
 
-void
-fbOverlayPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
-
 Bool
 fbOverlaySetupScreen(ScreenPtr	pScreen,
 		     pointer	pbits1,
diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c
index 271e981..411bde1 100644
--- a/fb/fbpseudocolor.c
+++ b/fb/fbpseudocolor.c
@@ -94,8 +94,6 @@ typedef struct {
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr		CreateWindow;
     CopyWindowProcPtr		CopyWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
-    PaintWindowProcPtr		PaintWindowBorder;
     WindowExposuresProcPtr	WindowExposures;
     CreateGCProcPtr		CreateGC;
     CreateColormapProcPtr	CreateColormap;
@@ -795,70 +793,6 @@ xxWindowExposures (WindowPtr	pWin,
 }
 
 static void
-xxPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    xxScrPriv(pWin->drawable.pScreen);
-    RegionRec		rgni;
-
-    DBG("xxPaintWindow\n");
-
-    REGION_NULL (pWin->drawable.pScreen, &rgni);
-#if 0
-    REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, &pWin->borderClip);
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgni, &rgni, pRegion);
-#else
-    REGION_UNION (pWin->drawable.pScreen, &rgni, &rgni, pRegion);
-#endif
-    switch (what) {
-    case PW_BORDER:
-	REGION_SUBTRACT (pWin->drawable.pScreen, &rgni, &rgni, &pWin->winSize);
-	if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
-	    DBG("PaintWindowBorder\n");
-	    REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
-			  &pScrPriv->region, &rgni);
-	} else {
-	    DBG("PaintWindowBorder NoOverlay\n");
-	    REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
-			     &pScrPriv->region, &rgni);	
-	}
-	unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBorder);
-	pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
-	wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBorder,
-	     xxPaintWindow);	
-	break;
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	default:
-	    REGION_INTERSECT (pWin->drawable.pScreen, &rgni,
-			      &rgni,&pWin->winSize);
-	    if (fbGetWindowPixmap(pWin) == pScrPriv->pPixmap) {
-		DBG("PaintWindowBackground\n");
-		REGION_UNION (pWin->drawable.pScreen, &pScrPriv->region,
-			      &pScrPriv->region, &rgni);
-	    } else {
-		DBG("PaintWindowBackground NoOverlay\n");
-		REGION_SUBTRACT (pWin->drawable.pScreen, &pScrPriv->region,
-				 &pScrPriv->region, &rgni);	
-	    }
-	    break;
-	}
-	
-	unwrap (pScrPriv, pWin->drawable.pScreen, PaintWindowBackground);
-	pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
-	wrap(pScrPriv, pWin->drawable.pScreen, PaintWindowBackground,
-	     xxPaintWindow);
-	break;
-    }
-    PRINT_RECTS(rgni);
-    PRINT_RECTS(pScrPriv->region);
-#if 1
-    REGION_UNINIT(pWin->drawable.pScreen,&rgni);
-#endif
-}
-
-static void
 xxCopyPseudocolorRegion(ScreenPtr pScreen, RegionPtr pReg,
 			xxCmapPrivPtr pCmapPriv)
 {
@@ -1171,8 +1105,6 @@ xxSetup(ScreenPtr pScreen, int myDepth, 
     wrap (pScrPriv, pScreen, CreateScreenResources, xxCreateScreenResources);
     wrap (pScrPriv, pScreen, CreateWindow, xxCreateWindow);
     wrap (pScrPriv, pScreen, CopyWindow, xxCopyWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, xxPaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, xxPaintWindow);
 #if 0 /* can we leave this out even with backing store enabled ? */
     wrap (pScrPriv, pScreen, WindowExposures, xxWindowExposures);
 #endif
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 661268c..41bef47 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -122,8 +122,6 @@ fbSetupScreen(ScreenPtr	pScreen, 
     pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
     pScreen->RealizeWindow = fbMapWindow;
     pScreen->UnrealizeWindow = fbUnmapWindow;
-    pScreen->PaintWindowBackground = fbPaintWindow;
-    pScreen->PaintWindowBorder = fbPaintWindow;
     pScreen->CopyWindow = fbCopyWindow;
     pScreen->CreatePixmap = fbCreatePixmap;
     pScreen->DestroyPixmap = fbDestroyPixmap;
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 144f083..602b7e0 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -315,58 +315,3 @@ fbFillRegionTiled (DrawablePtr	pDrawable
     fbFinishAccess (&pTile->drawable);
     fbFinishAccess (pDrawable);
 }
-
-void
-fbPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    WindowPtr	pBgWin;
-    
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    break;
-	case BackgroundPixmap:
-	    fbFillRegionTiled (&pWin->drawable,
-			       pRegion,
-			       pWin->background.pixmap);
-	    break;
-	case BackgroundPixel:
-	    fbFillRegionSolid (&pWin->drawable,
-			       pRegion,
-			       0,
-			       fbReplicatePixel (pWin->background.pixel,
-						 pWin->drawable.bitsPerPixel));
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    fbFillRegionSolid (&pWin->drawable,
-			       pRegion,
-			       0,
-			       fbReplicatePixel (pWin->border.pixel,
-						 pWin->drawable.bitsPerPixel));
-	}
-	else
-	{
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    fbFillRegionTiled (&pBgWin->drawable,
-			       pRegion,
-			       pWin->border.pixmap);
-	}
-	break;
-    }
-    fbValidateDrawable (&pWin->drawable);
-}
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 5ea9092..93ce41b 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -119,14 +119,12 @@
 #define fbOverlayGeneration wfbOverlayGeneration
 #define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
 #define fbOverlayPaintKey wfbOverlayPaintKey
-#define fbOverlayPaintWindow wfbOverlayPaintWindow
 #define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
 #define fbOverlaySetupScreen wfbOverlaySetupScreen
 #define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
 #define fbOverlayWindowExposures wfbOverlayWindowExposures
 #define fbOverlayWindowLayer wfbOverlayWindowLayer
 #define fbPadPixmap wfbPadPixmap
-#define fbPaintWindow wfbPaintWindow
 #define fbPictureInit wfbPictureInit
 #define fbPixmapToRegion wfbPixmapToRegion
 #define fbPolyArc wfbPolyArc
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 038b21e..b309b7b 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -217,7 +217,7 @@ static void QuartzUpdateScreens(void)
     pRoot = WindowTable[pScreen->myNum];
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
-    pScreen->PaintWindowBackground(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
 //    QuartzIgnoreNextWarpCursor();
     DefineInitialRootWindow(pRoot);
 
diff --git a/hw/darwin/quartz/xpr/xprScreen.c b/hw/darwin/quartz/xpr/xprScreen.c
index 67a0737..034cbac 100644
--- a/hw/darwin/quartz/xpr/xprScreen.c
+++ b/hw/darwin/quartz/xpr/xprScreen.c
@@ -306,9 +306,6 @@ static Bool
 xprSetupScreen(int index, ScreenPtr pScreen)
 {
     // Add alpha protecting replacements for fb screen functions
-    pScreen->PaintWindowBackground = SafeAlphaPaintWindow;
-    pScreen->PaintWindowBorder = SafeAlphaPaintWindow;
-
 #ifdef RENDER
     {
         PictureScreenPtr ps = GetPictureScreen(pScreen);
diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h
index 37f42a7..4fef915 100644
--- a/hw/dmx/dmx.h
+++ b/hw/dmx/dmx.h
@@ -209,8 +209,6 @@ typedef struct _DMXScreenInfo {
     UnrealizeWindowProcPtr         UnrealizeWindow;
     RestackWindowProcPtr           RestackWindow;
     WindowExposuresProcPtr         WindowExposures;
-    PaintWindowBackgroundProcPtr   PaintWindowBackground;
-    PaintWindowBorderProcPtr       PaintWindowBorder;
     CopyWindowProcPtr              CopyWindow;
 
     ResizeWindowProcPtr            ResizeWindow;
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index 8ae448a..a78e3ae 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -346,9 +346,6 @@ Bool dmxScreenInit(int idx, ScreenPtr pS
 	DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
 	DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
 	DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
-	DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen,
-		 pScreen);
-	DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
 	DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
 
 	DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
@@ -485,8 +482,6 @@ Bool dmxCloseScreen(int idx, ScreenPtr p
 	DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
 	DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
 	DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
-	DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
-	DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
 	DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
 
 	DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index b66f2a3..7ccecfb 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -796,57 +796,6 @@ void dmxWindowExposures(WindowPtr pWindo
     DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
 }
 
-/** Paint background of \a pWindow in \a pRegion. */
-void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion, int what)
-{
-    ScreenPtr      pScreen = pWindow->drawable.pScreen;
-    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-    dmxWinPrivPtr  pWinPriv = DMX_GET_WINDOW_PRIV(pWindow);
-    BoxPtr         pBox;
-    int            nBox;
-
-    DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
-#if 0
-    if (pScreen->PaintWindowBackground)
-	pScreen->PaintWindowBackground(pWindow, pRegion, what);
-#endif
-
-    if (pWinPriv->window) {
-	/* Paint window background on back-end server */
-	pBox = REGION_RECTS(pRegion);
-	nBox = REGION_NUM_RECTS(pRegion);
-	while (nBox--) {
-	    XClearArea(dmxScreen->beDisplay, pWinPriv->window,
-		       pBox->x1 - pWindow->drawable.x,
-		       pBox->y1 - pWindow->drawable.y,
-		       pBox->x2 - pBox->x1,
-		       pBox->y2 - pBox->y1,
-		       False);
-	    pBox++;
-	}
-	dmxSync(dmxScreen, False);
-    }
-
-    DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen, pScreen);
-}
-
-/** Paint window border for \a pWindow in \a pRegion. */
-void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion, int what)
-{
-    ScreenPtr      pScreen = pWindow->drawable.pScreen;
-    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
-
-    DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
-#if 0
-    if (pScreen->PaintWindowBorder)
-	pScreen->PaintWindowBorder(pWindow, pRegion, what);
-#endif
-
-    /* Paint window border on back-end server */
-
-    DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
-}
-
 /** Move \a pWindow on the back-end server.  Determine whether or not it
  *  is on or offscreen, and realize it if it is newly on screen and the
  *  lazy window creation optimization is enabled. */
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index f976c79..79f85ac 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -81,10 +81,6 @@ extern Bool dmxUnrealizeWindow(WindowPtr
 extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib);
 extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
 			       RegionPtr other_exposed);
-extern void dmxPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
-				     int what);
-extern void dmxPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion,
-				 int what);
 extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
 			  RegionPtr prgnSrc);
 
diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c
index d2ae098..e1ff2be 100644
--- a/hw/kdrive/igs/igsdraw.c
+++ b/hw/kdrive/igs/igsdraw.c
@@ -1367,74 +1367,6 @@ igsCopyWindow(WindowPtr pWin, DDXPointRe
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-void
-igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    KdScreenPriv(pWin->drawable.pScreen);
-    PixmapPtr	pTile;
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pTile = pWin->background.pixmap;
-	    if (igsPatternDimOk (pTile->drawable.width) &&
-		igsPatternDimOk (pTile->drawable.height))
-	    {
-		igsFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    igsFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy, ~0);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    igsFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	else
-	{
-	    pTile = pWin->border.pixmap;
-	    if (igsPatternDimOk (pTile->drawable.width) &&
-		igsPatternDimOk (pTile->drawable.height))
-	    {
-		igsFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
 
 Bool
 igsDrawInit (ScreenPtr pScreen)
@@ -1453,9 +1385,7 @@ igsDrawInit (ScreenPtr pScreen)
      */
     pScreen->CreateGC = igsCreateGC;
     pScreen->CopyWindow = igsCopyWindow;
-    pScreen->PaintWindowBackground = igsPaintWindow;
-    pScreen->PaintWindowBorder = igsPaintWindow;
-    
+
     /*
      * Initialize patterns
      */
diff --git a/hw/kdrive/savage/s3.h b/hw/kdrive/savage/s3.h
index 628abc8..d8db0eb 100644
--- a/hw/kdrive/savage/s3.h
+++ b/hw/kdrive/savage/s3.h
@@ -470,7 +470,6 @@ void	s3CursorDisable (ScreenPtr pScreen)
 void	s3CursorFini (ScreenPtr pScreen);
 void	s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
 
-void	s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
 void	s3DumbCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
     
 Bool	s3DrawInit (ScreenPtr pScreen);
diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c
index 258dbcf..7b6543b 100644
--- a/hw/kdrive/savage/s3draw.c
+++ b/hw/kdrive/savage/s3draw.c
@@ -2262,71 +2262,6 @@ s3PaintKey (DrawablePtr	pDrawable,
 #endif
 
 void
-s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    SetupS3(pWin->drawable.pScreen);
-    s3ScreenInfo(pScreenPriv);
-    s3PatternPtr    pPattern;
-
-    DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
-		 pWin->drawable.id,
-		 pRegion->extents.x1, pRegion->extents.y1,
-		 pRegion->extents.x2, pRegion->extents.y2,
-		 REGION_NUM_RECTS(pRegion)));
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pPattern = s3GetWindowPrivate(pWin);
-	    if (pPattern)
-	    {
-		s3FillBoxPattern ((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  GXcopy, ~0, pPattern);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    s3FillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy, ~0);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-#ifndef S3_TRIO
-	if (s3s->fbmap[1] >= 0)
-	    fbOverlayUpdateLayerRegion (pWin->drawable.pScreen,
-					fbOverlayWindowLayer (pWin),
-					pRegion);
-#endif
-	if (pWin->borderIsPixel)
-	{
-	    s3FillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
-void
 s3CopyWindowProc (DrawablePtr pSrcDrawable,
 		  DrawablePtr pDstDrawable,
 		  GCPtr       pGC,
@@ -3006,55 +2941,6 @@ s3_24CreateWindow(WindowPtr pWin)
     return fbCreateWindow (pWin);
 }
 
-void
-s3_24PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    SetupS3(pWin->drawable.pScreen);
-    s3PatternPtr    pPattern;
-
-    DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
-		 pWin->drawable.id,
-		 pRegion->extents.x1, pRegion->extents.y1,
-		 pRegion->extents.x2, pRegion->extents.y2,
-		 REGION_NUM_RECTS(pRegion)));
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixel:
-	    if (ok24(pWin->background.pixel))
-	    {
-		s3_24FillBoxSolid((DrawablePtr)pWin,
-				  (int)REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion),
-				  pWin->background.pixel, GXcopy, ~0);
-		return;
-	    }
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel && ok24(pWin->border.pixel))
-	{
-	    s3_24FillBoxSolid((DrawablePtr)pWin,
-			      (int)REGION_NUM_RECTS(pRegion),
-			      REGION_RECTS(pRegion),
-			      pWin->border.pixel, GXcopy, ~0);
-	    return;
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
 
 Bool
 s3DrawInit (ScreenPtr pScreen)
@@ -3089,8 +2975,6 @@ s3DrawInit (ScreenPtr pScreen)
     {
 	pScreen->CreateGC = s3_24CreateGC;
 	pScreen->CreateWindow = s3_24CreateWindow;
-	pScreen->PaintWindowBackground = s3_24PaintWindow;
-	pScreen->PaintWindowBorder = s3_24PaintWindow;
 	pScreen->CopyWindow = s3CopyWindow;
     }
     else
@@ -3109,8 +2993,6 @@ s3DrawInit (ScreenPtr pScreen)
 	pScreen->CreateWindow = s3CreateWindow;
 	pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes;
 	pScreen->DestroyWindow = s3DestroyWindow;
-	pScreen->PaintWindowBackground = s3PaintWindow;
-	pScreen->PaintWindowBorder = s3PaintWindow;
 #ifndef S3_TRIO
 	if (pScreenPriv->screen->fb[1].depth)
 	{
diff --git a/hw/kdrive/sis530/sisdraw.c b/hw/kdrive/sis530/sisdraw.c
index fd80fa7..f2b39a4 100644
--- a/hw/kdrive/sis530/sisdraw.c
+++ b/hw/kdrive/sis530/sisdraw.c
@@ -1537,75 +1537,6 @@ sisCopyWindow(WindowPtr pWin, DDXPointRe
     REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
 }
 
-void
-sisPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    KdScreenPriv(pWin->drawable.pScreen);
-    PixmapPtr	pTile;
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    pTile = pWin->background.pixmap;
-	    if (sisPatternDimOk (pTile->drawable.width) &&
-		sisPatternDimOk (pTile->drawable.height))
-	    {
-		sisFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    sisFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel, GXcopy);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    sisFillBoxSolid((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel, GXcopy);
-	    return;
-	}
-	else
-	{
-	    pTile = pWin->border.pixmap;
-	    if (sisPatternDimOk (pTile->drawable.width) &&
-		sisPatternDimOk (pTile->drawable.height))
-	    {
-		sisFillBoxTiled ((DrawablePtr)pWin,
-				 (int)REGION_NUM_RECTS(pRegion),
-				 REGION_RECTS(pRegion),
-				 pTile, 
-				 pWin->drawable.x, pWin->drawable.y, GXcopy);
-		return;
-	    }
-	}
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 sisDrawInit (ScreenPtr pScreen)
 {
@@ -1621,9 +1552,7 @@ sisDrawInit (ScreenPtr pScreen)
      */
     pScreen->CreateGC = sisCreateGC;
     pScreen->CopyWindow = sisCopyWindow;
-    pScreen->PaintWindowBackground = sisPaintWindow;
-    pScreen->PaintWindowBorder = sisPaintWindow;
-    
+
     return TRUE;
 }
 
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index c9805dd..7ee6c0b 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -1009,52 +1009,6 @@ kaaFillRegionTiled (DrawablePtr pDrawabl
 }
 #endif
 
-static void
-kaaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-
-    if (!REGION_NUM_RECTS(pRegion)) 
-	return;
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixel:
-	    kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel);
-	    return;
-#if 0	    
-	case BackgroundPixmap:
-	    kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap);
-	    return;
-#endif
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    kaaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel);
-	    return;
-	}
-#if 0
-	else
-	{
-	    kaaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap);
-	    return;
-	}
-#endif
-	break;
-    }
-    KdCheckPaintWindow (pWin, pRegion, what);
-}
-
 Bool
 kaaDrawInit (ScreenPtr		pScreen,
 	     KaaScreenInfoPtr	pScreenInfo)
@@ -1091,8 +1045,6 @@ kaaDrawInit (ScreenPtr		pScreen,
      */
     pScreen->CreateGC = kaaCreateGC;
     pScreen->CopyWindow = kaaCopyWindow;
-    pScreen->PaintWindowBackground = kaaPaintWindow;
-    pScreen->PaintWindowBorder = kaaPaintWindow;
 #ifdef RENDER
     if (ps) {
 	ps->Composite = kaaComposite;
diff --git a/hw/kdrive/src/kasync.c b/hw/kdrive/src/kasync.c
index 5190963..5388f21 100644
--- a/hw/kdrive/src/kasync.c
+++ b/hw/kdrive/src/kasync.c
@@ -224,14 +224,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 }
 
 void
-KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    kaaWaitSync (pWin->drawable.pScreen);
-    kaaDrawableDirty ((DrawablePtr)pWin);
-    fbPaintWindow (pWin, pRegion, what);
-}
-
-void
 KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
     kaaWaitSync (pWin->drawable.pScreen);
@@ -265,8 +257,6 @@ KdScreenInitAsync (ScreenPtr pScreen)
 {
     pScreen->GetImage = KdCheckGetImage;
     pScreen->GetSpans = KdCheckGetSpans;
-    pScreen->PaintWindowBackground = KdCheckPaintWindow;
-    pScreen->PaintWindowBorder = KdCheckPaintWindow;
     pScreen->CopyWindow = KdCheckCopyWindow;
 #ifdef RENDER
     KdPictureInitAsync (pScreen);
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 2da008d..2fde66c 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -612,9 +612,6 @@ KdCheckGetSpans (DrawablePtr pDrawable,
 		 char *pdstStart);
 
 void
-KdCheckPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
-
-void
 KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
 void
diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c
index 8492cdb..9d2812c 100644
--- a/hw/xfree86/rac/xf86RAC.c
+++ b/hw/xfree86/rac/xf86RAC.c
@@ -98,8 +98,6 @@ typedef struct _RACScreen {
     GetImageProcPtr 		GetImage;
     GetSpansProcPtr 		GetSpans;
     SourceValidateProcPtr 	SourceValidate;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr 	PaintWindowBorder;
     CopyWindowProcPtr 		CopyWindow;
     ClearToBackgroundProcPtr 	ClearToBackground;
     CreatePixmapProcPtr         CreatePixmap;
@@ -139,8 +137,6 @@ static void RACGetSpans (DrawablePtr pDr
 			 int *pwidth, int nspans, char	*pdstStart);
 static void RACSourceValidate (DrawablePtr	pDrawable,
 			       int x, int y, int width, int height );
-static void RACPaintWindowBackground(WindowPtr pWin, RegionPtr prgn, int what);
-static void RACPaintWindowBorder(WindowPtr pWin, RegionPtr prgn, int what);
 static void RACCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
 			  RegionPtr prgnSrc );
 static void RACClearToBackground (WindowPtr pWin, int x, int y,
@@ -296,8 +292,6 @@ xf86RACInit(ScreenPtr pScreen, unsigned 
     WRAP_SCREEN_COND(GetImage, RACGetImage, RAC_FB);
     WRAP_SCREEN_COND(GetSpans, RACGetSpans, RAC_FB);
     WRAP_SCREEN_COND(SourceValidate, RACSourceValidate, RAC_FB);
-    WRAP_SCREEN_COND(PaintWindowBackground, RACPaintWindowBackground, RAC_FB);
-    WRAP_SCREEN_COND(PaintWindowBorder, RACPaintWindowBorder, RAC_FB);
     WRAP_SCREEN_COND(CopyWindow, RACCopyWindow, RAC_FB);
     WRAP_SCREEN_COND(ClearToBackground, RACClearToBackground, RAC_FB);
     WRAP_SCREEN_COND(CreatePixmap, RACCreatePixmap, RAC_FB);
@@ -341,8 +335,6 @@ RACCloseScreen (int i, ScreenPtr pScreen
     UNWRAP_SCREEN(GetImage);
     UNWRAP_SCREEN(GetSpans);
     UNWRAP_SCREEN(SourceValidate);
-    UNWRAP_SCREEN(PaintWindowBackground);
-    UNWRAP_SCREEN(PaintWindowBorder);
     UNWRAP_SCREEN(CopyWindow);
     UNWRAP_SCREEN(ClearToBackground);
     UNWRAP_SCREEN(SaveScreen);
@@ -427,38 +419,6 @@ RACSourceValidate (
 }
 
 static void
-RACPaintWindowBackground(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-  )
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    DPRINT_S("RACPaintWindowBackground",pScreen->myNum);
-    SCREEN_PROLOG (PaintWindowBackground);
-    ENABLE;
-    (*pScreen->PaintWindowBackground) (pWin, prgn, what);
-    SCREEN_EPILOG (PaintWindowBackground, RACPaintWindowBackground);
-}
-
-static void
-RACPaintWindowBorder(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    DPRINT_S("RACPaintWindowBorder",pScreen->myNum);
-    SCREEN_PROLOG (PaintWindowBorder);
-    ENABLE;
-    (*pScreen->PaintWindowBorder) (pWin, prgn, what);
-    SCREEN_EPILOG (PaintWindowBorder, RACPaintWindowBorder);
-}
-
-static void
 RACCopyWindow(
     WindowPtr pWin,
     DDXPointRec ptOldOrg,
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index c1b6ed1..3511a63 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -35,11 +35,6 @@
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
 static Bool ShadowCloseScreen (int i, ScreenPtr pScreen);
-static void ShadowPaintWindow (
-    WindowPtr pWin,
-    RegionPtr prgn,
-    int what 
-);
 static void ShadowCopyWindow(
     WindowPtr pWin,
     DDXPointRec ptOldOrg,
@@ -82,8 +77,6 @@ typedef struct {
   RefreshAreaFuncPtr			preRefresh;
   RefreshAreaFuncPtr                    postRefresh;
   CloseScreenProcPtr			CloseScreen;
-  PaintWindowBackgroundProcPtr		PaintWindowBackground;
-  PaintWindowBorderProcPtr		PaintWindowBorder;
   CopyWindowProcPtr			CopyWindow;
   CreateGCProcPtr			CreateGC;
   ModifyPixmapHeaderProcPtr		ModifyPixmapHeader;
@@ -200,8 +193,6 @@ ShadowFBInit2 (
     pPriv->vtSema = TRUE;
 
     pPriv->CloseScreen = pScreen->CloseScreen;
-    pPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
     pPriv->CopyWindow = pScreen->CopyWindow;
     pPriv->CreateGC = pScreen->CreateGC;
     pPriv->ModifyPixmapHeader = pScreen->ModifyPixmapHeader;
@@ -210,8 +201,6 @@ ShadowFBInit2 (
     pPriv->LeaveVT = pScrn->LeaveVT;
 
     pScreen->CloseScreen = ShadowCloseScreen;
-    pScreen->PaintWindowBackground = ShadowPaintWindow;
-    pScreen->PaintWindowBorder = ShadowPaintWindow;
     pScreen->CopyWindow = ShadowCopyWindow;
     pScreen->CreateGC = ShadowCreateGC;
     pScreen->ModifyPixmapHeader = ShadowModifyPixmapHeader;
@@ -276,8 +265,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
 #endif /* RENDER */
 
     pScreen->CloseScreen = pPriv->CloseScreen;
-    pScreen->PaintWindowBackground = pPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pPriv->PaintWindowBorder;
     pScreen->CopyWindow = pPriv->CopyWindow;
     pScreen->CreateGC = pPriv->CreateGC;
     pScreen->ModifyPixmapHeader = pPriv->ModifyPixmapHeader;
@@ -296,35 +283,6 @@ ShadowCloseScreen (int i, ScreenPtr pScr
     return (*pScreen->CloseScreen) (i, pScreen);
 }
 
-static void
-ShadowPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    ShadowScreenPtr pPriv = GET_SCREEN_PRIVATE(pScreen);
-    int num = 0;
-
-    if(pPriv->vtSema && (num = REGION_NUM_RECTS(prgn)))
-        if(pPriv->preRefresh)
-            (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));
-
-    if(what == PW_BACKGROUND) {
-	pScreen->PaintWindowBackground = pPriv->PaintWindowBackground;
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	pScreen->PaintWindowBackground = ShadowPaintWindow;
-    } else {
-	pScreen->PaintWindowBorder = pPriv->PaintWindowBorder;
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	pScreen->PaintWindowBorder = ShadowPaintWindow;
-    }
-
-    if(num && pPriv->postRefresh)
-        (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(prgn));    
-}
-
-
 static void 
 ShadowCopyWindow(
    WindowPtr pWin,
diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am
index 6ed8303..58c8e88 100644
--- a/hw/xfree86/xaa/Makefile.am
+++ b/hw/xfree86/xaa/Makefile.am
@@ -16,7 +16,7 @@ libxaa_la_SOURCES = xaaInit.c xaaGC.c xa
                    xaaBitBlt.c xaaCpyArea.c xaaGCmisc.c xaaCpyWin.c \
                    xaaCpyPlane.c xaaFillRect.c xaaTEText.c xaaNonTEText.c \
                    xaaPCache.c xaaSpans.c xaaROP.c xaaImage.c xaaWrapper.c \
-                   xaaPaintWin.c xaaRect.c xaaLineMisc.c xaaBitOrder.c \
+                   xaaRect.c xaaLineMisc.c xaaBitOrder.c \
                    xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c \
                    xaaLine.c xaaDashLine.c xaaOverlay.c xaaOffscreen.c \
                    xaaOverlayDF.c xaaStateChange.c xaaPict.c $(POLYSEG) \
diff --git a/hw/xfree86/xaa/xaa.h b/hw/xfree86/xaa/xaa.h
index c8d0467..1dc7ed2 100644
--- a/hw/xfree86/xaa/xaa.h
+++ b/hw/xfree86/xaa/xaa.h
@@ -1238,8 +1238,6 @@ typedef struct _XAAInfoRec {
 
    GetImageProcPtr GetImage;
    GetSpansProcPtr GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr PaintWindowBorder;
    CopyWindowProcPtr CopyWindow;
    BackingStoreSaveAreasProcPtr SaveAreas;
    BackingStoreRestoreAreasProcPtr RestoreAreas;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 93f6995..4222425 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -147,10 +147,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
 	infoRec->GetImage = XAAGetImage;
     if(!infoRec->GetSpans)
 	infoRec->GetSpans = XAAGetSpans;
-    if(!infoRec->PaintWindowBackground)
-	infoRec->PaintWindowBackground = XAAPaintWindow;
-    if(!infoRec->PaintWindowBorder)
-	infoRec->PaintWindowBorder = XAAPaintWindow;
     if(!infoRec->CopyWindow)
 	infoRec->CopyWindow = XAACopyWindow;
 
@@ -162,10 +158,6 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr
     pScreen->GetImage = infoRec->GetImage;
     pScreenPriv->GetSpans = pScreen->GetSpans;
     pScreen->GetSpans = infoRec->GetSpans;
-    pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreen->PaintWindowBackground = infoRec->PaintWindowBackground;
-    pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
-    pScreen->PaintWindowBorder = infoRec->PaintWindowBorder;
     pScreenPriv->CopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = infoRec->CopyWindow;
     pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
@@ -236,8 +228,6 @@ XAACloseScreen (int i, ScreenPtr pScreen
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
     pScreen->CopyWindow = pScreenPriv->CopyWindow;
     pScreen->WindowExposures = pScreenPriv->WindowExposures;
     pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c
index 0164590..86b30ff 100644
--- a/hw/xfree86/xaa/xaaOverlay.c
+++ b/hw/xfree86/xaa/xaaOverlay.c
@@ -93,183 +93,6 @@ XAACopyWindow8_32(
 	REGION_DESTROY(pScreen, borderClip);
 }
 
-
-
-
-static void
-XAAPaintWindow8_32(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-){
-    ScreenPtr  pScreen = pWin->drawable.pScreen;
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
-    int nBox = REGION_NUM_RECTS(prgn);
-    BoxPtr pBox = REGION_RECTS(prgn);
-    PixmapPtr pPix = NULL;
-    int depth = pWin->drawable.depth;
-    int fg = 0, pm;
-
-    if(!infoRec->pScrn->vtSema) goto BAILOUT;	
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch(pWin->backgroundState) {
-	case None: return;
-	case ParentRelative:
-	    do { pWin = pWin->parent; }
-	    while(pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
-	    return;
-	case BackgroundPixel:
-	    fg = pWin->background.pixel;
-	    break;
-	case BackgroundPixmap:
-	    pPix = pWin->background.pixmap;
-	    break;
-	}
-	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) 
-	    fg = pWin->border.pixel;
-	else 	/* pixmap */ 
-	    pPix = pWin->border.pixmap;
-	break;
-    default: return;
-    }
-
-    if(depth == 8) {
-	pm = 0xff000000;
-	fg <<= 24;
-    } else
-	pm = 0x00ffffff;
-
-    if(!pPix) {	
-        if(infoRec->FillSolidRects &&
-           !(infoRec->FillSolidRectsFlags & NO_PLANEMASK) &&
-           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) ||
-			(depth == 8) || CHECK_RGB_EQUAL(fg)))  
-	{
-	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, 
-						pm, nBox, pBox);
-	    return;
-	}
-    } else {	/* pixmap */
-        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
-	WindowPtr pBgWin = pWin;
-	int xorg, yorg;
-
-	if (what == PW_BORDER) {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-	}
-
-        xorg = pBgWin->drawable.x;
-        yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	if(!noPanoramiXExtension) {
-	    int index = pScreen->myNum;
-	    if(WindowTable[index] == pBgWin) {
-		xorg -= panoramiXdataPtr[index].x;
-		yorg -= panoramiXdataPtr[index].y;
-	    }
-	}
-#endif
-
-	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
-	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
-
-	    pCache->x = pPriv->offscreenArea->box.x1;
-	    pCache->y = pPriv->offscreenArea->box.y1;
-	    pCache->w = pCache->orig_w = 
-		pPriv->offscreenArea->box.x2 - pCache->x;
-	    pCache->h = pCache->orig_h = 
-		pPriv->offscreenArea->box.y2 - pCache->y;
-	    pCache->trans_color = -1;
-	     
-	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
-				nBox, pBox, xorg, yorg, pCache);
-
-	    return;
-	}
-
-	if(pPriv->flags & DIRTY) {
-	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
-	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-        }
-
-    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
-	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
-	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
-	}
-
-	if(pPriv->flags & REDUCIBLE_TO_8x8) {
-	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
-		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
-		!(infoRec->FillMono8x8PatternRectsFlags & NO_PLANEMASK) &&
-		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
-		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
-		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) 
-	    {
-		(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
-			pPriv->fg, pPriv->bg, GXcopy, pm, nBox, pBox,
-			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
-		return;
-	    }
-	    if(infoRec->CanDoColor8x8 && infoRec->FillColor8x8PatternRects &&
-		!(infoRec->FillColor8x8PatternRectsFlags & NO_PLANEMASK)) 
-	    {
-		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
-					infoRec->pScrn, pPix, -1, -1);
-
-		(*infoRec->FillColor8x8PatternRects) (infoRec->pScrn, 
-			GXcopy, pm, nBox, pBox, xorg, yorg, pCache);
-		return;
-	    }        
-	}
-
-	if(infoRec->UsingPixmapCache && infoRec->FillCacheBltRects && 
-	    !(infoRec->FillCacheBltRectsFlags & NO_PLANEMASK) && 
-	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
-	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) 
-	{
-	     XAACacheInfoPtr pCache = 
-			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
-	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, pm,
-				nBox, pBox, xorg, yorg, pCache);
-	     return;
-	}
-
-	if(infoRec->FillImageWriteRects && 
-		!(infoRec->FillImageWriteRectsFlags & NO_PLANEMASK)) 
-	{
-	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
-			pm, nBox, pBox, xorg, yorg, pPix);
-	    return;
-	}
-    }
-
-    if(infoRec->NeedToSync) {
-	(*infoRec->Sync)(infoRec->pScrn);
-	infoRec->NeedToSync = FALSE;
-    }
-
-BAILOUT:
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow8_32);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow8_32);
-    }
-}
-
-
 static void
 XAASetColorKey8_32(
     ScreenPtr pScreen,
@@ -295,8 +118,6 @@ XAASetupOverlay8_32Planar(ScreenPtr pScr
     XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
     int i;
 
-    pScreen->PaintWindowBackground = XAAPaintWindow8_32;
-    pScreen->PaintWindowBorder = XAAPaintWindow8_32;
     pScreen->CopyWindow = XAACopyWindow8_32;
 
     if(!(infoRec->FillSolidRectsFlags & NO_PLANEMASK))
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 5897e32..bf91098 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -28,7 +28,6 @@
 /* Screen funcs */
 
 static void XAAOverCopyWindow(WindowPtr, DDXPointRec, RegionPtr);
-static void XAAOverPaintWindow(WindowPtr, RegionPtr, int);
 static void XAAOverWindowExposures(WindowPtr, RegionPtr, RegionPtr);
 
 static int XAAOverStippledFillChooser(GCPtr);
@@ -194,8 +193,6 @@ XAAInitDualFramebufferOverlay(
     /* Overwrite key screen functions.  The XAA core will clean up */
 
     pScreen->CopyWindow = XAAOverCopyWindow;
-    pScreen->PaintWindowBackground = XAAOverPaintWindow;
-    pScreen->PaintWindowBorder = XAAOverPaintWindow;
     pScreen->WindowExposures = XAAOverWindowExposures;
 
     pOverPriv->StippledFillChooser = infoRec->StippledFillChooser;
@@ -410,56 +407,6 @@ XAAOverCopyWindow(
 }
 
 
-static void
-XAAOverPaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
-    ScrnInfoPtr pScrn = infoRec->pScrn;
-
-    if(pScrn->vtSema) {
-	if(what == PW_BACKGROUND) {
-	    SWITCH_DEPTH(pWin->drawable.depth);
-	    (*infoRec->PaintWindowBackground)(pWin, pRegion, what);
-	    return;
-	} else {
-	    if(pWin->drawable.bitsPerPixel == 8) {
-		SWITCH_DEPTH(8);
-		(*infoRec->PaintWindowBorder)(pWin, pRegion, what);
-		return;
-	    } else if (infoRec->FillSolidRects)  {
-		SWITCH_DEPTH(8);
-		(*infoRec->FillSolidRects)(pScrn, pScrn->colorKey, GXcopy, 
-			~0, REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion));
-
-		SWITCH_DEPTH(pWin->drawable.depth);
-		(*infoRec->PaintWindowBorder)(pWin, pRegion, what);
-		return;
-	    } 
-	}
-
-	if(infoRec->NeedToSync) {
-	    (*infoRec->Sync)(infoRec->pScrn);
-	    infoRec->NeedToSync = FALSE;
-	}
-    }
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAOverPaintWindow);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, pRegion, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAOverPaintWindow);
-    }
-}
-
-
 void
 XAAOverWindowExposures(
    WindowPtr pWin,
diff --git a/hw/xfree86/xaa/xaaPaintWin.c b/hw/xfree86/xaa/xaaPaintWin.c
deleted file mode 100644
index af5680c..0000000
--- a/hw/xfree86/xaa/xaaPaintWin.c
+++ /dev/null
@@ -1,200 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "gcstruct.h"
-#include "pixmapstr.h"
-#include "xaawrap.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-void
-XAAPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-)
-{
-    ScreenPtr  pScreen = pWin->drawable.pScreen;
-    XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_DRAWABLE((&pWin->drawable));
-    int nBox = REGION_NUM_RECTS(prgn);
-    BoxPtr pBox = REGION_RECTS(prgn);
-    int fg = -1;
-    PixmapPtr pPix = NULL;
-
-    if(!infoRec->pScrn->vtSema) goto BAILOUT;	
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch(pWin->backgroundState) {
-	case None: return;
-	case ParentRelative:
-	    do { pWin = pWin->parent; }
-	    while(pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, what);
-	    return;
-	case BackgroundPixel:
-	    fg = pWin->background.pixel;
-	    break;
-	case BackgroundPixmap:
-	    pPix = pWin->background.pixmap;
-	    break;
-	}
-	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) 
-	    fg = pWin->border.pixel;
-	else 	/* pixmap */ 
-	    pPix = pWin->border.pixmap;
-	break;
-    default: return;
-    }
-
-
-    if(!pPix) {
-        if(infoRec->FillSolidRects &&
-           (!(infoRec->FillSolidRectsFlags & RGB_EQUAL) || 
-                (CHECK_RGB_EQUAL(fg))) )  {
-	    (*infoRec->FillSolidRects)(infoRec->pScrn, fg, GXcopy, ~0,
-					nBox, pBox);
-	    return;
-	}
-    } else {	/* pixmap */
-        XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pPix);
-	WindowPtr pBgWin = pWin;
-	Bool NoCache = FALSE;
-	int xorg, yorg;
-
-	/* Hack so we can use this with the dual framebuffer layers
-	   which only support the pixmap cache in the primary bpp */
-	if(pPix->drawable.bitsPerPixel != infoRec->pScrn->bitsPerPixel)
-	    NoCache = TRUE;
-
-	if (what == PW_BORDER) {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-	}
-
-        xorg = pBgWin->drawable.x;
-        yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	if(!noPanoramiXExtension) {
-	    int index = pScreen->myNum;
-	    if(WindowTable[index] == pBgWin) {
-		xorg -= panoramiXdataPtr[index].x;
-		yorg -= panoramiXdataPtr[index].y;
-	    }
-	}
-#endif
-
-	if(IS_OFFSCREEN_PIXMAP(pPix) && infoRec->FillCacheBltRects) {
-	    XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
-
-	    pCache->x = pPriv->offscreenArea->box.x1;
-	    pCache->y = pPriv->offscreenArea->box.y1;
-	    pCache->w = pCache->orig_w = 
-		pPriv->offscreenArea->box.x2 - pCache->x;
-	    pCache->h = pCache->orig_h = 
-		pPriv->offscreenArea->box.y2 - pCache->y;
-	    pCache->trans_color = -1;
-	     
-	    (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
-				nBox, pBox, xorg, yorg, pCache);
-	    return;
-	}
-
-	if(pPriv->flags & DIRTY) {
-	    pPriv->flags &= ~(DIRTY | REDUCIBILITY_MASK);
-	    pPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-        }
-
-    	if(!(pPriv->flags & REDUCIBILITY_CHECKED) &&
-	    (infoRec->CanDoMono8x8 || infoRec->CanDoColor8x8)) {
-	    XAACheckTileReducibility(pPix, infoRec->CanDoMono8x8);
-	}
-
-	if(pPriv->flags & REDUCIBLE_TO_8x8) {
-	    if((pPriv->flags & REDUCIBLE_TO_2_COLOR) &&
-		infoRec->CanDoMono8x8 && infoRec->FillMono8x8PatternRects &&
-		!(infoRec->FillMono8x8PatternRectsFlags & TRANSPARENCY_ONLY) && 
-		(!(infoRec->FillMono8x8PatternRectsFlags & RGB_EQUAL) || 
-		(CHECK_RGB_EQUAL(pPriv->fg) && CHECK_RGB_EQUAL(pPriv->bg)))) {
-
-	    	(*infoRec->FillMono8x8PatternRects)(infoRec->pScrn,
-			pPriv->fg, pPriv->bg, GXcopy, ~0, nBox, pBox,
-			pPriv->pattern0, pPriv->pattern1, xorg, yorg);
-		return;
-	    }
-	    if(infoRec->CanDoColor8x8 && !NoCache &&
-				infoRec->FillColor8x8PatternRects) {
-		XAACacheInfoPtr pCache = (*infoRec->CacheColor8x8Pattern)(
-					infoRec->pScrn, pPix, -1, -1);
-
-		(*infoRec->FillColor8x8PatternRects) ( infoRec->pScrn, 
-				GXcopy, ~0, nBox, pBox, xorg, yorg, pCache);
-		return;
-	    }        
-	}
-
-	/* The window size check is to reduce pixmap cache thrashing
-	   when there are lots of little windows with pixmap backgrounds
-	   like are sometimes used for buttons, etc... */
-
-	if(infoRec->UsingPixmapCache && 
-	    infoRec->FillCacheBltRects && !NoCache &&
-	    ((what == PW_BORDER) ||
-		(pPix->drawable.height != pWin->drawable.height) ||
-		(pPix->drawable.width != pWin->drawable.width)) &&
-	    (pPix->drawable.height <= infoRec->MaxCacheableTileHeight) &&
-	    (pPix->drawable.width <= infoRec->MaxCacheableTileWidth)) {
-
-	     XAACacheInfoPtr pCache = 
-			(*infoRec->CacheTile)(infoRec->pScrn, pPix);
-	     (*infoRec->FillCacheBltRects)(infoRec->pScrn, GXcopy, ~0,
-					nBox, pBox, xorg, yorg, pCache);
-	     return;
-	}
-
-	if(infoRec->FillImageWriteRects && 
-		!(infoRec->FillImageWriteRectsFlags & NO_GXCOPY)) {
-	    (*infoRec->FillImageWriteRects) (infoRec->pScrn, GXcopy, 
-                   		~0, nBox, pBox, xorg, yorg, pPix);
-	    return;
-	}
-    }
-
-
-    if(infoRec->NeedToSync) {
-	(*infoRec->Sync)(infoRec->pScrn);
-	infoRec->NeedToSync = FALSE;
-    }
-
-BAILOUT:
-
-    if(what == PW_BACKGROUND) {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBackground, XAAPaintWindow);
-    } else {
-	XAA_SCREEN_PROLOGUE (pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWin, prgn, what);
-	XAA_SCREEN_EPILOGUE(pScreen, PaintWindowBorder, XAAPaintWindow);
-    }
-
-}
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 711f779..02c556b 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -259,8 +259,6 @@ typedef struct _XAAStateWrapRec {
 				       XAACacheInfoPtr pCache);
    GetImageProcPtr GetImage;
    GetSpansProcPtr GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr PaintWindowBorder;
    CopyWindowProcPtr CopyWindow;
 #ifdef RENDER
    Bool (*SetupForCPUToScreenAlphaTexture2)(ScrnInfoPtr pScrn, int op,
@@ -1449,26 +1447,6 @@ static void XAAStateWrapGetSpans(Drawabl
 			   pwidth, nspans, pdstStart);
 }
 
-static void XAAStateWrapPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
-					      int what)
-{
-   GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->PaintWindowBackground)(pWindow, pRegion,
-					what);
-}
-
-static void XAAStateWrapPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion, 
-					  int what)
-{
-   GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
-   STATE_CHECK_SP(pStatePriv);
-
-   (*pStatePriv->PaintWindowBorder)(pWindow, pRegion, 
-				    what);
-}
-
 static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, 
 				   RegionPtr prgnSrc)
 {
@@ -1649,8 +1627,6 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAI
    XAA_STATE_WRAP(WriteColor8x8PatternToCache);
    XAA_STATE_WRAP(GetImage);
    XAA_STATE_WRAP(GetSpans);
-   XAA_STATE_WRAP(PaintWindowBackground);
-   XAA_STATE_WRAP(PaintWindowBorder);
    XAA_STATE_WRAP(CopyWindow);
 #ifdef RENDER
    XAA_STATE_WRAP(SetupForCPUToScreenAlphaTexture2);
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index 6d8107b..b0176f0 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -54,8 +54,6 @@ typedef struct {
     CreateScreenResourcesProcPtr CreateScreenResources;
     CreateWindowProcPtr		CreateWindow;
     CopyWindowProcPtr		CopyWindow;
-    PaintWindowProcPtr		PaintWindowBackground;
-    PaintWindowProcPtr		PaintWindowBorder;
     WindowExposuresProcPtr	WindowExposures;
     CreateGCProcPtr		CreateGC;
     CreateColormapProcPtr	CreateColormap;
@@ -73,8 +71,6 @@ typedef struct {
     CreateScreenResourcesProcPtr wrapCreateScreenResources;
     CreateWindowProcPtr		wrapCreateWindow;
     CopyWindowProcPtr		wrapCopyWindow;
-    PaintWindowProcPtr		wrapPaintWindowBackground;
-    PaintWindowProcPtr		wrapPaintWindowBorder;
     WindowExposuresProcPtr	wrapWindowExposures;
     CreateGCProcPtr		wrapCreateGC;
     CreateColormapProcPtr	wrapCreateColormap;
@@ -208,33 +204,6 @@ xaaWrapperWindowExposures (WindowPtr	pWi
 	      WindowExposures, wrapWindowExposures, xaaWrapperWindowExposures);
 }
 
-static void
-xaaWrapperPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    xaaWrapperScrPriv(pWin->drawable.pScreen);
-
-    switch (what) {
-	case PW_BORDER:
-	    cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-			PaintWindowBorder, wrapPaintWindowBorder);
-
-	    pWin->drawable.pScreen->PaintWindowBorder (pWin, pRegion, what);
-	    cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-		      PaintWindowBorder, wrapPaintWindowBorder,
-		      xaaWrapperPaintWindow);
-	    break;
-	case PW_BACKGROUND:
-	    cond_unwrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-			PaintWindowBackground, wrapPaintWindowBackground);
-
-	    pWin->drawable.pScreen->PaintWindowBackground (pWin, pRegion, what);
-	    cond_wrap(pScrPriv, &pWin->drawable, pWin->drawable.pScreen,
-		      PaintWindowBackground, wrapPaintWindowBackground,
-		      xaaWrapperPaintWindow);
-	    break;
-    }
-}
-
 static Bool
 xaaWrapperCreateColormap(ColormapPtr pmap)
 {
@@ -327,8 +296,6 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAIn
     get (pScrPriv, pScreen, CreateScreenResources, wrapCreateScreenResources);
     get (pScrPriv, pScreen, CreateWindow, wrapCreateWindow);
     get (pScrPriv, pScreen, CopyWindow, wrapCopyWindow);
-    get (pScrPriv, pScreen, PaintWindowBorder, wrapPaintWindowBorder);
-    get (pScrPriv, pScreen, PaintWindowBackground, wrapPaintWindowBackground);
     get (pScrPriv, pScreen, WindowExposures, wrapWindowExposures);
     get (pScrPriv, pScreen, CreateGC, wrapCreateGC);
     get (pScrPriv, pScreen, CreateColormap, wrapCreateColormap);
@@ -351,8 +318,6 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAIn
 	  xaaWrapperCreateScreenResources);
     wrap (pScrPriv, pScreen, CreateWindow, xaaWrapperCreateWindow);
     wrap (pScrPriv, pScreen, CopyWindow, xaaWrapperCopyWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, xaaWrapperPaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, xaaWrapperPaintWindow);
     wrap (pScrPriv, pScreen, WindowExposures, xaaWrapperWindowExposures);
     wrap (pScrPriv, pScreen, CreateGC, xaaWrapperCreateGC);
     wrap (pScrPriv, pScreen, CreateColormap, xaaWrapperCreateColormap);
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 3ddea24..686cc87 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -45,8 +45,6 @@ typedef struct _XAAScreen {
    CloseScreenProcPtr 		CloseScreen;
    GetImageProcPtr 		GetImage;
    GetSpansProcPtr 		GetSpans;
-   PaintWindowBackgroundProcPtr PaintWindowBackground;
-   PaintWindowBorderProcPtr 	PaintWindowBorder;
    CopyWindowProcPtr 		CopyWindow;
    WindowExposuresProcPtr	WindowExposures;
    CreatePixmapProcPtr 		CreatePixmap;
@@ -1315,14 +1313,6 @@ XAAWritePixmapToCacheLinear(
    int bpp, int depth
 );
 
-
-void
-XAAPaintWindow(
-  WindowPtr pWin,
-  RegionPtr prgn,
-  int what 
-);
-
 void 
 XAASolidHorVertLineAsRects(
    ScrnInfoPtr pScrn,
diff --git a/hw/xfree86/xf1bpp/Makefile.am b/hw/xfree86/xf1bpp/Makefile.am
index 4ea7ef0..c724f76 100644
--- a/hw/xfree86/xf1bpp/Makefile.am
+++ b/hw/xfree86/xf1bpp/Makefile.am
@@ -45,7 +45,6 @@ libxf1bppmfb_a_SOURCES = \
         mfbline.c \
         mfbmisc.c \
         mfbpixmap.c \
-        mfbpntwin.c \
         mfbpolypnt.c \
         mfbpushpxl.c \
         mfbscrclse.c \
diff --git a/hw/xfree86/xf1bpp/mfbmap.h b/hw/xfree86/xf1bpp/mfbmap.h
index 5825c1c..e330ebd 100644
--- a/hw/xfree86/xf1bpp/mfbmap.h
+++ b/hw/xfree86/xf1bpp/mfbmap.h
@@ -61,7 +61,6 @@
 #define mfbListInstalledColormaps  xf1bppListInstalledColormaps
 #define mfbMapWindow  xf1bppMapWindow
 #define mfbPadPixmap  xf1bppPadPixmap
-#define mfbPaintWindow  xf1bppPaintWindow
 #define mfbPixmapToRegion  xf1bppPixmapToRegion
 #define mfbPixmapToRegionWeak xf1bppPixmapToRegionWeak
 #define mfbPolyFillArcSolid  xf1bppPolyFillArcSolid
diff --git a/hw/xfree86/xf1bpp/mfbunmap.h b/hw/xfree86/xf1bpp/mfbunmap.h
index 16237a1..56b734b 100644
--- a/hw/xfree86/xf1bpp/mfbunmap.h
+++ b/hw/xfree86/xf1bpp/mfbunmap.h
@@ -53,7 +53,6 @@
 #undef mfbListInstalledColormaps
 #undef mfbMapWindow
 #undef mfbPadPixmap
-#undef mfbPaintWindow
 #undef mfbPixmapToRegion
 #undef mfbPixmapToRegionWeak
 #undef mfbPolyFillArcSolid
diff --git a/hw/xfree86/xf4bpp/Makefile.am b/hw/xfree86/xf4bpp/Makefile.am
index 8665b2a..1414a0d 100644
--- a/hw/xfree86/xf4bpp/Makefile.am
+++ b/hw/xfree86/xf4bpp/Makefile.am
@@ -17,7 +17,6 @@ libxf4bpp_la_SOURCES = \
         ppcGetSp.c \
         ppcImg.c \
         ppcPixmap.c \
-        ppcPntWin.c \
         ppcPolyPnt.c \
         ppcQuery.c \
         ppcRslvC.c \
diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c
index b59dab3..674a38b 100644
--- a/hw/xfree86/xf4bpp/ppcGC.c
+++ b/hw/xfree86/xf4bpp/ppcGC.c
@@ -176,8 +176,7 @@ register GCPtr pGC ;
 
 	pGC->fExpose = TRUE;
 	pGC->freeCompClip = FALSE;
-	pGC->pRotatedPixmap = NullPixmap;
-	
+
 	/* GJA: I don't like this code:
          * they allocated a mfbPrivGC, ignore the allocated data and place
          * a pointer to a ppcPrivGC in its slot.
@@ -200,12 +199,6 @@ xf4bppDestroyGC( pGC )
 {
     TRACE( ( "xf4bppDestroyGC(pGC=0x%x)\n", pGC ) ) ;
 
-    /* (ef) 11/9/87 -- ppc doesn't use rotated tile or stipple, but */
-    /*		*does* call mfbValidateGC under some conditions.    */
-    /*		mfbValidateGC *does* use rotated tile and stipple   */
-    if ( pGC->pRotatedPixmap )
-	mfbDestroyPixmap( pGC->pRotatedPixmap ) ;
-
     if ( pGC->freeCompClip && pGC->pCompositeClip )
 	REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
     if(pGC->ops->devPrivate.val) xfree( pGC->ops );
diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c
index 8d726e7..313fcb0 100644
--- a/hw/xfree86/xf4bpp/ppcIO.c
+++ b/hw/xfree86/xf4bpp/ppcIO.c
@@ -205,8 +205,6 @@ xf4bppScreenInit( pScreen, pbits, virtx,
   pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware;
   pScreen-> DestroyWindow = xf4bppDestroyWindow;
   pScreen-> PositionWindow = xf4bppPositionWindow;
-  pScreen-> PaintWindowBackground = xf4bppPaintWindow;
-  pScreen-> PaintWindowBorder = xf4bppPaintWindow;
   pScreen-> CopyWindow = xf4bppCopyWindow;
   pScreen-> CreatePixmap = xf4bppCreatePixmap;
   pScreen-> CreateGC = xf4bppCreateGC;
@@ -219,7 +217,7 @@ xf4bppScreenInit( pScreen, pbits, virtx,
   pScreen-> ResolveColor = xf4bppResolveColor;
   mfbFillInScreen(pScreen);
 
-  if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
+  if (!mfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
 
   if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width,
diff --git a/hw/xfree86/xf4bpp/ppcPntWin.c b/hw/xfree86/xf4bpp/ppcPntWin.c
deleted file mode 100644
index 5d7a07e..0000000
--- a/hw/xfree86/xf4bpp/ppcPntWin.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright IBM Corporation 1987,1988,1989
- *
- * All Rights Reserved
- *
- * 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 IBM not be
- * used in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- *
- * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * IBM 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.
- *
-*/
-
-/***********************************************************
-
-Copyright (c) 1987  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-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
-X CONSORTIUM 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 X Consortium 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 X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf4bpp.h"
-#include "mfbmap.h"
-#include "mfb.h"
-#include "mi.h"
-#include "scrnintstr.h"
-#include "ibmTrace.h"
-
-/* NOTE: These functions only work for visuals up to 31-bits deep */
-static void xf4bppPaintWindowSolid(
-    WindowPtr,
-    RegionPtr,
-    int 
-);
-static void xf4bppPaintWindowTile(
-    WindowPtr,
-    RegionPtr,
-    int 
-);
-
-void
-xf4bppPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-
-    register mfbPrivWin	*pPrivWin;
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
-
-    TRACE(("xf4bppPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
-							pWin,pRegion,what));
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		xf4bppPaintWindowTile(pWin, pRegion, what);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    xf4bppPaintWindowSolid(pWin, pRegion, what);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    xf4bppPaintWindowSolid(pWin, pRegion, what);
-	    return;
-	}
-	else if (pPrivWin->fastBorder)
-	{
-            xf4bppPaintWindowTile(pWin, pRegion, what);
-	    return;
-	}
-	break;
-    }
-    miPaintWindow(pWin, pRegion, what);
-}
-
-static void
-xf4bppPaintWindowSolid(pWin, pRegion, what)
-    register WindowPtr pWin;
-    register RegionPtr pRegion;
-    int what;		
-{
-    register int nbox;
-    register BoxPtr pbox;
-    register unsigned long int pixel;
-    register unsigned long int pm ;
-
-    TRACE(("xf4bppPaintWindowSolid(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
-
-    if ( !( nbox = REGION_NUM_RECTS(pRegion)))
-	return ;
-    pbox = REGION_RECTS(pRegion);
-
-    if (what == PW_BACKGROUND)
-	pixel = pWin->background.pixel;
-    else
-	pixel = pWin->border.pixel; 
-
-    pm = ( 1 << pWin->drawable.depth ) - 1 ;
-    for ( ; nbox-- ; pbox++ ) {
-	/*
-	 * call fill routine, the parms are:
-	 * 	fill(color, alu, planes, x, y, width, height);
-	 */
-	xf4bppFillSolid( pWin, pixel, GXcopy, pm, pbox->x1, pbox->y1, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; 
-    }
-    return ;
-}
-
-static void
-xf4bppPaintWindowTile(pWin, pRegion, what)
-    register WindowPtr pWin;
-    register RegionPtr pRegion;
-    int what;		
-{
-    register int nbox;
-    register BoxPtr pbox;
-    register PixmapPtr pTile;
-    register unsigned long int pm ;
-
-    TRACE(("xf4bppPaintWindowTile(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
-
-    if ( !( nbox = REGION_NUM_RECTS(pRegion)))
-	return ;
-    pbox = REGION_RECTS(pRegion);
-
-    if (what == PW_BACKGROUND)
-	pTile = pWin->background.pixmap;
-    else
-	pTile = pWin->border.pixmap;
-
-    pm = ( 1 << pWin->drawable.depth ) - 1 ;
-    for ( ; nbox-- ; pbox++ ) {
-	/*
-	 * call tile routine, the parms are:
-	 * 	tile(tile, alu, planes, x, y, width, height,xSrc,ySrc);
-	 */
-	xf4bppTileRect(pWin, pTile, GXcopy, pm, 
-		pbox->x1, pbox->y1, 
-		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
-		pWin->drawable.x, pWin->drawable.y );
-    }
-    return ;
-}
diff --git a/hw/xfree86/xf4bpp/ppcWindow.c b/hw/xfree86/xf4bpp/ppcWindow.c
index 01768d9..8261af1 100644
--- a/hw/xfree86/xf4bpp/ppcWindow.c
+++ b/hw/xfree86/xf4bpp/ppcWindow.c
@@ -214,15 +214,7 @@ Bool
 xf4bppCreateWindowForXYhardware(pWin)
 register WindowPtr pWin ;
 {
-    register mfbPrivWin *pPrivWin;
-
     TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin));
 
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = 0;
-    pPrivWin->fastBorder = 0;
-
     return TRUE;
 }
diff --git a/hw/xfree86/xf4bpp/xf4bpp.h b/hw/xfree86/xf4bpp/xf4bpp.h
index 5d5dcdd..e7e3721 100644
--- a/hw/xfree86/xf4bpp/xf4bpp.h
+++ b/hw/xfree86/xf4bpp/xf4bpp.h
@@ -189,13 +189,6 @@ PixmapPtr xf4bppCopyPixmap(
     PixmapPtr
 );
 
-/* ppcPntWin.c */
-void xf4bppPaintWindow(
-    WindowPtr,
-    RegionPtr,
-    int
-);
-
 /* ppcPolyPnt.c */
 void xf4bppPolyPoint(
     DrawablePtr,
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h
index 31028a3..e140965 100644
--- a/hw/xfree86/xf8_32bpp/cfb8_32.h
+++ b/hw/xfree86/xf8_32bpp/cfb8_32.h
@@ -111,13 +111,6 @@ cfb8_32GetImage (
     char *pdstLine
 );
 
-void
-cfb8_32PaintWindow (
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-);
-
 Bool
 cfb8_32ScreenInit (
     ScreenPtr pScreen,
@@ -135,15 +128,6 @@ cfb8_32FillBoxSolid8 (
    unsigned long color
 );
 
-
-void
-cfb8_32FillBoxSolid32 (
-   DrawablePtr pDraw,
-   int nbox,
-   BoxPtr pBox,
-   unsigned long color
-);
-
 RegionPtr 
 cfb8_32CopyPlane(
     DrawablePtr pSrc,
diff --git a/hw/xfree86/xf8_32bpp/cfbpntwin.c b/hw/xfree86/xf8_32bpp/cfbpntwin.c
index a1b9887..fbf597d 100644
--- a/hw/xfree86/xf8_32bpp/cfbpntwin.c
+++ b/hw/xfree86/xf8_32bpp/cfbpntwin.c
@@ -23,97 +23,6 @@
 #endif
 
 void
-cfb8_32PaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what
-){
-    WindowPtr pBgWin;
-    int xorg, yorg;
-
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    break;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(
-						pWin, pRegion, what);
-	    break;
-	case BackgroundPixmap:
-	    xorg = pWin->drawable.x;
-	    yorg = pWin->drawable.y;
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-	    cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin,
-			(int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion),
-			pWin->background.pixmap, xorg, yorg, GXcopy, 
-			(pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000);
-	    break;
-	case BackgroundPixel:
-	    if(pWin->drawable.depth == 24) 
-		cfb8_32FillBoxSolid32 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    else
-		cfb8_32FillBoxSolid8 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->background.pixel);
-	    break;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel) {
-	    if(pWin->drawable.depth == 24) {
-		cfb8_32FillBoxSolid32 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	    } else
-		cfb8_32FillBoxSolid8 ((DrawablePtr)pWin,
-			     (int)REGION_NUM_RECTS(pRegion),
-			     REGION_RECTS(pRegion),
-			     pWin->border.pixel);
-	} else {
-	    for (pBgWin = pWin;
-		 pBgWin->backgroundState == ParentRelative;
-		 pBgWin = pBgWin->parent);
-
-	    xorg = pBgWin->drawable.x;
-	    yorg = pBgWin->drawable.y;
-
-#ifdef PANORAMIX
-	    if(!noPanoramiXExtension) {
-		int index = pWin->drawable.pScreen->myNum;
-		if(WindowTable[index] == pBgWin) {
-		    xorg -= panoramiXdataPtr[index].x;
-		    yorg -= panoramiXdataPtr[index].y;
-		}
-	    }
-#endif
-	    cfb32FillBoxTileOddGeneral ((DrawablePtr)pWin,
-			(int)REGION_NUM_RECTS(pRegion), REGION_RECTS(pRegion),
-			pWin->border.pixmap, xorg, yorg, GXcopy, 
-			(pWin->drawable.depth == 24) ? 0x00ffffff : 0xff000000);
-	}
-	break;
-    }
-
-}
-
-void
 cfb8_32FillBoxSolid8(
    DrawablePtr pDraw,
    int nbox,
@@ -140,41 +49,3 @@ cfb8_32FillBoxSolid8(
 	pbox++;
     }
 }
-
-
-void
-cfb8_32FillBoxSolid32(
-   DrawablePtr pDraw,
-   int nbox,
-   BoxPtr pbox,
-   unsigned long color
-){
-    CARD8 *ptr, *data;
-    CARD16 *ptr2, *data2;
-    int pitch, pitch2;
-    int height, width, i;
-    CARD8 c = (CARD8)(color >> 16);
-    CARD16 c2 = (CARD16)color;
-
-    cfbGetByteWidthAndPointer(pDraw, pitch, ptr);
-    cfbGetTypedWidthAndPointer(pDraw, pitch2, ptr2, CARD16, CARD16);
-    ptr += 2; /* point to the third byte */
-
-    while(nbox--) {
-	data = ptr + (pbox->y1 * pitch) + (pbox->x1 << 2);
-	data2 = ptr2 + (pbox->y1 * pitch2) + (pbox->x1 << 1);
-	width = (pbox->x2 - pbox->x1) << 1;
-	height = pbox->y2 - pbox->y1;
-
-	while(height--) {
-            for(i = 0; i < width; i+=2) {
-		data[i << 1] = c;
-		data2[i] = c2;
-	    }
-            data += pitch;
-            data2 += pitch2;
-	}
-	pbox++;
-    }
-}
-
diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c
index 29dc669..5e2657f 100644
--- a/hw/xfree86/xf8_32bpp/cfbscrinit.c
+++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c
@@ -56,11 +56,7 @@ cfb8_32AllocatePrivates(ScreenPtr pScree
    
    
    /* All cfb will have the same GC and Window private indicies */
-   if(!mfbAllocatePrivates(pScreen,&cfbWindowPrivateIndex, &cfbGCPrivateIndex))
-	return FALSE;
-
-   /* The cfb indicies are the mfb indicies. Reallocating them resizes them */ 
-   if(!AllocateWindowPrivate(pScreen,cfbWindowPrivateIndex,sizeof(cfbPrivWin)))
+   if(!mfbAllocatePrivates(pScreen, &cfbGCPrivateIndex))
 	return FALSE;
 
    if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
@@ -109,8 +105,6 @@ cfb8_32SetupScreen(
     pScreen->ChangeWindowAttributes = cfb8_32ChangeWindowAttributes;
     pScreen->RealizeWindow = cfb32MapWindow;			/* OK */
     pScreen->UnrealizeWindow = cfb32UnmapWindow;		/* OK */
-    pScreen->PaintWindowBackground = cfb8_32PaintWindow;
-    pScreen->PaintWindowBorder = cfb8_32PaintWindow;
     pScreen->CopyWindow = cfb8_32CopyWindow;
     pScreen->CreatePixmap = cfb32CreatePixmap;			/* OK */
     pScreen->DestroyPixmap = cfb32DestroyPixmap; 		/* OK */
diff --git a/hw/xfree86/xf8_32bpp/cfbwindow.c b/hw/xfree86/xf8_32bpp/cfbwindow.c
index ce741cb..787cbde 100644
--- a/hw/xfree86/xf8_32bpp/cfbwindow.c
+++ b/hw/xfree86/xf8_32bpp/cfbwindow.c
@@ -27,11 +27,6 @@
 Bool
 cfb8_32CreateWindow(WindowPtr pWin)
 {
-    cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin);
-
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-
     pWin->drawable.bitsPerPixel = 32;
     return TRUE;
 }
diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c
index c5585ca..3cd351a 100644
--- a/hw/xfree86/xf8_32bpp/xf86overlay.c
+++ b/hw/xfree86/xf8_32bpp/xf86overlay.c
@@ -34,7 +34,6 @@ static Bool OverlayCreateGC(GCPtr pGC);
 static Bool OverlayDestroyPixmap(PixmapPtr);
 static PixmapPtr OverlayCreatePixmap(ScreenPtr, int, int, int);
 static Bool OverlayChangeWindowAttributes(WindowPtr, unsigned long);
-static void OverlayPaintWindow(WindowPtr, RegionPtr, int);
 
 /** Funcs **/
 static void OverlayValidateGC(GCPtr, unsigned long, DrawablePtr);
@@ -159,8 +158,6 @@ typedef struct {
    CreatePixmapProcPtr		CreatePixmap;
    DestroyPixmapProcPtr		DestroyPixmap;
    ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-   PaintWindowBackgroundProcPtr	PaintWindowBackground;
-   PaintWindowBorderProcPtr	PaintWindowBorder;
    int				LockPrivate;
 } OverlayScreenRec, *OverlayScreenPtr;
 
@@ -284,16 +281,12 @@ xf86Overlay8Plus32Init (ScreenPtr pScree
     pScreenPriv->CreatePixmap = pScreen->CreatePixmap;
     pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap;
     pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
-    pScreenPriv->PaintWindowBackground = pScreen->PaintWindowBackground;
-    pScreenPriv->PaintWindowBorder = pScreen->PaintWindowBorder;
 
     pScreen->CreateGC = OverlayCreateGC;
     pScreen->CloseScreen = OverlayCloseScreen;
     pScreen->CreatePixmap = OverlayCreatePixmap; 
     pScreen->DestroyPixmap = OverlayDestroyPixmap; 
     pScreen->ChangeWindowAttributes = OverlayChangeWindowAttributes; 
-    pScreen->PaintWindowBackground = OverlayPaintWindow; 
-    pScreen->PaintWindowBorder = OverlayPaintWindow; 
 
     pScreenPriv->LockPrivate = 0; 
 
@@ -402,8 +395,6 @@ OverlayCloseScreen (int i, ScreenPtr pSc
     pScreen->CreatePixmap = pScreenPriv->CreatePixmap;
     pScreen->DestroyPixmap = pScreenPriv->DestroyPixmap;
     pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
 
     xfree ((pointer) pScreenPriv);
 
@@ -435,62 +426,6 @@ OverlayChangeWindowAttributes (WindowPtr
     return result;
 }
 
-static void
-OverlayPaintWindow(
-  WindowPtr pWin,
-  RegionPtr pReg,
-  int what
-){
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    OverlayScreenPtr pScreenPriv = OVERLAY_GET_SCREEN_PRIVATE(pScreen);
-    OverlayPixmapPtr pixPriv;
-    PixmapPtr oldPix = NULL;
-
-    if(what == PW_BACKGROUND) {
-	if(pWin->drawable.depth == 8) {
-	   if(pWin->backgroundState == ParentRelative) {
-		do {
-		   pWin = pWin->parent;
-		} while (pWin->backgroundState == ParentRelative);
-	   }
-
-	   if(pWin->backgroundState == BackgroundPixmap) {
-		oldPix = pWin->background.pixmap;
-		pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
-		/* have to do this here because alot of applications
-		   incorrectly assume changes to a pixmap that is
-		   a window background go into effect immediatedly */
-		if(pixPriv->dirty & IS_DIRTY)
-		    OverlayRefreshPixmap(pWin->background.pixmap);
-		pWin->background.pixmap = pixPriv->pix32;
-	   }
-	}
-
-	pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-	(*pScreen->PaintWindowBackground) (pWin, pReg, what);
-	pScreen->PaintWindowBackground = OverlayPaintWindow;
-
-	if(oldPix)
-	   pWin->background.pixmap = oldPix;
-    } else {
-	if((pWin->drawable.depth == 8) && !pWin->borderIsPixel) {
-	   oldPix = pWin->border.pixmap;
-	   pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
-	   if(pixPriv->dirty & IS_DIRTY)
-		OverlayRefreshPixmap(pWin->border.pixmap);
-	   pWin->border.pixmap = pixPriv->pix32;
-        }
-
-	pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
-	(*pScreen->PaintWindowBorder) (pWin, pReg, what);
-	pScreen->PaintWindowBorder = OverlayPaintWindow;
-
-	if(oldPix)
-	   pWin->border.pixmap = oldPix;
-    }
-}
-
-
 /*********************** GC Funcs *****************************/
 
 
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 92974f0..87d8a4e 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -927,7 +927,7 @@ xglxWindowExposures (WindowPtr pWin,
 	REGION_SUBTRACT (pScreen, &ClipList, &pWin->borderClip,
 			 &pWin->winSize);
 	REGION_INTERSECT (pScreen, &ClipList, &ClipList, (RegionPtr) pReg);
-	(*pScreen->PaintWindowBorder) (pWin, &ClipList, PW_BORDER);
+	miPaintWindow(pWin, &ClipList, PW_BORDER);
 	REGION_UNINIT (pScreen, &ClipList);
     }
 
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
index 5710bbf..7bca1d5 100644
--- a/hw/xgl/xgl.h
+++ b/hw/xgl/xgl.h
@@ -272,8 +272,6 @@ typedef struct _xglScreen {
     CreateWindowProcPtr		  CreateWindow;
     DestroyWindowProcPtr	  DestroyWindow;
     ChangeWindowAttributesProcPtr ChangeWindowAttributes;
-    PaintWindowBackgroundProcPtr  PaintWindowBackground;
-    PaintWindowBorderProcPtr	  PaintWindowBorder;
     CopyWindowProcPtr		  CopyWindow;
     CreateGCProcPtr		  CreateGC;
     CloseScreenProcPtr		  CloseScreen;
@@ -1090,16 +1088,6 @@ xglCopyWindow (WindowPtr   pWin,
 	       DDXPointRec ptOldOrg,
 	       RegionPtr   prgnSrc);
 
-void
-xglPaintWindowBackground (WindowPtr pWin,
-			  RegionPtr pRegion,
-			  int	    what);
-
-void
-xglPaintWindowBorder (WindowPtr pWin,
-		      RegionPtr pRegion,
-		      int	what);
-
 PixmapPtr
 xglGetWindowPixmap (WindowPtr pWin);
 
diff --git a/hw/xgl/xglscreen.c b/hw/xgl/xglscreen.c
index e468697..9b7297b 100644
--- a/hw/xgl/xglscreen.c
+++ b/hw/xgl/xglscreen.c
@@ -210,8 +210,6 @@ xglScreenInit (ScreenPtr pScreen)
     XGL_SCREEN_WRAP (CreateWindow, xglCreateWindow);
     XGL_SCREEN_WRAP (DestroyWindow, xglDestroyWindow);
     XGL_SCREEN_WRAP (ChangeWindowAttributes, xglChangeWindowAttributes);
-    XGL_SCREEN_WRAP (PaintWindowBackground, xglPaintWindowBackground);
-    XGL_SCREEN_WRAP (PaintWindowBorder, xglPaintWindowBorder);
 
     XGL_SCREEN_WRAP (CreateGC, xglCreateGC);
 
diff --git a/hw/xgl/xglwindow.c b/hw/xgl/xglwindow.c
index 967d10f..393f01d 100644
--- a/hw/xgl/xglwindow.c
+++ b/hw/xgl/xglwindow.c
@@ -141,181 +141,6 @@ xglCopyWindow (WindowPtr   pWin,
     REGION_UNINIT (pWin->drawable.pScreen, &rgnDst);
 }
 
-static Bool
-xglFillRegionSolid (DrawablePtr	pDrawable,
-		    RegionPtr	pRegion,
-		    Pixel	pixel)
-{
-    glitz_pixel_format_t format;
-    glitz_surface_t      *solid;
-    glitz_buffer_t	 *buffer;
-    BoxPtr		 pExtent;
-    Bool		 ret;
-
-    XGL_DRAWABLE_PIXMAP_PRIV (pDrawable);
-    XGL_SCREEN_PRIV (pDrawable->pScreen);
-
-    if (!xglPrepareTarget (pDrawable))
-	return FALSE;
-
-    solid = glitz_surface_create (pScreenPriv->drawable,
-				  pPixmapPriv->pVisual->format.surface,
-				  1, 1, 0, NULL);
-    if (!solid)
-	return FALSE;
-
-    glitz_surface_set_fill (solid, GLITZ_FILL_REPEAT);
-
-    format.fourcc	  = GLITZ_FOURCC_RGB;
-    format.masks	  = pPixmapPriv->pVisual->pPixel->masks;
-    format.xoffset	  = 0;
-    format.skip_lines     = 0;
-    format.bytes_per_line = sizeof (CARD32);
-    format.scanline_order = GLITZ_PIXEL_SCANLINE_ORDER_BOTTOM_UP;
-
-    buffer = glitz_buffer_create_for_data (&pixel);
-
-    glitz_set_pixels (solid, 0, 0, 1, 1, &format, buffer);
-
-    glitz_buffer_destroy (buffer);
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-
-    ret = xglSolid (pDrawable,
-		    GLITZ_OPERATOR_SRC,
-		    solid,
-		    NULL,
-		    pExtent->x1, pExtent->y1,
-		    pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		    REGION_RECTS (pRegion),
-		    REGION_NUM_RECTS (pRegion));
-
-    glitz_surface_destroy (solid);
-
-    return ret;
-}
-
-static Bool
-xglFillRegionTiled (DrawablePtr	pDrawable,
-		    RegionPtr	pRegion,
-		    PixmapPtr	pTile,
-		    int		tileX,
-		    int		tileY)
-{
-    BoxPtr pExtent;
-
-    pExtent = REGION_EXTENTS (pDrawable->pScreen, pRegion);
-
-    if (xglTile (pDrawable,
-		 GLITZ_OPERATOR_SRC,
-		 pTile,
-		 tileX, tileY,
-		 NULL,
-		 pExtent->x1, pExtent->y1,
-		 pExtent->x2 - pExtent->x1, pExtent->y2 - pExtent->y1,
-		 REGION_RECTS (pRegion),
-		 REGION_NUM_RECTS (pRegion)))
-	return TRUE;
-
-    return FALSE;
-}
-
-void
-xglPaintWindowBackground (WindowPtr pWin,
-			  RegionPtr pRegion,
-			  int	    what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    switch (pWin->backgroundState) {
-    case None:
-	return;
-    case ParentRelative:
-	do {
-	    pWin = pWin->parent;
-	} while (pWin->backgroundState == ParentRelative);
-
-	(*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-	return;
-    case BackgroundPixmap:
-	if (xglFillRegionTiled (&pWin->drawable,
-				pRegion,
-				pWin->background.pixmap,
-				-pWin->drawable.x,
-				-pWin->drawable.y))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-
-	if (!xglSyncBits (&pWin->background.pixmap->drawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-	break;
-    case BackgroundPixel:
-	if (xglFillRegionSolid (&pWin->drawable,
-				pRegion,
-				pWin->background.pixel))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-	break;
-    }
-
-    XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBackground);
-    (*pScreen->PaintWindowBackground) (pWin, pRegion, what);
-    XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBackground,
-				  xglPaintWindowBackground);
-}
-
-void
-xglPaintWindowBorder (WindowPtr pWin,
-		      RegionPtr pRegion,
-		      int	what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    XGL_SCREEN_PRIV (pScreen);
-
-    if (pWin->borderIsPixel)
-    {
-	if (xglFillRegionSolid (&pWin->drawable,
-				pRegion,
-				pWin->border.pixel))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-    }
-    else
-    {
-	WindowPtr pBgWin = pWin;
-
-	while (pBgWin->backgroundState == ParentRelative)
-	    pBgWin = pBgWin->parent;
-
-	if (xglFillRegionTiled (&pBgWin->drawable,
-				pRegion,
-				pWin->border.pixmap,
-				-pBgWin->drawable.x,
-				-pBgWin->drawable.y))
-	{
-	    xglAddCurrentBitDamage (&pWin->drawable);
-	    return;
-	}
-
-	if (!xglSyncBits (&pWin->border.pixmap->drawable, NullBox))
-	    FatalError (XGL_SW_FAILURE_STRING);
-    }
-
-    XGL_WINDOW_FALLBACK_PROLOGUE (pWin, PaintWindowBorder);
-    (*pScreen->PaintWindowBorder) (pWin, pRegion, what);
-    XGL_WINDOW_FALLBACK_EPILOGUE (pWin, pRegion, PaintWindowBorder,
-				  xglPaintWindowBorder);
-}
-
 PixmapPtr
 xglGetWindowPixmap (WindowPtr pWin)
 {
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index d08e482..86f856e 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -294,8 +294,6 @@ xnestOpenScreen(int index, ScreenPtr pSc
   pScreen->UnrealizeWindow = xnestUnrealizeWindow;
   pScreen->PostValidateTree = NULL;
   pScreen->WindowExposures = xnestWindowExposures;
-  pScreen->PaintWindowBackground = xnestPaintWindowBackground;
-  pScreen->PaintWindowBorder = xnestPaintWindowBorder;
   pScreen->CopyWindow = xnestCopyWindow;
   pScreen->ClipNotify = xnestClipNotify;
 
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index f87a1ba..e83fb90 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -379,30 +379,6 @@ xnestUnrealizeWindow(WindowPtr pWin)
 }
 
 void
-xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-  int i;
-  BoxPtr pBox;
-
-  xnestConfigureWindow(pWin, CWWidth | CWHeight);
-
-  pBox = REGION_RECTS(pRegion);
-  for (i = 0; i < REGION_NUM_RECTS(pRegion); i++)
-    XClearArea(xnestDisplay, xnestWindow(pWin),
-	       pBox[i].x1 - pWin->drawable.x,
-	       pBox[i].y1 - pWin->drawable.y,
-	       pBox[i].x2 - pBox[i].x1, 
-	       pBox[i].y2 - pBox[i].y1,
-	       False);
-}
-
-void
-xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-  xnestConfigureWindow(pWin, CWBorderWidth);
-}
-
-void
 xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion)
 {
 }
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 21be5f5..6c63f1f 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -64,8 +64,6 @@ void xnestConfigureWindow(WindowPtr pWin
 Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
 Bool xnestRealizeWindow(WindowPtr pWin);
 Bool xnestUnrealizeWindow(WindowPtr pWin);
-void xnestPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what);
-void xnestPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what);
 void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
 void xnestClipNotify(WindowPtr pWin, int dx, int dy);
 void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
diff --git a/hw/xprint/pcl/Pcl.h b/hw/xprint/pcl/Pcl.h
index 217e304..0c50ed2 100644
--- a/hw/xprint/pcl/Pcl.h
+++ b/hw/xprint/pcl/Pcl.h
@@ -568,10 +568,6 @@ extern void PclCopyWindow(
 extern Bool PclChangeWindowAttributes(
     register WindowPtr pWin,
     register unsigned long mask);
-extern void PclPaintWindow(
-    WindowPtr   pWin,
-    RegionPtr   pRegion,
-    int         what);
 
 /******
  * Functions in PclFonts.c
diff --git a/hw/xprint/pcl/PclInit.c b/hw/xprint/pcl/PclInit.c
index 1832252..574b481 100644
--- a/hw/xprint/pcl/PclInit.c
+++ b/hw/xprint/pcl/PclInit.c
@@ -201,8 +201,6 @@ InitializePclDriver(
     pScreen->RealizeWindow = PclMapWindow;
     pScreen->UnrealizeWindow = PclUnmapWindow;
 */
-    pScreen->PaintWindowBackground = PclPaintWindow;
-    pScreen->PaintWindowBorder = PclPaintWindow;
     pScreen->CopyWindow = PclCopyWindow; /* XXX Hard routine to write! */
 
     pScreen->CreatePixmap = fbCreatePixmap;
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index 80f4e91..f34ad7f 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -198,232 +198,6 @@ PclChangeWindowAttributes(
     return TRUE;
 }
 
-
-/*
- * This function is largely ripped from miPaintWindow, but modified so
- * that the background is not painted to the root window, and so that
- * the backing store is not referenced.
- */
-void
-PclPaintWindow(
-    WindowPtr	pWin,
-    RegionPtr	pRegion,
-    int		what)
-{
-	
-#define FUNCTION	0
-#define FOREGROUND	1
-#define TILE		2
-#define FILLSTYLE	3
-#define ABSX		4
-#define ABSY		5
-#define CLIPMASK	6
-#define SUBWINDOW	7
-#define COUNT_BITS	8
-
-    pointer gcval[7];
-    pointer newValues [COUNT_BITS];
-
-    BITS32 gcmask, index, mask;
-    RegionRec prgnWin;
-    DDXPointRec oldCorner;
-    BoxRec box;
-    WindowPtr	pBgWin;
-    GCPtr pGC;
-    register int i;
-    register BoxPtr pbox;
-    register ScreenPtr pScreen = pWin->drawable.pScreen;
-    register xRectangle *prect;
-    int numRects;
-
-    gcmask = 0;
-
-    /*
-     * We don't want to paint a window that has no place to put the
-     * PCL output.
-     */
-    if( PclGetContextFromWindow( pWin ) == (XpContextPtr)NULL )
-      return;
-    
-    if (what == PW_BACKGROUND)
-    {
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    (*pWin->parent->drawable.pScreen->PaintWindowBackground)
-	      (pWin->parent, pRegion, what);
-	    return;
-	case BackgroundPixel:
-	    newValues[FOREGROUND] = (pointer)pWin->background.pixel;
-	    newValues[FILLSTYLE] = (pointer)FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	    break;
-	case BackgroundPixmap:
-	    newValues[TILE] = (pointer)pWin->background.pixmap;
-	    newValues[FILLSTYLE] = (pointer)FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | 
-	      GCTileStipYOrigin;
-	    break;
-	}
-    }
-    else
-    {
-	if (pWin->borderIsPixel)
-	{
-	    newValues[FOREGROUND] = (pointer)pWin->border.pixel;
-	    newValues[FILLSTYLE] = (pointer)FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	}
-	else
-	{
-	    newValues[TILE] = (pointer)pWin->border.pixmap;
-	    newValues[FILLSTYLE] = (pointer)FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin
-	      | GCTileStipYOrigin;
-	}
-    }
-
-    prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
-					 sizeof(xRectangle));
-    if (!prect)
-	return;
-
-    newValues[FUNCTION] = (pointer)GXcopy;
-    gcmask |= GCFunction | GCClipMask;
-
-    i = pScreen->myNum;
-
-    pBgWin = pWin;
-    if (what == PW_BORDER)
-    {
-	while (pBgWin->backgroundState == ParentRelative)
-	    pBgWin = pBgWin->parent;
-    }
-
-    pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
-    if (!pGC)
-      {
-	  DEALLOCATE_LOCAL(prect);
-	  return;
-      }
-    /*
-     * mash the clip list so we can paint the border by
-     * mangling the window in place, pretending it
-     * spans the entire screen
-     */
-    if (what == PW_BORDER)
-      {
-	  prgnWin = pWin->clipList;
-	  oldCorner.x = pWin->drawable.x;
-	  oldCorner.y = pWin->drawable.y;
-	  pWin->drawable.x = pWin->drawable.y = 0;
-	  box.x1 = 0;
-	  box.y1 = 0;
-	  box.x2 = pScreen->width;
-	  box.y2 = pScreen->height;
-	  REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-	  pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-	  newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
-	  newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
-      }
-    else
-      {
-	  newValues[ABSX] = (pointer)0;
-	  newValues[ABSY] = (pointer)0;
-      }
-
-    mask = gcmask;
-    gcmask = 0;
-    i = 0;
-    while (mask) {
-    	index = lowbit (mask);
-	mask &= ~index;
-	switch (index) {
-	case GCFunction:
-	    if ((pointer)(long) pGC->alu != newValues[FUNCTION]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FUNCTION];
-	    }
-	    break;
-	case GCTileStipXOrigin:
-	    if ((pointer)(long) pGC->patOrg.x != newValues[ABSX]) {
-		gcmask |= index;
-		gcval[i++] = newValues[ABSX];
-	    }
-	    break;
-	case GCTileStipYOrigin:
-	    if ((pointer)(long) pGC->patOrg.y != newValues[ABSY]) {
-		gcmask |= index;
-		gcval[i++] = newValues[ABSY];
-	    }
-	    break;
-	case GCClipMask:
-	    if ((pointer)(long) pGC->clientClipType != (pointer)CT_NONE) {
-		gcmask |= index;
-		gcval[i++] = (pointer)CT_NONE;
-	    }
-	    break;
-	case GCSubwindowMode:
-	    if ((pointer)(long) pGC->subWindowMode != newValues[SUBWINDOW]) {
-		gcmask |= index;
-		gcval[i++] = newValues[SUBWINDOW];
-	    }
-	    break;
-	case GCTile:
-	    if (pGC->tileIsPixel || 
-		(pointer) pGC->tile.pixmap != newValues[TILE])
- 	    {
-		gcmask |= index;
-		gcval[i++] = newValues[TILE];
-	    }
-	    break;
-	case GCFillStyle:
-	    if ((pointer)(long) pGC->fillStyle != newValues[FILLSTYLE]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FILLSTYLE];
-	    }
-	    break;
-	case GCForeground:
-	    if ((pointer) pGC->fgPixel != newValues[FOREGROUND]) {
-		gcmask |= index;
-		gcval[i++] = newValues[FOREGROUND];
-	    }
-	    break;
-	}
-    }
-
-    if (gcmask)
-        DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
-
-    if (pWin->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC((DrawablePtr)pWin, pGC);
-
-    numRects = REGION_NUM_RECTS(pRegion);
-    pbox = REGION_RECTS(pRegion);
-    for (i= numRects; --i >= 0; pbox++, prect++)
-    {
-	prect->x = pbox->x1 - pWin->drawable.x;
-	prect->y = pbox->y1 - pWin->drawable.y;
-	prect->width = pbox->x2 - pbox->x1;
-	prect->height = pbox->y2 - pbox->y1;
-    }
-    prect -= numRects;
-    (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
-    DEALLOCATE_LOCAL(prect);
-
-    if (what == PW_BORDER)
-      {
-	  REGION_UNINIT(pScreen, &pWin->clipList);
-	  pWin->clipList = prgnWin;
-	  pWin->drawable.x = oldCorner.x;
-	  pWin->drawable.y = oldCorner.y;
-	  pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-      }
-    FreeScratchGC(pGC);
-
-}
-
 /*ARGSUSED*/
 Bool
 PclDestroyWindow(
diff --git a/hw/xprint/pcl/Pclmap.h b/hw/xprint/pcl/Pclmap.h
index ae88b5a..3990ab2 100644
--- a/hw/xprint/pcl/Pclmap.h
+++ b/hw/xprint/pcl/Pclmap.h
@@ -105,7 +105,6 @@ copyright holders.
 #define PclUnmapWindow			PCLNAME(UnmapWindow)
 #define PclCopyWindow			PCLNAME(CopyWindow)
 #define PclChangeWindowAttributes	PCLNAME(ChangeWindowAttributes)
-#define PclPaintWindow			PCLNAME(PaintWindow)
 #define PclDestroyWindow		PCLNAME(DestroyWindow)
 
 /* PclGC.c */
diff --git a/hw/xprint/ps/Ps.h b/hw/xprint/ps/Ps.h
index 3adad39..25bd533 100644
--- a/hw/xprint/ps/Ps.h
+++ b/hw/xprint/ps/Ps.h
@@ -517,7 +517,6 @@ extern Bool PsUnmapWindow(WindowPtr pWin
 extern void PsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
                          RegionPtr prgnSrc);
 extern Bool PsChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
-extern void PsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 extern Bool PsDestroyWindow(WindowPtr pWin);
 
 /*
diff --git a/hw/xprint/ps/PsInit.c b/hw/xprint/ps/PsInit.c
index 639908f..6d4bd06 100644
--- a/hw/xprint/ps/PsInit.c
+++ b/hw/xprint/ps/PsInit.c
@@ -169,8 +169,6 @@ InitializePsDriver(ndx, pScreen, argc, a
   pScreen->ChangeWindowAttributes = PsChangeWindowAttributes;
   pScreen->RealizeWindow          = PsMapWindow;
   pScreen->UnrealizeWindow        = PsUnmapWindow;
-  pScreen->PaintWindowBackground  = PsPaintWindow;
-  pScreen->PaintWindowBorder      = PsPaintWindow;
   pScreen->CloseScreen            = PsCloseScreen;
   pScreen->CopyWindow             = PsCopyWindow;
        /* XXX Hard routine to write! */
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index 26075a8..ded7dd6 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -213,230 +213,6 @@ PsChangeWindowAttributes(
   return TRUE;
 }
 
-
-void
-PsPaintWindow(
-  WindowPtr pWin,
-  RegionPtr pRegion,
-  int       what)
-{
-  WindowPtr pRoot;
-
-#define FUNCTION        0
-#define FOREGROUND      1
-#define TILE            2
-#define FILLSTYLE       3
-#define ABSX            4
-#define ABSY            5
-#define CLIPMASK        6
-#define SUBWINDOW       7
-#define COUNT_BITS      8
-
-  pointer              gcval[7];
-  pointer              newValues [COUNT_BITS];
-
-  BITS32               gcmask, index, mask;
-  RegionRec            prgnWin;
-  DDXPointRec          oldCorner;
-  BoxRec               box;
-  WindowPtr            pBgWin;
-  GCPtr                pGC;
-  register int         i;
-  register BoxPtr      pbox;
-  register ScreenPtr   pScreen = pWin->drawable.pScreen;
-  register xRectangle *prect;
-  int                  numRects;
-
-  gcmask = 0;
-
-  /*
-   * We don't want to paint a window that has no place to put the
-   * PS output.
-   */
-  if( PsGetContextFromWindow(pWin)==(XpContextPtr)NULL ) return;
-
-  if( what==PW_BACKGROUND )
-  {
-    switch(pWin->backgroundState)
-    {
-      case None: return;
-      case ParentRelative:
-        (*pWin->parent->drawable.pScreen->PaintWindowBackground)
-          (pWin->parent, pRegion, what);
-        return;
-      case BackgroundPixel:
-        newValues[FOREGROUND] = (pointer)pWin->background.pixel;
-        newValues[FILLSTYLE] = (pointer)FillSolid;
-        gcmask |= GCForeground | GCFillStyle;
-        break;
-      case BackgroundPixmap:
-        newValues[TILE] = (pointer)pWin->background.pixmap;
-        newValues[FILLSTYLE] = (pointer)FillTiled;
-        gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
-        break;
-    }
-  }
-  else
-  {
-    if( pWin->borderIsPixel )
-    {
-      newValues[FOREGROUND] = (pointer)pWin->border.pixel;
-      newValues[FILLSTYLE] = (pointer)FillSolid;
-      gcmask |= GCForeground | GCFillStyle;
-    }
-    else
-    {
-      newValues[TILE] = (pointer)pWin->border.pixmap;
-      newValues[FILLSTYLE] = (pointer)FillTiled;
-      gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
-    }
-  }
-
-  prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
-                                         sizeof(xRectangle));
-  if( !prect ) return;
-
-  newValues[FUNCTION] = (pointer)GXcopy;
-  gcmask |= GCFunction | GCClipMask;
-
-  i = pScreen->myNum;
-  pRoot = WindowTable[i];
-
-  pBgWin = pWin;
-  if (what == PW_BORDER)
-  {
-    while( pBgWin->backgroundState==ParentRelative ) pBgWin = pBgWin->parent;
-  }
-
-  pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
-  if( !pGC )
-  {
-    DEALLOCATE_LOCAL(prect);
-    return;
-  }
-  /*
-   * mash the clip list so we can paint the border by
-   * mangling the window in place, pretending it
-   * spans the entire screen
-   */
-  if( what==PW_BORDER )
-  {
-    prgnWin = pWin->clipList;
-    oldCorner.x = pWin->drawable.x;
-    oldCorner.y = pWin->drawable.y;
-    pWin->drawable.x = pWin->drawable.y = 0;
-    box.x1 = 0;
-    box.y1 = 0;
-    box.x2 = pScreen->width;
-    box.y2 = pScreen->height;
-    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
-    newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
-  }
-  else
-  {
-    newValues[ABSX] = (pointer)0;
-    newValues[ABSY] = (pointer)0;
-  }
-
-  mask = gcmask;
-  gcmask = 0;
-  i = 0;
-  while( mask )
-  {
-    index = lowbit (mask);
-    mask &= ~index;
-    switch(index)
-    {
-      case GCFunction:
-        if( (pointer)(long)pGC->alu!=newValues[FUNCTION] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FUNCTION];
-        }
-        break;
-      case GCTileStipXOrigin:
-        if( (pointer)(long)pGC->patOrg.x!=newValues[ABSX] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[ABSX];
-        }
-        break;
-      case GCTileStipYOrigin:
-        if( (pointer)(long)pGC->patOrg.y!=newValues[ABSY] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[ABSY];
-        }
-        break;
-      case GCClipMask:
-        if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
-        {
-          gcmask |= index;
-          gcval[i++] = (pointer)CT_NONE;
-        }
-        break;
-      case GCSubwindowMode:
-        if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[SUBWINDOW];
-        }
-        break;
-      case GCTile:
-        if( pGC->tileIsPixel || (pointer)pGC->tile.pixmap!=newValues[TILE] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[TILE];
-        }
-        break;
-      case GCFillStyle:
-        if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FILLSTYLE];
-        }
-        break;
-      case GCForeground:
-        if( (pointer)pGC->fgPixel!=newValues[FOREGROUND] )
-        {
-          gcmask |= index;
-          gcval[i++] = newValues[FOREGROUND];
-        }
-        break;
-    }
-  }
-
-  if( gcmask ) DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
-
-  if( pWin->drawable.serialNumber!=pGC->serialNumber )
-    ValidateGC((DrawablePtr)pWin, pGC);
-
-  numRects = REGION_NUM_RECTS(pRegion);
-  pbox = REGION_RECTS(pRegion);
-  for( i=numRects ; --i >= 0 ; pbox++,prect++ )
-  {
-    prect->x = pbox->x1 - pWin->drawable.x;
-    prect->y = pbox->y1 - pWin->drawable.y;
-    prect->width = pbox->x2 - pbox->x1;
-    prect->height = pbox->y2 - pbox->y1;
-  }
-  prect -= numRects;
-  (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
-  DEALLOCATE_LOCAL(prect);
-
-  if( what==PW_BORDER )
-  {
-    REGION_UNINIT(pScreen, &pWin->clipList);
-    pWin->clipList = prgnWin;
-    pWin->drawable.x = oldCorner.x;
-    pWin->drawable.y = oldCorner.y;
-    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-  }
-  FreeScratchGC(pGC);
-}
-
 /*ARGSUSED*/
 Bool
 PsDestroyWindow(WindowPtr pWin)
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 09a9fb2..d3be39b 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -579,8 +579,6 @@ typedef struct _winPrivScreenRec
   ValidateTreeProcPtr			ValidateTree;
   PostValidateTreeProcPtr		PostValidateTree;
   WindowExposuresProcPtr		WindowExposures;
-  PaintWindowBackgroundProcPtr		PaintWindowBackground;
-  PaintWindowBorderProcPtr		PaintWindowBorder;
   CopyWindowProcPtr			CopyWindow;
   ClearToBackgroundProcPtr		ClearToBackground;
   ClipNotifyProcPtr			ClipNotify;
@@ -1052,17 +1050,6 @@ winModifyPixmapHeaderNativeGDI (PixmapPt
 				pointer pPixData);
 #endif
 
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpntwin.c
- */
-
-void
-winPaintWindowNativeGDI (WindowPtr pWin, RegionPtr pRegion, int what);
-#endif
-
-
 #ifdef XWIN_NATIVEGDI
 /*
  * winpolyline.c
diff --git a/hw/xwin/winpntwin.c b/hw/xwin/winpntwin.c
deleted file mode 100644
index caee712..0000000
--- a/hw/xwin/winpntwin.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, sublicense, and/or sell copies of the Software, and to
- *permit persons to whom the Software is furnished to do so, subject to
- *the following conditions:
- *
- *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 HAROLD L HUNT II 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 Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 39
- * Sometimes implemented as two functions:
- *  PaintWindowBackground (nKind = PW_BACKGROUND)
- *  PaintWindowBorder (nKind = PW_BORDER)
- */
-void
-winPaintWindowNativeGDI (WindowPtr pWin,
-			 RegionPtr pRegion,
-			 int nKind)
-{
-  ErrorF ("winPaintWindow()\n");
-}
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 52adba8..a49f68f 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -717,8 +717,6 @@ winFinishScreenInitNativeGDI (int index,
   pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
 
   /* Paint window */
-  pScreen->PaintWindowBackground = miPaintWindow;
-  pScreen->PaintWindowBorder = miPaintWindow;
   pScreen->CopyWindow = winCopyWindowNativeGDI;
 
   /* Fonts */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 110f4dc..bcec02e 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -477,8 +477,8 @@ typedef struct _Screen {
     ValidateTreeProcPtr		ValidateTree;
     PostValidateTreeProcPtr	PostValidateTree;
     WindowExposuresProcPtr	WindowExposures;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
+    PaintWindowBackgroundProcPtr PaintWindowBackground; /** unused */
+    PaintWindowBorderProcPtr	PaintWindowBorder; /** unused */
     CopyWindowProcPtr		CopyWindow;
     ClearToBackgroundProcPtr	ClearToBackground;
     ClipNotifyProcPtr		ClipNotify;
diff --git a/mfb/Makefile.am b/mfb/Makefile.am
index 8ff0260..274a32d 100644
--- a/mfb/Makefile.am
+++ b/mfb/Makefile.am
@@ -12,7 +12,7 @@ libmfb_gen_sources = mfbseg.c mfbpgbwht.
 DISTCLEANFILES = $(libmfb_gen_sources)
 
 libmfb_la_SOURCES = mfbgc.c mfbwindow.c mfbfont.c \
-	 mfbfillrct.c mfbpntwin.c maskbits.c mfbpixmap.c \
+	 mfbfillrct.c maskbits.c mfbpixmap.c \
 	 mfbimage.c mfbline.c mfbbres.c mfbhrzvert.c mfbbresd.c \
 	 mfbpushpxl.c mfbzerarc.c mfbfillarc.c \
          mfbfillsp.c mfbsetsp.c mfbscrinit.c mfbscrclse.c mfbclip.c \
diff --git a/mfb/mfb.h b/mfb/mfb.h
index bc07f02..69d2d69 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -649,13 +649,6 @@ extern void mfbFillPolyWhite(
     int /*count*/,
     DDXPointPtr /*ptsIn*/
 );
-/* mfbpntwin.c */
-
-extern void mfbPaintWindow(
-    WindowPtr /*pWin*/,
-    RegionPtr /*pRegion*/,
-    int /*what*/
-);
 /* mfbpolypnt.c */
 
 extern void mfbPolyPoint(
@@ -704,7 +697,6 @@ extern Bool mfbCloseScreen(
 
 extern Bool mfbAllocatePrivates(
     ScreenPtr /*pScreen*/,
-    int * /*pWinIndex*/,
     int * /*pGCIndex*/
 );
 
@@ -893,24 +885,12 @@ typedef mfbPrivGC	*mfbPrivGCPtr;
 /* XXX these should be static, but it breaks the ABI */
 extern int  mfbGCPrivateIndex;		/* index into GC private array */
 extern int  mfbGetGCPrivateIndex(void);
-extern int  mfbWindowPrivateIndex;	/* index into Window private array */
-extern int  mfbGetWindowPrivateIndex(void);
 #ifdef PIXMAP_PER_WINDOW
 extern int  frameWindowPrivateIndex;	/* index into Window private array */
 extern int  frameGetWindowPrivateIndex(void);
 #endif
 
 #ifndef MFB_PROTOTYPES_ONLY
-/* private field of window */
-typedef struct {
-    unsigned char fastBorder;	/* non-zero if border tile is 32 bits wide */
-    unsigned char fastBackground;
-    unsigned short unused; /* pad for alignment with Sun compiler */
-    DDXPointRec	oldRotate;
-    PixmapPtr	pRotatedBackground;
-    PixmapPtr	pRotatedBorder;
-    } mfbPrivWin;
-
 /* Common macros for extracting drawing information */
 
 #define mfbGetTypedWidth(pDrawable,wtype) (\
diff --git a/mfb/mfbpntwin.c b/mfb/mfbpntwin.c
deleted file mode 100644
index b18797a..0000000
--- a/mfb/mfbpntwin.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
-/***********************************************************
-
-Copyright 1987, 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.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL 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 <X11/X.h>
-
-#include "windowstr.h"
-#include "regionstr.h"
-#include "pixmapstr.h"
-#include "scrnintstr.h"
-
-#include "mfb.h"
-#include "maskbits.h"
-#include "mi.h"
-
-void
-mfbPaintWindow(pWin, pRegion, what)
-    WindowPtr	pWin;
-    RegionPtr	pRegion;
-    int		what;
-{
-    register mfbPrivWin	*pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    
-    switch (what) {
-    case PW_BACKGROUND:
-	switch (pWin->backgroundState) {
-	case None:
-	    return;
-	case ParentRelative:
-	    do {
-		pWin = pWin->parent;
-	    } while (pWin->backgroundState == ParentRelative);
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-							     what);
-	    return;
-	case BackgroundPixmap:
-	    if (pPrivWin->fastBackground)
-	    {
-		mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXcopy,
-				  pPrivWin->pRotatedBackground);
-		return;
-	    }
-	    break;
-	case BackgroundPixel:
-	    if (pWin->background.pixel & 1)
-		mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXset, NullPixmap);
-	    else
-		mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXclear, NullPixmap);
-	    return;
-    	}
-    	break;
-    case PW_BORDER:
-	if (pWin->borderIsPixel)
-	{
-	    if (pWin->border.pixel & 1)
-		mfbSolidWhiteArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXset, NullPixmap);
-	    else
-		mfbSolidBlackArea((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXclear, NullPixmap);
-	    return;
-	}
-	else if (pPrivWin->fastBorder)
-	{
-	    mfbTileAreaPPWCopy((DrawablePtr)pWin, REGION_NUM_RECTS(pRegion),
-				  REGION_RECTS(pRegion), GXcopy,
-				  pPrivWin->pRotatedBorder);
-	    return;
-	}
-	break;
-    }
-    miPaintWindow(pWin, pRegion, what);
-}
diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c
index 13ea5d3..6d364b7 100644
--- a/mfb/mfbscrinit.c
+++ b/mfb/mfbscrinit.c
@@ -71,8 +71,6 @@ SOFTWARE.
 int frameWindowPrivateIndex;
 int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
 #endif
-int mfbWindowPrivateIndex;
-int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; }
 int mfbGCPrivateIndex;
 int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
 static unsigned long mfbGeneration = 0;
@@ -90,30 +88,23 @@ static DepthRec depth = {
 };
 
 Bool
-mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
-    ScreenPtr pScreen;
-    int *pWinIndex, *pGCIndex;
+mfbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
 {
     if (mfbGeneration != serverGeneration)
     {
 #ifdef PIXMAP_PER_WINDOW
 	frameWindowPrivateIndex = AllocateWindowPrivateIndex();
 #endif
-	mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
 	mfbGCPrivateIndex = miAllocateGCPrivateIndex();
 	visual.vid = FakeClientID(0);
 	VID = visual.vid;
 	mfbGeneration = serverGeneration;
     }
-    if (pWinIndex)
-	*pWinIndex = mfbWindowPrivateIndex;
     if (pGCIndex)
 	*pGCIndex = mfbGCPrivateIndex;
     pScreen->GetWindowPixmap = mfbGetWindowPixmap;
     pScreen->SetWindowPixmap = mfbSetWindowPixmap;
-    return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
-				  sizeof(mfbPrivWin)) &&
-	    AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
+    return AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC));
 }
 
 
@@ -126,7 +117,7 @@ mfbScreenInit(pScreen, pbits, xsize, ysi
     int dpix, dpiy;		/* dots per inch */
     int width;			/* pixel width of frame buffer */
 {
-    if 	(!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
+    if (!mfbAllocatePrivates(pScreen, NULL))
 	return FALSE;
     pScreen->defColormap = (Colormap) FakeClientID(0);
     /* whitePixel, blackPixel */
@@ -135,13 +126,9 @@ mfbScreenInit(pScreen, pbits, xsize, ysi
     pScreen->GetImage = mfbGetImage;
     pScreen->GetSpans = mfbGetSpans;
     pScreen->CreateWindow = mfbCreateWindow;
-    pScreen->DestroyWindow = mfbDestroyWindow;
     pScreen->PositionWindow = mfbPositionWindow;
-    pScreen->ChangeWindowAttributes = mfbChangeWindowAttributes;
     pScreen->RealizeWindow = mfbMapWindow;
     pScreen->UnrealizeWindow = mfbUnmapWindow;
-    pScreen->PaintWindowBackground = mfbPaintWindow;
-    pScreen->PaintWindowBorder = mfbPaintWindow;
     pScreen->CopyWindow = mfbCopyWindow;
     pScreen->CreatePixmap = mfbCreatePixmap;
     pScreen->DestroyPixmap = mfbDestroyPixmap;
diff --git a/mfb/mfbwindow.c b/mfb/mfbwindow.c
index b138d58..4cbf59f 100644
--- a/mfb/mfbwindow.c
+++ b/mfb/mfbwindow.c
@@ -64,31 +64,14 @@ Bool
 mfbCreateWindow(pWin)
     register WindowPtr pWin;
 {
-    register mfbPrivWin *pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    pPrivWin->pRotatedBorder = NullPixmap;
-    pPrivWin->pRotatedBackground = NullPixmap;
-    pPrivWin->fastBackground = FALSE;
-    pPrivWin->fastBorder = FALSE;
-
     return (TRUE);
 }
 
 /* This always returns true, because Xfree can't fail.  It might be possible
  * on some devices for Destroy to fail */
 Bool 
-mfbDestroyWindow(pWin)
-    WindowPtr pWin;
+mfbDestroyWindow(WindowPtr pWin)
 {
-    register mfbPrivWin *pPrivWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-
-    if (pPrivWin->pRotatedBorder)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
-    if (pPrivWin->pRotatedBackground)
-	(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBackground);
     return (TRUE);
 }
 
@@ -113,35 +96,6 @@ mfbPositionWindow(pWin, x, y)
     register WindowPtr pWin;
     int x, y;
 {
-    register mfbPrivWin *pPrivWin;
-    int	reset = 0;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
-    {
-	mfbXRotatePixmap(pPrivWin->pRotatedBackground,
-			 pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBackground,
-			 pWin->drawable.y - pPrivWin->oldRotate.y);
-	reset = 1;
-    }
-
-    if (!pWin->borderIsPixel && pPrivWin->fastBorder)
-    {
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-	mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-			 pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-			 pWin->drawable.y - pPrivWin->oldRotate.y);
-	reset = 1;
-    }
-    if (reset)
-    {
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-
     /* This is the "wrong" fix to the right problem, but it doesn't really
      * cost very much.  When the window is moved, we need to invalidate any
      * RotatedPixmap that exists in any GC currently validated against this
@@ -211,131 +165,3 @@ mfbCopyWindow(pWin, ptOldOrg, prgnSrc)
     DEALLOCATE_LOCAL(pptSrc);
     REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
 }
-
-
-
-/* swap in correct PaintWindow* routine.  If we can use a fast output
-routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivate.
-*/
-Bool
-mfbChangeWindowAttributes(pWin, mask)
-    register WindowPtr pWin;
-    register unsigned long mask;
-{
-    register unsigned long index;
-    register mfbPrivWin *pPrivWin;
-    WindowPtr	pBgWin;
-
-    pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-    /*
-     * When background state changes from ParentRelative and
-     * we had previously rotated the fast border pixmap to match
-     * the parent relative origin, rerotate to match window
-     */
-    if (mask & (CWBackPixmap | CWBackPixel) &&
-	pWin->backgroundState != ParentRelative &&
-	pPrivWin->fastBorder &&
-	(pPrivWin->oldRotate.x != pWin->drawable.x ||
-	 pPrivWin->oldRotate.y != pWin->drawable.y))
-    {
-	mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.x - pPrivWin->oldRotate.x);
-	mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-		      pWin->drawable.y - pPrivWin->oldRotate.y);
-	pPrivWin->oldRotate.x = pWin->drawable.x;
-	pPrivWin->oldRotate.y = pWin->drawable.y;
-    }
-    while(mask)
-    {
-	index = lowbit (mask);
-	mask &= ~index;
-	switch(index)
-	{
-	  case CWBackPixmap:
-	      if (pWin->backgroundState == None)
-	      {
-		  pPrivWin->fastBackground = FALSE;
-	      }
-	      else if (pWin->backgroundState == ParentRelative)
-	      {
-		  pPrivWin->fastBackground = FALSE;
-		  /* Rotate border to match parent origin */
-		  if (pPrivWin->pRotatedBorder) {
-		      for (pBgWin = pWin->parent;
-			   pBgWin->backgroundState == ParentRelative;
-			   pBgWin = pBgWin->parent);
-		      mfbXRotatePixmap(pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.x - pPrivWin->oldRotate.x);
-		      mfbYRotatePixmap(pPrivWin->pRotatedBorder,
-				    pBgWin->drawable.y - pPrivWin->oldRotate.y);
-		      pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		      pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		  }
-	      }
-	      else if ((pWin->background.pixmap->drawable.width <= PPW) &&
-		       !(pWin->background.pixmap->drawable.width &
-			 (pWin->background.pixmap->drawable.width - 1)))
-	      {
-		  mfbCopyRotatePixmap(pWin->background.pixmap,
-				      &pPrivWin->pRotatedBackground,
-				      pWin->drawable.x,
-				      pWin->drawable.y);
-		  if (pPrivWin->pRotatedBackground)
-		  {
-		      pPrivWin->fastBackground = TRUE;
-		      pPrivWin->oldRotate.x = pWin->drawable.x;
-		      pPrivWin->oldRotate.y = pWin->drawable.y;
-		  }
-		  else
-		  {
-		      pPrivWin->fastBackground = FALSE;
-		  }
-	      }
-	      else
-	      {
-		  pPrivWin->fastBackground = FALSE;
-	      }
-	      break;
-
-	  case CWBackPixel:
-	      pPrivWin->fastBackground = FALSE;
-	      break;
-
-	  case CWBorderPixmap:
-	      if ((pWin->border.pixmap->drawable.width <= PPW) &&
-		  !(pWin->border.pixmap->drawable.width &
-		    (pWin->border.pixmap->drawable.width - 1)))
-	      {
-		  for (pBgWin = pWin;
-		       pBgWin->backgroundState == ParentRelative;
-		       pBgWin = pBgWin->parent);
-		  mfbCopyRotatePixmap(pWin->border.pixmap,
-				      &pPrivWin->pRotatedBorder,
-				      pBgWin->drawable.x,
-				      pBgWin->drawable.y);
-		  if (pPrivWin->pRotatedBorder)
-		  {
-		      pPrivWin->fastBorder = TRUE;
-		      pPrivWin->oldRotate.x = pBgWin->drawable.x;
-		      pPrivWin->oldRotate.y = pBgWin->drawable.y;
-		  }
-		  else
-		  {
-		      pPrivWin->fastBorder = FALSE;
-		  }
-	      }
-	      else
-	      {
-		  pPrivWin->fastBorder = FALSE;
-	      }
-	      break;
-	    case CWBorderPixel:
-	      pPrivWin->fastBorder = FALSE;
-	      break;
-	}
-    }
-    /* Again, we have no failure modes indicated by any of the routines
-     * we've called, so we have to assume it worked */
-    return (TRUE);
-}
diff --git a/mi/mibank.c b/mi/mibank.c
index 00638a4..3492f1e 100644
--- a/mi/mibank.c
+++ b/mi/mibank.c
@@ -121,8 +121,6 @@ typedef struct _miBankScreen
     GetImageProcPtr               GetImage;
     GetSpansProcPtr               GetSpans;
     CreateGCProcPtr               CreateGC;
-    PaintWindowBackgroundProcPtr  PaintWindowBackground;
-    PaintWindowBorderProcPtr      PaintWindowBorder;
     CopyWindowProcPtr             CopyWindow;
 } miBankScreenRec, *miBankScreenPtr;
 
@@ -1712,8 +1710,6 @@ miBankCloseScreen(
     SCREEN_UNWRAP(GetImage);
     SCREEN_UNWRAP(GetSpans);
     SCREEN_UNWRAP(CreateGC);
-    SCREEN_UNWRAP(PaintWindowBackground);
-    SCREEN_UNWRAP(PaintWindowBorder);
     SCREEN_UNWRAP(CopyWindow);
 
     Xfree(pScreenPriv);
@@ -1878,71 +1874,6 @@ miBankCreateGC(
 }
 
 static void
-miBankPaintWindow(
-    WindowPtr pWin,
-    RegionPtr pRegion,
-    int       what
-)
-{
-    ScreenPtr          pScreen = pWin->drawable.pScreen;
-    RegionRec          tmpReg;
-    int                i;
-    PaintWindowProcPtr PaintWindow;
-
-    SCREEN_INIT;
-    SCREEN_SAVE;
-
-    if (what == PW_BORDER)
-    {
-        SCREEN_UNWRAP(PaintWindowBorder);
-        PaintWindow = pScreen->PaintWindowBorder;
-    }
-    else
-    {
-        SCREEN_UNWRAP(PaintWindowBackground);
-        PaintWindow = pScreen->PaintWindowBackground;
-    }
-
-    if (!IS_BANKED(pWin))
-    {
-        (*PaintWindow)(pWin, pRegion, what);
-    }
-    else
-    {
-        REGION_NULL(pScreen, &tmpReg);
-
-        for (i = 0;  i < pScreenPriv->nBanks;  i++)
-        {
-            if (!pScreenPriv->pBanks[i])
-                continue;
-
-            REGION_INTERSECT(pScreen, &tmpReg, pRegion,
-                pScreenPriv->pBanks[i]);
-
-            if (REGION_NIL(&tmpReg))
-                continue;
-
-            SET_SINGLE_BANK(pScreenPriv->pScreenPixmap, -1, -1, i);
-
-            (*PaintWindow)(pWin, &tmpReg, what);
-        }
-
-        REGION_UNINIT(pScreen, &tmpReg);
-    }
-
-    if (what == PW_BORDER)
-    {
-        SCREEN_WRAP(PaintWindowBorder, miBankPaintWindow);
-    }
-    else
-    {
-        SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
-    }
-
-    SCREEN_RESTORE;
-}
-
-static void
 miBankCopyWindow(
     WindowPtr   pWindow,
     DDXPointRec ptOldOrg,
@@ -2269,8 +2200,6 @@ miInitializeBanking(
     SCREEN_WRAP(GetImage,              miBankGetImage);
     SCREEN_WRAP(GetSpans,              miBankGetSpans);
     SCREEN_WRAP(CreateGC,              miBankCreateGC);
-    SCREEN_WRAP(PaintWindowBackground, miBankPaintWindow);
-    SCREEN_WRAP(PaintWindowBorder,     miBankPaintWindow);
     SCREEN_WRAP(CopyWindow,            miBankCopyWindow);
 
     BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
diff --git a/mi/miexpose.c b/mi/miexpose.c
index e82a0b5..03d4c27 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -307,8 +307,7 @@ miHandleExposures(pSrcDrawable, pDstDraw
 	    /* PaintWindowBackground doesn't clip, so we have to */
 	    REGION_INTERSECT(pscr, &rgnExposed, &rgnExposed, &pWin->clipList);
 	}
-	(*pWin->drawable.pScreen->PaintWindowBackground)(
-			(WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
+	miPaintWindow((WindowPtr)pDstDrawable, &rgnExposed, PW_BACKGROUND);
 
 	if (extents)
 	{
@@ -517,7 +516,7 @@ miWindowExposures(pWin, prgn, other_expo
 	    REGION_INTERSECT( pWin->drawable.pScreen, prgn, prgn, &pWin->clipList);
 	}
 	if (prgn && !REGION_NIL(prgn))
-	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND);
+	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
 	if (clientInterested && exposures && !REGION_NIL(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
@@ -534,60 +533,13 @@ miWindowExposures(pWin, prgn, other_expo
 	REGION_DESTROY( pWin->drawable.pScreen, exposures);
 }
 
-
-/*
-    this code is highly unlikely.  it is not haile selassie.
-
-    there is some hair here.  we can't just use the window's
-clip region as it is, because if we are painting the border,
-the border is not in the client area and so we will be excluded
-when we validate the GC, and if we are painting a parent-relative
-background, the area we want to paint is in some other window.
-since we trust the code calling us to tell us to paint only areas
-that are really ours, we will temporarily give the window a
-clipList the size of the whole screen and an origin at (0,0).
-this more or less assumes that ddX code will do translation
-based on the window's absolute position, and that ValidateGC will
-look at clipList, and that no other fields from the
-window will be used.  it's not possible to just draw
-in the root because it may be a different depth.
-
-to get the tile to align correctly we set the GC's tile origin to
-be the (x,y) of the window's upper left corner, after which we
-get the right bits when drawing into the root.
-
-because the clip_mask is being set to None, we may call DoChangeGC with
-fPointer set true, thus we no longer need to install the background or
-border tile in the resource table.
-*/
-
-static RESTYPE ResType = 0;
-static int numGCs = 0;
-static GCPtr	screenContext[MAXSCREENS];
-
-/*ARGSUSED*/
-static int
-tossGC (
-    pointer value,
-    XID id)
-{
-    GCPtr pGC = (GCPtr)value;
-    screenContext[pGC->pScreen->myNum] = (GCPtr)NULL;
-    FreeGC (pGC, id);
-    numGCs--;
-    if (!numGCs)
-	ResType = 0;
-
-    return 0;
-}
-
 _X_EXPORT void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 {
     ScreenPtr	pScreen = pWin->drawable.pScreen;
     ChangeGCVal gcval[5];
     BITS32	gcmask;
-    PixmapPtr	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+    PixmapPtr	pPixmap;
     GCPtr	pGC;
     int		i;
     BoxPtr	pbox;
@@ -595,8 +547,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     int		numRects;
     int		xoff, yoff;
 
-    while (pWin->backgroundState == ParentRelative)
-        pWin = pWin->parent;
+    pPixmap = (*pScreen->GetWindowPixmap) (pWin);
 
 #ifdef COMPOSITE
     xoff = -pPixmap->screen_x;
@@ -610,6 +561,9 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
 
     if (what == PW_BACKGROUND)
     {
+	while (pWin->backgroundState == ParentRelative)
+	    pWin = pWin->parent;
+
 	switch (pWin->backgroundState) {
 	case None:
 	    return;
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1dbb85d..1dd28b8 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -865,9 +865,10 @@ miOverlayHandleExposures(WindowPtr pWin)
 	while (1) {
 	    if((mival = pTree->valdata)) {
 		if(!((*pPriv->InOverlay)(pTree->pWin))) {
-		    if (REGION_NOTEMPTY(pScreen, &mival->borderExposed))
-			(*pWin->drawable.pScreen->PaintWindowBorder)(
-				pTree->pWin, &mival->borderExposed, PW_BORDER);
+		    if (REGION_NOTEMPTY(pScreen, &mival->borderExposed)) {
+			miPaintWindow(pTree->pWin, &mival->borderExposed,
+				      PW_BORDER);
+		    }
 		    REGION_UNINIT(pScreen, &mival->borderExposed);
 
 		    (*WindowExposures)(pTree->pWin,&mival->exposed,NullRegion);
@@ -903,10 +904,10 @@ miOverlayHandleExposures(WindowPtr pWin)
 				REGION_RECTS(&val->after.exposed));
 		}
 	    } else {
-		if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
-		    (*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
-						    &val->after.borderExposed,
-						    PW_BORDER);
+		if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed)) {
+			miPaintWindow(pChild, &val->after.borderExposed,
+				      PW_BORDER);
+		}
 		(*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 	    }
 	    REGION_UNINIT(pScreen, &val->after.borderExposed);
@@ -1066,8 +1067,7 @@ miOverlayWindowExposures(
 		REGION_INTERSECT(pScreen, prgn, prgn, &pWin->clipList);
 	}
 	if (prgn && !REGION_NIL(prgn))
-	    (*pScreen->PaintWindowBackground)(
-			pWin, prgn, PW_BACKGROUND);
+	    miPaintWindow(pWin, prgn, PW_BACKGROUND);
 	if (clientInterested && exposures && !REGION_NIL(exposures))
 	    miSendExposures(pWin, exposures,
 			    pWin->drawable.x, pWin->drawable.y);
@@ -1738,7 +1738,7 @@ miOverlayClearToBackground(
     if (generateExposures)
         (*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+	miPaintWindow(pWin, &reg, PW_BACKGROUND);
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
         REGION_DESTROY(pScreen, pBSReg);
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index cc40cbe..d88eb71 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -251,7 +251,7 @@ miScreenInit(pScreen, pbits, xsize, ysiz
     pScreen->ValidateTree = miValidateTree;
     pScreen->PostValidateTree = (PostValidateTreeProcPtr) 0;
     pScreen->WindowExposures = miWindowExposures;
-    /* PaintWindowBackground, PaintWindowBorder, CopyWindow */
+    /* CopyWindow */
     pScreen->ClearToBackground = miClearToBackground;
     pScreen->ClipNotify = (ClipNotifyProcPtr) 0;
     pScreen->RestackWindow = (RestackWindowProcPtr) 0;
diff --git a/mi/miwindow.c b/mi/miwindow.c
index cab67ea..77cb750 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -118,7 +118,7 @@ miClearToBackground(pWin, x, y, w, h, ge
     if (generateExposures)
 	(*pScreen->WindowExposures)(pWin, &reg, pBSReg);
     else if (pWin->backgroundState != None)
-        (*pScreen->PaintWindowBackground)(pWin, &reg, PW_BACKGROUND);
+	miPaintWindow(pWin, &reg, PW_BACKGROUND);
     REGION_UNINIT(pScreen, &reg);
     if (pBSReg)
 	REGION_DESTROY(pScreen, pBSReg);
@@ -451,9 +451,7 @@ miHandleValidateExposures(pWin)
 	if ( (val = pChild->valdata) )
 	{
 	    if (REGION_NOTEMPTY(pScreen, &val->after.borderExposed))
-		(*pChild->drawable.pScreen->PaintWindowBorder)(pChild,
-						    &val->after.borderExposed,
-						    PW_BORDER);
+		miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
 	    REGION_UNINIT(pScreen, &val->after.borderExposed);
 	    (*WindowExposures)(pChild, &val->after.exposed, NullRegion);
 	    REGION_UNINIT(pScreen, &val->after.exposed);
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index 7ee013b..bd49f3f 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -380,149 +380,6 @@ cwGetSpans(DrawablePtr pSrc, int wMax, D
     SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
 }
 
-static void
-cwFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, unsigned long pixel)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    GCPtr     pGC;
-    BoxPtr    pBox;
-    int       nbox, i;
-    ChangeGCVal v[3];
-
-    pGC = GetScratchGC(pDrawable->depth, pScreen);
-    v[0].val = GXcopy;
-    v[1].val = pixel;
-    v[2].val = FillSolid;
-    dixChangeGC(NullClient, pGC, (GCFunction | GCForeground | GCFillStyle),
-		NULL, v);
-    ValidateGC(pDrawable, pGC);
-
-    pBox = REGION_RECTS(pRegion);
-    nbox = REGION_NUM_RECTS(pRegion);
-
-    for (i = 0; i < nbox; i++, pBox++) {
-	xRectangle rect;
-	rect.x      = pBox->x1;
-	rect.y      = pBox->y1;
-	rect.width  = pBox->x2 - pBox->x1;
-	rect.height = pBox->y2 - pBox->y1;
-	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
-    }
-
-   FreeScratchGC(pGC);
-}
-
-static void
-cwFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
-		  int x_off, int y_off)
-{
-    ScreenPtr pScreen = pDrawable->pScreen;
-    GCPtr     pGC;
-    BoxPtr    pBox;
-    int       nbox, i;
-    ChangeGCVal v[5];
-
-    pGC = GetScratchGC(pDrawable->depth, pScreen);
-    v[0].val = GXcopy;
-    v[1].val = FillTiled;
-    v[2].ptr = (pointer) pTile;
-    v[3].val = x_off;
-    v[4].val = y_off;
-    dixChangeGC(NullClient, pGC, (GCFunction | GCFillStyle | GCTile |
-		GCTileStipXOrigin | GCTileStipYOrigin), NULL, v);
-
-    ValidateGC(pDrawable, pGC);
-
-    pBox = REGION_RECTS(pRegion);
-    nbox = REGION_NUM_RECTS(pRegion);
-
-    for (i = 0; i < nbox; i++, pBox++) {
-	xRectangle rect;
-	rect.x      = pBox->x1;
-	rect.y      = pBox->y1;
-	rect.width  = pBox->x2 - pBox->x1;
-	rect.height = pBox->y2 - pBox->y1;
-	(*pGC->ops->PolyFillRect)(pDrawable, pGC, 1, &rect);
-    }
-
-   FreeScratchGC(pGC);
-}
-
-static void
-cwPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    SCREEN_PROLOGUE(pScreen, PaintWindowBackground);
-
-    if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
-	(*pScreen->PaintWindowBackground)(pWin, pRegion, what);
-    } else {
-	DrawablePtr pBackingDrawable;
-	int x_off, y_off, x_screen, y_screen;
-
-	while (pWin->backgroundState == ParentRelative)
-	    pWin = pWin->parent;
-
-	pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
-						&y_off);
-
-	x_screen = x_off - pWin->drawable.x;
-	y_screen = y_off - pWin->drawable.y;
-
-	if (pWin && (pWin->backgroundState == BackgroundPixel ||
-		pWin->backgroundState == BackgroundPixmap))
-	{
-	    REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
-
-	    if (pWin->backgroundState == BackgroundPixel) {
-		cwFillRegionSolid(pBackingDrawable, pRegion,
-				  pWin->background.pixel);
-	    } else {
-		cwFillRegionTiled(pBackingDrawable, pRegion,
-				  pWin->background.pixmap, x_off, y_off);
-	    }
-
-	    REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
-	}
-    }
-
-    SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
-}
-
-static void
-cwPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    SCREEN_PROLOGUE(pScreen, PaintWindowBorder);
-
-    if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) {
-	(*pScreen->PaintWindowBorder)(pWin, pRegion,  what);
-    } else {
-	DrawablePtr pBackingDrawable;
-	int x_off, y_off, x_screen, y_screen;
-
-	pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off,
-						&y_off);
-
-	x_screen = x_off - pWin->drawable.x;
-	y_screen = y_off - pWin->drawable.y;
-
-	REGION_TRANSLATE(pScreen, pRegion, x_screen, y_screen);
-
-	if (pWin->borderIsPixel) {
-	    cwFillRegionSolid(pBackingDrawable, pRegion, pWin->border.pixel);
-	} else {
-	    cwFillRegionTiled(pBackingDrawable, pRegion, pWin->border.pixmap,
-			      x_off, y_off);
-	}
-
-	REGION_TRANSLATE(pScreen, pRegion, -x_screen, -y_screen);
-    }
-
-    SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
-}
 
 static void
 cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
@@ -654,8 +511,6 @@ miInitializeCompositeWrapper(ScreenPtr p
     SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
     SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans);
     SCREEN_EPILOGUE(pScreen, CreateGC, cwCreateGC);
-    SCREEN_EPILOGUE(pScreen, PaintWindowBackground, cwPaintWindowBackground);
-    SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
     SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
 
     SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
@@ -681,8 +536,6 @@ cwCloseScreen (int i, ScreenPtr pScreen)
     pScreen->GetImage = pScreenPriv->GetImage;
     pScreen->GetSpans = pScreenPriv->GetSpans;
     pScreen->CreateGC = pScreenPriv->CreateGC;
-    pScreen->PaintWindowBackground = pScreenPriv->PaintWindowBackground;
-    pScreen->PaintWindowBorder = pScreenPriv->PaintWindowBorder;
     pScreen->CopyWindow = pScreenPriv->CopyWindow;
 
 #ifdef RENDER
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index 0d57b9b..8e42ac2 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -84,8 +84,6 @@ typedef struct {
     GetSpansProcPtr		GetSpans;
     CreateGCProcPtr		CreateGC;
 
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
     CopyWindowProcPtr		CopyWindow;
 
     GetWindowPixmapProcPtr	GetWindowPixmap;
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 472b1b8..58f37e9 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1635,35 +1635,6 @@ damageDestroyPixmap (PixmapPtr pPixmap)
 }
 
 static void
-damagePaintWindow(WindowPtr pWindow,
-		  RegionPtr prgn,
-		  int	    what)
-{
-    ScreenPtr pScreen = pWindow->drawable.pScreen;
-    damageScrPriv(pScreen);
-
-    /*
-     * Painting background none doesn't actually *do* anything, so
-     * no damage is recorded
-     */
-    if ((what != PW_BACKGROUND || pWindow->backgroundState != None) &&
-	getWindowDamage (pWindow))
-	damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1);
-    if(what == PW_BACKGROUND) {
-	unwrap (pScrPriv, pScreen, PaintWindowBackground);
-	(*pScreen->PaintWindowBackground) (pWindow, prgn, what);
-	damageReportPostOp (&pWindow->drawable);
-	wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
-    } else {
-	unwrap (pScrPriv, pScreen, PaintWindowBorder);
-	(*pScreen->PaintWindowBorder) (pWindow, prgn, what);
-	damageReportPostOp (&pWindow->drawable);
-	wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
-    }
-}
-
-
-static void
 damageCopyWindow(WindowPtr	pWindow,
 		 DDXPointRec	ptOldOrg,
 		 RegionPtr	prgnSrc)
@@ -1763,8 +1734,6 @@ damageCloseScreen (int i, ScreenPtr pScr
 
     unwrap (pScrPriv, pScreen, DestroyPixmap);
     unwrap (pScrPriv, pScreen, CreateGC);
-    unwrap (pScrPriv, pScreen, PaintWindowBackground);
-    unwrap (pScrPriv, pScreen, PaintWindowBorder);
     unwrap (pScrPriv, pScreen, CopyWindow);
     unwrap (pScrPriv, pScreen, CloseScreen);
     xfree (pScrPriv);
@@ -1814,8 +1783,6 @@ DamageSetup (ScreenPtr pScreen)
 
     wrap (pScrPriv, pScreen, DestroyPixmap, damageDestroyPixmap);
     wrap (pScrPriv, pScreen, CreateGC, damageCreateGC);
-    wrap (pScrPriv, pScreen, PaintWindowBackground, damagePaintWindow);
-    wrap (pScrPriv, pScreen, PaintWindowBorder, damagePaintWindow);
     wrap (pScrPriv, pScreen, DestroyWindow, damageDestroyWindow);
     wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap);
     wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow);
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 1e0efad..e603f02 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -60,8 +60,6 @@ typedef struct _damageScrPriv {
      */
     DamagePtr			pScreenDamage;
 
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr	PaintWindowBorder;
     CopyWindowProcPtr		CopyWindow;
     CloseScreenProcPtr		CloseScreen;
     CreateGCProcPtr		CreateGC;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 3bf6af0..66b930d 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -86,8 +86,6 @@ typedef struct _RootlessScreenRec {
     ChangeWindowAttributesProcPtr ChangeWindowAttributes;
 
     CreateGCProcPtr CreateGC;
-    PaintWindowBackgroundProcPtr PaintWindowBackground;
-    PaintWindowBorderProcPtr PaintWindowBorder;
     CopyWindowProcPtr CopyWindow;
     GetImageProcPtr GetImage;
     SourceValidateProcPtr SourceValidate;
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 700de6e..0bcd2f7 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -598,8 +598,6 @@ RootlessWrap(ScreenPtr pScreen)
     WRAP(CreateScreenResources);
     WRAP(CloseScreen);
     WRAP(CreateGC);
-    WRAP(PaintWindowBackground);
-    WRAP(PaintWindowBorder);
     WRAP(CopyWindow);
     WRAP(GetImage);
     WRAP(SourceValidate);
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 30b7daa..f712659 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -217,10 +217,8 @@ RootlessSetShape(WindowPtr pWin)
 
 
 /* Disallow ParentRelative background on top-level windows
-   because the root window doesn't really have the right background
-   and fb will try to draw on the root instead of on the window.
-   ParentRelative prevention is also in PaintWindowBackground/Border()
-   so it is no longer really needed here. */
+   because the root window doesn't really have the right background.
+ */
 Bool
 RootlessChangeWindowAttributes(WindowPtr pWin, unsigned long vmask)
 {
@@ -670,7 +668,7 @@ RootlessResizeCopyWindow(WindowPtr pWin,
 /*
  * RootlessCopyWindow
  *  Update *new* location of window. Old location is redrawn with
- *  PaintWindowBackground/Border. Cloned from fbCopyWindow.
+ *  miPaintWindow. Cloned from fbCopyWindow.
  *  The original always draws on the root pixmap, which we don't have.
  *  Instead, draw on the parent window's pixmap.
  */
@@ -1326,96 +1324,6 @@ out:
     }
 }
 
-
-/*
- * SetPixmapOfAncestors
- *  Set the Pixmaps on all ParentRelative windows up the ancestor chain.
- */
-static void
-SetPixmapOfAncestors(WindowPtr pWin)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    WindowPtr topWin = TopLevelParent(pWin);
-    RootlessWindowRec *topWinRec = WINREC(topWin);
-
-    while (pWin->backgroundState == ParentRelative) {
-        if (pWin == topWin) {
-            // disallow ParentRelative background state on top level
-            XID pixel = 0;
-            ChangeWindowAttributes(pWin, CWBackPixel, &pixel, serverClient);
-            RL_DEBUG_MSG("Cleared ParentRelative on 0x%x.\n", pWin);
-            break;
-        }
-
-        pWin = pWin->parent;
-        pScreen->SetWindowPixmap(pWin, topWinRec->pixmap);
-    }
-}
-
-
-/*
- * RootlessPaintWindowBackground
- */
-void
-RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
- 
-    if (IsRoot(pWin))
-        return;
-
-    RL_DEBUG_MSG("paintwindowbackground start (win 0x%x, framed %i) ",
-                 pWin, IsFramedWindow(pWin));
-
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, pRegion);
-
-        // For ParentRelative windows, we have to make sure the window
-        // pixmap is set correctly all the way up the ancestor chain.
-        if (pWin->backgroundState == ParentRelative) {
-            SetPixmapOfAncestors(pWin);
-        }
-    }
-
-    SCREEN_UNWRAP(pScreen, PaintWindowBackground);
-    pScreen->PaintWindowBackground(pWin, pRegion, what);
-    SCREEN_WRAP(pScreen, PaintWindowBackground);
-
-    RL_DEBUG_MSG("paintwindowbackground end\n");
-}
-
-
-/*
- * RootlessPaintWindowBorder
- */
-void
-RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion, int what)
-{
-    RL_DEBUG_MSG("paintwindowborder start (win 0x%x) ", pWin);
-
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, pRegion);
-
-        // For ParentRelative windows with tiled borders, we have to make
-        // sure the window pixmap is set correctly all the way up the
-        // ancestor chain.
-        if (!pWin->borderIsPixel &&
-            pWin->backgroundState == ParentRelative)
-        {
-            SetPixmapOfAncestors(pWin);
-        }
-    }
-
-    SCREEN_UNWRAP(pWin->drawable.pScreen, PaintWindowBorder);
-    pWin->drawable.pScreen->PaintWindowBorder(pWin, pRegion, what);
-    SCREEN_WRAP(pWin->drawable.pScreen, PaintWindowBorder);
-
-    RL_DEBUG_MSG("paintwindowborder end\n");
-}
-
-
 /*
  * RootlessChangeBorderWidth
  *  FIXME: untested!
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index 093a2b3..9573068 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -54,10 +54,6 @@ void RootlessMoveWindow(WindowPtr pWin,i
 void RootlessResizeWindow(WindowPtr pWin, int x, int y,
 			  unsigned int w, unsigned int h, WindowPtr pSib);
 void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent);
-void RootlessPaintWindowBackground(WindowPtr pWin, RegionPtr pRegion,
-                                   int what);
-void RootlessPaintWindowBorder(WindowPtr pWin, RegionPtr pRegion,
-                               int what);
 void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
 
 #endif
diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am
index 7592c18..823fb77 100644
--- a/miext/rootless/safeAlpha/Makefile.am
+++ b/miext/rootless/safeAlpha/Makefile.am
@@ -6,7 +6,6 @@ INCLUDES = -I$(srcdir)/.. -I$(top_srcdir
 
 
 noinst_LTLIBRARIES = libsafeAlpha.la
-libsafeAlpha_la_SOURCES = safeAlphaPicture.c \
-		       safeAlphaWindow.c
+libsafeAlpha_la_SOURCES = safeAlphaPicture.c
 
 EXTRA_DIST = safeAlpha.h
diff --git a/miext/rootless/safeAlpha/safeAlpha.h b/miext/rootless/safeAlpha/safeAlpha.h
index bd1ce32..9b9b39c 100644
--- a/miext/rootless/safeAlpha/safeAlpha.h
+++ b/miext/rootless/safeAlpha/safeAlpha.h
@@ -32,8 +32,6 @@
 
 #include "picturestr.h"
 
-void SafeAlphaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
-
 #ifdef RENDER
 void
 SafeAlphaComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
diff --git a/miext/rootless/safeAlpha/safeAlphaWindow.c b/miext/rootless/safeAlpha/safeAlphaWindow.c
deleted file mode 100644
index 5226782..0000000
--- a/miext/rootless/safeAlpha/safeAlphaWindow.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Specialized window functions to protect the alpha channel
- */
-/*
- * Copyright (c) 2002-2003 Torrey T. Lyons. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * 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 ABOVE LISTED COPYRIGHT HOLDER(S) 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(s) of the above copyright
- * holders shall not be used in advertising or otherwise to promote the sale,
- * use or other dealings in this Software without prior written authorization.
- */
-/* Portions of this file are based on fbwindow.c, which contains the
- * following copyright:
- *
- * Copyright © 1998 Keith Packard
- */
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-#include "fb.h"
-#include "safeAlpha.h"
-#include "rootlessCommon.h"
-
-#ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-#endif
-
-/*
- * SafeAlphaFillRegionTiled
- *  Fill using a tile while leaving the alpha channel untouched.
- *  Based on fbfillRegionTiled.
- */
-void
-SafeAlphaFillRegionTiled(
-    DrawablePtr pDrawable,
-    RegionPtr   pRegion,
-    PixmapPtr   pTile)
-{
-    FbBits      *dst;
-    FbStride    dstStride;
-    int         dstBpp;
-    int         dstXoff, dstYoff;
-    FbBits      *tile;
-    FbStride    tileStride;
-    int         tileBpp;
-    int         tileXoff, tileYoff; /* XXX assumed to be zero */
-    int         tileWidth, tileHeight;
-    int         n = REGION_NUM_RECTS(pRegion);
-    BoxPtr      pbox = REGION_RECTS(pRegion);
-    int         xRot = pDrawable->x;
-    int         yRot = pDrawable->y;
-    FbBits      planeMask;
-
-#ifdef PANORAMIX
-    if(!noPanoramiXExtension)
-    {
-        int index = pDrawable->pScreen->myNum;
-        if(&WindowTable[index]->drawable == pDrawable)
-        {
-            xRot -= panoramiXdataPtr[index].x;
-            yRot -= panoramiXdataPtr[index].y;
-        }
-    }
-#endif
-    fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
-    fbGetDrawable (&pTile->drawable, tile, tileStride, tileBpp,
-                   tileXoff, tileYoff);
-    tileWidth = pTile->drawable.width;
-    tileHeight = pTile->drawable.height;
-    xRot += dstXoff;
-    yRot += dstYoff;
-    planeMask = FB_ALLONES & ~RootlessAlphaMask(dstBpp);
-
-    while (n--)
-    {
-        fbTile (dst + (pbox->y1 + dstYoff) * dstStride,
-                dstStride,
-                (pbox->x1 + dstXoff) * dstBpp,
-                (pbox->x2 - pbox->x1) * dstBpp,
-                pbox->y2 - pbox->y1,
-                tile,
-                tileStride,
-                tileWidth * dstBpp,
-                tileHeight,
-                GXcopy,
-                planeMask,
-                dstBpp,
-                xRot * dstBpp,
-                yRot - pbox->y1);
-        pbox++;
-    }
-}
-
-
-/*
- * SafeAlphaPaintWindow
- *  Paint the window while filling in the alpha channel with all on.
- *  We can't use fbPaintWindow because it zeros the alpha channel.
- */
-void
-SafeAlphaPaintWindow(
-    WindowPtr pWin,
-    RegionPtr pRegion,
-    int what)
-{
-    switch (what) {
-      case PW_BACKGROUND:
-
-        switch (pWin->backgroundState) {
-            case None:
-                break;
-            case ParentRelative:
-                do {
-                    pWin = pWin->parent;
-                } while (pWin->backgroundState == ParentRelative);
-                (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
-                                                                 what);
-                break;
-            case BackgroundPixmap:
-                SafeAlphaFillRegionTiled (&pWin->drawable,
-                                          pRegion,
-                                          pWin->background.pixmap);
-                break;
-            case BackgroundPixel:
-            {
-                Pixel pixel = pWin->background.pixel |
-                              RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-                fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                                   fbReplicatePixel (pixel,
-                                        pWin->drawable.bitsPerPixel));
-                break;
-            }
-        }
-    	break;
-      case PW_BORDER:
-        if (pWin->borderIsPixel)
-        {
-            Pixel pixel = pWin->border.pixel |
-                          RootlessAlphaMask(pWin->drawable.bitsPerPixel);
-            fbFillRegionSolid (&pWin->drawable, pRegion, 0,
-                               fbReplicatePixel (pixel,
-                                    pWin->drawable.bitsPerPixel));
-        }
-        else
-        {
-            WindowPtr pBgWin;
-            for (pBgWin = pWin; pBgWin->backgroundState == ParentRelative;
-                 pBgWin = pBgWin->parent);
-    
-            SafeAlphaFillRegionTiled (&pBgWin->drawable,
-                                      pRegion,
-                                      pWin->border.pixmap);
-        }
-        break;
-    }
-    fbValidateDrawable (&pWin->drawable);
-}
diff-tree 06d27f8045966c1fb154eafaff308a01b93f265b (from dd3992eb86377684a5dbe86fa19c756a9e53cda2)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 12 23:57:30 2007 +0100

    Try again to fix drawable and tile offsets in miPaintWindow
    
    Many coordinate spaces are hard. Let's go drinking.

diff --git a/mi/miexpose.c b/mi/miexpose.c
index ad1356f..2dc8f15 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -592,22 +592,30 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     BoxPtr	pbox;
     xRectangle	*prect;
     int		numRects;
-    int		tile_x_off = 0, tile_y_off = 0;
-    int		draw_x_off = 0, draw_y_off = 0;
+    /*
+     * Distance from screen to destination drawable, use this
+     * to adjust rendering coordinates which come in in screen space
+     */
+    int		draw_x_off, draw_y_off;
+    /*
+     * Tile offset for drawing; these need to align the tile
+     * to the appropriate window origin
+     */
+    int		tile_x_off, tile_y_off;
     PixUnion	fill;
     Bool	solid = TRUE;
     DrawablePtr	drawable = &pWin->drawable;
 
-    draw_x_off = pWin->drawable.x;
-    draw_y_off = pWin->drawable.y;
-
     while (pWin->backgroundState == ParentRelative)
         pWin = pWin->parent;
 
     if (what == PW_BACKGROUND)
     {
-	tile_x_off = -pWin->drawable.x;
-	tile_y_off = -pWin->drawable.y;
+	draw_x_off = drawable->x;
+	draw_y_off = drawable->y;
+
+	tile_x_off = 0;
+	tile_y_off = 0;
 	fill = pWin->background;
 	switch (pWin->backgroundState) {
 	case None:
@@ -619,16 +627,21 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     }
     else
     {
-	PixmapPtr   pPixmap;
+	PixmapPtr   pixmap;
 
+	tile_x_off = drawable->x;
+	tile_y_off = drawable->y;
+	
 	/* servers without pixmaps draw their own borders */
 	if (!pScreen->GetWindowPixmap)
 	    return;
-	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
-	drawable = &pPixmap->drawable;
+	pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
+	drawable = &pixmap->drawable;
 #ifdef COMPOSITE
-	draw_x_off = -pPixmap->screen_x;
-	draw_y_off = -pPixmap->screen_y;
+	draw_x_off = pixmap->screen_x;
+	draw_y_off = pixmap->screen_y;
+	tile_x_off -= draw_x_off;
+	tile_y_off -= draw_y_off;
 #else
 	draw_x_off = 0;
 	draw_y_off = 0;
@@ -650,8 +663,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     {
 	gcval[1].val = FillTiled;
 	gcval[2].ptr = (pointer)fill.pixmap;
-	gcval[3].val = tile_x_off + draw_x_off;
-	gcval[4].val = tile_y_off + draw_y_off;
+	gcval[3].val = tile_x_off;
+	gcval[4].val = tile_y_off;
 	gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
     }
 
@@ -674,8 +687,8 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
-	prect->x = pbox->x1 + draw_x_off;
-	prect->y = pbox->y1 + draw_y_off;
+	prect->x = pbox->x1 - draw_x_off;
+	prect->y = pbox->y1 - draw_y_off;
 	prect->width = pbox->x2 - pbox->x1;
 	prect->height = pbox->y2 - pbox->y1;
     }
diff-tree dd3992eb86377684a5dbe86fa19c756a9e53cda2 (from 6da39c67905500ab2db00a45cda4a9f756cdde96)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 12 22:39:31 2007 +0100

    miPaintWindow draw to window for background.
    
    Instead of drawing to window pixmap for everything, draw to window for
    background as that works for Xnest and Xdmx; draw to pixmap for borders
    which neither of those X servers use.

diff --git a/mi/miexpose.c b/mi/miexpose.c
index e82a0b5..ad1356f 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -587,62 +587,72 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     ScreenPtr	pScreen = pWin->drawable.pScreen;
     ChangeGCVal gcval[5];
     BITS32	gcmask;
-    PixmapPtr	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
     GCPtr	pGC;
     int		i;
     BoxPtr	pbox;
     xRectangle	*prect;
     int		numRects;
-    int		xoff, yoff;
+    int		tile_x_off = 0, tile_y_off = 0;
+    int		draw_x_off = 0, draw_y_off = 0;
+    PixUnion	fill;
+    Bool	solid = TRUE;
+    DrawablePtr	drawable = &pWin->drawable;
+
+    draw_x_off = pWin->drawable.x;
+    draw_y_off = pWin->drawable.y;
 
     while (pWin->backgroundState == ParentRelative)
         pWin = pWin->parent;
 
-#ifdef COMPOSITE
-    xoff = -pPixmap->screen_x;
-    yoff = -pPixmap->screen_y;
-#else
-    xoff = 0;
-    yoff = 0;
-#endif
-    gcval[0].val = GXcopy;
-    gcmask = GCFunction;
-
     if (what == PW_BACKGROUND)
     {
+	tile_x_off = -pWin->drawable.x;
+	tile_y_off = -pWin->drawable.y;
+	fill = pWin->background;
 	switch (pWin->backgroundState) {
 	case None:
 	    return;
-	case BackgroundPixel:
-	    gcval[1].val = pWin->background.pixel;
-	    gcval[2].val  = FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	    break;
 	case BackgroundPixmap:
-	    gcval[1].val = FillTiled;
-	    gcval[2].ptr = (pointer)pWin->background.pixmap;
-	    gcval[3].val = pWin->drawable.x + xoff;
-	    gcval[4].val = pWin->drawable.y + yoff;
-	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
+	    solid = FALSE;
 	    break;
 	}
     }
     else
     {
-	if (pWin->borderIsPixel)
-	{
-	    gcval[1].val = pWin->border.pixel;
-	    gcval[2].val  = FillSolid;
-	    gcmask |= GCForeground | GCFillStyle;
-	}
-	else
-	{
-	    gcval[1].val = FillTiled;
-	    gcval[2].ptr = (pointer)pWin->border.pixmap;
-	    gcval[3].val = pWin->drawable.x + xoff;
-	    gcval[4].val = pWin->drawable.y + yoff;
-	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
-	}
+	PixmapPtr   pPixmap;
+
+	/* servers without pixmaps draw their own borders */
+	if (!pScreen->GetWindowPixmap)
+	    return;
+	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+	drawable = &pPixmap->drawable;
+#ifdef COMPOSITE
+	draw_x_off = -pPixmap->screen_x;
+	draw_y_off = -pPixmap->screen_y;
+#else
+	draw_x_off = 0;
+	draw_y_off = 0;
+#endif
+	fill = pWin->border;
+	solid = pWin->borderIsPixel;
+    }
+    
+    gcval[0].val = GXcopy;
+    gcmask = GCFunction;
+
+    if (solid)
+    {
+	gcval[1].val = fill.pixel;
+	gcval[2].val  = FillSolid;
+	gcmask |= GCForeground | GCFillStyle;
+    }
+    else
+    {
+	gcval[1].val = FillTiled;
+	gcval[2].ptr = (pointer)fill.pixmap;
+	gcval[3].val = tile_x_off + draw_x_off;
+	gcval[4].val = tile_y_off + draw_y_off;
+	gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
     }
 
     prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(prgn) *
@@ -650,27 +660,27 @@ miPaintWindow(WindowPtr pWin, RegionPtr 
     if (!prect)
 	return;
 
-    pGC = GetScratchGC(pPixmap->drawable.depth, pPixmap->drawable.pScreen);
+    pGC = GetScratchGC(drawable->depth, drawable->pScreen);
     if (!pGC)
     {
 	DEALLOCATE_LOCAL(prect);
 	return;
     }
     
-    dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
-    ValidateGC(&pPixmap->drawable, pGC);
+    dixChangeGC (NullClient, pGC, gcmask, NULL, gcval);
+    ValidateGC (drawable, pGC);
 
     numRects = REGION_NUM_RECTS(prgn);
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
-	prect->x = pbox->x1 + xoff;
-	prect->y = pbox->y1 + yoff;
+	prect->x = pbox->x1 + draw_x_off;
+	prect->y = pbox->y1 + draw_y_off;
 	prect->width = pbox->x2 - pbox->x1;
 	prect->height = pbox->y2 - pbox->y1;
     }
     prect -= numRects;
-    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, numRects, prect);
+    (*pGC->ops->PolyFillRect)(drawable, pGC, numRects, prect);
     DEALLOCATE_LOCAL(prect);
 
     FreeScratchGC(pGC);
diff-tree 6da39c67905500ab2db00a45cda4a9f756cdde96 (from 257c8ed17f4f908e0d0d5e53aaf13aa3b1313f50)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 12 13:23:13 2007 +0000

    Fix build on FreeBSD after Popen changes.

diff --git a/os/utils.c b/os/utils.c
index afcaae4..144098b 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1720,7 +1720,7 @@ static struct pid {
     int pid;
 } *pidlist;
 
-static sighandler_t old_alarm = NULL; /* XXX horrible awful hack */
+void (*old_alarm)(int) = NULL; /* XXX horrible awful hack */
 
 pointer
 Popen(char *command, char *type)
diff-tree 257c8ed17f4f908e0d0d5e53aaf13aa3b1313f50 (from 43dc41034735d84765233a78bd619f3f0e7ace75)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 12 12:11:49 2007 +0100

    Rewrite miPaintWindow to draw to window pixmap.
    
    miPaintWindow was drawing to the root window, or (sometimes) drawing to the
    window after smashing the window clip list. This is losing, and easily fixed
    by just drawing to the window pixmap.

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 8ae4118..e82a0b5 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -581,62 +581,49 @@ tossGC (
     return 0;
 }
 
-
 _X_EXPORT void
-miPaintWindow(pWin, prgn, what)
-WindowPtr pWin;
-RegionPtr prgn;
-int what;
+miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
 {
-    int	status;
-
-    Bool usingScratchGC = FALSE;
-    WindowPtr pRoot;
-	
-#define FUNCTION	0
-#define FOREGROUND	1
-#define TILE		2
-#define FILLSTYLE	3
-#define ABSX		4
-#define ABSY		5
-#define CLIPMASK	6
-#define SUBWINDOW	7
-#define COUNT_BITS	8
-
-    ChangeGCVal gcval[7];
-    ChangeGCVal newValues [COUNT_BITS];
-
-    BITS32 gcmask, index, mask;
-    RegionRec prgnWin;
-    DDXPointRec oldCorner;
-    BoxRec box;
-    WindowPtr	pBgWin;
-    GCPtr pGC;
-    int i;
-    BoxPtr pbox;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    xRectangle *prect;
-    int numRects;
-
-    gcmask = 0;
+    ScreenPtr	pScreen = pWin->drawable.pScreen;
+    ChangeGCVal gcval[5];
+    BITS32	gcmask;
+    PixmapPtr	pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+    GCPtr	pGC;
+    int		i;
+    BoxPtr	pbox;
+    xRectangle	*prect;
+    int		numRects;
+    int		xoff, yoff;
+
+    while (pWin->backgroundState == ParentRelative)
+        pWin = pWin->parent;
+
+#ifdef COMPOSITE
+    xoff = -pPixmap->screen_x;
+    yoff = -pPixmap->screen_y;
+#else
+    xoff = 0;
+    yoff = 0;
+#endif
+    gcval[0].val = GXcopy;
+    gcmask = GCFunction;
 
     if (what == PW_BACKGROUND)
     {
 	switch (pWin->backgroundState) {
 	case None:
 	    return;
-	case ParentRelative:
-	    (*pWin->parent->drawable.pScreen->PaintWindowBackground)(pWin->parent, prgn, what);
-	    return;
 	case BackgroundPixel:
-	    newValues[FOREGROUND].val = pWin->background.pixel;
-	    newValues[FILLSTYLE].val  = FillSolid;
+	    gcval[1].val = pWin->background.pixel;
+	    gcval[2].val  = FillSolid;
 	    gcmask |= GCForeground | GCFillStyle;
 	    break;
 	case BackgroundPixmap:
-	    newValues[TILE].ptr = (pointer)pWin->background.pixmap;
-	    newValues[FILLSTYLE].val = FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+	    gcval[1].val = FillTiled;
+	    gcval[2].ptr = (pointer)pWin->background.pixmap;
+	    gcval[3].val = pWin->drawable.x + xoff;
+	    gcval[4].val = pWin->drawable.y + yoff;
+	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
 	    break;
 	}
     }
@@ -644,15 +631,17 @@ int what;
     {
 	if (pWin->borderIsPixel)
 	{
-	    newValues[FOREGROUND].val = pWin->border.pixel;
-	    newValues[FILLSTYLE].val  = FillSolid;
+	    gcval[1].val = pWin->border.pixel;
+	    gcval[2].val  = FillSolid;
 	    gcmask |= GCForeground | GCFillStyle;
 	}
 	else
 	{
-	    newValues[TILE].ptr = (pointer)pWin->border.pixmap;
-	    newValues[FILLSTYLE].val = FillTiled;
-	    gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
+	    gcval[1].val = FillTiled;
+	    gcval[2].ptr = (pointer)pWin->border.pixmap;
+	    gcval[3].val = pWin->drawable.x + xoff;
+	    gcval[4].val = pWin->drawable.y + yoff;
+	    gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
 	}
     }
 
@@ -661,169 +650,30 @@ int what;
     if (!prect)
 	return;
 
-    newValues[FUNCTION].val = GXcopy;
-    gcmask |= GCFunction | GCClipMask;
-
-    i = pScreen->myNum;
-    pRoot = WindowTable[i];
-
-    pBgWin = pWin;
-    if (what == PW_BORDER)
-    {
-	while (pBgWin->backgroundState == ParentRelative)
-	    pBgWin = pBgWin->parent;
-    }
-
-    if ((pWin->drawable.depth != pRoot->drawable.depth) ||
-	(pWin->drawable.bitsPerPixel != pRoot->drawable.bitsPerPixel))
+    pGC = GetScratchGC(pPixmap->drawable.depth, pPixmap->drawable.pScreen);
+    if (!pGC)
     {
-	usingScratchGC = TRUE;
-	pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
-	if (!pGC)
-	{
-	    DEALLOCATE_LOCAL(prect);
-	    return;
-	}
-	/*
-	 * mash the clip list so we can paint the border by
-	 * mangling the window in place, pretending it
-	 * spans the entire screen
-	 */
-	if (what == PW_BORDER)
-	{
-	    prgnWin = pWin->clipList;
-	    oldCorner.x = pWin->drawable.x;
-	    oldCorner.y = pWin->drawable.y;
-	    pWin->drawable.x = pWin->drawable.y = 0;
-	    box.x1 = 0;
-	    box.y1 = 0;
-	    box.x2 = pScreen->width;
-	    box.y2 = pScreen->height;
-	    REGION_INIT(pScreen, &pWin->clipList, &box, 1);
-	    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-	    newValues[ABSX].val = pBgWin->drawable.x;
-	    newValues[ABSY].val = pBgWin->drawable.y;
-	}
-	else
-	{
-	    newValues[ABSX].val = 0;
-	    newValues[ABSY].val = 0;
-	}
-    } else {
-	/*
-	 * draw the background to the root window
-	 */
-	if (screenContext[i] == (GCPtr)NULL)
-	{
-	    if (!ResType && !(ResType = CreateNewResourceType(tossGC)))
-		return;
-	    screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0,
-					(XID *)NULL, &status);
-	    if (!screenContext[i])
-		return;
-	    numGCs++;
-	    if (!AddResource(FakeClientID(0), ResType,
-			     (pointer)screenContext[i]))
-	        return;
-	}
-	pGC = screenContext[i];
-	newValues[SUBWINDOW].val = IncludeInferiors;
-	newValues[ABSX].val = pBgWin->drawable.x;
-	newValues[ABSY].val = pBgWin->drawable.y;
-	gcmask |= GCSubwindowMode;
-	pWin = pRoot;
+	DEALLOCATE_LOCAL(prect);
+	return;
     }
     
-    mask = gcmask;
-    gcmask = 0;
-    i = 0;
-    while (mask) {
-    	index = lowbit (mask);
-	mask &= ~index;
-	switch (index) {
-	case GCFunction:
-	    if (pGC->alu != newValues[FUNCTION].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[FUNCTION].val;
-	    }
-	    break;
-	case GCTileStipXOrigin:
-	    if ( pGC->patOrg.x != newValues[ABSX].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[ABSX].val;
-	    }
-	    break;
-	case GCTileStipYOrigin:
-	    if ( pGC->patOrg.y != newValues[ABSY].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[ABSY].val;
-	    }
-	    break;
-	case GCClipMask:
-	    if ( pGC->clientClipType != CT_NONE) {
-		gcmask |= index;
-		gcval[i++].val = CT_NONE;
-	    }
-	    break;
-	case GCSubwindowMode:
-	    if ( pGC->subWindowMode != newValues[SUBWINDOW].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[SUBWINDOW].val;
-	    }
-	    break;
-	case GCTile:
-	    if (pGC->tileIsPixel || pGC->tile.pixmap != newValues[TILE].ptr)
- 	    {
-		gcmask |= index;
-		gcval[i++].ptr = newValues[TILE].ptr;
-	    }
-	    break;
-	case GCFillStyle:
-	    if ( pGC->fillStyle != newValues[FILLSTYLE].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[FILLSTYLE].val;
-	    }
-	    break;
-	case GCForeground:
-	    if ( pGC->fgPixel != newValues[FOREGROUND].val) {
-		gcmask |= index;
-		gcval[i++].val = newValues[FOREGROUND].val;
-	    }
-	    break;
-	}
-    }
-
-    if (gcmask)
-        dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
-
-    if (pWin->drawable.serialNumber != pGC->serialNumber)
-	ValidateGC((DrawablePtr)pWin, pGC);
+    dixChangeGC(NullClient, pGC, gcmask, NULL, gcval);
+    ValidateGC(&pPixmap->drawable, pGC);
 
     numRects = REGION_NUM_RECTS(prgn);
     pbox = REGION_RECTS(prgn);
     for (i= numRects; --i >= 0; pbox++, prect++)
     {
-	prect->x = pbox->x1 - pWin->drawable.x;
-	prect->y = pbox->y1 - pWin->drawable.y;
+	prect->x = pbox->x1 + xoff;
+	prect->y = pbox->y1 + yoff;
 	prect->width = pbox->x2 - pbox->x1;
 	prect->height = pbox->y2 - pbox->y1;
     }
     prect -= numRects;
-    (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
+    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, numRects, prect);
     DEALLOCATE_LOCAL(prect);
 
-    if (usingScratchGC)
-    {
-	if (what == PW_BORDER)
-	{
-	    REGION_UNINIT(pScreen, &pWin->clipList);
-	    pWin->clipList = prgnWin;
-	    pWin->drawable.x = oldCorner.x;
-	    pWin->drawable.y = oldCorner.y;
-	    pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-	}
-	FreeScratchGC(pGC);
-    }
+    FreeScratchGC(pGC);
 }
 
 
diff-tree 43dc41034735d84765233a78bd619f3f0e7ace75 (from a5b8053606d6e786cdcf6734f271acc05f9cc588)
Author: Brice Goglin <bgoglin at debian.org>
Date:   Wed Sep 12 01:43:37 2007 +0200

    Replace a non-ascii char with the corresponding groff escape in exa.man.pre

diff --git a/hw/xfree86/exa/exa.man.pre b/hw/xfree86/exa/exa.man.pre
index b0eecd5..31e1cfe 100644
--- a/hw/xfree86/exa/exa.man.pre
+++ b/hw/xfree86/exa/exa.man.pre
@@ -37,4 +37,4 @@ default is intended to be the best perfo
 may help with specific use cases.  Available options include \*qalways\*q,
 \*qgreedy\*q, and \*qsmart\*q.  Default: always.
 .SH AUTHORS
-Authors include: Keith Packard, Eric Anholt, Zack Rusin, and Michel Dänzer
+Authors include: Keith Packard, Eric Anholt, Zack Rusin, and Michel D\(:anzer
diff-tree a5b8053606d6e786cdcf6734f271acc05f9cc588 (from 2e3e08d31e908ceadeef16d6069cdaf8c61d7ed1)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Tue Sep 11 11:37:06 2007 -0400

    Ignore - not just block - SIGALRM around Popen()/Pclose().
    
    Because our "popen" implementation uses stdio, and because nobody's stdio
    library is capable of surviving signals, we need to make absolutely sure
    that we hide the SIGALRM from the smart scheduler.  Otherwise, when you
    open a menu in openoffice, and it recompiles XKB to deal with the
    accelerators, and you popen xkbcomp because we suck, then the scheduler
    will tell you you're taking forever doing something stupid, and the
    wait() code will get confused, and input will hang and your CPU usage
    slams to 100%.  Down, not across.

diff --git a/os/utils.c b/os/utils.c
index 3bb7dbe..afcaae4 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1720,6 +1720,8 @@ static struct pid {
     int pid;
 } *pidlist;
 
+static sighandler_t old_alarm = NULL; /* XXX horrible awful hack */
+
 pointer
 Popen(char *command, char *type)
 {
@@ -1741,11 +1743,15 @@ Popen(char *command, char *type)
 	return NULL;
     }
 
+    /* Ignore the smart scheduler while this is going on */
+    old_alarm = signal(SIGALRM, SIG_IGN);
+
     switch (pid = fork()) {
     case -1: 	/* error */
 	close(pdes[0]);
 	close(pdes[1]);
 	xfree(cur);
+	signal(SIGALRM, old_alarm);
 	return NULL;
     case 0:	/* child */
 	if (setgid(getgid()) == -1)
@@ -1921,6 +1927,8 @@ Pclose(pointer iop)
     /* allow EINTR again */
     OsReleaseSignals ();
     
+    signal(SIGALRM, old_alarm);
+
     return pid == -1 ? -1 : pstat;
 }
 
diff-tree 2e3e08d31e908ceadeef16d6069cdaf8c61d7ed1 (from e8c73ac697aa472e10b4d8c093a715df0bf545af)
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Tue Sep 11 08:50:41 2007 +0200

    xserver: test presence of strlcpy in configure
    
            * configure.ac: define HAVE_STRLCPY when function strlcat is present
              this serves at least to unbreak libxtrans code compilation.

diff --git a/configure.ac b/configure.ac
index 0025ecc..24b12df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,6 +186,7 @@ AC_CHECK_FUNC([getpeerucred],
 	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
 AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
 AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])	
+AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
 
 AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
 
diff-tree e8c73ac697aa472e10b4d8c093a715df0bf545af (from 321e0a21600e418bbeb164043a9a21a0ff80cbe9)
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Tue Sep 11 00:20:45 2007 +0200

    Xephyr: fix compilation breakage.
    
            * hw/kdrive/ephyr/ephyr_draw.c:
              (exaDDXDriverInit): pExaScr->hideOffscreenPixmapData does not exist
              anymore, so don't set it.

diff --git a/hw/kdrive/ephyr/ephyr_draw.c b/hw/kdrive/ephyr/ephyr_draw.c
index 84faecc..93ef27a 100644
--- a/hw/kdrive/ephyr/ephyr_draw.c
+++ b/hw/kdrive/ephyr/ephyr_draw.c
@@ -520,6 +520,5 @@ exaDDXDriverInit(ScreenPtr pScreen)
     ExaScreenPriv(pScreen);
 
     pExaScr->migration = ExaMigrationSmart;
-    pExaScr->hideOffscreenPixmapData = TRUE;
     pExaScr->checkDirtyCorrectness = TRUE;
 }
diff-tree 321e0a21600e418bbeb164043a9a21a0ff80cbe9 (from 0ff273fd1e2ea7242b3e6c5effb2a623ef32ec6f)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Sun Sep 9 16:28:41 2007 -0700

    fixed cut-and-paste typo

diff --git a/configure.ac b/configure.ac
index f02ad6d..0025ecc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1688,10 +1688,8 @@ AC_MSG_CHECKING([whether to build XDarwi
 if test "x$XDARWIN" = xauto; then
 	case $host_os in
 		darwin*) XDARWIN="yes" ;;
-		*) XWIN="no" ;;
+		*) XDARWIN="no" ;;
 	esac
-	XWIN_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $SHADOW_LIB"
-	AC_SUBST([XWIN_LIBS])
 fi
 AC_MSG_RESULT([$XDARWIN])
 
diff-tree 0ff273fd1e2ea7242b3e6c5effb2a623ef32ec6f (from f8637137ab43818d45d249b337820cbf427a05ec)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Thu Sep 6 18:52:26 2007 -0700

    XDARWIN: fixes to make Xquartz build again

diff --git a/hw/darwin/apple/X11Application.m b/hw/darwin/apple/X11Application.m
index 57795f4..2d21321 100644
--- a/hw/darwin/apple/X11Application.m
+++ b/hw/darwin/apple/X11Application.m
@@ -41,7 +41,7 @@
 # include "micmap.h"
 #undef BOOL
 
-#include "xf86Version.h"
+//#include "xf86Version.h"
 
 #include <mach/mach.h>
 #include <unistd.h>
diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 4e34954..0b22141 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -6,6 +6,7 @@
  **************************************************************/
 /*
  * Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
+ * Copyright (c) 2007 Apple Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -46,8 +47,6 @@
 #include "fb.h"			// fb framebuffer code
 #include "site.h"
 #include "globals.h"
-#include "xorgVersion.h"
-#include "xf86Date.h"
 #include "dix.h"
 
 #ifdef XINPUT
@@ -83,7 +82,7 @@ int                     darwinScreenInde
 io_connect_t            darwinParamConnect = 0;
 int                     darwinEventReadFD = -1;
 int                     darwinEventWriteFD = -1;
-int                     darwinMouseAccelChange = 1;
+// int                     darwinMouseAccelChange = 1;
 int                     darwinFakeButtons = 0;
 
 // location of X11's (0,0) point in global screen coordinates
@@ -127,86 +126,23 @@ const int NUMFORMATS = sizeof(formats)/s
 #ifndef PRE_RELEASE
 #define PRE_RELEASE XORG_VERSION_SNAP
 #endif
-
-void
-DarwinPrintBanner()
-{
-#if PRE_RELEASE
-  ErrorF("\n"
-    "This is a pre-release version of the " XVENDORNAME " X11.\n"
-    "Portions of this release are based on XFree86 4.4RC2 and selected\n"
-    "files from XFree86 4.4RC3. It is not supported in any way.\n"
-    "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
-    "Select the \"xorg\" product for bugs you find in this release.\n"
-    "Before reporting bugs in pre-release versions please check the\n"
-    "latest version in the " XVENDORNAME " \"monolithic tree\" CVS\n"
-    "repository hosted at http://www.freedesktop.org/Software/xorg/");
+#ifndef BUILD_DATE
+#define BUILD_DATE ""
 #endif
-#if XORG_VERSION_SNAP > 0
-  ErrorF(".%d", XORG_VERSION_SNAP);
+#ifndef XORG_RELEASE
+#define XORG_RELEASE "?"
 #endif
 
-#if XORG_VERSION_SNAP >= 900
-  ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, XORG_VERSION_MINOR + 1,
-				XORG_VERSION_SNAP - 900);
-#endif
-
-#ifdef XORG_CUSTOM_VERSION
-  ErrorF(" (%s)", XF86_CUSTOM_VERSION);
-#endif
-  ErrorF("\nRelease Date: %s\n", XF86_DATE);
-  ErrorF("X Protocol Version %d, Revision %d, %s\n",
-         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_VERSION_CURRENT );
-  ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR);
-#ifdef HAS_UTSNAME
-  {
-    struct utsname name;
-
-    if (uname(&name) == 0) {
-      ErrorF("Current Operating System: %s %s %s %s %s\n",
-	name.sysname, name.nodename, name.release, name.version, name.machine);
-    }
-  }
-#endif
-#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
-  {
-    struct tm t;
-    char buf[100];
-
-    bzero(&t, sizeof(t));
-    bzero(buf, sizeof(buf));
-    t.tm_mday = BUILD_DATE % 100;
-    t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
-    t.tm_year = BUILD_DATE / 10000 - 1900;
-    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
-       ErrorF("Build Date: %s\n", buf);
-  }
-#endif
-#if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
-  {
-    struct tm t;
-    char buf[100];
-
-    bzero(&t, sizeof(t));
-    bzero(buf, sizeof(buf));
-    t.tm_mday = CLOG_DATE % 100;
-    t.tm_mon = (CLOG_DATE / 100) % 100 - 1;
-    t.tm_year = CLOG_DATE / 10000 - 1900;
-    if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
-       ErrorF("Changelog Date: %s\n", buf);
-  }
-#endif
-#if defined(BUILDERSTRING)
-  ErrorF("%s \n",BUILDERSTRING);
-#endif
-  ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__"\n"
-	 "\tto make sure that you have the latest version.\n");
+void DDXRingBell(int volume, int pitch, int duration) {
+  // FIXME -- make some noise, yo
 }
 
-
-void DDXRingBell(int volume, int pitch, int duration)
-{
-  // FIXME -- make some noise, yo
+void
+DarwinPrintBanner(void)
+{ 
+  // this should change depending on which specific server we are building
+  ErrorF("X11.app starting:\n");
+  ErrorF("Xquartz server based on X.org %s, built on %s\n", XORG_RELEASE, BUILD_DATE );
 }
 
 
@@ -359,8 +295,8 @@ static Bool DarwinAddScreen(
     dixScreenOrigins[index].x = dfb->x;
     dixScreenOrigins[index].y = dfb->y;
 
-    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
-            index, dfb->width, dfb->height, dfb->x, dfb->y);
+    /*    ErrorF("Screen %d added: %dx%d @ (%d,%d)\n",
+	  index, dfb->width, dfb->height, dfb->x, dfb->y); */
 
     return TRUE;
 }
@@ -373,6 +309,7 @@ static Bool DarwinAddScreen(
  =============================================================================
 */
 
+#if 0
 /*
  * DarwinChangePointerControl
  *  Set mouse acceleration and thresholding
@@ -393,7 +330,7 @@ static void DarwinChangePointerControl(
     if (kr != KERN_SUCCESS)
         ErrorF( "Could not set mouse acceleration with kernel return = 0x%x.\n", kr );
 }
-
+#endif
 
 /*
  * DarwinMouseProc
@@ -416,12 +353,11 @@ static int DarwinMouseProc(
             map[3] = 3;
             map[4] = 4;
             map[5] = 5;
-            InitPointerDeviceStruct( (DevicePtr)pPointer,
-                        map,
-                        5,   // numbuttons (4 & 5 are scroll wheel)
-                        GetMotionHistory,
-                        DarwinChangePointerControl,
-                        GetMotionHistorySize(), 2 );
+            InitPointerDeviceStruct( (DevicePtr)pPointer, map, 5,
+				     GetMotionHistory,
+				     (PtrCtrlProcPtr)NoopDDA,
+				     GetMotionHistorySize(), 2);
+
 #ifdef XINPUT
             InitValuatorAxisStruct( pPointer,
                                     0,     // X axis
@@ -643,8 +579,8 @@ DarwinAdjustScreenOrigins(ScreenInfo *pS
         for (i = 0; i < pScreenInfo->numScreens; i++) {
             dixScreenOrigins[i].x -= darwinMainScreenX;
             dixScreenOrigins[i].y -= darwinMainScreenY;
-            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
-                   i, dixScreenOrigins[i].x, dixScreenOrigins[i].y);
+    /*            ErrorF("Screen %d placed at X11 coordinate (%d,%d).\n",
+		  i, dixScreenOrigins[i].x, dixScreenOrigins[i].y); */
         }
     }
 }
@@ -725,10 +661,6 @@ void OsVendorInit(void)
         }
         darwinKeymapFile = tempStr;
     }
-
-    if ( !darwinKeymapFile ) {
-        ErrorF("Reading keymap from the system.\n");
-    }
 }
 
 
@@ -926,7 +858,7 @@ void ddxUseMsg( void )
  */
 void ddxGiveUp( void )
 {
-    ErrorF( "Quitting XDarwin...\n" );
+    ErrorF( "Quitting XQuartz...\n" );
 
     DarwinModeGiveUp();
 }
@@ -949,7 +881,6 @@ void AbortDDX( void )
 }
 
 
-#ifdef DPMSExtension
 /*
  * DPMS extension stubs
  */
@@ -966,8 +897,6 @@ int DPMSGet(int *level)
 {
     return -1;
 }
-#endif
-
 
 #include "mivalidate.h" // for union _Validate used by windowstr.h
 #include "windowstr.h"  // for struct _Window
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index fc4a58a..de10400 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -48,7 +48,7 @@ typedef struct {
 
 
 // From darwin.c
-void DarwinPrintBanner();
+void DarwinPrintBanner(void);
 int DarwinParseModifierList(const char *constmodifiers);
 void DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo);
 void xf86SetRootClip (ScreenPtr pScreen, BOOL enable);
diff --git a/hw/darwin/quartz/Preferences.m b/hw/darwin/quartz/Preferences.m
index eb78fd3..a79454b 100644
--- a/hw/darwin/quartz/Preferences.m
+++ b/hw/darwin/quartz/Preferences.m
@@ -356,7 +356,7 @@ static NSString *X11EnableKeyEquivalents
     [[NSUserDefaults standardUserDefaults] setBool:newMouseAccelChange
             forKey:@"AllowMouseAccelChange"];
     // Update the setting used by the X server thread
-    darwinMouseAccelChange = newMouseAccelChange;
+    //    darwinMouseAccelChange = newMouseAccelChange;
 }
 
 + (void)setUseQDCursor:(int)newUseQDCursor
diff --git a/hw/darwin/quartz/quartzCocoa.m b/hw/darwin/quartz/quartzCocoa.m
index c54c18a..42eabcb 100644
--- a/hw/darwin/quartz/quartzCocoa.m
+++ b/hw/darwin/quartz/quartzCocoa.m
@@ -66,7 +66,7 @@ void QuartzReadPreferences(void)
     darwinFakeButtons = [Preferences fakeButtons];
     darwinFakeMouse2Mask = [Preferences button2Mask];
     darwinFakeMouse3Mask = [Preferences button3Mask];
-    darwinMouseAccelChange = [Preferences mouseAccelChange];
+    //    darwinMouseAccelChange = [Preferences mouseAccelChange];
     quartzUseSysBeep = [Preferences systemBeep];
     quartzEnableKeyEquivalents = [Preferences enableKeyEquivalents];
 
diff-tree f8637137ab43818d45d249b337820cbf427a05ec (from e8093e15c7df7a3d5a9717bc9d7d7517b0743f29)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Sep 6 05:39:57 2007 -0700

    XDARWIN: build fix for quartz/pseudoramiX.c

diff --git a/hw/darwin/quartz/pseudoramiX.c b/hw/darwin/quartz/pseudoramiX.c
index 7ba6d5a..e65be69 100644
--- a/hw/darwin/quartz/pseudoramiX.c
+++ b/hw/darwin/quartz/pseudoramiX.c
@@ -43,6 +43,9 @@ Equipment Corporation.
 #include <X11/extensions/panoramiXproto.h>
 #include "globals.h"
 
+extern int noPseudoramiXExtension;
+extern int noPanoramiXExtension;
+
 extern int ProcPanoramiXQueryVersion (ClientPtr client);
 
 static void PseudoramiXResetProc(ExtensionEntry *extEntry);
diff-tree e8093e15c7df7a3d5a9717bc9d7d7517b0743f29 (from e81af8ba643df3be53b0a46d9d4a0eaf21557c9e)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 3 13:52:29 2007 +0200

    EXA: Exclude bits that will be overwritten from migration in exaCopyNtoN.
    
    Also plug a region leak in exaPolyFillRect.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 0a03d71..232ec99 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -483,14 +483,48 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     int	    src_off_x, src_off_y;
     int	    dst_off_x, dst_off_y;
     ExaMigrationRec pixmaps[2];
+    RegionPtr region = NULL;
+
+    pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
+    pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
+
+    exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
+    exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
+
+    if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
+				       pGC->fillStyle, pGC->alu)) {
+	xRectangle *rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+
+	if (rects) {
+	    int i;
+
+	    for (i = 0; i < nbox; i++) {
+		rects[i].x = pbox[i].x1 + dst_off_x;
+		rects[i].y = pbox[i].y1 + dst_off_y;
+		rects[i].width = pbox[i].x2 - pbox[i].x1;
+		rects[i].height = pbox[i].y2 - pbox[i].y1;
+	    }
+
+	    region  = RECTS_TO_REGION(pScreen, nbox, rects, CT_YXBANDED);
+	    DEALLOCATE_LOCAL(rects);
+
+	    if (region) {
+		src_off_x -= dst_off_x;
+		src_off_y -= dst_off_y;
+		dst_off_x = dst_off_y = 0;
+		pbox = REGION_RECTS(region);
+		nbox = REGION_NUM_RECTS(region);
+	    }
+	}
+    }
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pPix = pDstPixmap;
+    pixmaps[0].pReg = region;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
-    pixmaps[1].pPix = pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
+    pixmaps[1].pPix = pSrcPixmap;
     pixmaps[1].pReg = NULL;
 
     /* Respect maxX/maxY in a trivial way: don't set up drawing when we might
@@ -512,16 +546,10 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	reverse != upsidedown) {
 	if (exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox,
 			       dx, dy))
-	    return;
+	    goto out;
 	goto fallback;
     }
 
-    pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
-    pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
-
-    exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
-    exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
-
     if (!exaPixmapIsOffscreen(pSrcPixmap) ||
 	!exaPixmapIsOffscreen(pDstPixmap) ||
 	!(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1,
@@ -544,18 +572,24 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     (*pExaScr->info->DoneCopy) (pDstPixmap);
     exaMarkSync (pDstDrawable->pScreen);
 
-    return;
+    goto out;
 
 fallback:
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
 		  exaDrawableLocation(pSrcDrawable),
 		  exaDrawableLocation(pDstDrawable)));
-    exaPrepareAccessReg (pDstDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
+    exaPrepareAccessReg (pDstDrawable, EXA_PREPARE_DEST, region);
     exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
     fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy, reverse,
 		upsidedown, bitplane, closure);
     exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC);
     exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST);
+
+out:
+    if (region) {
+	REGION_UNINIT(pScreen, region);
+	REGION_DESTROY(pScreen, region);
+    }
 }
 
 RegionPtr
@@ -870,6 +904,7 @@ fallback:
     exaMarkSync(pDrawable->pScreen);
 
 out:
+    REGION_UNINIT(pScreen, pReg);
     REGION_DESTROY(pScreen, pReg);
 }
 
diff-tree e81af8ba643df3be53b0a46d9d4a0eaf21557c9e (from 5f7da4da8de7449e1c2a4c679632a0b2a5858b7e)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Mon Sep 3 13:14:29 2007 +0200

    EXA: exaFillRegion{Solid,Tiled} improvements.
    
    Use region to exclude bits that will be overwritten from migration.
    
    Also make exaFillRegionSolid use the same logic as exaFillRegionTiled.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e44ce60..0a03d71 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1074,7 +1074,11 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillSolid,
+					    alu) ? NULL : pRegion;
+
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+    REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
 
     if (pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
@@ -1090,8 +1094,6 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
 	int nbox;
 	BoxPtr pBox;
 
-	REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
-
 	nbox = REGION_NUM_RECTS (pRegion);
 	pBox = REGION_RECTS (pRegion);
 
@@ -1124,19 +1126,21 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
 	}
 
 	REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+	return TRUE;
     }
-    else
-    {
+
 fallback:
-	if (alu != GXcopy || planemask != FB_ALLONES)
-	    return FALSE;
-	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
-		      exaDrawableLocation(pDrawable)));
-	exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
-	fbFillRegionSolid (pDrawable, pRegion, 0,
-			   fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
-	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
+    if (alu != GXcopy || !EXA_PM_IS_SOLID(pDrawable, planemask)) {
+	REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+	return FALSE;
     }
+    EXA_FALLBACK(("to %p (%c)\n", pDrawable,
+		  exaDrawableLocation(pDrawable)));
+    exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
+    REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
+    fbFillRegionSolid (pDrawable, pRegion, 0,
+		       fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+    exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
 
     return TRUE;
 }
@@ -1174,12 +1178,16 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillTiled,
+					    alu) ? NULL : pRegion;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
     pixmaps[1].pPix = pTile;
     pixmaps[1].pReg = NULL;
 
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+    REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+
     if (pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY ||
 	tileWidth > pExaScr->info->maxX ||
@@ -1208,7 +1216,7 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 	    int dstY = pBox->y1;
 	    int tileY;
 
-	    tileY = (dstY - pDrawable->y - pPatOrg->y) % tileHeight;
+	    tileY = (dstY - yoff - pDrawable->y - pPatOrg->y) % tileHeight;
 	    while (height > 0) {
 		int width = pBox->x2 - pBox->x1;
 		int dstX = pBox->x1;
@@ -1219,7 +1227,7 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 		    h = height;
 		height -= h;
 
-		tileX = (dstX - pDrawable->x - pPatOrg->x) % tileWidth;
+		tileX = (dstX - xoff - pDrawable->x - pPatOrg->x) % tileWidth;
 		while (width > 0) {
 		    int w = tileWidth - tileX;
 		    if (w > width)
@@ -1228,8 +1236,7 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 
 		    (*pExaScr->info->Copy) (pPixmap,
 					    tileX + tileXoff, tileY + tileYoff,
-					    dstX + xoff, dstY + yoff,
-					    w, h);
+					    dstX, dstY, w, h);
 		    dstX += w;
 		    tileX = 0;
 		}
@@ -1240,16 +1247,20 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
 	}
 	(*pExaScr->info->DoneCopy) (pPixmap);
 	exaMarkSync(pDrawable->pScreen);
+	REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
 	return TRUE;
     }
 
 fallback:
-    if (alu != GXcopy || planemask != FB_ALLONES)
+    if (alu != GXcopy || !EXA_PM_IS_SOLID(pDrawable, planemask)) {
+	REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
 	return FALSE;
+    }
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
 		  exaDrawableLocation(&pTile->drawable),
 		  exaDrawableLocation(pDrawable)));
     exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
+    REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
     exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
     fbFillRegionTiled (pDrawable, pRegion, pTile);
     exaFinishAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
diff-tree 5f7da4da8de7449e1c2a4c679632a0b2a5858b7e (from be922b30486abce3a8c13996d579b211a7b56f0e)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Fri Aug 31 16:59:28 2007 +0200

    EXA: Use exaShmPutImage for pushing glyphs to scratch pixmap in exaGlyphs.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 136fca2..e44ce60 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -287,7 +287,7 @@ exaDoShmPutImage(DrawablePtr pDrawable, 
  * We also need to set the pending damage to ensure correct migration in all
  * cases.
  */
-static void
+void
 exaShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int format,
 	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
 	       char *data)
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a6ac921..02371d7 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -300,6 +300,11 @@ void
 exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what);
 
 void
+exaShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int format,
+	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
+	       char *data);
+
+void
 exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
 	     unsigned int format, unsigned long planeMask, char *d);
 
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 9df795f..943a4c8 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -1282,6 +1282,15 @@ exaGlyphs (CARD8	op,
 		    pScratchPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 		}
 
+#ifdef MITSHM
+		if (pExaScr->info->PrepareComposite)
+		    exaShmPutImage(&pPixmap->drawable, pGC,
+				   pPixmap->drawable.depth, ZPixmap,
+				   glyph->info.width, glyph->info.height, 0, 0,
+				   glyph->info.width, glyph->info.height, 0, 0,
+				   glyphdata);
+		else
+#endif
 		exaCopyArea (&pScratchPixmap->drawable, &pPixmap->drawable, pGC,
 			     0, 0, glyph->info.width, glyph->info.height, 0, 0);
 	    }
diff-tree be922b30486abce3a8c13996d579b211a7b56f0e (from ea92ea415665e294a1ba233e9a1d39b6daa0cee1)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:59:07 2007 +0200

    EXA: exa(Shm)PutImage improvements.
    
    Improve exaShmPutImage performance and reuse its core in exaPutImage as it
    seems faster than the previous code when the driver doesn't provide an
    UploadToScreen hook.
    
    Make sure all damage records are notified of the damage incurred by actual
    ShmPutImage calls.
    
    Remove superfluous manual damage tracking for actual PutImage calls.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index df6a62d..136fca2 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -139,10 +139,11 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 
 static Bool
 exaDoPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
-	       int w, int h, int leftPad, int format, char *bits, int src_stride)
+	       int w, int h, int format, char *bits, int src_stride)
 {
     ExaScreenPriv (pDrawable->pScreen);
-    PixmapPtr pPix;
+    PixmapPtr pPix = exaGetDrawablePixmap (pDrawable);
+    ExaPixmapPriv(pPix);
     ExaMigrationRec pixmaps[1];
     RegionPtr pClip;
     BoxPtr pbox;
@@ -151,26 +152,28 @@ exaDoPutImage (DrawablePtr pDrawable, GC
     int bpp = pDrawable->bitsPerPixel;
     Bool access_prepared = FALSE;
 
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
-    pixmaps[0].pReg = NULL;
-
     /* Don't bother with under 8bpp, XYPixmaps. */
     if (format != ZPixmap || bpp < 8)
-	goto fallback;
+	return FALSE;
 
     /* Only accelerate copies: no rop or planemask. */
     if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy)
-	goto fallback;
+	return FALSE;
 
     if (pExaScr->swappedOut)
-	goto fallback;
+	return FALSE;
 
+    pixmaps[0].as_dst = TRUE;
+    pixmaps[0].as_src = FALSE;
+    pixmaps[0].pPix = pPix;
+    pixmaps[0].pReg = DamagePendingRegion(pExaPixmap->pDamage);
     exaDoMigration (pixmaps, 1, TRUE);
 
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
 
+    if (!pPix || !pExaScr->info->UploadToScreen)
+	return FALSE;
+
     x += pDrawable->x;
     y += pDrawable->y;
 
@@ -199,10 +202,8 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 	    continue;
 
 	src = bits + (y1 - y) * src_stride + (x1 - x) * (bpp / 8);
-	ok = (pPix && pExaScr->info->UploadToScreen) ?
-	     pExaScr->info->UploadToScreen(pPix, x1 + xoff, y1 + yoff,
-					   x2 - x1, y2 - y1, src, src_stride) :
-	     FALSE;
+	ok = pExaScr->info->UploadToScreen(pPix, x1 + xoff, y1 + yoff,
+					   x2 - x1, y2 - y1, src, src_stride);
 	/* If we fail to accelerate the upload, fall back to using unaccelerated
 	 * fb calls.
 	 */
@@ -231,8 +232,6 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 		      y2 - y1,
 		      GXcopy, FB_ALLONES, dstBpp);
 	}
-
-	exaPixmapDirty(pixmaps[0].pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff);
     }
 
     if (access_prepared)
@@ -241,45 +240,110 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 	exaMarkSync(pDrawable->pScreen);
 
     return TRUE;
-
-fallback:
-    return FALSE;
 }
 
-static void
-exaPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
-	     int w, int h, int leftPad, int format, char *bits)
+#ifdef MITSHM
+
+static Bool
+exaDoShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
+		 unsigned int format, int w, int h, int sx, int sy, int sw,
+		 int sh, int dx, int dy, char *data)
 {
-    if (!exaDoPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits,
-		       PixmapBytePad(w, pDrawable->depth)))
-	ExaCheckPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
-			 bits);
-}
+    int src_stride = PixmapBytePad(w, depth);
 
-#ifdef MITSHM
+    if (exaDoPutImage(pDrawable, pGC, depth, dx, dy, sw, sh, format, data +
+		      sy * src_stride + sx * BitsPerPixel(depth) / 8,
+		      src_stride))
+	return TRUE;
+
+    if (format == ZPixmap)
+    {
+	PixmapPtr pPixmap;
+
+	pPixmap = GetScratchPixmapHeader(pDrawable->pScreen, w, h, depth,
+		BitsPerPixel(depth), PixmapBytePad(w, depth), (pointer)data);
+	if (!pPixmap)
+	    return FALSE;
 
+	if (exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
+				  pGC->alu))
+	    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	else
+	    ExaDoPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	fbCopyArea((DrawablePtr)pPixmap, pDrawable, pGC, sx, sy, sw, sh, dx, dy);
+	exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
+
+	FreeScratchPixmapHeader(pPixmap);
+
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
+/* The actual ShmPutImage isn't wrapped by the damage layer, so we need to
+ * inform any interested parties of the damage incurred to the drawable.
+ *
+ * We also need to set the pending damage to ensure correct migration in all
+ * cases.
+ */
 static void
 exaShmPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int format,
 	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
 	       char *data)
 {
-    int src_stride = PixmapBytePad(w, depth);
+    PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
+    ExaPixmapPriv(pPixmap);
+    BoxRec box = { .x1 = pDrawable->x + dx, .y1 = pDrawable->y + dy,
+		   .x2 = pDrawable->x + dx + sw, .y2 = pDrawable->y + dy + sh };
+    RegionRec region;
+    int xoff, yoff;
+    RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
 
-    if (exaDoPutImage(pDrawable, pGC, depth, dx, dy, sw, sh, 0, format, data +
-		      sy * src_stride + sx * BitsPerPixel(depth) / 8,
-		      src_stride))
-	return;
+    REGION_INIT(pScreen, &region, &box, 1);
 
-    exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
-    fbShmPutImage(pDrawable, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
-		  data);
-    exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+
+    REGION_TRANSLATE(pScreen, &region, xoff, yoff);
+    REGION_UNION(pScreen, pending_damage, pending_damage, &region);
+
+    if (!exaDoShmPutImage(pDrawable, pGC, depth, format, w, h, sx, sy, sw, sh,
+			  dx, dy, data)) {
+	if (exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
+				  pGC->alu))
+	    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	else
+	    ExaDoPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	fbShmPutImage(pDrawable, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
+		      data);
+	exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
+    }
+
+    REGION_TRANSLATE(pScreen, &region, -xoff, -yoff);
+    DamageDamageRegion(pDrawable, &region);
+
+    REGION_UNINIT(pScreen, &region);
 }
 
 ShmFuncs exaShmFuncs = { NULL, exaShmPutImage };
 
 #endif
 
+static void
+exaPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+	     int w, int h, int leftPad, int format, char *bits)
+{
+#ifdef MITSHM
+    if (!exaDoShmPutImage(pDrawable, pGC, depth, format, w, h, 0, 0, w, h, x, y,
+			  bits))
+#else
+    if (!exaDoPutImage(pDrawable, pGC, depth, x, y, w, h, format, bits,
+		       PixmapBytePad(w, pDrawable->depth)))
+#endif
+	ExaCheckPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
+			 bits);
+}
+
 static Bool inline
 exaCopyNtoNTwoDir (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
 		   GCPtr pGC, BoxPtr pbox, int nbox, int dx, int dy)
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 8e51f5d..a6ac921 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -279,6 +279,16 @@ CARD32
 exaGetPixmapFirstPixel (PixmapPtr pPixmap); 
 
 /* exa_accel.c */
+
+static _X_INLINE Bool
+exaGCReadsDestination(DrawablePtr pDrawable, unsigned long planemask,
+		      unsigned int fillStyle, unsigned char alu)
+{
+    return ((alu != GXcopy && alu != GXclear &&alu != GXset &&
+	     alu != GXcopyInverted) || fillStyle == FillStippled ||
+	    !EXA_PM_IS_SOLID(pDrawable, planemask));
+}
+
 void
 exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 8fb7b52..f4d453e 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -97,14 +97,14 @@ ExaCheckPutImage (DrawablePtr pDrawable,
 		 int x, int y, int w, int h, int leftPad, int format,
 		 char *bits)
 {
-    PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
-    int xoff, yoff;
-
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
-    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    if (exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
+			      pGC->alu))
+	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    else
+	ExaDoPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
 }
 
 RegionPtr
diff-tree ea92ea415665e294a1ba233e9a1d39b6daa0cee1 (from aa2ed73e0ec881947c969b67269e3206da4de359)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:54:18 2007 +0200

    EXA: exaGetImage improvements.
    
    Use the new migration infrastructure to cache FB bits we need in the system
    copy, for the benefit of repeated calls.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 36815e2..df6a62d 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1247,22 +1247,43 @@ exaPaintWindow(WindowPtr pWin, RegionPtr
  * Accelerates GetImage for solid ZPixmap downloads from framebuffer memory.
  *
  * This is probably the only case we actually care about.  The rest fall through
- * to migration and ExaCheckGetImage, which hopefully will result in migration
- * pushing the pixmap out of framebuffer.
+ * to migration and fbGetImage, which hopefully will result in migration pushing
+ * the pixmap out of framebuffer.
  */
 void
 exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
 	     unsigned int format, unsigned long planeMask, char *d)
 {
     ExaScreenPriv (pDrawable->pScreen);
+    ExaMigrationRec pixmaps[1];
+    BoxRec Box;
+    RegionRec Reg;
     PixmapPtr pPix;
     int xoff, yoff;
     Bool ok;
 
-    if (pExaScr->swappedOut || (w == 1 && h == 1))
+    if (pExaScr->swappedOut)
 	goto fallback;
 
-    if (pExaScr->info->DownloadFromScreen == NULL)
+    pixmaps[0].as_dst = FALSE;
+    pixmaps[0].as_src = TRUE;
+    pixmaps[0].pPix = pPix = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = &Reg;
+
+    exaGetDrawableDeltas (pDrawable, pPix, &xoff, &yoff);
+
+    Box.x1 = pDrawable->y + x + xoff;
+    Box.y1 = pDrawable->y + y + yoff;
+    Box.x2 = Box.x1 + w;
+    Box.y2 = Box.y1 + h;
+
+    REGION_INIT(pScreen, &Reg, &Box, 1);
+
+    exaDoMigration(pixmaps, 1, FALSE);
+
+    pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
+
+    if (pPix == NULL || pExaScr->info->DownloadFromScreen == NULL)
 	goto fallback;
 
     /* Only cover the ZPixmap, solid copy case. */
@@ -1275,20 +1296,22 @@ exaGetImage (DrawablePtr pDrawable, int 
     if (pDrawable->bitsPerPixel < 8)
 	goto fallback;
 
-    pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
-    if (pPix == NULL)
-	goto fallback;
-
-    xoff += pDrawable->x;
-    yoff += pDrawable->y;
-
-    ok = pExaScr->info->DownloadFromScreen(pPix, x + xoff, y + yoff, w, h, d,
+    ok = pExaScr->info->DownloadFromScreen(pPix, pDrawable->x + x + xoff,
+					   pDrawable->y + y + yoff, w, h, d,
 					   PixmapBytePad(w, pDrawable->depth));
     if (ok) {
 	exaWaitSync(pDrawable->pScreen);
-	return;
+	goto out;
     }
 
 fallback:
-    ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d);
+    EXA_FALLBACK(("from %p (%c)\n", pDrawable,
+		  exaDrawableLocation(pDrawable)));
+
+    exaPrepareAccessReg (pDrawable, EXA_PREPARE_SRC, &Reg);
+    fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
+    exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
+
+out:
+    REGION_UNINIT(pScreen, &Reg);
 }
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a8bdbd6..8e51f5d 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -265,12 +265,6 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 		   int w, int h, int x, int y);
 
 void
-ExaCheckGetImage (DrawablePtr pDrawable,
-		 int x, int y, int w, int h,
-		 unsigned int format, unsigned long planeMask,
-		 char *d);
-
-void
 ExaCheckGetSpans (DrawablePtr pDrawable,
 		 int wMax,
 		 DDXPointPtr ppt,
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 970c2cb..8fb7b52 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -265,19 +265,6 @@ ExaCheckPushPixels (GCPtr pGC, PixmapPtr
 }
 
 void
-ExaCheckGetImage (DrawablePtr pDrawable,
-		 int x, int y, int w, int h,
-		 unsigned int format, unsigned long planeMask,
-		 char *d)
-{
-    EXA_FALLBACK(("from %p (%c)\n", pDrawable,
-		  exaDrawableLocation(pDrawable)));
-    exaPrepareAccess (pDrawable, EXA_PREPARE_SRC);
-    fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
-    exaFinishAccess (pDrawable, EXA_PREPARE_SRC);
-}
-
-void
 ExaCheckGetSpans (DrawablePtr pDrawable,
 		 int wMax,
 		 DDXPointPtr ppt,
diff-tree aa2ed73e0ec881947c969b67269e3206da4de359 (from a634c9b03494ba80aeec28be19662ac96657cc23)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:50:42 2007 +0200

    EXA: Remove superfluous manual damage tracking.
    
    These should all be covered by damage wrappers.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 4cae198..36815e2 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -394,8 +394,6 @@ exaCopyNtoNTwoDir (DrawablePtr pSrcDrawa
 				       dst_off_y + pbox->y1 + i,
 				       pbox->x2 - pbox->x1, 1);
 	}
-	exaPixmapDirty(pDstPixmap, dst_off_x + pbox->x1, dst_off_y + pbox->y1,
-		       dst_off_x + pbox->x2, dst_off_y + pbox->y2);
     }
     if (dirsetup != 0)
 	pExaScr->info->DoneCopy(pDstPixmap);
@@ -421,7 +419,6 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     int	    src_off_x, src_off_y;
     int	    dst_off_x, dst_off_y;
     ExaMigrationRec pixmaps[2];
-    Bool fallback = FALSE;
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
@@ -441,18 +438,18 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	pDstPixmap->drawable.width > pExaScr->info->maxX ||
 	pDstPixmap->drawable.height > pExaScr->info->maxY)
     {
-	fallback = TRUE;
+	goto fallback;
     } else {
 	exaDoMigration (pixmaps, 2, TRUE);
     }
 
     /* Mixed directions must be handled specially if the card is lame */
-    if (!fallback && (pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS) &&
+    if ((pExaScr->info->flags & EXA_TWO_BITBLT_DIRECTIONS) &&
 	reverse != upsidedown) {
 	if (exaCopyNtoNTwoDir(pSrcDrawable, pDstDrawable, pGC, pbox, nbox,
 			       dx, dy))
 	    return;
-	fallback = TRUE;
+	goto fallback;
     }
 
     pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
@@ -461,43 +458,40 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     exaGetDrawableDeltas (pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
     exaGetDrawableDeltas (pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
 
-    if (fallback || !exaPixmapIsOffscreen(pSrcPixmap) ||
+    if (!exaPixmapIsOffscreen(pSrcPixmap) ||
 	!exaPixmapIsOffscreen(pDstPixmap) ||
 	!(*pExaScr->info->PrepareCopy) (pSrcPixmap, pDstPixmap, reverse ? -1 : 1,
 					upsidedown ? -1 : 1,
 					pGC ? pGC->alu : GXcopy,
 					pGC ? pGC->planemask : FB_ALLONES)) {
-	fallback = TRUE;
-	EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
-		      exaDrawableLocation(pSrcDrawable),
-		      exaDrawableLocation(pDstDrawable)));
-	exaPrepareAccessReg (pDstDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
-	exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
-	fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
-		    pbox, nbox, dx, dy, reverse, upsidedown,
-		    bitplane, closure);
-	exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC);
-	exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST);
+	goto fallback;
     }
 
     while (nbox--)
     {
-	if (!fallback)
-	    (*pExaScr->info->Copy) (pDstPixmap,
-				    pbox->x1 + dx + src_off_x,
-				    pbox->y1 + dy + src_off_y,
-				    pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-				    pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
-	exaPixmapDirty (pDstPixmap, pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-			pbox->x2  + dst_off_x, pbox->y2 + dst_off_y);
+	(*pExaScr->info->Copy) (pDstPixmap,
+				pbox->x1 + dx + src_off_x,
+				pbox->y1 + dy + src_off_y,
+				pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
+				pbox->x2 - pbox->x1, pbox->y2 - pbox->y1);
 	pbox++;
     }
 
-    if (fallback)
-	return;
-
     (*pExaScr->info->DoneCopy) (pDstPixmap);
     exaMarkSync (pDstDrawable->pScreen);
+
+    return;
+
+fallback:
+    EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
+		  exaDrawableLocation(pSrcDrawable),
+		  exaDrawableLocation(pDstDrawable)));
+    exaPrepareAccessReg (pDstDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
+    exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
+    fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC, pbox, nbox, dx, dy, reverse,
+		upsidedown, bitplane, closure);
+    exaFinishAccess (pSrcDrawable, EXA_PREPARE_SRC);
+    exaFinishAccess (pDstDrawable, EXA_PREPARE_DEST);
 }
 
 RegionPtr
@@ -1204,12 +1198,8 @@ void
 exaPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
 {
     ExaScreenPriv (pWin->drawable.pScreen);
-    PixmapPtr pPixmap = exaGetDrawablePixmap((DrawablePtr)pWin);
-    int xoff, yoff;
-    BoxPtr pBox;
-    int nbox = REGION_NUM_RECTS(pRegion);
 
-    if (!nbox)
+    if (REGION_NIL(pRegion))
 	return;
 
     if (!pExaScr->swappedOut) {
@@ -1230,39 +1220,27 @@ exaPaintWindow(WindowPtr pWin, RegionPtr
             case BackgroundPixel:
 		exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->background.pixel,
 				   FB_ALLONES, GXcopy);
-                goto damage;
+                return;
             case BackgroundPixmap:
                 exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->background.pixmap,
 				   &zeros, FB_ALLONES, GXcopy);
-                goto damage;
+                return;
             }
             break;
         case PW_BORDER:
             if (pWin->borderIsPixel) {
                 exaFillRegionSolid((DrawablePtr)pWin, pRegion, pWin->border.pixel,
 				   FB_ALLONES, GXcopy);
-                goto damage;
+                return;
             } else {
                 exaFillRegionTiled((DrawablePtr)pWin, pRegion, pWin->border.pixmap,
 				   &zeros, FB_ALLONES, GXcopy);
-                goto damage;
+                return;
             }
             break;
         }
     }
     ExaCheckPaintWindow (pWin, pRegion, what);
-
-damage:
-    exaGetDrawableDeltas((DrawablePtr)pWin, pPixmap, &xoff, &yoff);
-
-    pBox = REGION_RECTS(pRegion);
-
-    while (nbox--)
-    {
-	exaPixmapDirty (pPixmap, pBox->x1 + xoff, pBox->y1 + yoff,
-			pBox->x2 + xoff, pBox->y2 + yoff);
-	pBox++;
-    }
 }
 
 /**
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 24d5e3f..970c2cb 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -105,7 +105,6 @@ ExaCheckPutImage (DrawablePtr pDrawable,
     fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
     exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
-    exaPixmapDirty(pPixmap, x + xoff, y + yoff, x + xoff + w, y + yoff + h);
 }
 
 RegionPtr
diff-tree a634c9b03494ba80aeec28be19662ac96657cc23 (from 1f457ff3db24178eefecfbbf177aaf6554adb204)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:48:03 2007 +0200

    EXA: RENDER improvements.
    
    Exclude bits that will be overwritten from migration.
    
    Use exaGlyphs even when Composite can't be accelerated, to avoid PolyFillRect
    roundtrip via offscreen memory.
    
    Initialize mask pixmap in exaGlyphs in FB in addition to system if the driver
    provides Composite hooks to avoid migration overhead.
    
    Remove manual damage tracking where superfluous.

diff --git a/exa/exa.c b/exa/exa.c
index ad8d967..458272d 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -285,15 +285,19 @@ static Bool
 exaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
 		      int bitsPerPixel, int devKind, pointer pPixData)
 {
-    ExaScreenPriv(pPixmap->drawable.pScreen);
-    ExaPixmapPriv(pPixmap);
+    ExaScreenPrivPtr pExaScr;
+    ExaPixmapPrivPtr pExaPixmap;
 
     if (!pPixmap)
         return FALSE;
 
+    pExaPixmap = ExaGetPixmapPriv(pPixmap);
+
     if (pExaPixmap)
 	pExaPixmap->sys_ptr = pPixData;
 
+    pExaScr = ExaGetScreenPriv(pPixmap->drawable.pScreen);
+
     return pExaScr->SavedModifyPixmapHeader(pPixmap, width, height, depth,
 					    bitsPerPixel, devKind, pPixData);
 }
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index db5bd02..a8bdbd6 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -384,6 +384,9 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	     void	    *closure);
 
 /* exa_render.c */
+Bool
+exaOpReadsDestination (CARD8 op);
+
 void
 exaComposite(CARD8	op,
 	     PicturePtr pSrc,
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 3cfa81e..9df795f 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -111,7 +111,7 @@ exaPrintCompositeFallback(CARD8 op,
 }
 #endif /* DEBUG_TRACE_FALL */
 
-static Bool
+Bool
 exaOpReadsDestination (CARD8 op)
 {
     /* FALSE (does not read destination) is the list of ops in the protocol
@@ -261,17 +261,21 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
 				   width, height))
 	return 1;
 
+    pDstPix = exaGetDrawablePixmap (pDst->pDrawable);
+    exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
+
+    REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+
     pSrcPix = exaGetDrawablePixmap (pSrc->pDrawable);
     pixel = exaGetPixmapFirstPixel (pSrcPix);
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pPix = pDstPix;
+    pixmaps[0].pReg = &region;
     exaDoMigration(pixmaps, 1, TRUE);
 
-    pDstPix = exaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
-    if (!pDstPix) {
+    if (!exaPixmapIsOffscreen(pDstPix)) {
 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
 	return 0;
     }
@@ -301,9 +305,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
 
     while (nbox--)
     {
-	(*pExaScr->info->Solid) (pDstPix,
-				 pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
-				 pbox->x2 + dst_off_x, pbox->y2 + dst_off_y);
+	(*pExaScr->info->Solid) (pDstPix, pbox->x1, pbox->y1, pbox->x2, pbox->y2);
 	pbox++;
     }
 
@@ -367,22 +369,26 @@ exaTryDriverComposite(CARD8		op,
     xSrc += pSrc->pDrawable->x;
     ySrc += pSrc->pDrawable->y;
 
-    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
-				   xSrc, ySrc, xMask, yMask, xDst, yDst,
-				   width, height))
-	return 1;
-
     if (pExaScr->info->CheckComposite &&
 	!(*pExaScr->info->CheckComposite) (op, pSrc, pMask, pDst))
     {
-	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
 	return -1;
     }
 
+    if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+				   xSrc, ySrc, xMask, yMask, xDst, yDst,
+				   width, height))
+	return 1;
+
+    pDstPix = exaGetDrawablePixmap (pDst->pDrawable);
+    exaGetDrawableDeltas (pDst->pDrawable, pDstPix, &dst_off_x, &dst_off_y);
+
+    REGION_TRANSLATE(pScreen, &region, dst_off_x, dst_off_y);
+
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = exaOpReadsDestination(op);
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pPix = pDstPix;
+    pixmaps[0].pReg = pixmaps[0].as_src ? NULL : &region;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
     pixmaps[1].pPix = exaGetDrawablePixmap (pSrc->pDrawable);
@@ -401,9 +407,8 @@ exaTryDriverComposite(CARD8		op,
     if (pMask)
 	pMaskPix = exaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x,
 					  &mask_off_y);
-    pDstPix = exaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
 
-    if (!pDstPix) {
+    if (!exaPixmapIsOffscreen(pDstPix)) {
 	REGION_UNINIT(pDst->pDrawable->pScreen, &region);
 	return 0;
     }
@@ -433,21 +438,21 @@ exaTryDriverComposite(CARD8		op,
     nbox = REGION_NUM_RECTS(&region);
     pbox = REGION_RECTS(&region);
 
-    xMask -= xDst;
-    yMask -= yDst;
+    xMask = xMask + mask_off_x - xDst - dst_off_x;
+    yMask = yMask + mask_off_y - yDst - dst_off_y;
 
-    xSrc -= xDst;
-    ySrc -= yDst;
+    xSrc = xSrc + src_off_x - xDst - dst_off_x;
+    ySrc = ySrc + src_off_y - yDst - dst_off_y;
 
     while (nbox--)
     {
 	(*pExaScr->info->Composite) (pDstPix,
-				     pbox->x1 + xSrc + src_off_x,
-				     pbox->y1 + ySrc + src_off_y,
-				     pbox->x1 + xMask + mask_off_x,
-				     pbox->y1 + yMask + mask_off_y,
-				     pbox->x1 + dst_off_x,
-				     pbox->y1 + dst_off_y,
+				     pbox->x1 + xSrc,
+				     pbox->y1 + ySrc,
+				     pbox->x1 + xMask,
+				     pbox->y1 + yMask,
+				     pbox->x1,
+				     pbox->y1,
 				     pbox->x2 - pbox->x1,
 				     pbox->y2 - pbox->y1);
 	pbox++;
@@ -523,9 +528,6 @@ exaTryMagicTwoPassCompositeHelper(CARD8 
 				  CARD16 height)
 {
     ExaScreenPriv (pDst->pDrawable->pScreen);
-    DrawablePtr pDstDraw = pDst->pDrawable;
-    PixmapPtr pDstPixmap = exaGetDrawablePixmap(pDstDraw);
-    int xoff, yoff;
 
     assert(op == PictOpOver);
 
@@ -544,12 +546,6 @@ exaTryMagicTwoPassCompositeHelper(CARD8 
     exaComposite(PictOpOutReverse, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
 		 xDst, yDst, width, height);
 
-    exaGetDrawableDeltas(pDstDraw, pDstPixmap, &xoff, &yoff);
-    xoff += pDstDraw->x;
-    yoff += pDstDraw->y;
-    exaPixmapDirty(pDstPixmap, xDst + xoff, yDst + yoff, xDst + xoff + width,
-		   yDst + yoff + height);
-
     /* Then, add in the source value times the destination alpha factors (1.0).
      */
     exaComposite(PictOpAdd, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
@@ -576,31 +572,8 @@ exaComposite(CARD8	op,
     int ret = -1;
     Bool saveSrcRepeat = pSrc->repeat;
     Bool saveMaskRepeat = pMask ? pMask->repeat : 0;
-    ExaMigrationRec pixmaps[3];
-    int npixmaps = 1;
     PixmapPtr pSrcPixmap = NULL;
-
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = exaOpReadsDestination(op);
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
-    pixmaps[0].pReg = NULL;
-
-    if (pSrc->pDrawable) {
-	pSrcPixmap = exaGetDrawablePixmap (pSrc->pDrawable);
-	pixmaps[npixmaps].as_dst = FALSE;
-	pixmaps[npixmaps].as_src = TRUE;
-	pixmaps[npixmaps].pPix = pSrcPixmap;
-	pixmaps[npixmaps].pReg = NULL;
-	npixmaps++;
-    }
-
-    if (pMask && pMask->pDrawable) {
-	pixmaps[npixmaps].as_dst = FALSE;
-	pixmaps[npixmaps].as_src = TRUE;
-	pixmaps[npixmaps].pPix = exaGetDrawablePixmap (pMask->pDrawable);
-	pixmaps[npixmaps].pReg = NULL;
-	npixmaps++;
-    }
+    RegionRec region;
 
     /* We currently don't support acceleration of gradients, or other pictures
      * with a NULL pDrawable.
@@ -638,8 +611,6 @@ exaComposite(CARD8	op,
 	    }
 	    else if (pSrcPixmap && !pSrc->repeat && !pSrc->transform)
 	    {
-		RegionRec	region;
-
 		xDst += pDst->pDrawable->x;
 		yDst += pDst->pDrawable->y;
 		xSrc += pSrc->pDrawable->x;
@@ -661,7 +632,6 @@ exaComposite(CARD8	op,
 	    else if (pSrcPixmap && !pSrc->transform &&
 		     pSrc->repeatType == RepeatNormal)
 	    {
-		RegionRec region;
 		DDXPointRec srcOrg;
 
 		/* Let's see if the driver can do the repeat in one go */
@@ -1092,6 +1062,9 @@ exaGlyphsIntersect(int nlist, GlyphListP
  * issue is that miGlyphs' use of ModifyPixmapHeader makes it impossible to
  * migrate these pixmaps.  So, instead we create a pixmap at the beginning of
  * the loop and upload each glyph into the pixmap before compositing.
+ *
+ * This is now used even when Composite can't be accelerated for better
+ * migration control.
  */
 void
 exaGlyphs (CARD8	op,
@@ -1108,11 +1081,10 @@ exaGlyphs (CARD8	op,
     PixmapPtr	pPixmap = NULL;
     PicturePtr	pPicture;
     PixmapPtr   pMaskPixmap = NULL;
-    PixmapPtr   pDstPixmap = exaGetDrawablePixmap(pDst->pDrawable);
     PicturePtr  pMask;
     ScreenPtr   pScreen = pDst->pDrawable->pScreen;
     int		width = 0, height = 0;
-    int		x, y, x1, y1, xoff, yoff;
+    int		x, y, x1, y1;
     int		xDst = list->xOff, yDst = list->yOff;
     int		n;
     int		error;
@@ -1140,16 +1112,6 @@ exaGlyphs (CARD8	op,
 	}
     }
 
-    /* If the driver doesn't support accelerated composite, there's no point in
-     * going to this extra work.  Assume that any driver that supports Composite
-     * will be able to support component alpha using the two-pass helper.
-     */
-    if (!pExaScr->info->PrepareComposite)
-    {
-	miGlyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs);
-	return;
-    }
-
     if (maskFormat)
     {
 	GCPtr	    pGC;
@@ -1186,8 +1148,11 @@ exaGlyphs (CARD8	op,
 	rect.y = 0;
 	rect.width = width;
 	rect.height = height;
-	(*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
-	exaPixmapDirty(pMaskPixmap, 0, 0, width, height);
+	ExaCheckPolyFillRect (&pMaskPixmap->drawable, pGC, 1, &rect);
+	if (pExaScr->info->PrepareComposite)
+	    (*pGC->ops->PolyFillRect) (&pMaskPixmap->drawable, pGC, 1, &rect);
+	else
+	    exaPixmapDirty(pMaskPixmap, 0, 0, width, height);
 	FreeScratchGC (pGC);
 	x = -extents.x1;
 	y = -extents.y1;
@@ -1199,8 +1164,6 @@ exaGlyphs (CARD8	op,
 	y = 0;
     }
 
-    exaGetDrawableDeltas(pDst->pDrawable, pDstPixmap, &xoff, &yoff);
-
     while (nlist--)
     {
 	GCPtr pGC = NULL;
@@ -1339,10 +1302,6 @@ exaGlyphs (CARD8	op,
 			      xSrc + x1 - xDst, ySrc + y1 - yDst,
 			      0, 0, x1, y1, glyph->info.width,
 			      glyph->info.height);
-		x1 += pDst->pDrawable->x + xoff;
-		y1 += pDst->pDrawable->y + yoff;
-		exaPixmapDirty(pDstPixmap, x1, y1, x1 + glyph->info.width,
-			       y1 + glyph->info.height);
 	    }
 nextglyph:
 	    x += glyph->info.xOff;
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index fbc48dd..24d5e3f 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -23,6 +23,10 @@
 
 #include "exa_priv.h"
 
+#ifdef RENDER
+#include "mipict.h"
+#endif
+
 /*
  * These functions wrap the low-level fb rendering functions and
  * synchronize framebuffer/accelerated drawing by stalling until
@@ -319,9 +323,30 @@ ExaCheckComposite (CARD8      op,
                    CARD16     width,
                    CARD16     height)
 {
+    RegionRec region;
+    int xoff, yoff;
+
+    REGION_NULL(pScreen, &region);
+
+    if (!exaOpReadsDestination(op)) {
+	if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+				       xSrc, ySrc, xMask, yMask, xDst, yDst,
+				       width, height))
+	    return;
+
+	exaGetDrawableDeltas (pDst->pDrawable,
+			      exaGetDrawablePixmap(pDst->pDrawable),
+			      &xoff, &yoff);
+
+	REGION_TRANSLATE(pScreen, &region, xoff, yoff);
+
+	exaPrepareAccessReg (pDst->pDrawable, EXA_PREPARE_DEST, &region);
+    } else
+	exaPrepareAccess (pDst->pDrawable, EXA_PREPARE_DEST);
+
     EXA_FALLBACK(("from picts %p/%p to pict %p\n",
 		 pSrc, pMask, pDst));
-    exaPrepareAccess (pDst->pDrawable, EXA_PREPARE_DEST);
+
     if (pSrc->pDrawable != NULL)
 	exaPrepareAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
     if (pMask && pMask->pDrawable != NULL)
@@ -343,6 +368,8 @@ ExaCheckComposite (CARD8      op,
     if (pSrc->pDrawable != NULL)
 	exaFinishAccess (pSrc->pDrawable, EXA_PREPARE_SRC);
     exaFinishAccess (pDst->pDrawable, EXA_PREPARE_DEST);
+
+    REGION_UNINIT(pScreen, &region);
 }
 
 /**
diff-tree 1f457ff3db24178eefecfbbf177aaf6554adb204 (from 489bc7551ffc7360ba9648ca5c98b59c7e7a1fd1)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:44:20 2007 +0200

    EXA: Improvements for 1x1 pixmaps.
    
    Initialize system and FB copy in exaFillRegionSolid and adapt
    exaGetPixmapFirstPixel to the new migration infrastructure.
    
    This should mostly eliminate migration overhead for these, whether they are
    used for acceleration or fallbacks.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e9ca472..4cae198 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -1012,8 +1012,6 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     PixmapPtr pPixmap;
     int xoff, yoff;
     ExaMigrationRec pixmaps[1];
-    int nbox = REGION_NUM_RECTS (pRegion);
-    BoxPtr pBox = REGION_RECTS (pRegion);
 
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
@@ -1031,15 +1029,43 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     if ((pPixmap = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&
 	(*pExaScr->info->PrepareSolid) (pPixmap, alu, planemask, pixel))
     {
+	int nbox;
+	BoxPtr pBox;
+
+	REGION_TRANSLATE(pScreen, pRegion, xoff, yoff);
+
+	nbox = REGION_NUM_RECTS (pRegion);
+	pBox = REGION_RECTS (pRegion);
+
 	while (nbox--)
 	{
-	    (*pExaScr->info->Solid) (pPixmap,
-				     pBox->x1 + xoff, pBox->y1 + yoff,
-				     pBox->x2 + xoff, pBox->y2 + yoff);
+	    (*pExaScr->info->Solid) (pPixmap, pBox->x1, pBox->y1, pBox->x2,
+				     pBox->y2);
 	    pBox++;
 	}
 	(*pExaScr->info->DoneSolid) (pPixmap);
 	exaMarkSync(pDrawable->pScreen);
+
+	if (pDrawable->width == 1 && pDrawable->height == 1 &&
+	    pDrawable->bitsPerPixel != 24) {
+	    ExaPixmapPriv(pPixmap);
+
+	    switch (pDrawable->bitsPerPixel) {
+	    case 32:
+		*(CARD32*)pExaPixmap->sys_ptr = pixel;
+		break;
+	    case 16:
+		*(CARD16*)pExaPixmap->sys_ptr = pixel;
+		break;
+	    case 8:
+		*(CARD8*)pExaPixmap->sys_ptr = pixel;
+	    }
+
+	    REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+			 pRegion);
+	}
+
+	REGION_TRANSLATE(pScreen, pRegion, -xoff, -yoff);
     }
     else
     {
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 8dadd06..fbc48dd 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -358,16 +358,28 @@ exaGetPixmapFirstPixel (PixmapPtr pPixma
     void *fb;
     Bool need_finish = FALSE;
     BoxRec box;
+    RegionRec migration;
     ExaPixmapPriv (pPixmap);
+    Bool sys_valid = !miPointInRegion(&pExaPixmap->validSys, 0, 0,  &box);
+    Bool damaged = miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0,
+				   &box);
+    Bool offscreen = exaPixmapIsOffscreen(pPixmap);
 
     fb = pExaPixmap->sys_ptr;
 
     /* Try to avoid framebuffer readbacks */
-    if (exaPixmapIsOffscreen(pPixmap) &&
-        miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0,  &box))
+    if ((!offscreen && !sys_valid && !damaged) ||
+	(offscreen && (!sys_valid || damaged)))
     {
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = 1;
+	box.y2 = 1;
+	REGION_INIT(pScreen, &migration, &box, 1);
+
 	need_finish = TRUE;
-	exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+
+	exaPrepareAccessReg(&pPixmap->drawable, EXA_PREPARE_SRC, &migration);
 	fb = pPixmap->devPrivate.ptr;
     }
 
@@ -383,8 +395,10 @@ exaGetPixmapFirstPixel (PixmapPtr pPixma
 	break;
     }
 
-    if (need_finish)
+    if (need_finish) {
 	exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+	REGION_UNINIT(pScreen, &migration);
+    }
 
     return pixel;
 }
diff-tree 489bc7551ffc7360ba9648ca5c98b59c7e7a1fd1 (from 2e0895a4ba27c1308713022820444c8f57f7a69f)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:37:53 2007 +0200

    EXA: exaImageGlyphBlt improvements.
    
    As we can't actually accelerate anything interesting here, just migrate out
    once and call fbSolidBoxClipped instead of taking a round trip via offscreen
    memory with exaSolidBoxClipped.
    
    Reuse pending damage region for extents and to prevent any actual migration of
    pixmap contents when we're overwriting the whole pending damage region.
    
    Remove superfluous manual damage tracking.

diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 1fd299e..e9ca472 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -816,97 +816,6 @@ out:
 }
 
 static void
-exaSolidBoxClipped (DrawablePtr	pDrawable,
-		    RegionPtr	pClip,
-		    FbBits	pm,
-		    FbBits	fg,
-		    int		x1,
-		    int		y1,
-		    int		x2,
-		    int		y2)
-{
-    ExaScreenPriv (pDrawable->pScreen);
-    PixmapPtr   pPixmap;
-    BoxPtr	pbox;
-    int		nbox;
-    int		xoff, yoff;
-    int		partX1, partX2, partY1, partY2;
-    ExaMigrationRec pixmaps[1];
-    Bool	fallback = FALSE;
-
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = FALSE;
-    pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
-    pixmaps[0].pReg = NULL;
-
-    if (pExaScr->swappedOut ||
-	pPixmap->drawable.width > pExaScr->info->maxX ||
-	pPixmap->drawable.height > pExaScr->info->maxY)
-    {
-	fallback = TRUE;
-    } else {
-	exaDoMigration (pixmaps, 1, TRUE);
-    }
-
-    exaGetDrawableDeltas (pDrawable, pPixmap, &xoff, &yoff);
-
-    if (fallback || !exaPixmapIsOffscreen(pPixmap) ||
-	!(*pExaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
-    {
-	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
-		      exaDrawableLocation(pDrawable)));
-	fallback = TRUE;
-	exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
-	fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
-	fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,
-			   fbAnd (GXcopy, fg, pm),
-			   fbXor (GXcopy, fg, pm));
-	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-    }
-    for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
-	 nbox--;
-	 pbox++)
-    {
-	partX1 = pbox->x1;
-	if (partX1 < x1)
-	    partX1 = x1;
-
-	partX2 = pbox->x2;
-	if (partX2 > x2)
-	    partX2 = x2;
-
-	if (partX2 <= partX1)
-	    continue;
-
-	partY1 = pbox->y1;
-	if (partY1 < y1)
-	    partY1 = y1;
-
-	partY2 = pbox->y2;
-	if (partY2 > y2)
-	    partY2 = y2;
-
-	if (partY2 <= partY1)
-	    continue;
-
-	if (!fallback) {
-	    (*pExaScr->info->Solid) (pPixmap,
-				     partX1 + xoff, partY1 + yoff,
-				     partX2 + xoff, partY2 + yoff);
-	}
-
-	exaPixmapDirty (pPixmap, partX1 + xoff, partY1 + yoff, partX2 + xoff,
-			partY2 + yoff);
-    }
-
-    if (fallback)
-	return;
-
-    (*pExaScr->info->DoneSolid) (pPixmap);
-    exaMarkSync(pDrawable->pScreen);
-}
-
-static void
 exaImageGlyphBlt (DrawablePtr	pDrawable,
 		  GCPtr		pGC,
 		  int		x,
@@ -922,7 +831,6 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     int		    gWidth, gHeight;	/* width and height of glyph */
     FbStride	    gStride;		/* stride of glyph */
     Bool	    opaque;
-    int		    n;
     int		    gx, gy;
     void	    (*glyph) (FbBits *,
 			      FbStride,
@@ -936,37 +844,33 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     int		    dstBpp;
     int		    dstXoff, dstYoff;
     FbBits	    depthMask;
+    Bool	    fallback;
     PixmapPtr	    pPixmap = exaGetDrawablePixmap(pDrawable);
+    ExaPixmapPriv(pPixmap);
     ExaMigrationRec pixmaps[1];
-    int		    xBack, widthBack, yBack, heightBack;
-
-    for (ppci = ppciInit, n = nglyph, widthBack = 0; n; n--)
-	widthBack += (*ppci++)->metrics.characterWidth;
-
-    xBack = x;
-    if (widthBack < 0)
-    {
-	xBack += widthBack;
-	widthBack = -widthBack;
-    }
-    yBack = y - FONTASCENT(pGC->font);
-    heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+    RegionPtr	    pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+    BoxRec	    extents = *REGION_EXTENTS(pScreen, pending_damage);
+    int		    xoff, yoff;
 
-    if (xBack >= pDrawable->width || yBack >= pDrawable->height ||
-	(xBack + widthBack) <= 0 || (yBack + heightBack) <= 0)
+    if (extents.x1 >= extents.x2 || extents.y1 >= extents.y2)
 	return;
 
+    depthMask = FbFullMask(pDrawable->depth);
+    fallback = (pGC->planemask & depthMask) != depthMask;
+
     pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = TRUE;
+    pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap;
-    pixmaps[0].pReg = NULL;
+    pixmaps[0].pReg = fallback ? NULL : pending_damage;
 
-    depthMask = FbFullMask(pDrawable->depth);
-    if ((pGC->planemask & depthMask) != depthMask)
+    exaDoMigration(pixmaps, 1, FALSE);
+
+    if (fallback)
     {
 	ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
-	goto damage;
+	return;
     }
+
     glyph = NULL;
     switch (pDrawable->bitsPerPixel) {
     case 8:	glyph = fbGlyph8; break;
@@ -977,8 +881,14 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
 
     x += pDrawable->x;
     y += pDrawable->y;
-    xBack += pDrawable->x;
-    yBack += pDrawable->y;
+
+    exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
+    extents.x1 -= xoff;
+    extents.x2 -= xoff;
+    extents.y1 -= yoff;
+    extents.y2 -= yoff;
+
+    exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
 
     if (TERMINALFONT (pGC->font) && !glyph)
     {
@@ -986,19 +896,22 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
     else
     {
-        exaSolidBoxClipped (pDrawable,
-			    fbGetCompositeClip(pGC),
-			    pGC->planemask,
-			    pGC->bgPixel,
-			    xBack,
-			    yBack,
-			    xBack + widthBack,
-			    yBack + heightBack);
+	FbBits fg = fbReplicatePixel (pGC->bgPixel, pDrawable->bitsPerPixel);
+
+	fbSolidBoxClipped (pDrawable,
+			   fbGetCompositeClip(pGC),
+			   extents.x1,
+			   extents.y1,
+			   extents.x2,
+			   extents.y2,
+			   fbAnd (GXcopy, fg, pGC->planemask),
+			   fbXor (GXcopy, fg, pGC->planemask));
+
 	opaque = FALSE;
     }
 
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
-    exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
+
     exaPrepareAccessGC (pGC);
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
@@ -1011,9 +924,9 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
 	gx = x + pci->metrics.leftSideBearing;
 	gy = y - pci->metrics.ascent;
 
-	if (!gWidth || !gHeight || (gx + gWidth) <= xBack ||
-	    (gy + gHeight) <= yBack || gx >= (xBack + widthBack) ||
-	    gy >= (yBack + heightBack))
+	if (!gWidth || !gHeight || (gx + gWidth) <= extents.x1 ||
+	    (gy + gHeight) <= extents.y1 || gx >= extents.x2 ||
+	    gy >= extents.y2)
 	    continue;
 
 	pglyph = FONTGLYPHBITS(pglyphBase, pci);
@@ -1036,11 +949,6 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
     exaFinishAccessGC (pGC);
     exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
-
-damage:
-    exaGetDrawableDeltas(pDrawable, pPixmap, &dstXoff, &dstYoff);
-    exaPixmapDirty(pPixmap, xBack + dstXoff, yBack + dstYoff,
-		   xBack + dstXoff + widthBack, yBack + dstYoff + heightBack);
 }
 
 const GCOps exaOps = {
diff-tree 2e0895a4ba27c1308713022820444c8f57f7a69f (from 6c9d7ed61bc4a19d21c53717b8af3d90b5d82ca9)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Aug 30 13:30:03 2007 +0200

    EXA: Improvements for trapezoids and triangles.
    
    Only migrate once in exaTrapezoids/Triangles instead of every time in
    exaRasterizeTrapezoid/AddTriangles. Adapt manual damage tracking to new
    infrastructure.
    
    Also move definition of NeedsComponent() closer to where it's used.

diff --git a/exa/exa.c b/exa/exa.c
index 5a85037..ad8d967 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -766,11 +766,8 @@ exaDriverInit (ScreenPtr		pScreen,
         pExaScr->SavedComposite = ps->Composite;
 	ps->Composite = exaComposite;
 
-	pExaScr->SavedRasterizeTrapezoid = ps->RasterizeTrapezoid;
-	ps->RasterizeTrapezoid = exaRasterizeTrapezoid;
-
-	pExaScr->SavedAddTriangles = ps->AddTriangles;
-	ps->AddTriangles = exaAddTriangles;
+	pExaScr->SavedTriangles = ps->Triangles;
+	ps->Triangles = exaTriangles;
 
 	pExaScr->SavedGlyphs = ps->Glyphs;
 	ps->Glyphs = exaGlyphs;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index da5e459..db5bd02 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -111,8 +111,7 @@ typedef struct {
     ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
 #ifdef RENDER
     CompositeProcPtr             SavedComposite;
-    RasterizeTrapezoidProcPtr	 SavedRasterizeTrapezoid;
-    AddTrianglesProcPtr		 SavedAddTriangles;
+    TrianglesProcPtr		 SavedTriangles;
     GlyphsProcPtr                SavedGlyphs;
     TrapezoidsProcPtr            SavedTrapezoids;
 #endif
@@ -405,12 +404,9 @@ exaTrapezoids (CARD8 op, PicturePtr pSrc
                int ntrap, xTrapezoid *traps);
 
 void
-exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid  *trap,
-		       int x_off, int y_off);
-
-void
-exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
-		 xTriangle *tris);
+exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+	      PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+	      int ntri, xTriangle *tris);
 
 void
 exaGlyphs (CARD8	op,
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 067f88b..3cfa81e 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -760,7 +760,7 @@ done:
  * of PolyFillRect to initialize the pixmap after creating it, to prevent
  * the pixmap from being migrated.
  *
- * See the comments about exaTrapezoids.
+ * See the comments about exaTrapezoids and exaTriangles.
  */
 static PicturePtr
 exaCreateAlphaPicture (ScreenPtr     pScreen,
@@ -832,36 +832,70 @@ exaTrapezoids (CARD8 op, PicturePtr pSrc
 {
     ScreenPtr		pScreen = pDst->pDrawable->pScreen;
     PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    BoxRec		bounds;
+    Bool		direct = op == PictOpAdd && miIsSolidAlpha (pSrc);
+
+    if (maskFormat || direct) {
+	miTrapezoidBounds (ntrap, traps, &bounds);
+
+	if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+	    return;
+    }
 
     /*
      * Check for solid alpha add
      */
-    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    if (direct)
     {
+	DrawablePtr pDraw = pDst->pDrawable;
+	PixmapPtr pixmap = exaGetDrawablePixmap (pDraw);
+	ExaPixmapPriv (pixmap);
+	RegionRec migration;
+	RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+	int xoff, yoff;
+
+	exaGetDrawableDeltas(pDraw, pixmap, &xoff, &yoff);
+
+	xoff += pDraw->x;
+	yoff += pDraw->y;
+
+	bounds.x1 += xoff;
+	bounds.y1 += yoff;
+	bounds.x2 += xoff;
+	bounds.y2 += yoff;
+
+	REGION_INIT(pScreen, &migration, &bounds, 1);
+	REGION_UNION(pScreen, pending_damage, pending_damage, &migration);
+	REGION_UNINIT(pScreen, &migration);
+
+	exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
+
 	for (; ntrap; ntrap--, traps++)
 	    (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
+
+	exaFinishAccess(pDraw, EXA_PREPARE_DEST);
     }
     else if (maskFormat)
     {
 	PicturePtr	pPicture;
-	BoxRec		bounds;
 	INT16		xDst, yDst;
 	INT16		xRel, yRel;
 
 	xDst = traps[0].left.p1.x >> 16;
 	yDst = traps[0].left.p1.y >> 16;
 
-	miTrapezoidBounds (ntrap, traps, &bounds);
-	if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
-	    return;
 	pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat,
 	                                  bounds.x2 - bounds.x1,
 	                                  bounds.y2 - bounds.y1);
 	if (!pPicture)
 	    return;
+
+	exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
 	for (; ntrap; ntrap--, traps++)
 	    (*ps->RasterizeTrapezoid) (pPicture, traps,
 				       -bounds.x1, -bounds.y1);
+	exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+
 	xRel = bounds.x1 + xSrc - xDst;
 	yRel = bounds.y1 + ySrc - yDst;
 	CompositePicture (op, pSrc, pPicture, pDst,
@@ -881,51 +915,102 @@ exaTrapezoids (CARD8 op, PicturePtr pSrc
     }
 }
 
-#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
-
 /**
- * exaRasterizeTrapezoid is just a wrapper around the software implementation.
+ * exaTriangles is essentially a copy of miTriangles that uses
+ * exaCreateAlphaPicture instead of miCreateAlphaPicture.
  *
- * The trapezoid specification is basically too hard to be done in hardware (at
- * the very least, without programmability), so we just do the appropriate
- * Prepare/FinishAccess for it before using fbtrap.c.
+ * The problem with miCreateAlphaPicture is that it calls PolyFillRect
+ * to initialize the contents after creating the pixmap, which
+ * causes the pixmap to be moved in for acceleration. The subsequent
+ * call to AddTriangles won't be accelerated however, which forces the pixmap
+ * to be moved out again.
+ *
+ * exaCreateAlphaPicture avoids this roundtrip by using ExaCheckPolyFillRect
+ * to initialize the contents.
  */
 void
-exaRasterizeTrapezoid (PicturePtr pPicture, xTrapezoid  *trap,
-		       int x_off, int y_off)
+exaTriangles (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
+	      PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
+	      int ntri, xTriangle *tris)
 {
-    DrawablePtr pDraw = pPicture->pDrawable;
-    PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
-    int xoff, yoff;
-
-    exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
-    fbRasterizeTrapezoid(pPicture, trap, x_off, y_off);
-    exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
-    exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
-		   pDraw->x + xoff + pDraw->width,
-		   pDraw->y + yoff + pDraw->height);
-    exaFinishAccess(pDraw, EXA_PREPARE_DEST);
-}
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    BoxRec		bounds;
+    Bool		direct = op == PictOpAdd && miIsSolidAlpha (pSrc);
 
-/**
- * exaAddTriangles does migration and syncing before dumping down to the
- * software implementation.
- */
-void
-exaAddTriangles (PicturePtr pPicture, INT16 x_off, INT16 y_off, int ntri,
-		 xTriangle *tris)
-{
-    DrawablePtr pDraw = pPicture->pDrawable;
-    PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
-    int xoff, yoff;
-
-    exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
-    fbAddTriangles(pPicture, x_off, y_off, ntri, tris);
-    exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
-    exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
-		   pDraw->x + xoff + pDraw->width,
-		   pDraw->y + yoff + pDraw->height);
-    exaFinishAccess(pDraw, EXA_PREPARE_DEST);
+    if (maskFormat || direct) {
+	miTriangleBounds (ntri, tris, &bounds);
+
+	if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+	    return;
+    }
+
+    /*
+     * Check for solid alpha add
+     */
+    if (direct)
+    {
+	DrawablePtr pDraw = pDst->pDrawable;
+	PixmapPtr pixmap = exaGetDrawablePixmap (pDraw);
+	ExaPixmapPriv (pixmap);
+	RegionRec migration;
+	RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+	int xoff, yoff;
+
+	exaGetDrawableDeltas(pDraw, pixmap, &xoff, &yoff);
+
+	xoff += pDraw->x;
+	yoff += pDraw->y;
+
+	bounds.x1 += xoff;
+	bounds.y1 += yoff;
+	bounds.x2 += xoff;
+	bounds.y2 += yoff;
+
+	REGION_INIT(pScreen, &migration, &bounds, 1);
+	REGION_UNION(pScreen, pending_damage, pending_damage, &migration);
+	REGION_UNINIT(pScreen, &migration);
+
+	exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
+	(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
+	exaFinishAccess(pDraw, EXA_PREPARE_DEST);
+    }
+    else if (maskFormat)
+    {
+	PicturePtr	pPicture;
+	INT16		xDst, yDst;
+	INT16		xRel, yRel;
+	
+	xDst = tris[0].p1.x >> 16;
+	yDst = tris[0].p1.y >> 16;
+
+	pPicture = exaCreateAlphaPicture (pScreen, pDst, maskFormat,
+					  bounds.x2 - bounds.x1,
+					  bounds.y2 - bounds.y1);
+	if (!pPicture)
+	    return;
+
+	exaPrepareAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+	(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+	exaFinishAccess(pPicture->pDrawable, EXA_PREPARE_DEST);
+	
+	xRel = bounds.x1 + xSrc - xDst;
+	yRel = bounds.y1 + ySrc - yDst;
+	CompositePicture (op, pSrc, pPicture, pDst,
+			  xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			  bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	FreePicture (pPicture, 0);
+    }
+    else
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	
+	for (; ntri; ntri--, tris++)
+	    exaTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+    }
 }
 
 /**
@@ -1001,6 +1086,8 @@ exaGlyphsIntersect(int nlist, GlyphListP
     return FALSE;
 }
 
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+
 /* exaGlyphs is a slight variation on miGlyphs, to support acceleration.  The
  * issue is that miGlyphs' use of ModifyPixmapHeader makes it impossible to
  * migrate these pixmaps.  So, instead we create a pixmap at the beginning of
diff-tree 6c9d7ed61bc4a19d21c53717b8af3d90b5d82ca9 (from 962eddd7a2863a8475f5fd8107d3112df08d1172)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Thu Sep 6 13:10:16 2007 +0200

    EXA: Hide pixmap pointer outside of exaPrepare/FinishAccess whenever possible.
    
    We finally want to catch all cases where the pixmap pointer is dereferenced
    outside of exaPrepare/FinishAccess.
    
    Also fix a couple of such cases exposed by this change.

diff --git a/exa/exa.c b/exa/exa.c
index 145d5b2..5a85037 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -44,6 +44,17 @@ static int exaGeneration;
 int exaScreenPrivateIndex;
 int exaPixmapPrivateIndex;
 
+static _X_INLINE void*
+ExaGetPixmapAddress(PixmapPtr p)
+{
+    ExaPixmapPriv(p);
+
+    if (pExaPixmap->offscreen && pExaPixmap->fb_ptr)
+	return pExaPixmap->fb_ptr;
+    else
+	return pExaPixmap->sys_ptr;
+}
+
 /**
  * exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of
  * the beginning of the given pixmap.
@@ -58,16 +69,9 @@ unsigned long
 exaGetPixmapOffset(PixmapPtr pPix)
 {
     ExaScreenPriv (pPix->drawable.pScreen);
-    ExaPixmapPriv (pPix);
-    void *ptr;
 
-    /* Return the offscreen pointer if we've hidden the data. */
-    if (pPix->devPrivate.ptr == NULL)
-	ptr = pExaPixmap->fb_ptr;
-    else
-	ptr = pPix->devPrivate.ptr;
-
-    return ((unsigned long)ptr - (unsigned long)pExaScr->info->memoryBase);
+    return ((unsigned long)ExaGetPixmapAddress(pPix) -
+	    (unsigned long)pExaScr->info->memoryBase);
 }
 
 /**
@@ -241,6 +245,9 @@ exaCreatePixmap(ScreenPtr pScreen, int w
     pExaPixmap->sys_ptr = pPixmap->devPrivate.ptr;
     pExaPixmap->sys_pitch = pPixmap->devKind;
 
+    pPixmap->devPrivate.ptr = NULL;
+    pExaPixmap->offscreen = FALSE;
+
     pExaPixmap->fb_ptr = NULL;
     if (pExaScr->info->flags & EXA_OFFSCREEN_ALIGN_POT && w != 1)
 	pExaPixmap->fb_pitch = (1 << (exaLog2(w - 1) + 1)) * bpp / 8;
@@ -274,6 +281,23 @@ exaCreatePixmap(ScreenPtr pScreen, int w
     return pPixmap;
 }
 
+static Bool
+exaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth,
+		      int bitsPerPixel, int devKind, pointer pPixData)
+{
+    ExaScreenPriv(pPixmap->drawable.pScreen);
+    ExaPixmapPriv(pPixmap);
+
+    if (!pPixmap)
+        return FALSE;
+
+    if (pExaPixmap)
+	pExaPixmap->sys_ptr = pPixData;
+
+    return pExaScr->SavedModifyPixmapHeader(pPixmap, width, height, depth,
+					    bitsPerPixel, devKind, pPixData);
+}
+
 /**
  * exaPixmapIsOffscreen() is used to determine if a pixmap is in offscreen
  * memory, meaning that acceleration could probably be done to it, and that it
@@ -291,18 +315,25 @@ exaPixmapIsOffscreen(PixmapPtr p)
 {
     ScreenPtr	pScreen = p->drawable.pScreen;
     ExaScreenPriv(pScreen);
+    ExaPixmapPriv(p);
+    void *save_ptr;
+    Bool ret;
 
-    /* If the devPrivate.ptr is NULL, it's offscreen but we've hidden the data.
-     */
-    if (p->devPrivate.ptr == NULL)
-	return TRUE;
+    save_ptr = p->devPrivate.ptr;
+
+    if (!save_ptr && pExaPixmap)
+	p->devPrivate.ptr = ExaGetPixmapAddress(p);
 
     if (pExaScr->info->PixmapIsOffscreen)
-	return pExaScr->info->PixmapIsOffscreen(p);
+	ret = pExaScr->info->PixmapIsOffscreen(p);
+    else
+       ret = ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
+			       (CARD8 *) pExaScr->info->memoryBase) <
+	      pExaScr->info->memorySize);
+
+    p->devPrivate.ptr = save_ptr;
 
-    return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
-			     (CARD8 *) pExaScr->info->memoryBase) <
-	    pExaScr->info->memorySize);
+    return ret;
 }
 
 /**
@@ -336,22 +367,19 @@ ExaDoPrepareAccess(DrawablePtr pDrawable
 {
     ScreenPtr	    pScreen = pDrawable->pScreen;
     ExaScreenPriv  (pScreen);
-    PixmapPtr	    pPixmap;
-
-    pPixmap = exaGetDrawablePixmap (pDrawable);
-
-    if (exaPixmapIsOffscreen (pPixmap))
-	exaWaitSync (pDrawable->pScreen);
-    else
-	return;
+    PixmapPtr	    pPixmap = exaGetDrawablePixmap (pDrawable);
+    Bool	    offscreen = exaPixmapIsOffscreen(pPixmap);
 
     /* Unhide pixmap pointer */
     if (pPixmap->devPrivate.ptr == NULL) {
-	ExaPixmapPriv (pPixmap);
-
-	pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+	pPixmap->devPrivate.ptr = ExaGetPixmapAddress(pPixmap);
     }
 
+    if (!offscreen)
+	return;
+
+    exaWaitSync (pDrawable->pScreen);
+
     if (pExaScr->info->PrepareAccess == NULL)
 	return;
 
@@ -400,18 +428,13 @@ exaFinishAccess(DrawablePtr pDrawable, i
 {
     ScreenPtr	    pScreen = pDrawable->pScreen;
     ExaScreenPriv  (pScreen);
-    PixmapPtr	    pPixmap;
-    ExaPixmapPrivPtr pExaPixmap;
-
-    pPixmap = exaGetDrawablePixmap (pDrawable);
-
-    pExaPixmap = ExaGetPixmapPriv(pPixmap);
+    PixmapPtr	    pPixmap = exaGetDrawablePixmap (pDrawable);
+    ExaPixmapPriv  (pPixmap);
 
     /* Rehide pixmap pointer if we're doing that. */
-    if (pExaPixmap != NULL && pExaScr->hideOffscreenPixmapData &&
-	pExaPixmap->fb_ptr == pPixmap->devPrivate.ptr)
+    if (pExaPixmap)
     {
-	pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+	pPixmap->devPrivate.ptr = NULL;
     }
 
     if (pExaScr->info->FinishAccess == NULL)
@@ -783,6 +806,8 @@ exaDriverInit (ScreenPtr		pScreen,
         pExaScr->SavedDestroyPixmap = pScreen->DestroyPixmap;
 	pScreen->DestroyPixmap = exaDestroyPixmap;
 
+	pExaScr->SavedModifyPixmapHeader = pScreen->ModifyPixmapHeader;
+	pScreen->ModifyPixmapHeader = exaModifyPixmapHeader;
 	LogMessage(X_INFO, "EXA(%d): Offscreen pixmap area of %d bytes\n",
 		   pScreen->myNum,
 		   pExaScr->info->memorySize - pExaScr->info->offScreenBase);
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index ceb6c7b..1fd299e 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -213,8 +213,7 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 	    int	dstXoff, dstYoff;
 
 	    if (!access_prepared) {
-		exaPrepareAccessReg(pDrawable, EXA_PREPARE_DEST,
-				    pixmaps[0].pReg);
+		ExaDoPrepareAccess(pDrawable, EXA_PREPARE_DEST);
 
 		access_prepared = TRUE;
 	    }
@@ -233,14 +232,14 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 		      GXcopy, FB_ALLONES, dstBpp);
 	}
 
-	if (access_prepared)
-	    exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
-	else
-	    exaMarkSync(pDrawable->pScreen);
-
 	exaPixmapDirty(pixmaps[0].pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff);
     }
 
+    if (access_prepared)
+	exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
+    else
+	exaMarkSync(pDrawable->pScreen);
+
     return TRUE;
 
 fallback:
@@ -271,8 +270,10 @@ exaShmPutImage(DrawablePtr pDrawable, GC
 		      src_stride))
 	return;
 
+    exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
     fbShmPutImage(pDrawable, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy,
 		  data);
+    exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
 }
 
 ShmFuncs exaShmFuncs = { NULL, exaShmPutImage };
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index f48e93a..ace9076 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -323,10 +323,8 @@ exaDoMoveInPixmap (ExaMigrationPtr migra
 		  pPixmap->drawable.height,
 		  exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
 
-    if (pExaScr->hideOffscreenPixmapData)
-	pPixmap->devPrivate.ptr = NULL;
-    else
-	pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
+    pExaPixmap->offscreen = TRUE;
+
     pPixmap->devKind = pExaPixmap->fb_pitch;
     pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 }
@@ -365,7 +363,8 @@ exaDoMoveOutPixmap (ExaMigrationPtr migr
 		      pPixmap->drawable.height,
 		      exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
 
-	pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
+	pExaPixmap->offscreen = FALSE;
+
 	pPixmap->devKind = pExaPixmap->sys_pitch;
 	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
     }
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 491d80b..da5e459 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -108,6 +108,7 @@ typedef struct {
     CopyWindowProcPtr 		 SavedCopyWindow;
     ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
     BitmapToRegionProcPtr        SavedBitmapToRegion;
+    ModifyPixmapHeaderProcPtr    SavedModifyPixmapHeader;
 #ifdef RENDER
     CompositeProcPtr             SavedComposite;
     RasterizeTrapezoidProcPtr	 SavedRasterizeTrapezoid;
@@ -118,7 +119,6 @@ typedef struct {
   
     Bool			 swappedOut;
     enum ExaMigrationHeuristic	 migration;
-    Bool			 hideOffscreenPixmapData;
     Bool			 checkDirtyCorrectness;
     unsigned			 disableFbCount;
 } ExaScreenPrivRec, *ExaScreenPrivPtr;
@@ -160,6 +160,7 @@ extern int exaPixmapPrivateIndex;
 typedef struct {
     ExaOffscreenArea *area;
     int		    score;	/**< score for the move-in vs move-out heuristic */
+    Bool	    offscreen;
 
     CARD8	    *sys_ptr;	/**< pointer to pixmap data in system memory */
     int		    sys_pitch;	/**< pitch of pixmap in system memory */
diff-tree 962eddd7a2863a8475f5fd8107d3112df08d1172 (from f27931bdd26fc9a1e6bb5173b5537e32c51a98b3)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Aug 29 19:55:22 2007 +0200

    EXA: Support partial migration of pixmap contents between Sys and FB.
    
    The initiator of migration can pass in a region that defines the relevant area
    of each source pixmap or the irrelevant area of the destination pixmap. By
    default, the pending damage region is assumed relevant for the destination
    pixmap, and everything for source pixmaps.
    
    Thanks to Jarno Manninen for reassuring me that my own ideas for this were
    feasible and for providing additional ideas.

diff --git a/exa/exa.c b/exa/exa.c
index ecdb761..145d5b2 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -363,20 +363,15 @@ ExaDoPrepareAccess(DrawablePtr pDrawable
     }
 }
 
-/**
- * exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
- *
- * It deals with waiting for synchronization with the card, determining if
- * PrepareAccess() is necessary, and working around PrepareAccess() failure.
- */
 void
-exaPrepareAccess(DrawablePtr pDrawable, int index)
+exaPrepareAccessReg(DrawablePtr pDrawable, int index, RegionPtr pReg)
 {
     ExaMigrationRec pixmaps[1];
 
     pixmaps[0].as_dst = index == EXA_PREPARE_DEST;
     pixmaps[0].as_src = index != EXA_PREPARE_DEST;
     pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = pReg;
 
     exaDoMigration(pixmaps, 1, FALSE);
 
@@ -384,6 +379,18 @@ exaPrepareAccess(DrawablePtr pDrawable, 
 }
 
 /**
+ * exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
+ *
+ * It deals with waiting for synchronization with the card, determining if
+ * PrepareAccess() is necessary, and working around PrepareAccess() failure.
+ */
+void
+exaPrepareAccess(DrawablePtr pDrawable, int index)
+{
+    exaPrepareAccessReg(pDrawable, index, NULL);
+}
+
+/**
  * exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler.
  *
  * It deals with calling the driver's FinishAccess() only if necessary.
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 07ada15..ceb6c7b 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -55,6 +55,7 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = NULL;
 
     if (pExaScr->swappedOut ||
 	pGC->fillStyle != FillSolid ||
@@ -153,6 +154,7 @@ exaDoPutImage (DrawablePtr pDrawable, GC
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = NULL;
 
     /* Don't bother with under 8bpp, XYPixmaps. */
     if (format != ZPixmap || bpp < 8)
@@ -211,7 +213,8 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 	    int	dstXoff, dstYoff;
 
 	    if (!access_prepared) {
-		exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
+		exaPrepareAccessReg(pDrawable, EXA_PREPARE_DEST,
+				    pixmaps[0].pReg);
 
 		access_prepared = TRUE;
 	    }
@@ -232,6 +235,8 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 
 	if (access_prepared)
 	    exaFinishAccess(pDrawable, EXA_PREPARE_DEST);
+	else
+	    exaMarkSync(pDrawable->pScreen);
 
 	exaPixmapDirty(pixmaps[0].pPix, x1 + xoff, y1 + yoff, x2 + xoff, y2 + yoff);
     }
@@ -420,9 +425,11 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pDstPixmap = exaGetDrawablePixmap (pDstDrawable);
+    pixmaps[0].pReg = NULL;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
     pixmaps[1].pPix = pSrcPixmap = exaGetDrawablePixmap (pSrcDrawable);
+    pixmaps[1].pReg = NULL;
 
     /* Respect maxX/maxY in a trivial way: don't set up drawing when we might
      * violate the limits.  The proper solution would be a temporary pixmap
@@ -463,7 +470,7 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
 		      exaDrawableLocation(pSrcDrawable),
 		      exaDrawableLocation(pDstDrawable)));
-	exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST);
+	exaPrepareAccessReg (pDstDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
 	exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
 	fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
 		    pbox, nbox, dx, dy, reverse, upsidedown,
@@ -682,7 +689,8 @@ exaPolyFillRect(DrawablePtr pDrawable,
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap;
- 
+    pixmaps[0].pReg = NULL;
+
     exaGetDrawableDeltas(pDrawable, pPixmap, &xoff, &yoff);
 
     if (pExaScr->swappedOut ||
@@ -828,6 +836,7 @@ exaSolidBoxClipped (DrawablePtr	pDrawabl
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = NULL;
 
     if (pExaScr->swappedOut ||
 	pPixmap->drawable.width > pExaScr->info->maxX ||
@@ -846,7 +855,7 @@ exaSolidBoxClipped (DrawablePtr	pDrawabl
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
 	fallback = TRUE;
-	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
 	fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
 	fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,
 			   fbAnd (GXcopy, fg, pm),
@@ -949,6 +958,7 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = TRUE;
     pixmaps[0].pPix = pPixmap;
+    pixmaps[0].pReg = NULL;
 
     depthMask = FbFullMask(pDrawable->depth);
     if ((pGC->planemask & depthMask) != depthMask)
@@ -987,7 +997,7 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
 
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
-    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
     exaPrepareAccessGC (pGC);
 
     fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
@@ -1099,7 +1109,8 @@ exaFillRegionSolid (DrawablePtr	pDrawabl
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
- 
+    pixmaps[0].pReg = NULL;
+
     if (pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
     {
@@ -1128,7 +1139,7 @@ fallback:
 	    return FALSE;
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
-	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+	exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
 	fbFillRegionSolid (pDrawable, pRegion, 0,
 			   fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
 	exaFinishAccess (pDrawable, EXA_PREPARE_DEST);
@@ -1170,9 +1181,11 @@ exaFillRegionTiled (DrawablePtr	pDrawabl
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = pPixmap = exaGetDrawablePixmap (pDrawable);
+    pixmaps[0].pReg = NULL;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
     pixmaps[1].pPix = pTile;
+    pixmaps[1].pReg = NULL;
 
     if (pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY ||
@@ -1243,7 +1256,7 @@ fallback:
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
 		  exaDrawableLocation(&pTile->drawable),
 		  exaDrawableLocation(pDrawable)));
-    exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
+    exaPrepareAccessReg (pDrawable, EXA_PREPARE_DEST, pixmaps[0].pReg);
     exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
     fbFillRegionTiled (pDrawable, pRegion, pTile);
     exaFinishAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 99058f1..f48e93a 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -117,28 +117,62 @@ exaPixmapShouldBeInFB (PixmapPtr pPix)
  * FB to system or vice versa.  Both areas must be allocated.
  */
 static _X_INLINE void
-exaCopyDirty(PixmapPtr pPixmap, RegionPtr pValidDst, RegionPtr pValidSrc,
+exaCopyDirty(ExaMigrationPtr migrate, RegionPtr pValidDst, RegionPtr pValidSrc,
 	     Bool (*transfer) (PixmapPtr pPix, int x, int y, int w, int h,
 			       char *sys, int sys_pitch), CARD8 *fallback_src,
 	     CARD8 *fallback_dst, int fallback_srcpitch, int fallback_dstpitch,
 	     int fallback_index, void (*sync) (ScreenPtr pScreen))
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaPixmapPriv (pPixmap);
-    RegionPtr pDamageReg = DamageRegion (pExaPixmap->pDamage);
+    RegionPtr damage = DamageRegion (pExaPixmap->pDamage);
     RegionRec CopyReg;
     CARD8 *save_ptr;
     int save_pitch;
     BoxPtr pBox;
     int nbox;
-    Bool do_sync = FALSE;
+    Bool access_prepared = FALSE;
 
-    /* Damaged bits are valid in source but invalid in destination */
-    REGION_UNION(pScreen, pValidSrc, pValidSrc, pDamageReg);
-    REGION_SUBTRACT(pScreen, pValidDst, pValidDst, pDamageReg);
+    /* Damaged bits are valid in current copy but invalid in other one */
+    if (exaPixmapIsOffscreen(pPixmap)) {
+	REGION_UNION(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+		     damage);
+	REGION_SUBTRACT(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+			damage);
+    } else {
+	REGION_UNION(pScreen, &pExaPixmap->validSys, &pExaPixmap->validSys,
+		     damage);
+	REGION_SUBTRACT(pScreen, &pExaPixmap->validFB, &pExaPixmap->validFB,
+			damage);
+    }
+
+    REGION_EMPTY(pScreen, damage);
 
-    /* Copy bits valid in ssource but not in destination */
+    /* Copy bits valid in source but not in destination */
     REGION_NULL(pScreen, &CopyReg);
     REGION_SUBTRACT(pScreen, &CopyReg, pValidSrc, pValidDst);
+
+    if (migrate->as_dst) {
+	RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
+
+	if (REGION_NIL(pending_damage)) {
+	    static Bool firsttime = TRUE;
+
+	    if (firsttime) {
+		ErrorF("%s: Pending damage region empty!\n", __func__);
+		firsttime = FALSE;
+	    }
+	}
+
+	REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, pending_damage);
+
+	if (migrate->pReg)
+	    REGION_SUBTRACT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+    } else {
+	if (migrate->pReg)
+	    REGION_INTERSECT(pScreen, &CopyReg, &CopyReg, migrate->pReg);
+    }
+
     pBox = REGION_RECTS(&CopyReg);
     nbox = REGION_NUM_RECTS(&CopyReg);
 
@@ -165,29 +199,30 @@ exaCopyDirty(PixmapPtr pPixmap, RegionPt
 				    + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
 				    pExaPixmap->sys_pitch))
 	{
-	    ExaDoPrepareAccess(&pPixmap->drawable, fallback_index);
+	    if (!access_prepared) {
+		ExaDoPrepareAccess(&pPixmap->drawable, fallback_index);
+		access_prepared = TRUE;
+	    }
 	    exaMemcpyBox (pPixmap, pBox,
 			  fallback_src, fallback_srcpitch,
 			  fallback_dst, fallback_dstpitch);
-	    exaFinishAccess(&pPixmap->drawable, fallback_index);
 	}
-	else
-	    do_sync = TRUE;
 
 	pBox++;
     }
 
-    if (do_sync)
+    if (access_prepared)
+	exaFinishAccess(&pPixmap->drawable, fallback_index);
+    else
 	sync (pPixmap->drawable.pScreen);
 
     pPixmap->devPrivate.ptr = save_ptr;
     pPixmap->devKind = save_pitch;
 
-    /* The copied bits are now no longer damaged but valid in destination */
+    /* The copied bits are now valid in destination */
     REGION_UNION(pScreen, pValidDst, pValidDst, &CopyReg);
-    REGION_SUBTRACT(pScreen, pDamageReg, pDamageReg, &CopyReg);
 
-    REGION_NULL(pScreen, &CopyReg);
+    REGION_UNINIT(pScreen, &CopyReg);
 }
 
 /**
@@ -196,12 +231,13 @@ exaCopyDirty(PixmapPtr pPixmap, RegionPt
  * allocated.
  */
 static void
-exaCopyDirtyToSys (PixmapPtr pPixmap)
+exaCopyDirtyToSys (ExaMigrationPtr migrate)
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaScreenPriv (pPixmap->drawable.pScreen);
     ExaPixmapPriv (pPixmap);
 
-    exaCopyDirty(pPixmap, &pExaPixmap->validSys, &pExaPixmap->validFB,
+    exaCopyDirty(migrate, &pExaPixmap->validSys, &pExaPixmap->validFB,
 		 pExaScr->info->DownloadFromScreen, pExaPixmap->fb_ptr,
 		 pExaPixmap->sys_ptr, pExaPixmap->fb_pitch,
 		 pExaPixmap->sys_pitch, EXA_PREPARE_SRC, exaWaitSync);
@@ -213,51 +249,19 @@ exaCopyDirtyToSys (PixmapPtr pPixmap)
  * allocated.
  */
 static void
-exaCopyDirtyToFb (PixmapPtr pPixmap)
+exaCopyDirtyToFb (ExaMigrationPtr migrate)
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaScreenPriv (pPixmap->drawable.pScreen);
     ExaPixmapPriv (pPixmap);
 
-    exaCopyDirty(pPixmap, &pExaPixmap->validFB, &pExaPixmap->validSys,
+    exaCopyDirty(migrate, &pExaPixmap->validFB, &pExaPixmap->validSys,
 		 pExaScr->info->UploadToScreen, pExaPixmap->sys_ptr,
 		 pExaPixmap->fb_ptr, pExaPixmap->sys_pitch,
 		 pExaPixmap->fb_pitch, EXA_PREPARE_DEST, exaMarkSync);
 }
 
 /**
- * Copies out important pixmap data and removes references to framebuffer area.
- * Called when the memory manager decides it's time to kick the pixmap out of
- * framebuffer entirely.
- */
-void
-exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area)
-{
-    PixmapPtr pPixmap = area->privData;
-    ExaPixmapPriv(pPixmap);
-
-    DBG_MIGRATE (("Save %p (%p) (%dx%d) (%c)\n", pPixmap,
-		  (void*)(ExaGetPixmapPriv(pPixmap)->area ?
-                          ExaGetPixmapPriv(pPixmap)->area->offset : 0),
-		  pPixmap->drawable.width,
-		  pPixmap->drawable.height,
-		  exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
-
-    if (exaPixmapIsOffscreen(pPixmap)) {
-	exaCopyDirtyToSys (pPixmap);
-	pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
-	pPixmap->devKind = pExaPixmap->sys_pitch;
-	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    }
-
-    pExaPixmap->fb_ptr = NULL;
-    pExaPixmap->area = NULL;
-
-    /* Mark all FB bits as invalid, so all valid system bits get copied to FB
-     * next time */
-    REGION_NULL(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
-}
-
-/**
  * Allocates a framebuffer copy of the pixmap if necessary, and then copies
  * any necessary pixmap data into the framebuffer copy and points the pixmap at
  * it.
@@ -272,10 +276,11 @@ exaPixmapSave (ScreenPtr pScreen, ExaOff
  * we mark the pixmap dirty, so that the next exaMoveInPixmap will actually move
  * all the data, since it's almost surely all valid now.
  */
-void
-exaMoveInPixmap (PixmapPtr pPixmap)
+static void
+exaDoMoveInPixmap (ExaMigrationPtr migrate)
 {
-    ScreenPtr	pScreen = pPixmap->drawable.pScreen;
+    PixmapPtr pPixmap = migrate->pPix;
+    ScreenPtr pScreen = pPixmap->drawable.pScreen;
     ExaScreenPriv (pScreen);
     ExaPixmapPriv (pPixmap);
 
@@ -283,10 +288,6 @@ exaMoveInPixmap (PixmapPtr pPixmap)
     if (pExaScr->swappedOut)
 	return;
 
-    /* If we're already in FB, our work is done. */
-    if (exaPixmapIsOffscreen(pPixmap))
-	return;
-
     /* If we're not allowed to move, then fail. */
     if (exaPixmapIsPinned(pPixmap))
 	return;
@@ -310,6 +311,11 @@ exaMoveInPixmap (PixmapPtr pPixmap)
 				       pExaPixmap->area->offset;
     }
 
+    exaCopyDirtyToFb (migrate);
+
+    if (exaPixmapIsOffscreen(pPixmap))
+	return;
+
     DBG_MIGRATE (("-> %p (0x%x) (%dx%d) (%c)\n", pPixmap,
 		  (ExaGetPixmapPriv(pPixmap)->area ?
                    ExaGetPixmapPriv(pPixmap)->area->offset : 0),
@@ -317,8 +323,6 @@ exaMoveInPixmap (PixmapPtr pPixmap)
 		  pPixmap->drawable.height,
 		  exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
 
-    exaCopyDirtyToFb (pPixmap);
-
     if (pExaScr->hideOffscreenPixmapData)
 	pPixmap->devPrivate.ptr = NULL;
     else
@@ -327,18 +331,31 @@ exaMoveInPixmap (PixmapPtr pPixmap)
     pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 }
 
+void
+exaMoveInPixmap (PixmapPtr pPixmap)
+{
+    static ExaMigrationRec migrate = { .as_dst = FALSE, .as_src = TRUE,
+				       .pReg = NULL };
+
+    migrate.pPix = pPixmap;
+    exaDoMoveInPixmap (&migrate);
+}
+
 /**
  * Switches the current active location of the pixmap to system memory, copying
  * updated data out if necessary.
  */
-void
-exaMoveOutPixmap (PixmapPtr pPixmap)
+static void
+exaDoMoveOutPixmap (ExaMigrationPtr migrate)
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaPixmapPriv (pPixmap);
 
-    if (exaPixmapIsPinned(pPixmap))
+    if (!pExaPixmap->area || exaPixmapIsPinned(pPixmap))
 	return;
 
+    exaCopyDirtyToSys (migrate);
+
     if (exaPixmapIsOffscreen(pPixmap)) {
 
 	DBG_MIGRATE (("<- %p (%p) (%dx%d) (%c)\n", pPixmap,
@@ -348,21 +365,52 @@ exaMoveOutPixmap (PixmapPtr pPixmap)
 		      pPixmap->drawable.height,
 		      exaPixmapIsDirty(pPixmap) ? 'd' : 'c'));
 
-	exaCopyDirtyToSys (pPixmap);
-
 	pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
 	pPixmap->devKind = pExaPixmap->sys_pitch;
 	pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
     }
 }
 
+void
+exaMoveOutPixmap (PixmapPtr pPixmap)
+{
+    static ExaMigrationRec migrate = { .as_dst = FALSE, .as_src = TRUE,
+				       .pReg = NULL };
+
+    migrate.pPix = pPixmap;
+    exaDoMoveOutPixmap (&migrate);
+}
+
+
+/**
+ * Copies out important pixmap data and removes references to framebuffer area.
+ * Called when the memory manager decides it's time to kick the pixmap out of
+ * framebuffer entirely.
+ */
+void
+exaPixmapSave (ScreenPtr pScreen, ExaOffscreenArea *area)
+{
+    PixmapPtr pPixmap = area->privData;
+    ExaPixmapPriv(pPixmap);
+
+    exaMoveOutPixmap(pPixmap);
+
+    pExaPixmap->fb_ptr = NULL;
+    pExaPixmap->area = NULL;
+
+    /* Mark all FB bits as invalid, so all valid system bits get copied to FB
+     * next time */
+    REGION_EMPTY(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
+}
+
 /**
  * For the "greedy" migration scheme, pushes the pixmap toward being located in
  * framebuffer memory.
  */
 static void
-exaMigrateTowardFb (PixmapPtr pPixmap)
+exaMigrateTowardFb (ExaMigrationPtr migrate)
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaPixmapPriv (pPixmap);
 
     if (pExaPixmap == NULL) {
@@ -382,7 +430,7 @@ exaMigrateTowardFb (PixmapPtr pPixmap)
 		 (pointer)pPixmap, pExaPixmap->score));
 
     if (pExaPixmap->score == EXA_PIXMAP_SCORE_INIT) {
-	exaMoveInPixmap(pPixmap);
+	exaDoMoveInPixmap(migrate);
 	pExaPixmap->score = 0;
     }
 
@@ -392,7 +440,7 @@ exaMigrateTowardFb (PixmapPtr pPixmap)
     if (pExaPixmap->score >= EXA_PIXMAP_SCORE_MOVE_IN &&
 	!exaPixmapIsOffscreen(pPixmap))
     {
-	exaMoveInPixmap (pPixmap);
+	exaDoMoveInPixmap(migrate);
     }
 
     ExaOffscreenMarkUsed (pPixmap);
@@ -403,8 +451,9 @@ exaMigrateTowardFb (PixmapPtr pPixmap)
  * system memory.
  */
 static void
-exaMigrateTowardSys (PixmapPtr pPixmap)
+exaMigrateTowardSys (ExaMigrationPtr migrate)
 {
+    PixmapPtr pPixmap = migrate->pPix;
     ExaPixmapPriv (pPixmap);
 
     if (pExaPixmap == NULL) {
@@ -426,7 +475,7 @@ exaMigrateTowardSys (PixmapPtr pPixmap)
 	pExaPixmap->score--;
 
     if (pExaPixmap->score <= EXA_PIXMAP_SCORE_MOVE_OUT && pExaPixmap->area)
-	exaMoveOutPixmap (pPixmap);
+	exaDoMoveOutPixmap(migrate);
 }
 
 /**
@@ -438,15 +487,24 @@ exaAssertNotDirty (PixmapPtr pPixmap)
 {
     ExaPixmapPriv (pPixmap);
     CARD8 *dst, *src;
-    RegionPtr pValidReg = exaPixmapIsOffscreen(pPixmap) ? &pExaPixmap->validFB :
-			  &pExaPixmap->validSys;
-    int dst_pitch, src_pitch, cpp, y, nbox = REGION_NUM_RECTS(pValidReg);
-    BoxPtr pBox = REGION_RECTS(pValidReg);
+    RegionRec ValidReg;
+    int dst_pitch, src_pitch, cpp, y, nbox;
+    BoxPtr pBox;
     Bool ret = TRUE;
 
-    if (!nbox || exaPixmapIsPinned(pPixmap) || pExaPixmap->fb_ptr == NULL)
+    if (exaPixmapIsPinned(pPixmap) || pExaPixmap->area == NULL)
 	return ret;
 
+    REGION_NULL(pScreen, &ValidReg);
+    REGION_INTERSECT(pScreen, &ValidReg, &pExaPixmap->validFB,
+		     &pExaPixmap->validSys);
+    nbox = REGION_NUM_RECTS(&ValidReg);
+
+    if (!nbox)
+	goto out;
+
+    pBox = REGION_RECTS(&ValidReg);
+
     dst_pitch = pExaPixmap->sys_pitch;
     src_pitch = pExaPixmap->fb_pitch;
     cpp = pPixmap->drawable.bitsPerPixel / 8;
@@ -479,6 +537,8 @@ exaAssertNotDirty (PixmapPtr pPixmap)
     }
     exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
 
+out:
+    REGION_UNINIT(pScreen, &ValidReg);
     return ret;
 }
 
@@ -533,7 +593,7 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	    {
 		for (i = 0; i < npixmaps; i++) {
 		    if (!exaPixmapIsDirty (pixmaps[i].pPix))
-			exaMoveOutPixmap (pixmaps[i].pPix);
+			exaDoMoveOutPixmap (pixmaps + i);
 		}
 		return;
 	    }
@@ -544,17 +604,17 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	 */
 	if (!can_accel) {
 	    for (i = 0; i < npixmaps; i++) {
-		exaMigrateTowardSys (pixmaps[i].pPix);
+		exaMigrateTowardSys (pixmaps + i);
 		if (!exaPixmapIsDirty (pixmaps[i].pPix))
-		    exaMoveOutPixmap (pixmaps[i].pPix);
+		    exaDoMoveOutPixmap (pixmaps + i);
 	    }
 	    return;
 	}
 
 	/* Finally, the acceleration path.  Move them all in. */
 	for (i = 0; i < npixmaps; i++) {
-	    exaMigrateTowardFb(pixmaps[i].pPix);
-	    exaMoveInPixmap(pixmaps[i].pPix);
+	    exaMigrateTowardFb(pixmaps + i);
+	    exaDoMoveInPixmap(pixmaps + i);
 	}
     } else if (pExaScr->migration == ExaMigrationGreedy) {
 	/* If we can't accelerate, either because the driver can't or because one of
@@ -570,7 +630,7 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	 */
 	if (!can_accel) {
 	    for (i = 0; i < npixmaps; i++)
-		exaMigrateTowardSys (pixmaps[i].pPix);
+		exaMigrateTowardSys (pixmaps + i);
 	    return;
 	}
 
@@ -578,14 +638,14 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	    if (exaPixmapIsOffscreen(pixmaps[i].pPix)) {
 		/* Found one in FB, so move all to FB. */
 		for (j = 0; j < npixmaps; j++)
-		    exaMigrateTowardFb(pixmaps[j].pPix);
+		    exaMigrateTowardFb(pixmaps + i);
 		return;
 	    }
 	}
 
 	/* Nobody's in FB, so move all away from FB. */
 	for (i = 0; i < npixmaps; i++)
-	    exaMigrateTowardSys(pixmaps[i].pPix);
+	    exaMigrateTowardSys(pixmaps + i);
     } else if (pExaScr->migration == ExaMigrationAlways) {
 	/* Always move the pixmaps out if we can't accelerate.  If we can
 	 * accelerate, try to move them all in.  If that fails, then move them
@@ -593,13 +653,13 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	 */
 	if (!can_accel) {
 	    for (i = 0; i < npixmaps; i++)
-		exaMoveOutPixmap(pixmaps[i].pPix);
+		exaDoMoveOutPixmap(pixmaps + i);
 	    return;
 	}
 
 	/* Now, try to move them all into FB */
 	for (i = 0; i < npixmaps; i++) {
-	    exaMoveInPixmap(pixmaps[i].pPix);
+	    exaDoMoveInPixmap(pixmaps + i);
 	}
 
 	/* If we couldn't fit everything in, abort */
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index b9e5016..491d80b 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -185,6 +185,7 @@ typedef struct _ExaMigrationRec {
     Bool as_dst;
     Bool as_src;
     PixmapPtr pPix;
+    RegionPtr pReg;
 } ExaMigrationRec, *ExaMigrationPtr;
 
 /**
@@ -338,6 +339,9 @@ void
 ExaDoPrepareAccess(DrawablePtr pDrawable, int index);
 
 void
+exaPrepareAccessReg(DrawablePtr pDrawable, int index, RegionPtr pReg);
+
+void
 exaPrepareAccess(DrawablePtr pDrawable, int index);
 
 void
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 738ac15..067f88b 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -267,6 +267,7 @@ exaTryDriverSolidFill(PicturePtr	pSrc,
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = FALSE;
     pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
+    pixmaps[0].pReg = NULL;
     exaDoMigration(pixmaps, 1, TRUE);
 
     pDstPix = exaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
@@ -381,13 +382,16 @@ exaTryDriverComposite(CARD8		op,
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = exaOpReadsDestination(op);
     pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
+    pixmaps[0].pReg = NULL;
     pixmaps[1].as_dst = FALSE;
     pixmaps[1].as_src = TRUE;
     pixmaps[1].pPix = exaGetDrawablePixmap (pSrc->pDrawable);
+    pixmaps[1].pReg = NULL;
     if (pMask) {
 	pixmaps[2].as_dst = FALSE;
 	pixmaps[2].as_src = TRUE;
 	pixmaps[2].pPix = exaGetDrawablePixmap (pMask->pDrawable);
+	pixmaps[2].pReg = NULL;
 	exaDoMigration(pixmaps, 3, TRUE);
     } else {
 	exaDoMigration(pixmaps, 2, TRUE);
@@ -579,12 +583,14 @@ exaComposite(CARD8	op,
     pixmaps[0].as_dst = TRUE;
     pixmaps[0].as_src = exaOpReadsDestination(op);
     pixmaps[0].pPix = exaGetDrawablePixmap (pDst->pDrawable);
+    pixmaps[0].pReg = NULL;
 
     if (pSrc->pDrawable) {
 	pSrcPixmap = exaGetDrawablePixmap (pSrc->pDrawable);
 	pixmaps[npixmaps].as_dst = FALSE;
 	pixmaps[npixmaps].as_src = TRUE;
 	pixmaps[npixmaps].pPix = pSrcPixmap;
+	pixmaps[npixmaps].pReg = NULL;
 	npixmaps++;
     }
 
@@ -592,6 +598,7 @@ exaComposite(CARD8	op,
 	pixmaps[npixmaps].as_dst = FALSE;
 	pixmaps[npixmaps].as_src = TRUE;
 	pixmaps[npixmaps].pPix = exaGetDrawablePixmap (pMask->pDrawable);
+	pixmaps[npixmaps].pReg = NULL;
 	npixmaps++;
     }
 
@@ -1159,8 +1166,9 @@ exaGlyphs (CARD8	op,
 	 * it'll stick there.
 	 */
 	pixmaps[0].as_dst = TRUE;
-	pixmaps[0].as_src = TRUE;
+	pixmaps[0].as_src = FALSE;
 	pixmaps[0].pPix = pPixmap;
+	pixmaps[0].pReg = NULL;
 	exaDoMigration (pixmaps, 1, pExaScr->info->PrepareComposite != NULL);
 
 	while (n--)
diff-tree f27931bdd26fc9a1e6bb5173b5537e32c51a98b3 (from 5c7ee3f47fa0c067102a17dee3f75a51cc0bdb3a)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Aug 29 19:41:52 2007 +0200

    Add DamagePendingRegion.
    
    DamagePendingRegion returns a pointer to the region of a drawable that will
    be damaged by the current operation for damage records that chose to get damage
    reported only at the end of the operation.

diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 65314d8..472b1b8 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -1987,6 +1987,12 @@ DamageRegion (DamagePtr		    pDamage)
     return &pDamage->damage;
 }
 
+_X_EXPORT RegionPtr
+DamagePendingRegion (DamagePtr	    pDamage)
+{
+    return &pDamage->pendingDamage;
+}
+
 _X_EXPORT void
 DamageDamageRegion (DrawablePtr	pDrawable,
 		    RegionPtr	pRegion)
diff --git a/miext/damage/damage.h b/miext/damage/damage.h
index 4cfc812..102da6e 100755
--- a/miext/damage/damage.h
+++ b/miext/damage/damage.h
@@ -75,6 +75,9 @@ DamageEmpty (DamagePtr pDamage);
 RegionPtr
 DamageRegion (DamagePtr		    pDamage);
 
+RegionPtr
+DamagePendingRegion (DamagePtr	    pDamage);
+
 void
 DamageDamageRegion (DrawablePtr	    pDrawable,
 		    const RegionPtr pRegion);
diff-tree 5c7ee3f47fa0c067102a17dee3f75a51cc0bdb3a (from 8cfcf9973c765f11d1b45b95b8091ef7e01d7f01)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Fri Aug 24 19:24:18 2007 +0200

    EXA: Track valid bits in Sys and FB separately.
    
    Also consolidate exaCopyDirtyToFb/Sys.

diff --git a/exa/exa.c b/exa/exa.c
index 514b88b..ecdb761 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -186,7 +186,8 @@ exaDestroyPixmap (PixmapPtr pPixmap)
 	    pPixmap->devPrivate.ptr = pExaPixmap->sys_ptr;
 	    pPixmap->devKind = pExaPixmap->sys_pitch;
 	}
-	REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validReg);
+	REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validSys);
+	REGION_UNINIT(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
     }
     return fbDestroyPixmap (pPixmap);
 }
@@ -267,7 +268,8 @@ exaCreatePixmap(ScreenPtr pScreen, int w
     DamageSetReportAfterOp (pExaPixmap->pDamage, TRUE);
 
     /* None of the pixmap bits are valid initially */
-    REGION_NULL(pScreen, &pExaPixmap->validReg);
+    REGION_NULL(pScreen, &pExaPixmap->validSys);
+    REGION_NULL(pScreen, &pExaPixmap->validFB);
 
     return pPixmap;
 }
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 661ff40..99058f1 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -90,7 +90,8 @@ exaPixmapIsDirty (PixmapPtr pPix)
     ExaPixmapPriv (pPix);
 
     return pExaPixmap == NULL ||
-	REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage));
+	REGION_NOTEMPTY (pScreen, DamageRegion(pExaPixmap->pDamage)) ||
+	!REGION_EQUAL(pScreen, &pExaPixmap->validSys, &pExaPixmap->validFB);
 }
 
 /**
@@ -113,21 +114,34 @@ exaPixmapShouldBeInFB (PixmapPtr pPix)
 
 /**
  * If the pixmap is currently dirty, this copies at least the dirty area from
- * the framebuffer  memory copy to the system memory copy.  Both areas must be
- * allocated.
+ * FB to system or vice versa.  Both areas must be allocated.
  */
-static void
-exaCopyDirtyToSys (PixmapPtr pPixmap)
+static _X_INLINE void
+exaCopyDirty(PixmapPtr pPixmap, RegionPtr pValidDst, RegionPtr pValidSrc,
+	     Bool (*transfer) (PixmapPtr pPix, int x, int y, int w, int h,
+			       char *sys, int sys_pitch), CARD8 *fallback_src,
+	     CARD8 *fallback_dst, int fallback_srcpitch, int fallback_dstpitch,
+	     int fallback_index, void (*sync) (ScreenPtr pScreen))
 {
-    ExaScreenPriv (pPixmap->drawable.pScreen);
     ExaPixmapPriv (pPixmap);
-    RegionPtr pRegion = DamageRegion (pExaPixmap->pDamage);
+    RegionPtr pDamageReg = DamageRegion (pExaPixmap->pDamage);
+    RegionRec CopyReg;
     CARD8 *save_ptr;
     int save_pitch;
-    BoxPtr pBox = REGION_RECTS(pRegion);
-    int nbox = REGION_NUM_RECTS(pRegion);
+    BoxPtr pBox;
+    int nbox;
     Bool do_sync = FALSE;
 
+    /* Damaged bits are valid in source but invalid in destination */
+    REGION_UNION(pScreen, pValidSrc, pValidSrc, pDamageReg);
+    REGION_SUBTRACT(pScreen, pValidDst, pValidDst, pDamageReg);
+
+    /* Copy bits valid in ssource but not in destination */
+    REGION_NULL(pScreen, &CopyReg);
+    REGION_SUBTRACT(pScreen, &CopyReg, pValidSrc, pValidDst);
+    pBox = REGION_RECTS(&CopyReg);
+    nbox = REGION_NUM_RECTS(&CopyReg);
+
     save_ptr = pPixmap->devPrivate.ptr;
     save_pitch = pPixmap->devKind;
     pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
@@ -142,21 +156,20 @@ exaCopyDirtyToSys (PixmapPtr pPixmap)
 	if (pBox->x1 >= pBox->x2 || pBox->y1 >= pBox->y2)
 	    continue;
 
-	if (pExaScr->info->DownloadFromScreen == NULL ||
-	    !pExaScr->info->DownloadFromScreen (pPixmap,
-						pBox->x1, pBox->y1,
-						pBox->x2 - pBox->x1,
-						pBox->y2 - pBox->y1,
-						pExaPixmap->sys_ptr
-						+ pBox->y1 * pExaPixmap->sys_pitch
-						+ pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
-						pExaPixmap->sys_pitch))
+	if (!transfer || !transfer (pPixmap,
+				    pBox->x1, pBox->y1,
+				    pBox->x2 - pBox->x1,
+				    pBox->y2 - pBox->y1,
+				    pExaPixmap->sys_ptr
+				    + pBox->y1 * pExaPixmap->sys_pitch
+				    + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
+				    pExaPixmap->sys_pitch))
 	{
-	    ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+	    ExaDoPrepareAccess(&pPixmap->drawable, fallback_index);
 	    exaMemcpyBox (pPixmap, pBox,
-			  pExaPixmap->fb_ptr, pExaPixmap->fb_pitch,
-			  pExaPixmap->sys_ptr, pExaPixmap->sys_pitch);
-	    exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+			  fallback_src, fallback_srcpitch,
+			  fallback_dst, fallback_dstpitch);
+	    exaFinishAccess(&pPixmap->drawable, fallback_index);
 	}
 	else
 	    do_sync = TRUE;
@@ -164,84 +177,51 @@ exaCopyDirtyToSys (PixmapPtr pPixmap)
 	pBox++;
     }
 
-    /* Make sure the bits have actually landed, since we don't necessarily sync
-     * when accessing pixmaps in system memory.
-     */
     if (do_sync)
-	exaWaitSync (pPixmap->drawable.pScreen);
+	sync (pPixmap->drawable.pScreen);
 
     pPixmap->devPrivate.ptr = save_ptr;
     pPixmap->devKind = save_pitch;
 
-    /* The previously damaged bits are now no longer damaged but valid */
-    REGION_UNION(pPixmap->drawable.pScreen,
-		 &pExaPixmap->validReg, &pExaPixmap->validReg, pRegion);
-    DamageEmpty (pExaPixmap->pDamage);
+    /* The copied bits are now no longer damaged but valid in destination */
+    REGION_UNION(pScreen, pValidDst, pValidDst, &CopyReg);
+    REGION_SUBTRACT(pScreen, pDamageReg, pDamageReg, &CopyReg);
+
+    REGION_NULL(pScreen, &CopyReg);
 }
 
 /**
  * If the pixmap is currently dirty, this copies at least the dirty area from
- * the system memory copy to the framebuffer memory copy.  Both areas must be
+ * the framebuffer  memory copy to the system memory copy.  Both areas must be
  * allocated.
  */
 static void
-exaCopyDirtyToFb (PixmapPtr pPixmap)
+exaCopyDirtyToSys (PixmapPtr pPixmap)
 {
     ExaScreenPriv (pPixmap->drawable.pScreen);
     ExaPixmapPriv (pPixmap);
-    RegionPtr pRegion = DamageRegion (pExaPixmap->pDamage);
-    CARD8 *save_ptr;
-    int save_pitch;
-    BoxPtr pBox = REGION_RECTS(pRegion);
-    int nbox = REGION_NUM_RECTS(pRegion);
-    Bool do_sync = FALSE;
-
-    save_ptr = pPixmap->devPrivate.ptr;
-    save_pitch = pPixmap->devKind;
-    pPixmap->devPrivate.ptr = pExaPixmap->fb_ptr;
-    pPixmap->devKind = pExaPixmap->fb_pitch;
-
-    while (nbox--) {
-	pBox->x1 = max(pBox->x1, 0);
-	pBox->y1 = max(pBox->y1, 0);
-	pBox->x2 = min(pBox->x2, pPixmap->drawable.width);
-	pBox->y2 = min(pBox->y2, pPixmap->drawable.height);
 
-	if (pBox->x1 >= pBox->x2 || pBox->y1 >= pBox->y2)
-	    continue;
-
-	if (pExaScr->info->UploadToScreen == NULL ||
-	    !pExaScr->info->UploadToScreen (pPixmap,
-					    pBox->x1, pBox->y1,
-					    pBox->x2 - pBox->x1,
-					    pBox->y2 - pBox->y1,
-					    pExaPixmap->sys_ptr
-					    + pBox->y1 * pExaPixmap->sys_pitch
-					    + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
-					    pExaPixmap->sys_pitch))
-	{
-	    ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST);
-	    exaMemcpyBox (pPixmap, pBox,
-			  pExaPixmap->sys_ptr, pExaPixmap->sys_pitch,
-			  pExaPixmap->fb_ptr, pExaPixmap->fb_pitch);
-	    exaFinishAccess(&pPixmap->drawable, EXA_PREPARE_DEST);
-	}
-	else
-	    do_sync = TRUE;
-
-	pBox++;
-    }
-
-    if (do_sync)
-	exaMarkSync (pPixmap->drawable.pScreen);
+    exaCopyDirty(pPixmap, &pExaPixmap->validSys, &pExaPixmap->validFB,
+		 pExaScr->info->DownloadFromScreen, pExaPixmap->fb_ptr,
+		 pExaPixmap->sys_ptr, pExaPixmap->fb_pitch,
+		 pExaPixmap->sys_pitch, EXA_PREPARE_SRC, exaWaitSync);
+}
 
-    pPixmap->devPrivate.ptr = save_ptr;
-    pPixmap->devKind = save_pitch;
+/**
+ * If the pixmap is currently dirty, this copies at least the dirty area from
+ * the system memory copy to the framebuffer memory copy.  Both areas must be
+ * allocated.
+ */
+static void
+exaCopyDirtyToFb (PixmapPtr pPixmap)
+{
+    ExaScreenPriv (pPixmap->drawable.pScreen);
+    ExaPixmapPriv (pPixmap);
 
-    /* The previously damaged bits are now no longer damaged but valid */
-    REGION_UNION(pPixmap->drawable.pScreen,
-		 &pExaPixmap->validReg, &pExaPixmap->validReg, pRegion);
-    DamageEmpty (pExaPixmap->pDamage);
+    exaCopyDirty(pPixmap, &pExaPixmap->validFB, &pExaPixmap->validSys,
+		 pExaScr->info->UploadToScreen, pExaPixmap->sys_ptr,
+		 pExaPixmap->fb_ptr, pExaPixmap->sys_pitch,
+		 pExaPixmap->fb_pitch, EXA_PREPARE_DEST, exaMarkSync);
 }
 
 /**
@@ -254,7 +234,6 @@ exaPixmapSave (ScreenPtr pScreen, ExaOff
 {
     PixmapPtr pPixmap = area->privData;
     ExaPixmapPriv(pPixmap);
-    RegionPtr pDamageReg = DamageRegion(pExaPixmap->pDamage);
 
     DBG_MIGRATE (("Save %p (%p) (%dx%d) (%c)\n", pPixmap,
 		  (void*)(ExaGetPixmapPriv(pPixmap)->area ?
@@ -273,9 +252,9 @@ exaPixmapSave (ScreenPtr pScreen, ExaOff
     pExaPixmap->fb_ptr = NULL;
     pExaPixmap->area = NULL;
 
-    /* Mark all valid bits as damaged, so they'll get copied to FB next time */
-    REGION_UNION(pPixmap->drawable.pScreen, pDamageReg, pDamageReg,
-		 &pExaPixmap->validReg);
+    /* Mark all FB bits as invalid, so all valid system bits get copied to FB
+     * next time */
+    REGION_NULL(pPixmap->drawable.pScreen, &pExaPixmap->validFB);
 }
 
 /**
@@ -459,7 +438,8 @@ exaAssertNotDirty (PixmapPtr pPixmap)
 {
     ExaPixmapPriv (pPixmap);
     CARD8 *dst, *src;
-    RegionPtr pValidReg = &pExaPixmap->validReg;
+    RegionPtr pValidReg = exaPixmapIsOffscreen(pPixmap) ? &pExaPixmap->validFB :
+			  &pExaPixmap->validSys;
     int dst_pitch, src_pitch, cpp, y, nbox = REGION_NUM_RECTS(pValidReg);
     BoxPtr pBox = REGION_RECTS(pValidReg);
     Bool ret = TRUE;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 409bc4d..b9e5016 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -175,10 +175,10 @@ typedef struct {
      */
     DamagePtr	    pDamage;
     /**
-     * The valid region marks the valid bits of a drawable (at least, as it's
-     * derived from damage, which may be overreported).
+     * The valid regions mark the valid bits (at least, as they're derived from
+     * damage, which may be overreported) of a pixmap's system and FB copies.
      */
-    RegionRec	    validReg;
+    RegionRec	    validSys, validFB;
 } ExaPixmapPrivRec, *ExaPixmapPrivPtr;
  
 typedef struct _ExaMigrationRec {
diff-tree 8cfcf9973c765f11d1b45b95b8091ef7e01d7f01 (from e510a77ba4d65d5d6ead514cd698f1b1e3f8a2b6)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Sep 5 20:10:09 2007 +0200

    EXA: Migrate out pixmap in exaPrepareAccess.
    
    Also fix exaFinishAccessGC not to use the same index for tile and stipple.

diff --git a/exa/exa.c b/exa/exa.c
index 46fb557..514b88b 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -329,14 +329,8 @@ exaGetOffscreenPixmap (DrawablePtr pDraw
 	return NULL;
 }
 
-/**
- * exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
- *
- * It deals with waiting for synchronization with the card, determining if
- * PrepareAccess() is necessary, and working around PrepareAccess() failure.
- */
 void
-exaPrepareAccess(DrawablePtr pDrawable, int index)
+ExaDoPrepareAccess(DrawablePtr pDrawable, int index)
 {
     ScreenPtr	    pScreen = pDrawable->pScreen;
     ExaScreenPriv  (pScreen);
@@ -368,6 +362,26 @@ exaPrepareAccess(DrawablePtr pDrawable, 
 }
 
 /**
+ * exaPrepareAccess() is EXA's wrapper for the driver's PrepareAccess() handler.
+ *
+ * It deals with waiting for synchronization with the card, determining if
+ * PrepareAccess() is necessary, and working around PrepareAccess() failure.
+ */
+void
+exaPrepareAccess(DrawablePtr pDrawable, int index)
+{
+    ExaMigrationRec pixmaps[1];
+
+    pixmaps[0].as_dst = index == EXA_PREPARE_DEST;
+    pixmaps[0].as_src = index != EXA_PREPARE_DEST;
+    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
+
+    exaDoMigration(pixmaps, 1, FALSE);
+
+    ExaDoPrepareAccess(pDrawable, index);
+}
+
+/**
  * exaFinishAccess() is EXA's wrapper for the driver's FinishAccess() handler.
  *
  * It deals with calling the driver's FinishAccess() only if necessary.
@@ -698,7 +712,7 @@ exaDriverInit (ScreenPtr		pScreen,
     pScreen->GetImage = exaGetImage;
 
     pExaScr->SavedGetSpans = pScreen->GetSpans;
-    pScreen->GetSpans = exaGetSpans;
+    pScreen->GetSpans = ExaCheckGetSpans;
 
     pExaScr->SavedCopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = exaCopyWindow;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index feedd49..07ada15 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -61,7 +61,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 	pPixmap->drawable.width > pExaScr->info->maxX ||
 	pPixmap->drawable.height > pExaScr->info->maxY)
     {
-	exaDoMigration (pixmaps, 1, FALSE);
 	ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
 	return;
     } else {
@@ -74,7 +73,6 @@ exaFillSpans(DrawablePtr pDrawable, GCPt
 					 pGC->planemask,
 					 pGC->fgPixel))
     {
-	exaDoMigration (pixmaps, 1, FALSE);
 	ExaCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
 	return;
     }
@@ -158,11 +156,11 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 
     /* Don't bother with under 8bpp, XYPixmaps. */
     if (format != ZPixmap || bpp < 8)
-	goto migrate_and_fallback;
+	goto fallback;
 
     /* Only accelerate copies: no rop or planemask. */
     if (!EXA_PM_IS_SOLID(pDrawable, pGC->planemask) || pGC->alu != GXcopy)
-	goto migrate_and_fallback;
+	goto fallback;
 
     if (pExaScr->swappedOut)
 	goto fallback;
@@ -240,9 +238,6 @@ exaDoPutImage (DrawablePtr pDrawable, GC
 
     return TRUE;
 
-migrate_and_fallback:
-    exaDoMigration (pixmaps, 1, FALSE);
-
 fallback:
     return FALSE;
 }
@@ -468,7 +463,6 @@ exaCopyNtoN (DrawablePtr    pSrcDrawable
 	EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrcDrawable, pDstDrawable,
 		      exaDrawableLocation(pSrcDrawable),
 		      exaDrawableLocation(pDstDrawable)));
-	exaDoMigration (pixmaps, 2, FALSE);
 	exaPrepareAccess (pDstDrawable, EXA_PREPARE_DEST);
 	exaPrepareAccess (pSrcDrawable, EXA_PREPARE_SRC);
 	fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
@@ -731,15 +725,6 @@ exaPolyFillRect(DrawablePtr pDrawable,
 					 pGC->fgPixel))
     {
 fallback:
-	if (pGC->fillStyle == FillTiled && !pGC->tileIsPixel) {
-	    pixmaps[1].as_dst = FALSE;
-	    pixmaps[1].as_src = TRUE;
-	    pixmaps[1].pPix = pGC->tile.pixmap;
-	    exaDoMigration (pixmaps, 2, FALSE);
-	} else {
-	    exaDoMigration (pixmaps, 1, FALSE);
-	}
-
 	ExaCheckPolyFillRect (pDrawable, pGC, nrect, prect);
 	goto out;
     }
@@ -860,7 +845,6 @@ exaSolidBoxClipped (DrawablePtr	pDrawabl
     {
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
-	exaDoMigration (pixmaps, 1, FALSE);
 	fallback = TRUE;
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 	fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
@@ -969,7 +953,6 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     depthMask = FbFullMask(pDrawable->depth);
     if ((pGC->planemask & depthMask) != depthMask)
     {
-	exaDoMigration(pixmaps, 1, FALSE);
 	ExaCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
 	goto damage;
     }
@@ -1004,7 +987,6 @@ exaImageGlyphBlt (DrawablePtr	pDrawable,
     }
 
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
-    exaDoMigration(pixmaps, 1, FALSE);
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     exaPrepareAccessGC (pGC);
 
@@ -1146,7 +1128,6 @@ fallback:
 	    return FALSE;
 	EXA_FALLBACK(("to %p (%c)\n", pDrawable,
 		      exaDrawableLocation(pDrawable)));
-	exaDoMigration (pixmaps, 1, FALSE);
 	exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
 	fbFillRegionSolid (pDrawable, pRegion, 0,
 			   fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
@@ -1262,7 +1243,6 @@ fallback:
     EXA_FALLBACK(("from %p to %p (%c,%c)\n", pTile, pDrawable,
 		  exaDrawableLocation(&pTile->drawable),
 		  exaDrawableLocation(pDrawable)));
-    exaDoMigration (pixmaps, 2, FALSE);
     exaPrepareAccess (pDrawable, EXA_PREPARE_DEST);
     exaPrepareAccess ((DrawablePtr)pTile, EXA_PREPARE_SRC);
     fbFillRegionTiled (pDrawable, pRegion, pTile);
@@ -1349,7 +1329,6 @@ exaGetImage (DrawablePtr pDrawable, int 
 	     unsigned int format, unsigned long planeMask, char *d)
 {
     ExaScreenPriv (pDrawable->pScreen);
-    ExaMigrationRec pixmaps[1];
     PixmapPtr pPix;
     int xoff, yoff;
     Bool ok;
@@ -1362,13 +1341,13 @@ exaGetImage (DrawablePtr pDrawable, int 
 
     /* Only cover the ZPixmap, solid copy case. */
     if (format != ZPixmap || !EXA_PM_IS_SOLID(pDrawable, planeMask))
-	goto migrate_and_fallback;
+	goto fallback;
 
     /* Only try to handle the 8bpp and up cases, since we don't want to think
      * about <8bpp.
      */
     if (pDrawable->bitsPerPixel < 8)
-	goto migrate_and_fallback;
+	goto fallback;
 
     pPix = exaGetOffscreenPixmap (pDrawable, &xoff, &yoff);
     if (pPix == NULL)
@@ -1384,29 +1363,6 @@ exaGetImage (DrawablePtr pDrawable, int 
 	return;
     }
 
-migrate_and_fallback:
-    pixmaps[0].as_dst = FALSE;
-    pixmaps[0].as_src = TRUE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
-    exaDoMigration (pixmaps, 1, FALSE);
 fallback:
     ExaCheckGetImage (pDrawable, x, y, w, h, format, planeMask, d);
 }
-
-/**
- * GetSpans isn't accelerated yet, but performs migration so that we'll
- * hopefully avoid the read-from-framebuffer cost.
- */
-void
-exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
-	     int nspans, char *pdstStart)
-{
-    ExaMigrationRec pixmaps[1];
-
-    pixmaps[0].as_dst = FALSE;
-    pixmaps[0].as_src = TRUE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDrawable);
-    exaDoMigration (pixmaps, 1, FALSE);
-
-    ExaCheckGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-}
diff --git a/exa/exa_migration.c b/exa/exa_migration.c
index 5f07a8d..661ff40 100644
--- a/exa/exa_migration.c
+++ b/exa/exa_migration.c
@@ -152,7 +152,7 @@ exaCopyDirtyToSys (PixmapPtr pPixmap)
 						+ pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
 						pExaPixmap->sys_pitch))
 	{
-	    exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+	    ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
 	    exaMemcpyBox (pPixmap, pBox,
 			  pExaPixmap->fb_ptr, pExaPixmap->fb_pitch,
 			  pExaPixmap->sys_ptr, pExaPixmap->sys_pitch);
@@ -220,7 +220,7 @@ exaCopyDirtyToFb (PixmapPtr pPixmap)
 					    + pBox->x1 * pPixmap->drawable.bitsPerPixel / 8,
 					    pExaPixmap->sys_pitch))
 	{
-	    exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST);
+	    ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_DEST);
 	    exaMemcpyBox (pPixmap, pBox,
 			  pExaPixmap->sys_ptr, pExaPixmap->sys_pitch,
 			  pExaPixmap->fb_ptr, pExaPixmap->fb_pitch);
@@ -471,7 +471,7 @@ exaAssertNotDirty (PixmapPtr pPixmap)
     src_pitch = pExaPixmap->fb_pitch;
     cpp = pPixmap->drawable.bitsPerPixel / 8;
 
-    exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
+    ExaDoPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
     while (nbox--) {
 	    int rowbytes;
 
@@ -622,14 +622,9 @@ exaDoMigration (ExaMigrationPtr pixmaps,
 	    exaMoveInPixmap(pixmaps[i].pPix);
 	}
 
-	/* If we couldn't fit everything in, then kick back out */
+	/* If we couldn't fit everything in, abort */
 	for (i = 0; i < npixmaps; i++) {
 	    if (!exaPixmapIsOffscreen(pixmaps[i].pPix)) {
-		EXA_FALLBACK(("Pixmap %p (%dx%d) not in fb\n", pixmaps[i].pPix,
-			      pixmaps[i].pPix->drawable.width,
-			      pixmaps[i].pPix->drawable.height));
-		for (j = 0; j < npixmaps; j++)
-		    exaMoveOutPixmap(pixmaps[j].pPix);
 		return;
 	    }
 	}
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a08acfa..409bc4d 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -298,10 +298,6 @@ void
 exaGetImage (DrawablePtr pDrawable, int x, int y, int w, int h,
 	     unsigned int format, unsigned long planeMask, char *d);
 
-void
-exaGetSpans (DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
-	     int nspans, char *pdstStart);
-
 extern const GCOps exaOps;
 
 #ifdef MITSHM
@@ -339,6 +335,9 @@ ExaOffscreenFini (ScreenPtr pScreen);
 
 /* exa.c */
 void
+ExaDoPrepareAccess(DrawablePtr pDrawable, int index);
+
+void
 exaPrepareAccess(DrawablePtr pDrawable, int index);
 
 void
diff --git a/exa/exa_render.c b/exa/exa_render.c
index 2dd3fc1..738ac15 100644
--- a/exa/exa_render.c
+++ b/exa/exa_render.c
@@ -738,7 +738,6 @@ fallback:
     exaPrintCompositeFallback (op, pSrc, pMask, pDst);
 #endif
 
-    exaDoMigration(pixmaps, npixmaps, FALSE);
     ExaCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc,
 		      xMask, yMask, xDst, yDst, width, height);
 
@@ -889,18 +888,13 @@ exaRasterizeTrapezoid (PicturePtr pPictu
 		       int x_off, int y_off)
 {
     DrawablePtr pDraw = pPicture->pDrawable;
-    ExaMigrationRec pixmaps[1];
+    PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
     int xoff, yoff;
 
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = TRUE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDraw);
-    exaDoMigration(pixmaps, 1, FALSE);
-
     exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
     fbRasterizeTrapezoid(pPicture, trap, x_off, y_off);
-    exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff);
-    exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff,
+    exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
+    exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
 		   pDraw->x + xoff + pDraw->width,
 		   pDraw->y + yoff + pDraw->height);
     exaFinishAccess(pDraw, EXA_PREPARE_DEST);
@@ -915,18 +909,13 @@ exaAddTriangles (PicturePtr pPicture, IN
 		 xTriangle *tris)
 {
     DrawablePtr pDraw = pPicture->pDrawable;
-    ExaMigrationRec pixmaps[1];
+    PixmapPtr pPixmap = exaGetDrawablePixmap(pDraw);
     int xoff, yoff;
 
-    pixmaps[0].as_dst = TRUE;
-    pixmaps[0].as_src = TRUE;
-    pixmaps[0].pPix = exaGetDrawablePixmap (pDraw);
-    exaDoMigration(pixmaps, 1, FALSE);
-
     exaPrepareAccess(pDraw, EXA_PREPARE_DEST);
     fbAddTriangles(pPicture, x_off, y_off, ntri, tris);
-    exaGetDrawableDeltas(pDraw, pixmaps[0].pPix, &xoff, &yoff);
-    exaPixmapDirty(pixmaps[0].pPix, pDraw->x + xoff, pDraw->y + yoff,
+    exaGetDrawableDeltas(pDraw, pPixmap, &xoff, &yoff);
+    exaPixmapDirty(pPixmap, pDraw->x + xoff, pDraw->y + yoff,
 		   pDraw->x + xoff + pDraw->width,
 		   pDraw->y + yoff + pDraw->height);
     exaFinishAccess(pDraw, EXA_PREPARE_DEST);
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index 8db2866..8dadd06 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -41,7 +41,7 @@ void
 exaPrepareAccessGC(GCPtr pGC)
 {
     if (pGC->stipple)
-        exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
+        exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_MASK);
     if (pGC->fillStyle == FillTiled)
 	exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
 }
@@ -53,7 +53,7 @@ void
 exaFinishAccessGC(GCPtr pGC)
 {
     if (pGC->fillStyle == FillTiled)
-	exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
+	exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_MASK);
     if (pGC->stipple)
         exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
 }
@@ -358,7 +358,6 @@ exaGetPixmapFirstPixel (PixmapPtr pPixma
     void *fb;
     Bool need_finish = FALSE;
     BoxRec box;
-    ExaMigrationRec pixmaps[1];
     ExaPixmapPriv (pPixmap);
 
     fb = pExaPixmap->sys_ptr;
@@ -368,10 +367,6 @@ exaGetPixmapFirstPixel (PixmapPtr pPixma
         miPointInRegion(DamageRegion(pExaPixmap->pDamage), 0, 0,  &box))
     {
 	need_finish = TRUE;
-	pixmaps[0].as_dst = FALSE;
-	pixmaps[0].as_src = TRUE;
-	pixmaps[0].pPix = pPixmap;
-	exaDoMigration (pixmaps, 1, FALSE);
 	exaPrepareAccess(&pPixmap->drawable, EXA_PREPARE_SRC);
 	fb = pPixmap->devPrivate.ptr;
     }
diff-tree e510a77ba4d65d5d6ead514cd698f1b1e3f8a2b6 (from 84eb7e62248ddc2761af8cefe33d1b7147477528)
Author: Dave Airlie <airlied at linux.ie>
Date:   Tue Jul 17 17:16:51 2007 +1000

    EXA: Add a couple of missing exaPrepare/FinishAccess calls.

diff --git a/exa/exa.c b/exa/exa.c
index 99707fa..46fb557 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -452,11 +452,9 @@ exaValidateGC (GCPtr pGC, unsigned long 
 	if (!pGC->tileIsPixel && FbEvenTile (pGC->tile.pixmap->drawable.width *
 					     pDrawable->bitsPerPixel))
 	{
-	    /* XXX This fixes corruption with tiled pixmaps, but may just be a
-	     * workaround for broken drivers
-	     */
-	    exaMoveOutPixmap(pGC->tile.pixmap);
+	    exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
 	    fbPadPixmap (pGC->tile.pixmap);
+	    exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
 	    exaPixmapDirty(pGC->tile.pixmap, 0, 0,
 			   pGC->tile.pixmap->drawable.width,
 			   pGC->tile.pixmap->drawable.height);
@@ -467,7 +465,9 @@ exaValidateGC (GCPtr pGC, unsigned long 
 	changes &= ~GCTile;
     }
 
+    exaPrepareAccessGC(pGC);
     fbValidateGC (pGC, changes, pDrawable);
+    exaFinishAccessGC(pGC);
 
     pGC->ops = (GCOps *) &exaOps;
 }
@@ -497,6 +497,47 @@ exaCreateGC (GCPtr pGC)
     return TRUE;
 }
 
+void
+exaPrepareAccessWindow(WindowPtr pWin)
+{
+    if (pWin->backgroundState == BackgroundPixmap) 
+        exaPrepareAccess(&pWin->background.pixmap->drawable, EXA_PREPARE_SRC);
+
+    if (pWin->borderIsPixel == FALSE)
+        exaPrepareAccess(&pWin->border.pixmap->drawable, EXA_PREPARE_SRC);
+}
+
+void
+exaFinishAccessWindow(WindowPtr pWin)
+{
+    if (pWin->backgroundState == BackgroundPixmap) 
+        exaFinishAccess(&pWin->background.pixmap->drawable, EXA_PREPARE_SRC);
+
+    if (pWin->borderIsPixel == FALSE)
+        exaFinishAccess(&pWin->border.pixmap->drawable, EXA_PREPARE_SRC);
+}
+
+static Bool
+exaChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+    Bool ret;
+
+    exaPrepareAccessWindow(pWin);
+    ret = fbChangeWindowAttributes(pWin, mask);
+    exaFinishAccessWindow(pWin);
+    return ret;
+}
+
+static RegionPtr
+exaBitmapToRegion(PixmapPtr pPix)
+{
+  RegionPtr ret;
+  exaPrepareAccess(&pPix->drawable, EXA_PREPARE_SRC);
+  ret = fbPixmapToRegion(pPix);
+  exaFinishAccess(&pPix->drawable, EXA_PREPARE_SRC);
+  return ret;
+}
+
 /**
  * exaCloseScreen() unwraps its wrapped screen functions and tears down EXA's
  * screen private, before calling down to the next CloseSccreen.
@@ -518,6 +559,8 @@ exaCloseScreen(int i, ScreenPtr pScreen)
     pScreen->CreatePixmap = pExaScr->SavedCreatePixmap;
     pScreen->DestroyPixmap = pExaScr->SavedDestroyPixmap;
     pScreen->CopyWindow = pExaScr->SavedCopyWindow;
+    pScreen->ChangeWindowAttributes = pExaScr->SavedChangeWindowAttributes;
+    pScreen->BitmapToRegion = pExaScr->SavedBitmapToRegion;
 #ifdef RENDER
     if (ps) {
 	ps->Composite = pExaScr->SavedComposite;
@@ -660,6 +703,12 @@ exaDriverInit (ScreenPtr		pScreen,
     pExaScr->SavedCopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = exaCopyWindow;
 
+    pExaScr->SavedChangeWindowAttributes = pScreen->ChangeWindowAttributes;
+    pScreen->ChangeWindowAttributes = exaChangeWindowAttributes;
+
+    pExaScr->SavedBitmapToRegion = pScreen->BitmapToRegion;
+    pScreen->BitmapToRegion = exaBitmapToRegion;
+
     pExaScr->SavedPaintWindowBackground = pScreen->PaintWindowBackground;
     pScreen->PaintWindowBackground = exaPaintWindow;
 
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a456da0..a08acfa 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -106,6 +106,8 @@ typedef struct {
     DestroyPixmapProcPtr 	 SavedDestroyPixmap;
     PaintWindowBorderProcPtr 	 SavedPaintWindowBorder;
     CopyWindowProcPtr 		 SavedCopyWindow;
+    ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
+    BitmapToRegionProcPtr        SavedBitmapToRegion;
 #ifdef RENDER
     CompositeProcPtr             SavedComposite;
     RasterizeTrapezoidProcPtr	 SavedRasterizeTrapezoid;
@@ -113,6 +115,7 @@ typedef struct {
     GlyphsProcPtr                SavedGlyphs;
     TrapezoidsProcPtr            SavedTrapezoids;
 #endif
+  
     Bool			 swappedOut;
     enum ExaMigrationHeuristic	 migration;
     Bool			 hideOffscreenPixmapData;
@@ -190,6 +193,12 @@ typedef struct _ExaMigrationRec {
   */
 void exaDDXDriverInit (ScreenPtr pScreen);
 
+void
+exaPrepareAccessWindow(WindowPtr pWin);
+
+void
+exaFinishAccessWindow(WindowPtr pWin);
+
 /* exa_unaccel.c */
 void
 exaPrepareAccessGC(GCPtr pGC);
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index d793ec2..8db2866 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -35,10 +35,13 @@
  *
  * Solid doesn't use an extra pixmap source, and Stippled/OpaqueStippled are
  * 1bpp and never in fb, so we don't worry about them.
+ * We should worry about them for completeness sake and going forward.
  */
 void
 exaPrepareAccessGC(GCPtr pGC)
 {
+    if (pGC->stipple)
+        exaPrepareAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
     if (pGC->fillStyle == FillTiled)
 	exaPrepareAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
 }
@@ -51,6 +54,8 @@ exaFinishAccessGC(GCPtr pGC)
 {
     if (pGC->fillStyle == FillTiled)
 	exaFinishAccess(&pGC->tile.pixmap->drawable, EXA_PREPARE_SRC);
+    if (pGC->stipple)
+        exaFinishAccess(&pGC->stipple->drawable, EXA_PREPARE_SRC);
 }
 
 #if DEBUG_TRACE_FALL
@@ -294,7 +299,9 @@ ExaCheckPaintWindow (WindowPtr pWin, Reg
     EXA_FALLBACK(("from %p (%c)\n", pWin,
 		  exaDrawableLocation(&pWin->drawable)));
     exaPrepareAccess (&pWin->drawable, EXA_PREPARE_DEST);
+    exaPrepareAccessWindow(pWin);
     fbPaintWindow (pWin, pRegion, what);
+    exaFinishAccessWindow(pWin);
     exaFinishAccess (&pWin->drawable, EXA_PREPARE_DEST);
 }
 
diff-tree 84eb7e62248ddc2761af8cefe33d1b7147477528 (from 35ec8b89f4cdf5ec48b292d47b2dad42d2fb9534)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Thu Sep 6 13:36:37 2007 +0100

    Fix Xdmx build

diff --git a/configure.ac b/configure.ac
index 1621a03..f02ad6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1153,7 +1153,7 @@ if test "x$DMX" = xyes; then
 	fi
 	DMX_INCLUDES="$XEXT_INC $RENDER_INC $XTRAP_INC $RECORD_INC"
 	XDMX_CFLAGS="$DMXMODULES_CFLAGS"
-	XDMX_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $RENDER_LIB $XTRAP_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $CWRAP_LIB"
+	XDMX_LIBS="$XEXT_LIB $FB_LIB $CONFIG_LIB $RENDER_LIB $XTRAP_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB"
 	XDMX_SYS_LIBS="$DMXMODULES_LIBS"
 	AC_SUBST([XDMX_CFLAGS])
 	AC_SUBST([XDMX_LIBS])
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index d644b5d..83f8a4a 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -105,3 +105,14 @@ void dmxUpdateWindowInfo(DMXUpdateType t
         if (!dmxInput->detached && dmxInput->updateWindowInfo)
             dmxInput->updateWindowInfo(dmxInput, type, pWindow);
 }
+
+int
+NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
+{
+    return BadRequest;
+}
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+}
diff-tree 35ec8b89f4cdf5ec48b292d47b2dad42d2fb9534 (from f3f614cd01ae56d84d61b4f5c907c6edd7c8c6d3)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Thu Sep 6 05:34:14 2007 -0700

    DDX changes for XDarwin
    
    Creating a real DDX section for XDarwin instead of
    stuffing it into the XORG section in a half-assed manner.

diff --git a/GL/Makefile.am b/GL/Makefile.am
index df9f533..38cef7b 100644
--- a/GL/Makefile.am
+++ b/GL/Makefile.am
@@ -1,8 +1,4 @@
-# someone could get really crazy someday and add support for the SI...
-
-# xwin/darwin/xfree86 have their accel support under the DDX
-
-if BUILD_DARWIN
+if XDARWIN
 DARWIN_SUBDIRS = apple
 endif
 SUBDIRS = glx mesa $(DARWIN_SUBDIRS)
diff --git a/configure.ac b/configure.ac
index 74a0aea..1621a03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -525,6 +525,7 @@ AC_ARG_ENABLE(xorg,    	      AS_HELP_ST
 AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
+AC_ARG_ENABLE(xdarwin, 	      AS_HELP_STRING([--enable-xdarwin], [Build XDarwin server (default: auto)]), [XDARWIN=$enableval], [XDARWIN=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
 AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
@@ -1309,64 +1310,6 @@ dnl has it in libc), or if libdl is need
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
-         darwin*)
-               XORG_OS="Darwin"
-               build_darwin=yes
-               if test "X$XQUARTZ" = Xauto; then
-                 AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
-                 save_LDFLAGS=$LDFLAGS
-                 LDFLAGS="$LDFLAGS -framework Carbon"
-                 AC_LINK_IFELSE([char FSFindFolder();
-int main() {
-FSFindFolder();
-return 0;}
-                 ],[xorg_cv_Carbon_framework=yes],
-                  [xorg_cv_Carbon_framework=no])
-                  LDFLAGS=$save_LDFLAGS])
-                 if test "X$xorg_cv_Carbon_framework" = Xyes; then
-                   AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
-                         [Have Quartz])
-                   XQUARTZ=yes
-                 else
-                   XQUARTZ=no
-                 fi
-               fi
-#	       glxAGL / glxCGL don't work yet
-#               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
-#               save_LDFLAGS=$LDFLAGS
-#               LDFLAGS="$LDFLAGS -framework AGL"
-#               AC_LINK_IFELSE([char aglEnable();
-#int main() {
-#aglEnable();
-#return 0;}
-#               ],[xorg_cv_AGL_framework=yes],
-#               [xorg_cv_AGL_framework=no])
-#               LDFLAGS=$save_LDFLAGS
-#               ])
-               xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
-	       AC_SUBST([DARWIN_LIBS])
-               AC_CHECK_LIB([Xplugin],[xp_init],[:])
-               AC_SUBST([APPLE_APPLICATIONS_DIR])
-               CFLAGS="${CFLAGS} -D__DARWIN__"
-               PLIST_VERSION_STRING=$PACKAGE_VERSION
-               AC_SUBST([PLIST_VERSION_STRING])
-               PLIST_VENDOR_WEB=$VENDOR_WEB
-               AC_SUBST([PLIST_VENDOR_WEB])
-               # Not sure that we should be disabling all these...
-               if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86Misc extension])
-                       XF86MISC=no
-               fi
-               if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
-                       AC_MSG_NOTICE([Disabling XF86VidMode extension])
-                       XF86VIDMODE=no
-               fi
-               if test "x$DGA" = xyes || test "x$DGA" = xauto; then
-                       AC_MSG_NOTICE([Disabling DGA extension])
-                       DGA=no
-               fi
-               ;;
 	  linux*)
 		if test "x$LNXAPM" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
@@ -1600,8 +1543,6 @@ AM_CONDITIONAL([LINUX_ALPHA], [test "x$l
 AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
 AM_CONDITIONAL([SOLARIS_USL_CONSOLE], [test "x$solaris_usl_console" = xyes])
 AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
-AM_CONDITIONAL([BUILD_DARWIN],[test "X$build_darwin" = Xyes])
-AM_CONDITIONAL([XQUARTZ],[test "X$XQUARTZ" = Xyes])
 AM_CONDITIONAL(DGA, [test "x$DGA" = xyes])
 
 dnl legacy fb support
@@ -1743,10 +1684,73 @@ AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
 
 dnl Darwin / OS X DDX
-AM_CONDITIONAL(HAVE_X_PLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
-AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
-# Support for objc in autotools is minimal and not
-# documented.
+AC_MSG_CHECKING([whether to build XDarwin (Mac OS X) DDX])
+if test "x$XDARWIN" = xauto; then
+	case $host_os in
+		darwin*) XDARWIN="yes" ;;
+		*) XWIN="no" ;;
+	esac
+	XWIN_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $SHADOW_LIB"
+	AC_SUBST([XWIN_LIBS])
+fi
+AC_MSG_RESULT([$XDARWIN])
+
+if test "x$XDARWIN" = xyes; then
+        if test "X$XQUARTZ" = Xauto; then
+                 AC_CACHE_CHECK([for Carbon framework],xorg_cv_Carbon_framework,[
+                 save_LDFLAGS=$LDFLAGS
+                 LDFLAGS="$LDFLAGS -framework Carbon"
+                 AC_LINK_IFELSE([char FSFindFolder();
+int main() {
+FSFindFolder();
+return 0;}
+                 ],[xorg_cv_Carbon_framework=yes],
+                  [xorg_cv_Carbon_framework=no])
+                  LDFLAGS=$save_LDFLAGS])
+                 if test "X$xorg_cv_Carbon_framework" = Xyes; then
+                   AC_DEFINE([DARWIN_WITH_QUARTZ],[1],
+                         [Have Quartz])
+                   XQUARTZ=yes
+                 else
+                   XQUARTZ=no
+                 fi
+               fi
+#	       glxAGL / glxCGL don't work yet
+#               AC_CACHE_CHECK([for AGL framework],xorg_cv_AGL_framework,[
+#               save_LDFLAGS=$LDFLAGS
+#               LDFLAGS="$LDFLAGS -framework AGL"
+#               AC_LINK_IFELSE([char aglEnable();
+#int main() {
+#aglEnable();
+#return 0;}
+#               ],[xorg_cv_AGL_framework=yes],
+#               [xorg_cv_AGL_framework=no])
+#               LDFLAGS=$save_LDFLAGS
+#               ])
+               xorg_cv_AGL_framework=no
+	       DARWIN_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+	       AC_SUBST([DARWIN_LIBS])
+               AC_CHECK_LIB([Xplugin],[xp_init],[:])
+               AC_SUBST([APPLE_APPLICATIONS_DIR])
+               CFLAGS="${CFLAGS} -D__DARWIN__"
+               PLIST_VERSION_STRING=$PACKAGE_VERSION
+               AC_SUBST([PLIST_VERSION_STRING])
+               PLIST_VENDOR_WEB=$VENDOR_WEB
+               AC_SUBST([PLIST_VENDOR_WEB])
+               if test "x$XF86MISC" = xyes || test "x$XF86MISC" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86Misc extension])
+                       XF86MISC=no
+               fi
+               if test "x$XF86VIDMODE" = xyes || test "x$XF86VIDMODE" = xauto; then
+                       AC_MSG_NOTICE([Disabling XF86VidMode extension])
+                       XF86VIDMODE=no
+               fi
+               if test "x$DGA" = xyes || test "x$DGA" = xauto; then
+                       AC_MSG_NOTICE([Disabling DGA extension])
+                       DGA=no
+               fi
+fi
+# Support for objc in autotools is minimal and not documented.
 OBJC='$(CC)'
 OBJCLD='$(CCLD)'
 OBJCLINK='$(LINK)'
@@ -1757,7 +1761,10 @@ AC_SUBST([OBJCLINK])
 AC_SUBST([OBJCFLAGS])
 # internal, undocumented automake func follows :(
 _AM_DEPENDENCIES([OBJC])
-
+AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
+AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
+AM_CONDITIONAL(XDARWIN, [test "x$XDARWIN" = xyes])
+AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
 dnl kdrive DDX
 
 XEPHYR_LIBS=
diff --git a/hw/Makefile.am b/hw/Makefile.am
index 99df8e2..30662cc 100644
--- a/hw/Makefile.am
+++ b/hw/Makefile.am
@@ -1,5 +1,5 @@
 if DMX
-if BUILD_DARWIN
+if XDARWIN
 # Darwin does not need the dmx subdir
 else
 DMX_SUBDIRS = dmx
@@ -7,12 +7,8 @@ endif
 endif
 
 if XORG
-if BUILD_DARWIN
-# Darwin does not need the xfree86 subdir
-else
 XORG_SUBDIRS = xfree86
 endif
-endif
 
 if XVFB
 XVFB_SUBDIRS = vfb
@@ -38,15 +34,15 @@ if XPRINT
 XPRINT_SUBDIRS = xprint
 endif
 
-if BUILD_DARWIN
-DARWIN_SUBDIRS = darwin
+if XDARWIN
+XDARWIN_SUBDIRS = darwin
 endif
 
 SUBDIRS =			\
 	$(XORG_SUBDIRS)		\
 	$(XGL_SUBDIRS)		\
 	$(XWIN_SUBDIRS)		\
-	$(DARWIN_SUBDIRS)	\
+	$(XDARWIN_SUBDIRS)	\
 	$(XVFB_SUBDIRS)		\
 	$(XNEST_SUBDIRS)	\
 	$(DMX_SUBDIRS)          \
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 4cec3b1..a6f84ee 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -191,7 +191,7 @@ glxMesa_la_DEPENDENCIES = XDarwinApp	
 endif
 
 endif
-if HAVE_X_PLUGIN
+if HAVE_XPLUGIN
 
 xprplugindir = $(darwinappdir)/Contents/Resources/xpr.bundle/Contents/MacOS
 xprplugin_LTLIBRARIES = xpr.la
diff --git a/hw/darwin/quartz/Makefile.am b/hw/darwin/quartz/Makefile.am
index 993cdb0..f8dc167 100644
--- a/hw/darwin/quartz/Makefile.am
+++ b/hw/darwin/quartz/Makefile.am
@@ -5,7 +5,7 @@ AM_OBJCFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS
 
 INCLUDES = -I$(srcdir) -I$(srcdir)/.. @XORG_INCS@
 AM_DEFS = -DHAS_CG_MACH_PORT -DHAS_KL_API
-if HAVE_X_PLUGIN
+if HAVE_XPLUGIN
 AM_DEFS += -DBUILD_XPR
 endif
 DEFS = @DEFS@ $(AM_DEFS) -DXBINDIR=\"${bindir}\"
diff-tree f3f614cd01ae56d84d61b4f5c907c6edd7c8c6d3 (from bf1641b94cffa54b786e18eaeff3839d8790b9f2)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 5 20:34:00 2007 -0700

    Revert "configure.ac: exclude pci-access dependency from XDarwin"
    
    This reverts commit 20c6677d1b5f8d77325dd878ffa3df1d0fb01864.

diff --git a/configure.ac b/configure.ac
index 0d35d81..74a0aea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1304,6 +1304,8 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
 
+	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
@@ -1501,12 +1503,6 @@ return 0;}
 		;;
 	esac
 
-        if ! test "$XORG_OS" = "Darwin" ; then
-               PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
-               XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS"
-               XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
-        fi
-
 	if test "x$XORG_OS_PCI" = x ; then
 		XORG_OS_PCI=$XORG_OS
 	fi
diff-tree bf1641b94cffa54b786e18eaeff3839d8790b9f2 (from 71c21dea748ea0dcad758679c40ee39192d170f9)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 5 20:33:43 2007 -0700

    XDARWIN: Add launchd support
    
    This adds a bit of glue to configure.ac to support launchd detection;
    on OS X (or other platforms which choose to implement launchd), this allows
    the system to automagically start the Xserver as necessary to serve clients.

diff --git a/configure.ac b/configure.ac
index 44dbda4..0d35d81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1075,6 +1075,10 @@ XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${
 AC_SUBST([XSERVER_LIBS])
 AC_SUBST([XSERVER_SYS_LIBS])
 
+if test "x$HAVE_LAUNCHD" = xyes; then
+   XSERVER_CFLAGS="$XSERVER_CFLAGS -DHAVE_LAUNCHD"
+fi
+
 # The Xorg binary needs to export symbols so that they can be used from modules
 # Some platforms require extra flags to do this.   gcc should set these flags
 # when -rdynamic is passed to it, other compilers/linkers may need to be added
diff --git a/os/connection.c b/os/connection.c
index d975f87..d1bc4d0 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -74,6 +74,9 @@ SOFTWARE.
 #define TRANS_SERVER
 #define TRANS_REOPEN
 #include <X11/Xtrans/Xtrans.h>
+#ifdef HAVE_LAUNCHD
+#include <X11/Xtrans/Xtransint.h>
+#endif
 #include <errno.h>
 #include <signal.h>
 #include <stdio.h>
@@ -660,10 +663,21 @@ ClientAuthorized(ClientPtr client, 
     XID	 		auth_id;
     char	 	*reason = NULL;
     XtransConnInfo	trans_conn;
+#ifdef HAVE_LAUNCHD
+    struct sockaddr     *saddr;
+#endif
 
     priv = (OsCommPtr)client->osPrivate;
     trans_conn = priv->trans_conn;
 
+#ifdef HAVE_LAUNCHD
+    saddr = (struct sockaddr *) (trans_conn->addr);
+    /* Allow any client to connect without authorization on a launchd socket,
+       because it is securely created -- this prevents a race condition on launch */
+    if (saddr->sa_len > 11 && saddr->sa_family == AF_UNIX &&
+        !strncmp(saddr->sa_data, "/tmp/launch", 11)) goto done;
+#endif
+
     auth_id = CheckAuthorization (proto_n, auth_proto,
 				  string_n, auth_string, client, &reason);
 
@@ -719,6 +733,7 @@ ClientAuthorized(ClientPtr client, 
 	}
     }
     priv->auth_id = auth_id;
+ done:
     priv->conn_time = 0;
 
 #ifdef XDMCP
diff-tree 71c21dea748ea0dcad758679c40ee39192d170f9 (from 81c28ffd2b13a83770eadcfd7829d35d319d637f)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 18:45:50 2007 -0700

    added HAVE_LAUNCHD check to configure.ac (mostly for OSX)

diff --git a/configure.ac b/configure.ac
index 9c3ee99..44dbda4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,8 @@ AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
 
+AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
diff-tree 81c28ffd2b13a83770eadcfd7829d35d319d637f (from e332335241af28ef0ab66b102d0cbc4e5c73ac68)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Sep 5 17:46:23 2007 -0700

    Fix key repeats during VT switch.
    
    Add keyc->postdown, which represents the key state as of the last mieqEnqueue
    call, and use it when we need to know the posted state, instead of the
    processed state (keyc->down).  Add small functions to getevents.c to query and
    modify key state in postdown and use them all through, eliminating previously
    broken uses.

diff --git a/dix/devices.c b/dix/devices.c
index 923bc0d..9f3c576 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -868,6 +868,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr de
     else
 	bzero((char *)keyc->modifierMap, MAP_LENGTH);
     bzero((char *)keyc->down, DOWN_LENGTH);
+    bzero((char *)keyc->postdown, DOWN_LENGTH);
     for (i = 0; i < 8; i++)
 	keyc->modifierKeyCount[i] = 0;
     if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc))
diff --git a/dix/getevents.c b/dix/getevents.c
index 6899303..738bd36 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -80,6 +80,23 @@ GetMotionHistorySize(void)
     return MOTION_HISTORY_SIZE;
 }
 
+static void
+set_key_down(DeviceIntPtr pDev, int key_code)
+{
+    pDev->key->postdown[key_code >> 3] |= (1 << (key_code & 7));
+}
+
+static void
+set_key_up(DeviceIntPtr pDev, int key_code)
+{
+    pDev->key->postdown[key_code >> 3] &= ~(1 << (key_code & 7));
+}
+
+static Bool
+key_is_down(DeviceIntPtr pDev, int key_code)
+{
+    return pDev->key->postdown[key_code >> 3] >> (key_code & 7);
+}
 
 /**
  * Allocate the motion history buffer.
@@ -414,17 +431,15 @@ GetKeyboardValuatorEvents(xEvent *events
             case XK_Shift_Lock:
                 if (type == KeyRelease)
                     return 0;
-                else if (type == KeyPress &&
-                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-                        type = KeyRelease;
+                else if (type == KeyPress && key_is_down(pDev, key_code))
+                    type = KeyRelease;
         }
     }
 
     /* Handle core repeating, via press/release/press/release.
      * FIXME: In theory, if you're repeating with two keyboards in non-XKB,
      *        you could get unbalanced events here. */
-    if (type == KeyPress &&
-        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
+    if (type == KeyPress && key_is_down(pDev, key_code)) {
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
             pDev->key->modifierMap[key_code] ||
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
@@ -449,6 +464,10 @@ GetKeyboardValuatorEvents(xEvent *events
         events->u.keyButtonPointer.time = ms;
         events->u.u.type = type;
         events->u.u.detail = key_code;
+        if (type == KeyPress)
+	    set_key_down(inputInfo.keyboard, key_code);
+        else if (type == KeyRelease)
+	    set_key_up(inputInfo.keyboard, key_code);
         events++;
     }
 
@@ -456,10 +475,14 @@ GetKeyboardValuatorEvents(xEvent *events
     kbp->time = ms;
     kbp->deviceid = pDev->id;
     kbp->detail = key_code;
-    if (type == KeyPress)
+    if (type == KeyPress) {
         kbp->type = DeviceKeyPress;
-    else if (type == KeyRelease)
+	set_key_down(pDev, key_code);
+    }
+    else if (type == KeyRelease) {
         kbp->type = DeviceKeyRelease;
+	set_key_up(pDev, key_code);
+    }
 
     events++;
     if (num_valuators) {
diff --git a/hw/xfree86/common/atKeynames.h b/hw/xfree86/common/atKeynames.h
index f31f533..85f13ac 100644
--- a/hw/xfree86/common/atKeynames.h
+++ b/hw/xfree86/common/atKeynames.h
@@ -66,7 +66,7 @@
 #define KanaMask	Mod4Mask
 #define ScrollLockMask	Mod5Mask
 
-#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define KeyPressed(k) (keyc->postdown[k >> 3] & (1 << (k & 7)))
 #define ModifierDown(k) ((keyc->state & (k)) == (k))
 
 /*
diff --git a/include/inputstr.h b/include/inputstr.h
index 3398949..d0cc858 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -122,6 +122,7 @@ typedef struct _GrabRec {
 
 typedef struct _KeyClassRec {
     CARD8		down[DOWN_LENGTH];
+    CARD8		postdown[DOWN_LENGTH];
     KeyCode 		*modifierKeyMap;
     KeySymsRec		curKeySyms;
     int			modifierKeyCount[8];
diff-tree e332335241af28ef0ab66b102d0cbc4e5c73ac68 (from parents)
Merge: 7381e9149e3cbb7e672070781a16e3f096202be9 accd71bda6f958ea6892ad3a10879232d345774c
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 15:51:23 2007 -0700

    Merge branch 'master' of ssh://git.freedesktop.org/git/xorg/xserver

diff-tree 7381e9149e3cbb7e672070781a16e3f096202be9 (from 8b77dc7e808f61f1ed10fe05cf898bb47459a76d)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 15:51:11 2007 -0700

    added an exclusion for setting XORG on darwin

diff --git a/configure.ac b/configure.ac
index cba9d31..9c3ee99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1220,6 +1220,7 @@ if test "x$XORG" = xauto; then
 	XORG="yes"
 	case $host_os in
 		cygwin*) XORG="no" ;;
+		darwin*) XORG="no" ;;
 	esac
 fi
 AC_MSG_RESULT([$XORG])
diff-tree accd71bda6f958ea6892ad3a10879232d345774c (from 8b77dc7e808f61f1ed10fe05cf898bb47459a76d)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Wed Sep 5 14:19:19 2007 -0700

    Deliver correct event when releasing keys on VT switch.
    
    In commit 41bb9fce47f6366cc3f7d45790f7883f74289b5a, the event delivery loop
    for Xinput enabled keyboards was changed and accidentally used the wrong
    index variable, causing random events to be delivered when returning from VT
    switch.
    
    In addition, in commit aeba855b07832354f59678e20cc29a085e42bd99,
    SIGIO was blocked during delivery of these events, but not for the entire
    period the xf86Events array was being used. Block SIGIO for the whole loop
    to avoid other event delivery from trashing the key release events.
    (cherry picked from commit aa7ed1f5f35cd043bc38d985500aa0a32e857e84)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index dd9c34e..91964c9 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -811,9 +811,11 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
                     (*pDev->public.processInputProc) (&ke, pDev, 1);
                 }
                 else {
+		    int sigstate = xf86BlockSIGIO ();
                     nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
                     for (j = 0; j < nevents; j++)
-                        EqEnqueue(pDev, xf86Events + i);
+                        mieqEnqueue(pDev, xf86Events + j);
+		    xf86UnblockSIGIO(sigstate);
                 }
                 break;
             }
diff-tree 8b77dc7e808f61f1ed10fe05cf898bb47459a76d (from 20c6677d1b5f8d77325dd878ffa3df1d0fb01864)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 14:48:38 2007 -0700

    XDARWIN: build breakage fix

diff --git a/hw/darwin/darwin.c b/hw/darwin/darwin.c
index 7b48368..4e34954 100644
--- a/hw/darwin/darwin.c
+++ b/hw/darwin/darwin.c
@@ -156,7 +156,7 @@ DarwinPrintBanner()
 #endif
   ErrorF("\nRelease Date: %s\n", XF86_DATE);
   ErrorF("X Protocol Version %d, Revision %d, %s\n",
-         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_VERSION_CURRENT );
   ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR);
 #ifdef HAS_UTSNAME
   {
diff-tree 20c6677d1b5f8d77325dd878ffa3df1d0fb01864 (from ff01e44e33fd072958fb0157dae072f1b1c88944)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 14:31:01 2007 -0700

    configure.ac: exclude pci-access dependency from XDarwin
    
    XDarwin doesn't need any of this pci stuff since it doesn't talk directly to hardware,
    so it doesn't make sense to require it when building on OSX/Darwin.

diff --git a/configure.ac b/configure.ac
index fab5cf3..cba9d31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1297,8 +1297,6 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
 
-	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
-	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
@@ -1496,6 +1494,12 @@ return 0;}
 		;;
 	esac
 
+        if ! test "$XORG_OS" = "Darwin" ; then
+               PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+               XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS"
+               XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+        fi
+
 	if test "x$XORG_OS_PCI" = x ; then
 		XORG_OS_PCI=$XORG_OS
 	fi
diff-tree ff01e44e33fd072958fb0157dae072f1b1c88944 (from parents)
Merge: 8ba8c16af773ec83a0b1c0661a23d746b401944e 47300ed2be59d0ba7ea9345b954bf3104877c095
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 13:56:08 2007 -0700

    Merge branch 'master' of ssh://git.freedesktop.org/git/xorg/xserver

diff-tree 8ba8c16af773ec83a0b1c0661a23d746b401944e (from 28e48cd8e6e4c412a49d7177daad6d3c93c28e08)
Author: Ben Byer <bbyer at bbyer.apple.com>
Date:   Wed Sep 5 13:46:30 2007 -0700

    build fixes for XDarwin

diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index 00811e7..4cec3b1 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -90,6 +90,7 @@ Xquartz_LDFLAGS =  \
                  -Wl,-u,_miDCInitialize \
                  -Wl,-framework,Carbon \
                  -Wl,-framework,OpenGL \
+		 -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib \
                  -Wl,-framework,Cocoa \
                  -Wl,-framework,CoreAudio \
                  -Wl,-framework,IOKit
@@ -115,7 +116,6 @@ XDarwinApp_SOURCES = \
 
 XDARWINAPP_LIBS = \
 	$(DARWIN_LIBS) \
-	$(top_builddir)/dix/dixfonts.lo \
 	./quartz/XApplication.o \
 	./libdarwinShared.a \
 	./quartz/libXQuartz.a \
@@ -152,6 +152,7 @@ cr_la_LIBADD = \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la
 
 cr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
+		-lpixman-1 \
 		-Wl,-framework,Cocoa \
 		-Wl,-framework,Carbon \
 		-XCClinker -ObjC \
@@ -211,6 +212,7 @@ xpr_la_LIBADD = \
 		$(top_builddir)/miext/rootless/accel/librlAccel.la
 
 xpr_la_LDFLAGS = -shrext '' -Wl,-framework,ApplicationServices \
+		-lpixman-1 \
 		-lXplugin \
 		-XCClinker -bundle_loader -XCClinker XDarwinApp \
 		-module -avoid-version -no-undefined
diff-tree 47300ed2be59d0ba7ea9345b954bf3104877c095 (from 6c89d1237c4fdce961b30a8eaee964af5d56565e)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Sep 5 12:34:29 2007 -0700

    Fix server version reporting to be the server package version.
    
    Previously, the server version reported by xdpyinfo and Xorg -version would
    bear some vague resemblance to a X.Org katamari version, but in the presence
    of modularization (and client-server relationships with different katamari
    versions on each side) those numbers don't really make sense.  Instead, just
    report the package version.
    
    When branching a stable branch, master's version should be immediately updated
    to the endpoint of the stable branch plus a snapshot of 1 (for example,
    1.4.0.1 after server-1.4-branch).  The stable branch should then be changed to
    RC0 at that time (1.3.99.0, for example).
    
    This scheme was partially attempted for server 1.3, but lacked the appropriate
    master updates, thus why it had to be revisited now.  While here, we can also
    remove a lot of versioning complexity since everything is based on the package
    version.

diff --git a/configure.ac b/configure.ac
index c909c1d..fab5cf3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-dnl This is the not the Xorg version number, it's the server version number.
-dnl Yes, that's weird.
-AC_INIT([xorg-server], 1.3.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.4.0.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
@@ -374,14 +372,22 @@ case $host_os in
 esac
 AM_CONDITIONAL(KDRIVE_HW, test "x$KDRIVE_HW" = xyes)
 
-DEFAULT_VENDOR_NAME="The X.Org Foundation"
-DEFAULT_VENDOR_NAME_SHORT="X.Org"
-DEFAULT_VERSION_MAJOR=7
-DEFAULT_VERSION_MINOR=2
-DEFAULT_VERSION_PATCH=0
-DEFAULT_VERSION_SNAP=0
-DEFAULT_RELEASE_DATE="21 December 2005"
-DEFAULT_VENDOR_WEB="http://wiki.x.org"
+XORG_RELEASE_VERSION
+dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
+dnl major number
+PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
+PVS=`echo $PACKAGE_VERSION | cut -d . -f 4`
+if test "x$PVS" = "x"; then
+	PVS="0"
+fi
+
+VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + $PVS)"
+VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"
+
+VENDOR_NAME="The X.Org Foundation"
+VENDOR_NAME_SHORT="X.Org"
+RELEASE_DATE="5 September 2007"
+VENDOR_WEB="http://wiki.x.org"
 
 m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
 
@@ -397,36 +403,13 @@ AC_ARG_WITH(int10,           AS_HELP_STR
 				[INT10="$DEFAULT_INT10"])
 AC_ARG_WITH(vendor-name,     AS_HELP_STRING([--with-vendor-name=VENDOR],
 				  [Vendor string reported by the server]),
-			     	[ VENDOR_STRING="$withval" ],
-			     	[ VENDOR_STRING="$DEFAULT_VENDOR_NAME" ])
+				[ VENDOR_NAME="$withval" ], [])
 AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
 				  [Short version of vendor string reported by the server]),
-			     	[ VENDOR_STRING_SHORT="$withval" ],
-			     	[ VENDOR_STRING_SHORT="$DEFAULT_VENDOR_NAME_SHORT" ])
-AC_ARG_WITH(release-major,   AS_HELP_STRING([--with-release-major=MAJOR],
-				  [Release major number reported by the server]),
-				[ VERSION_MAJOR="$withval" ],
-				[ VERSION_MAJOR="$DEFAULT_VERSION_MAJOR" ])
-AC_ARG_WITH(release-minor,   AS_HELP_STRING([--with-release-minor=MINOR],
-				  [Release minor number reported by the server]),
-				[ VERSION_MINOR="$withval" ],
-				[ VERSION_MINOR="$DEFAULT_VERSION_MINOR" ])
-AC_ARG_WITH(release-patch,   AS_HELP_STRING([--with-release-patch=PATCH],
-				  [Release patch number reported by the server]),
-				[ VERSION_PATCH="$withval" ],
-				[ VERSION_PATCH="$DEFAULT_VERSION_PATCH" ])
-AC_ARG_WITH(release-snap,    AS_HELP_STRING([--with-release-snap=SNAP],
-				  [Release snap number reported by the server]),
-				[ VERSION_SNAP="$withval" ],
-				[ VERSION_SNAP="$DEFAULT_VERSION_SNAP" ])
-AC_ARG_WITH(release-date,    AS_HELP_STRING([--with-release-date=DATE],
-				  [Release date reported by the server]),
-				[ RELEASE_DATE="$withval" ],
-				[ RELEASE_DATE="$DEFAULT_RELEASE_DATE" ])
+				[ VENDOR_NAME_SHORT="$withval" ], [])
 AC_ARG_WITH(vendor-web,      AS_HELP_STRING([--with-vendor-web=URL],
 				  [Vendor web address reported by the server]),
-				[ VENDOR_WEB="$withval" ],
-				[ VENDOR_WEB="$DEFAULT_VENDOR_WEB" ])
+				[ VENDOR_WEB="$withval" ], [])
 AC_ARG_WITH(module-dir,      AS_HELP_STRING([--with-module-dir=DIR],
 				  [Directory where modules are installed (default: $libdir/xorg/modules)]),
 				[ moduledir="$withval" ],
@@ -1004,29 +987,13 @@ if test "x$USE_RGB_BUILTIN" = xyes; then
 	AC_DEFINE(USE_RGB_BUILTIN, 1, [Use built-in RGB color database])
 fi
 
-VENDOR_RELEASE="((($VERSION_MAJOR) * 10000000) + (($VERSION_MINOR) * 100000) + (($VERSION_PATCH) * 1000) + $VERSION_SNAP)"
-
-if test $VERSION_SNAP = "0"; then
-	if test $VERSION_PATCH = "0"; then
-		VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}"
-	else
-		VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
-	fi
-else
-	VENDOR_VERSION_STRING="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_SNAP}"
-fi
-
-VENDOR_RELEASE_STRING="Release ${VENDOR_VERSION_STRING}"
-VENDOR_MAN_VERSION="Version ${VENDOR_VERSION_STRING}"
-
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
 AC_DEFINE_DIR(RGB_DB, RGBPATH, [Default RGB path])
 AC_DEFINE_DIR(SERVERCONFIGdir, SERVERCONFIG, [Server config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
 AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
-AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name])
-AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_STRING_SHORT"], [Short vendor name])
-AC_DEFINE_UNQUOTED(XORG_RELEASE, ["$VENDOR_RELEASE_STRING"], [Vendor release])
+AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
+AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
 AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
 AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
 AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
@@ -1039,8 +1006,8 @@ AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], 
 AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
 AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
 
-AC_SUBST([VENDOR_STRING])
-AC_SUBST([VENDOR_STRING_SHORT])
+AC_SUBST([VENDOR_NAME])
+AC_SUBST([VENDOR_NAME_SHORT])
 AC_SUBST([VENDOR_RELEASE])
 AC_SUBST([VENDOR_MAN_VERSION])
 
@@ -1375,7 +1342,7 @@ return 0;}
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
                CFLAGS="${CFLAGS} -D__DARWIN__"
-               PLIST_VERSION_STRING=$VENDOR_VERSION_STRING
+               PLIST_VERSION_STRING=$PACKAGE_VERSION
                AC_SUBST([PLIST_VERSION_STRING])
                PLIST_VENDOR_WEB=$VENDOR_WEB
                AC_SUBST([PLIST_VENDOR_WEB])
@@ -2007,9 +1974,6 @@ AC_SUBST([libdir exec_prefix prefix])
 # Man page sections - used in config utils & generating man pages
 XORG_MANPAGE_SECTIONS
 
-# XORG in this case refers to the roll-up releases, not the Xorg DDX.
-XORG_RELEASE_VERSION
-
 AC_OUTPUT([
 Makefile
 GL/Makefile
diff --git a/dix/Makefile.am b/dix/Makefile.am
index 3c92a4a..28c2d8b 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libdix.la libxpstubs.la
 
 AM_CFLAGS = $(DIX_CFLAGS) \
-	-DVENDOR_STRING=\""@VENDOR_STRING@"\" \
+	-DVENDOR_NAME=\""@VENDOR_NAME@"\" \
 	-DVENDOR_RELEASE="@VENDOR_RELEASE@"
 
 libdix_la_SOURCES = 	\
diff --git a/dix/main.c b/dix/main.c
index 9fe822b..31e291b 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -509,7 +509,7 @@ main(int argc, char *argv[], char *envp[
 }
 
 static int  VendorRelease = VENDOR_RELEASE;
-static char *VendorString = VENDOR_STRING;
+static char *VendorString = VENDOR_NAME;
 
 void
 SetVendorRelease(int release)
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 72f7150..2f1651c 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1821,7 +1821,7 @@ xf86PrintBanner()
     "latest version in the X.Org Foundation git repository.\n"
     "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
 #endif
-  ErrorF("\nX Window System Version %d.%d.%d",
+  ErrorF("\nX.Org X Server %d.%d.%d",
 	 XORG_VERSION_MAJOR,
 	 XORG_VERSION_MINOR,
 	 XORG_VERSION_PATCH);
@@ -1855,8 +1855,8 @@ xf86PrintBanner()
 #define XORG_DATE XF86_DATE
 #endif
   ErrorF("\nRelease Date: %s\n", XORG_DATE);
-  ErrorF("X Protocol Version %d, Revision %d, %s\n",
-         X_PROTOCOL, X_PROTOCOL_REVISION, XORG_RELEASE );
+  ErrorF("X Protocol Version %d, Revision %d\n",
+         X_PROTOCOL, X_PROTOCOL_REVISION);
   ErrorF("Build Operating System: %s %s\n", OSNAME, OSVENDOR);
 #ifdef HAS_UTSNAME
   {
diff-tree 6c89d1237c4fdce961b30a8eaee964af5d56565e (from 28e48cd8e6e4c412a49d7177daad6d3c93c28e08)
Author: Dodji Seketeli <dodji at openedhand.com>
Date:   Wed Sep 5 17:46:49 2007 +0200

    Kdrive: unbreak kdrive linking
    
            * configure.ac: re-sort Kdrive libs so that symbols get properly resolved.
              Basically, all some libs are present in both $KDRIVE_LIBS and $XSERVER_LIBS,
              and some libs orders are not correct. So I made sure Kdrive servers don't have
              to link against $KDRIVE_LIBS  *and* $XSERVER_LIBS. They just have to link
              against $KDRIVE_LIBS now.
            * hw/kdrive/*/Makefile.am: update those makefile to reflect the change in configure.ac

diff --git a/configure.ac b/configure.ac
index a5bdfb4..c909c1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1868,7 +1868,7 @@ if test "$KDRIVE" = yes; then
     
     KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
 
-    KDRIVE_PURE_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
+    KDRIVE_PURE_LIBS="$FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
     case $host_os in
 	*linux*)
@@ -1877,8 +1877,10 @@ if test "$KDRIVE" = yes; then
 	    ;;
     esac
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
-    KDRIVE_LOCAL_LIBS="$DIX_LIB $CONFIG_LIB $KDRIVE_LIB $TSLIB_LIBS $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
-    KDRIVE_LIBS="$XSERVERLIBS_LIBS $KDRIVE_LOCAL_LIBS"
+    KDRIVE_LOCAL_LIBS="$TSLIB_LIBS $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
+    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
+    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
+    KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVERLIBS_LIBS"
 
     # check if we can build Xephyr
     PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
diff --git a/hw/kdrive/ati/Makefile.am b/hw/kdrive/ati/Makefile.am
index 9e1fc7f..8429250 100644
--- a/hw/kdrive/ati/Makefile.am
+++ b/hw/kdrive/ati/Makefile.am
@@ -60,8 +60,7 @@ ATI_LIBS =				\
 
 Xati_LDADD = \
 	$(ATI_LIBS)			\
-	@KDRIVE_LIBS@			\
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xati_DEPENDENCIES =	\
 	libati.a 			\
diff --git a/hw/kdrive/chips/Makefile.am b/hw/kdrive/chips/Makefile.am
index 8188a8e..51b0edf 100644
--- a/hw/kdrive/chips/Makefile.am
+++ b/hw/kdrive/chips/Makefile.am
@@ -22,8 +22,7 @@ CHIPS_LIBS =					 \
 
 Xchips_LDADD = \
 	$(CHIPS_LIBS)				\
-	@KDRIVE_LIBS@                           \
-	@XSERVER_LIBS@				
+	@KDRIVE_LIBS@
 
 Xchips_DEPENDENCIES = 	\
 	libchips.a 				 \
diff --git a/hw/kdrive/epson/Makefile.am b/hw/kdrive/epson/Makefile.am
index cd20571..2a44014 100644
--- a/hw/kdrive/epson/Makefile.am
+++ b/hw/kdrive/epson/Makefile.am
@@ -22,8 +22,7 @@ EPSON_LIBS =					\
 
 Xepson_LDADD = \
 	$(EPSON_LIBS)			       \
-	@KDRIVE_LIBS@                          \
-	@XSERVER_LIBS@				
+	@KDRIVE_LIBS@
 
 Xepson_DEPENDENCIES =	\
 	libepson.a 				\
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index ea2aff3..1ce4833 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -16,8 +16,7 @@ Xfbdev_SOURCES = \
 
 Xfbdev_LDADD = 						\
 	libfbdev.a					\
-	@KDRIVE_LIBS@					\
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xfbdev_DEPENDENCIES =	\
 	libfbdev.a					\
diff --git a/hw/kdrive/i810/Makefile.am b/hw/kdrive/i810/Makefile.am
index e3a702d..ea02cb6 100644
--- a/hw/kdrive/i810/Makefile.am
+++ b/hw/kdrive/i810/Makefile.am
@@ -25,8 +25,7 @@ I810_LIBS =						\
 
 Xi810_LDADD = \
 	$(I810_LIBS)					\
-	@KDRIVE_LIBS@                                  \
-	@XSERVER_LIBS@					
+	@KDRIVE_LIBS@
 
 Xi810_DEPENDENCIES =	\
 	libi810.a 					\
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am
index 5379390..746ffff 100644
--- a/hw/kdrive/mach64/Makefile.am
+++ b/hw/kdrive/mach64/Makefile.am
@@ -29,8 +29,7 @@ MACH64_LIBS =						\
 
 Xmach64_LDADD = 					\
 	$(MACH64_LIBS)					\
-	@KDRIVE_LIBS@					\
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xmach64_DEPENDENCIES =	\
 	libmach64.a 					\
diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am
index 0598651..37bc50c 100644
--- a/hw/kdrive/mga/Makefile.am
+++ b/hw/kdrive/mga/Makefile.am
@@ -24,8 +24,7 @@ MGA_LIBS =						\
 
 Xmga_LDADD = \
 	$(MGA_LIBS)					\
-	@KDRIVE_LIBS@                                  \
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xmga_DEPENDENCIES =	\
 	libmga.a 					\
diff --git a/hw/kdrive/nvidia/Makefile.am b/hw/kdrive/nvidia/Makefile.am
index 8ebfec9..b380e44 100644
--- a/hw/kdrive/nvidia/Makefile.am
+++ b/hw/kdrive/nvidia/Makefile.am
@@ -25,8 +25,7 @@ NVIDIA_LIBS =					\
 
 Xnvidia_LDADD = \
 	$(NVIDIA_LIBS)				\
-	@KDRIVE_LIBS@				\
-	@XSERVER_LIBS@			
+	@KDRIVE_LIBS@
 
 Xnvidia_DEPENDENCIES =	\
 	libnvidia.a 				\
diff --git a/hw/kdrive/pm2/Makefile.am b/hw/kdrive/pm2/Makefile.am
index b2b48ba..208d031 100644
--- a/hw/kdrive/pm2/Makefile.am
+++ b/hw/kdrive/pm2/Makefile.am
@@ -23,8 +23,7 @@ PM2_LIBS =					\
 
 Xpm2_LDADD = \
 	$(PM2_LIBS)				\
-	@KDRIVE_LIBS@                          \
-	@XSERVER_LIBS@			
+	@KDRIVE_LIBS@
 
 Xpm2_DEPENDENCIES =	\
 	libpm2.a 				\
diff --git a/hw/kdrive/r128/Makefile.am b/hw/kdrive/r128/Makefile.am
index 609e0f5..62c1fcf 100644
--- a/hw/kdrive/r128/Makefile.am
+++ b/hw/kdrive/r128/Makefile.am
@@ -22,8 +22,7 @@ R128_LIBS =					\
 
 Xr128_LDADD = \
 	$(R128_LIBS)				\
-	@KDRIVE_LIBS@                          \
-	@XSERVER_LIBS@					
+	@KDRIVE_LIBS@
 
 Xr128_DEPENDENCIES =	\
 	libr128.a 				\
diff --git a/hw/kdrive/sdl/Makefile.am b/hw/kdrive/sdl/Makefile.am
index e742499..fe9309e 100644
--- a/hw/kdrive/sdl/Makefile.am
+++ b/hw/kdrive/sdl/Makefile.am
@@ -7,9 +7,8 @@ bin_PROGRAMS = Xsdl
 
 Xsdl_SOURCES = sdl.c
 
-Xsdl_LDADD = @KDRIVE_PURE_LIBS@				\
+Xsdl_LDADD = \
 	@KDRIVE_LIBS@                                  \
-	@XSERVER_LIBS@					\
 	@XSDL_LIBS@
 
 Xsdl_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@
diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am
index 6cee316..a4d6624 100644
--- a/hw/kdrive/smi/Makefile.am
+++ b/hw/kdrive/smi/Makefile.am
@@ -27,8 +27,7 @@ SMI_LIBS =					\
 
 Xsmi_LDADD = \
 	$(SMI_LIBS)				\
-	@KDRIVE_LIBS@                          \
-	@XSERVER_LIBS@					
+	@KDRIVE_LIBS@
 
 Xsmi_DEPENDENCIES =	\
 	libsmi.a 				\
diff --git a/hw/kdrive/vesa/Makefile.am b/hw/kdrive/vesa/Makefile.am
index d58f20f..ac50d2b 100644
--- a/hw/kdrive/vesa/Makefile.am
+++ b/hw/kdrive/vesa/Makefile.am
@@ -21,8 +21,7 @@ Xvesa_SOURCES = \
 
 Xvesa_LDADD = \
 	libvesa.a 				\
-	@KDRIVE_LIBS@				\
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xvesa_DEPENDENCIES =	\
 	libvesa.a 				\
diff --git a/hw/kdrive/via/Makefile.am b/hw/kdrive/via/Makefile.am
index 8c8189d..249b3f3 100644
--- a/hw/kdrive/via/Makefile.am
+++ b/hw/kdrive/via/Makefile.am
@@ -23,8 +23,7 @@ VIA_LIBS =	\
 
 Xvia_LDADD =						\
 	$(VIA_LIBS)					\
-	@KDRIVE_LIBS@					\
-	@XSERVER_LIBS@
+	@KDRIVE_LIBS@
 
 Xvia_DEPENDENCIES =	\
 	libvia.a	\
diff-tree 28e48cd8e6e4c412a49d7177daad6d3c93c28e08 (from b6c0697fd67323893a9ad3676c33f2f1ec48e15e)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 5 04:43:17 2007 -0700

    Another pathname fix for event_status_driver.h

diff --git a/hw/darwin/utils/dumpkeymap.c b/hw/darwin/utils/dumpkeymap.c
index d2eeca5..0c8bdcd 100644
--- a/hw/darwin/utils/dumpkeymap.c
+++ b/hw/darwin/utils/dumpkeymap.c
@@ -143,7 +143,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #if !defined(DUMPKEYMAP_FILE_ONLY)
-#include <drivers/event_status_driver.h>
+#include <IOKit/hidsystem/event_status_driver.h>
 #endif
 
 #define PROG_NAME "dumpkeymap"
diff-tree b6c0697fd67323893a9ad3676c33f2f1ec48e15e (from 136fde2c7b5ed590bc6c63d11ede31e92dc679a2)
Author: Ben Byer <bbyer at bbyer.local>
Date:   Wed Sep 5 04:40:03 2007 -0700

    fixed path for event_status_driver.h
    (The path currently used is deprecated on Tiger and invalid on Leopard.)

diff --git a/hw/darwin/iokit/xfIOKit.c b/hw/darwin/iokit/xfIOKit.c
index c7ebd1c..9de33c0 100644
--- a/hw/darwin/iokit/xfIOKit.c
+++ b/hw/darwin/iokit/xfIOKit.c
@@ -62,8 +62,8 @@
 #define NO_CFPLUGIN
 #include <IOKit/IOKitLib.h>
 #include <IOKit/hidsystem/IOHIDShared.h>
+#include <IOKit/hidsystem/event_status_driver.h>
 #include <IOKit/graphics/IOGraphicsLib.h>
-#include <drivers/event_status_driver.h>
 
 // Define this to work around bugs in the display drivers for
 // older PowerBook G3's. If the X server starts without this
diff-tree 136fde2c7b5ed590bc6c63d11ede31e92dc679a2 (from eb6a933dc60bec5601260794eeb973e946af37b6)
Author: Ademar de Souza Reis Jr <ademar at mandriva.com.br>
Date:   Tue Jul 3 13:44:28 2007 -0300

    Add Xserver man section about catalogue:<dir> FPE
    
    catalogue:<dir> FPEs were introduced in libXfont 1.2.9

diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre
index aac3b51..c9ee019 100644
--- a/doc/Xserver.man.pre
+++ b/doc/Xserver.man.pre
@@ -508,8 +508,7 @@ its parent process after it has set up t
 \fIXdm\fP uses this feature to recognize when connecting to the server
 is possible.
 .SH FONTS
-The X server
-can obtain fonts from directories and/or from font servers.
+The X server can obtain fonts from directories and/or from font servers.
 The list of directories and font servers
 the X server uses when trying to open a font is controlled
 by the \fIfont path\fP.  
@@ -517,8 +516,45 @@ by the \fIfont path\fP.  
 The default font path is
 __default_font_path__ .
 .LP
+A special kind of directory can be specified using the the \fBcatalogue\fP:
+prefix. Directories specified this way can contain symlinks pointing to the
+real font directories. See the FONTPATH.D section for details.
+.LP
 The font path can be set with the \fB\-fp\fP option or by \fIxset\fP(1)
 after the server has started.
+.SH "FONTPATH.D"
+You can specify a special kind of font path in the form \fBcatalogue:<dir>\fR.
+The directory specified after the catalogue: prefix will be scanned for symlinks
+and each symlink destination will be added as a local fontfile FPE.
+.PP
+The symlink can be suffixed by attributes such as '\fBunscaled\fR', which
+will be passed through to the underlying fontfile FPE. The only exception is
+the newly introduced '\fBpri\fR' attribute, which will be used for ordering
+the font paths specified by the symlinks.
+
+An example configuration:
+
+.nf
+    75dpi:unscaled:pri=20 \-> /usr/share/X11/fonts/75dpi
+    ghostscript:pri=60 \-> /usr/share/fonts/default/ghostscript
+    misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
+    type1:pri=40 \-> /usr/share/X11/fonts/Type1
+    type1:pri=50 \-> /usr/share/fonts/default/Type1
+.fi
+
+This will add /usr/share/X11/fonts/misc as the first FPE with the attribute
+'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
+the attribute unscaled etc. This is functionally equivalent to setting
+the following font path:
+
+.nf
+    /usr/share/X11/fonts/misc:unscaled,
+    /usr/share/X11/fonts/75dpi:unscaled,
+    /usr/share/X11/fonts/Type1,
+    /usr/share/fonts/default/Type1,
+    /usr/share/fonts/default/ghostscript
+.fi
+
 .SH FILES
 .TP 30
 .I /etc/X\fBn\fP.hosts
diff-tree eb6a933dc60bec5601260794eeb973e946af37b6 (from 205183a733237ea418a25c7423b689fcc8eae628)
Author: Ademar de Souza Reis Jr <ademar at mandriva.com.br>
Date:   Tue Jul 3 13:44:03 2007 -0300

    Add xorg.conf man section about catalogue:<dir> FPE
    
    catalogue:<dir> FPEs were introduced in libXfont 1.2.9

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index ce54ea9..54d8eaa 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -293,15 +293,50 @@ server searches for font databases.
 Multiple
 .B FontPath
 entries may be specified, and they will be concatenated to build up the
-fontpath used by the server.  Font path elements may be either absolute
-directory paths, or a font server identifier.
+fontpath used by the server.  Font path elements can be absolute
+directory paths, catalogue directories or a font server identifier. The
+formats of the later two are explained below:
+.PP
+.RS 7
+Catalogue directories:
+.PP
+.RS 4
+Catalogue directories can be specified using the prefix \fBcatalogue:\fR
+before the directory name. The directory can then be populated with
+symlinks pointing to the real font directories, using the following
+syntax in the symlink name:
+.PP
+.RS 4
+.IR <identifier> : [attribute]: pri= <priority>
+.RE
+.PP
+where
+.I <identifier>
+is an alphanumeric identifier,
+.I [attribute]
+is an attribute wich will be passed to the underlying FPE and
+.I <priority>
+is a number used to order the fontfile FPEs. Examples:
+.PP
+.RS 4
+.nf
+.I 75dpi:unscaled:pri=20  -> /usr/share/X11/fonts/75dpi
+.I gscript:pri=60 -> /usr/share/fonts/default/ghostscript
+.I misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
+.fi
+.PP
+.RE .RE .RE
+.PP
+.RS 7
+Font server identifiers:
+.PP
+.RS 4
 Font server identifiers have the form:
+.RS 4
 .PP
-.RS 11
 .IR <trans> / <hostname> : <port\-number>
 .RE
 .PP
-.RS 7
 where
 .I <trans>
 is the transport type to use to connect to the font server (e.g.,
@@ -313,10 +348,11 @@ for a TCP/IP connection),
 is the hostname of the machine running the font server, and
 .I <port\-number>
 is the port number that the font server is listening on (usually 7100).
+.RE
 .PP
 When this entry is not specified in the config file, the server falls back
 to the compiled\-in default font path, which contains the following
-font path elements:
+font path elements (which can be set inside a catalogue directory):
 .PP
 .RS 4
 .nf
diff-tree 205183a733237ea418a25c7423b689fcc8eae628 (from d67e210f3458b62d7d4a6032aabfda0004d661c1)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 4 16:19:22 2007 -0700

    Fix driver build by including an appropriate Requires.private line on pixman.
    
    We'd previously been substituting PIXMAN_CFLAGS, but we've got a better tool
    now, plus I deleted the PIXMAN_CFLAGS substitution without noticing.

diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index fba3b15..d3ffaa2 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -8,5 +8,6 @@ sdkdir=@sdkdir@
 Name: xorg-server
 Description: Modular X.Org X Server
 Version: @PACKAGE_VERSION@
-Cflags: -I${sdkdir} @PIXMAN_CFLAGS@
+Requires.private: pixman-1
+Cflags: -I${sdkdir}
 Libs: -L${libdir}
diff-tree d67e210f3458b62d7d4a6032aabfda0004d661c1 (from f7f79724fdea0cc6fda0e90e56431df937d49335)
Author: Gerte Hoogewerf <g.hoogewerf at gmail.com>
Date:   Tue Sep 4 16:09:38 2007 -0700

    Add stub symbols to make xprint build.

diff --git a/hw/xprint/ddxInit.c b/hw/xprint/ddxInit.c
index a465c4c..1e7652e 100644
--- a/hw/xprint/ddxInit.c
+++ b/hw/xprint/ddxInit.c
@@ -310,6 +310,17 @@ ChangeDeviceControl (
     return BadMatch;
 }
 
+int
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+{
+    return BadValue;
+}
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr dev)
+{
+}
+
 void
 OpenInputDevice (
     DeviceIntPtr dev,
diff-tree f7f79724fdea0cc6fda0e90e56431df937d49335 (from e89d16be07e45e487913509788a9e8cb1ee09bc7)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 4 15:10:49 2007 -0700

    Increase despair by fixing xprint build after my _DEPENDENCIES changes.

diff --git a/configure.ac b/configure.ac
index f9c8408..a5bdfb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1649,11 +1649,10 @@ AC_MSG_CHECKING([whether to build Xprint
 AC_MSG_RESULT([$XPRINT])
 
 if test "x$XPRINT" = xyes; then
-	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau])
-	XPRINT_EXTENSIONS="$XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS"
-	XPRINT_LIBS="$DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MIEXT_DAMAGE_LIB $CWRAP_LIB $XPRINT_LIBS"
-	AC_SUBST([XPRINT_CFLAGS])
-	AC_SUBST([XPRINT_LIBS])
+	PKG_CHECK_MODULES([XPRINTMODULES], [printproto x11 xfont $XDMCP_MODULES xau])
+	XPRINT_CFLAGS="$XPRINTMODULES_CFLAGS"
+	XPRINT_LIBS="$XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS $MIEXT_DAMAGE_LIB $CWRAP_LIBS $XKB_LIB $XKB_STUB_LIB"
+	XPRINT_SYS_LIBS="$XPRINTMODULES_LIBS"
 
 	xpconfigdir=$libdir/X11/xserver
 	AC_SUBST([xpconfigdir])
@@ -1689,10 +1688,13 @@ if test "x$XPRINT" = xyes; then
             FREETYPE_LIBS=""
             FREETYPE_REQUIRES=""
         fi
-        AC_SUBST(FREETYPE_LIBS)
-        AC_SUBST(FREETYPE_CFLAGS)
-        AC_SUBST(FREETYPE_REQUIRES)
+	XPRINT_CFLAGS="$XPRINT_CFLAGS $FREETYPE_CFLAGS"
+	XPRINT_SYS_LIBS="$XPRINT_SYS_LIBS $FREETYPE_LIBS"
 	# end freetype support
+
+	AC_SUBST([XPRINT_CFLAGS])
+	AC_SUBST([XPRINT_LIBS])
+	AC_SUBST([XPRINT_SYS_LIBS])
 fi
 AM_CONDITIONAL(XP_USE_FREETYPE, [test "x$XPRINT" = xyes && test "x$XP_USE_FREETYPE" = xyes])
 
diff --git a/hw/xprint/Makefile.am b/hw/xprint/Makefile.am
index dc8764a..c440473 100644
--- a/hw/xprint/Makefile.am
+++ b/hw/xprint/Makefile.am
@@ -9,10 +9,22 @@ Xprt_CFLAGS = @DIX_CFLAGS@ @XPRINT_CFLAG
 	-DXFree86Server
 
 Xprt_LDFLAGS = -L$(top_srcdir)
-Xprt_LDADD = @XPRINT_LIBS@ ps/libps.la raster/libraster.la  \
-	pcl/libpcl.la pcl-mono/libpcl.la $(top_builddir)/fb/libfb.la \
-	$(top_builddir)/render/librender.la $(top_builddir)/mi/libmi.la \
-	$(top_builddir)/Xext/libXext.la  @FREETYPE_LIBS@
+XPRINT_LIBS = \
+	@XPRINT_LIBS@ \
+	ps/libps.la \
+	raster/libraster.la \
+	pcl/libpcl.la \
+	pcl-mono/libpcl.la \
+	$(top_builddir)/fb/libfb.la \
+	$(top_builddir)/render/librender.la \
+	$(XSERVER_LIBS) \
+	$(top_builddir)/Xext/libXext.la \
+	$(top_builddir)/xkb/libxkb.la \
+	$(top_builddir)/xkb/libxkbstubs.la \
+	$(top_builddir)/os/libos.la # for Xprintf
+
+Xprt_DEPENDENCIES = $(XPRINT_LIBS)
+Xprt_LDADD = $(XPRINT_LIBS) $(XPRINT_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 miinitext-wrapper.c:
 	echo "#include \"$(top_srcdir)/mi/miinitext.c\"" >> $@
diff-tree e89d16be07e45e487913509788a9e8cb1ee09bc7 (from bf5948518763b5e21eff806a0a9abc5f7757fa10)
Author: Ian Romanick <idr at us.ibm.com>
Date:   Tue Sep 4 14:49:49 2007 -0700

    Revert part of 529acb175440969af9d7fa38aab8d7dea0dc2661 because libtool is smart.

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index b9a8579..9be0220 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -35,7 +35,14 @@ INCLUDES = @XORG_INCS@ 
 
 Xorg_SOURCES = xorg.c
 
-xorg.c:
+# libxorgos and libcommon need symbols from each other
+noinst_LTLIBRARIES = libosandcommon.la
+libosandcommon_la_SOURCES = osandcommon.c
+libosandcommon_la_LIBADD = \
+            os-support/libxorgos.la \
+            common/libcommon.la
+
+osandcommon.c xorg.c:
 	touch $@
 
 DISTCLEANFILES = osandcommon.c xorg.c
@@ -44,9 +51,7 @@ XORG_LIBS = \
             $(XSERVER_LIBS) \
             common/libinit.a \
             loader/libloader.a \
-            os-support/libxorgos.la \
-            common/libcommon.la \
-            os-support/libxorgos.la \
+            libosandcommon.la \
 	    rac/librac.a \
             parser/libxf86config.a \
 	    dixmods/libdixmods.la \
diff-tree bf5948518763b5e21eff806a0a9abc5f7757fa10 (from parents)
Merge: 4062db4020c671fc0921a3a4e7fe5d8dc1be2e1d 735da3dcd09f59c40f68eca8c9a91c2e826cd1b9
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Tue Sep 4 22:40:31 2007 +0200

    Merge branch 'master' of git+ssh://herrb@git.freedesktop.org/git/xorg/xserver

diff-tree 4062db4020c671fc0921a3a4e7fe5d8dc1be2e1d (from 529acb175440969af9d7fa38aab8d7dea0dc2661)
Author: Matthieu Herrb <matthieu at bluenote.herrb.com>
Date:   Tue Sep 4 22:39:14 2007 +0200

    typo in comment

diff --git a/Xext/Makefile.am b/Xext/Makefile.am
index d0d23b7..946c118 100644
--- a/Xext/Makefile.am
+++ b/Xext/Makefile.am
@@ -87,7 +87,7 @@ endif
 XCALIBRATE_SRCS = xcalibrate.c
 if XCALIBRATE
 BUILTIN_SRCS += $(XCALIBRATE_SRCS)
-# XCalibrare needs tslib
+# XCalibrate needs tslib
 endif
 
 # X EVent Interception Extension: allows accessibility helpers & composite
diff-tree 735da3dcd09f59c40f68eca8c9a91c2e826cd1b9 (from 7c5de093d499de63d39fe038d86da0a085262017)
Author: Egbert Eich <eich at freedesktop.org>
Date:   Tue Sep 4 16:42:57 2007 +0200

    Fixing xf86I2CGetScreenBuses(), now dereferencing the correct pointer.

diff --git a/hw/xfree86/i2c/xf86i2c.c b/hw/xfree86/i2c/xf86i2c.c
index 0139612..5cc83fa 100644
--- a/hw/xfree86/i2c/xf86i2c.c
+++ b/hw/xfree86/i2c/xf86i2c.c
@@ -883,7 +883,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2C
 	    continue;
 
         *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr));
-	pppI2CBus[n - 1] = pI2CBus;
+	(*pppI2CBus)[n - 1] = pI2CBus;
     }
 
     return n;
diff-tree 7c5de093d499de63d39fe038d86da0a085262017 (from 9adea807038b64292403ede982075fe1dcfd4c9a)
Author: Egbert Eich <eich at freedesktop.org>
Date:   Tue Sep 4 15:07:17 2007 +0200

    Fixing sig11 in xf86I2CGetScreenBuses().
    
    Dereferencing a pointer once too often caused a
    sig11 in xf86I2CGetScreenBuses().

diff --git a/hw/xfree86/i2c/xf86i2c.c b/hw/xfree86/i2c/xf86i2c.c
index 53382a8..0139612 100644
--- a/hw/xfree86/i2c/xf86i2c.c
+++ b/hw/xfree86/i2c/xf86i2c.c
@@ -883,7 +883,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2C
 	    continue;
 
         *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr));
-	*pppI2CBus[n - 1] = pI2CBus;
+	pppI2CBus[n - 1] = pI2CBus;
     }
 
     return n;
diff-tree 9adea807038b64292403ede982075fe1dcfd4c9a (from 529acb175440969af9d7fa38aab8d7dea0dc2661)
Author: Hong Liu <hong.liu at intel.com>
Date:   Tue Sep 4 08:46:46 2007 +0100

    bgPixel (unsigned long) is 64-bit on x86_64, so -1 != 0xffffffff
    
    This patch should fix bug 8080.

diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c
index f3434c9..b3dc83a 100644
--- a/hw/xfree86/xaa/xaaGC.c
+++ b/hw/xfree86/xaa/xaaGC.c
@@ -80,10 +80,11 @@ XAAValidateGC(
     }
 
     if(pGC->depth != 32) {
-	if(pGC->bgPixel == -1) /* -1 is reserved for transparency */
-	    pGC->bgPixel = 0x7fffffff; 
-	if(pGC->fgPixel == -1) /* -1 is reserved for transparency */
-	    pGC->fgPixel = 0x7fffffff; 
+	/* 0xffffffff is reserved for transparency */
+	if(pGC->bgPixel == 0xffffffff)
+	    pGC->bgPixel = 0x7fffffff;
+	if(pGC->fgPixel == 0xffffffff)
+	    pGC->fgPixel = 0x7fffffff;
     }
 
     if((pDraw->type == DRAWABLE_PIXMAP) && !IS_OFFSCREEN_PIXMAP(pDraw)){
diff-tree 529acb175440969af9d7fa38aab8d7dea0dc2661 (from c56930e6ca90a61d2f4cbd845f7d0a51a66f83cb)
Author: Eric Anholt <eric at anholt.net>
Date:   Sun Sep 2 15:16:01 2007 -0700

    Fix Xorg build by listing circular dependency libraries twice.
    
    One of these I introduced by listing dix and mi in the same library list to
    simplify other servers.  The other had been hacked around using libosandcommon,
    which is now gone.

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 511e224..b9a8579 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -35,23 +35,18 @@ INCLUDES = @XORG_INCS@ 
 
 Xorg_SOURCES = xorg.c
 
-# libxorgos and libcommon need symbols from each other
-noinst_LTLIBRARIES = libosandcommon.la
-libosandcommon_la_SOURCES = osandcommon.c
-libosandcommon_la_LIBADD = \
-            os-support/libxorgos.la \
-            common/libcommon.la
-
-osandcommon.c xorg.c:
+xorg.c:
 	touch $@
 
 DISTCLEANFILES = osandcommon.c xorg.c
 
 XORG_LIBS = \
-            $(XSERVER_LIBS \
+            $(XSERVER_LIBS) \
             common/libinit.a \
             loader/libloader.a \
-            libosandcommon.la \
+            os-support/libxorgos.la \
+            common/libcommon.la \
+            os-support/libxorgos.la \
 	    rac/librac.a \
             parser/libxf86config.a \
 	    dixmods/libdixmods.la \
@@ -60,7 +55,10 @@ XORG_LIBS = \
 	    ddc/libddc.a \
 	    i2c/libi2c.a \
 	    dixmods/libxorgxkb.la \
-            @XORG_LIBS@
+	    $(top_builddir)/mi/libmi.la \
+	    $(top_builddir)/os/libos.la \
+	    @XORG_LIBS@ \
+	    dixmods/libxorgxkb.la
 
 Xorg_DEPENDENCIES = $(XORG_LIBS)
 Xorg_LDADD = $(XORG_LIBS) $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
diff-tree c56930e6ca90a61d2f4cbd845f7d0a51a66f83cb (from f98dfec79dadb70fa7bba84e7335f92b3a73dc02)
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 18:27:41 2007 -0700

    Remove backend.[ch] from neomagic to fix distcheck.

diff --git a/hw/kdrive/neomagic/Makefile.am b/hw/kdrive/neomagic/Makefile.am
index 4686547..95f0e1e 100644
--- a/hw/kdrive/neomagic/Makefile.am
+++ b/hw/kdrive/neomagic/Makefile.am
@@ -19,8 +19,6 @@ bin_PROGRAMS = Xneomagic
 noinst_LIBRARIES = libneomagic.a
 
 libneomagic_a_SOURCES =         \
-	backend.h                   \
-	backend.c                   \
 	neomagic.c                  \
 	neomagic.h                  \
 	neo_draw.c
diff-tree f98dfec79dadb70fa7bba84e7335f92b3a73dc02 (from 1afdf8b0a92437dffe84fa98b6083b3d8fd55e27)
Author: Keith Packard <keithp at koto.keithp.com>
Date:   Sat Sep 1 21:14:22 2007 -0700

    [COMPOSITE] Composite used for pixmap population on redirect. (Bug #7447)
    
    compNewPixmap copies bits from the parent window to the redirected child
    pixmap to populate the pixmap with reasonable data. It cannot always use
    CopyArea as that only works across matching depths. Use Composite when
    the depths do not match.

diff --git a/composite/compalloc.c b/composite/compalloc.c
index f555411..006e808 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -461,7 +461,6 @@ compNewPixmap (WindowPtr pWin, int x, in
     ScreenPtr	    pScreen = pWin->drawable.pScreen;
     WindowPtr	    pParent = pWin->parent;
     PixmapPtr	    pPixmap;
-    GCPtr	    pGC;
 
     pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth);
 
@@ -471,25 +470,63 @@ compNewPixmap (WindowPtr pWin, int x, in
     pPixmap->screen_x = x;
     pPixmap->screen_y = y;
     
-    pGC = GetScratchGC (pWin->drawable.depth, pScreen);
-    
-    /*
-     * Copy bits from the parent into the new pixmap so that it will
-     * have "reasonable" contents in case for background None areas.
-     */
-    if (pGC)
+    if (pParent->drawable.depth == pWin->drawable.depth)
     {
-	XID val = IncludeInferiors;
+	GCPtr	pGC = GetScratchGC (pWin->drawable.depth, pScreen);
 	
-	ValidateGC(&pPixmap->drawable, pGC);
-	dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
-	(*pGC->ops->CopyArea) (&pParent->drawable,
-			       &pPixmap->drawable,
-			       pGC,
-			       x - pParent->drawable.x,
-			       y - pParent->drawable.y,
-			       w, h, 0, 0);
-	FreeScratchGC (pGC);
+	/*
+	 * Copy bits from the parent into the new pixmap so that it will
+	 * have "reasonable" contents in case for background None areas.
+	 */
+	if (pGC)
+	{
+	    XID val = IncludeInferiors;
+	    
+	    ValidateGC(&pPixmap->drawable, pGC);
+	    dixChangeGC (serverClient, pGC, GCSubwindowMode, &val, NULL);
+	    (*pGC->ops->CopyArea) (&pParent->drawable,
+				   &pPixmap->drawable,
+				   pGC,
+				   x - pParent->drawable.x,
+				   y - pParent->drawable.y,
+				   w, h, 0, 0);
+	    FreeScratchGC (pGC);
+	}
+    }
+    else
+    {
+	PictFormatPtr	pSrcFormat = compWindowFormat (pParent);
+	PictFormatPtr	pDstFormat = compWindowFormat (pWin);
+	XID		inferiors = IncludeInferiors;
+	int		error;
+
+	PicturePtr	pSrcPicture = CreatePicture (None,
+						     &pParent->drawable,
+						     pSrcFormat,
+						     CPSubwindowMode,
+						     &inferiors,
+						     serverClient, &error);
+						    
+	PicturePtr	pDstPicture = CreatePicture (None,
+						     &pPixmap->drawable,
+						     pDstFormat,
+						     0, 0,
+						     serverClient, &error);
+
+	if (pSrcPicture && pDstPicture)
+	{
+	    CompositePicture (PictOpSrc,
+			      pSrcPicture,
+			      NULL,
+			      pDstPicture,
+			      x - pParent->drawable.x,
+			      y - pParent->drawable.y,
+			      0, 0, 0, 0, w, h);
+	}
+	if (pSrcPicture)
+	    FreePicture (pSrcPicture, 0);
+	if (pDstPicture)
+	    FreePicture (pDstPicture, 0);
     }
     return pPixmap;
 }
diff --git a/composite/compint.h b/composite/compint.h
index 38b1777..f69595c 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -237,6 +237,9 @@ compCheckTree (ScreenPtr pScreen);
 #define compCheckTree(s)
 #endif
 
+PictFormatPtr
+compWindowFormat (WindowPtr pWin);
+
 void
 compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap);
 
diff --git a/composite/compwindow.c b/composite/compwindow.c
index a4c4e6f..bfd2946 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -685,7 +685,7 @@ compGetWindowVisual (WindowPtr pWin)
     return 0;
 }
 
-static PictFormatPtr
+PictFormatPtr
 compWindowFormat (WindowPtr pWin)
 {
     ScreenPtr	pScreen = pWin->drawable.pScreen;
diff-tree 1afdf8b0a92437dffe84fa98b6083b3d8fd55e27 (from 0dc2bb6101704d0fd25f36e2c3df79687f119f5b)
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Aug 31 22:11:13 2007 -0700

    [RANDR] Don't mark Xinerama as active if no crtcs are enabled. (bug #11504).
    
    Clients expect any Xinerama-enabled screen to report at least one
    monitor, but with RandR, there may not be any enabled crtcs. In this case,
    tell the client that Xinerama is not active.

diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 2a57e4e..896f61f 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -148,12 +148,6 @@ ProcRRXineramaGetState(ClientPtr client)
 }
 
 static Bool
-RRXineramaScreenActive (ScreenPtr pScreen)
-{
-    return rrGetScrPriv(pScreen) != NULL;
-}
-
-static Bool
 RRXineramaCrtcActive (RRCrtcPtr crtc)
 {
     return crtc->mode != NULL && crtc->numOutputs > 0;
@@ -165,7 +159,7 @@ RRXineramaScreenCount (ScreenPtr pScreen
     int	i, n;
     
     n = 0;
-    if (RRXineramaScreenActive (pScreen))
+    if (rrGetScrPriv (pScreen))
     {
 	rrScrPriv(pScreen);
 	for (i = 0; i < pScrPriv->numCrtcs; i++)
@@ -175,6 +169,12 @@ RRXineramaScreenCount (ScreenPtr pScreen
     return n;
 }
 
+static Bool
+RRXineramaScreenActive (ScreenPtr pScreen)
+{
+    return RRXineramaScreenCount (pScreen) > 0;
+}
+
 int
 ProcRRXineramaGetScreenCount(ClientPtr client)
 {
diff-tree 0dc2bb6101704d0fd25f36e2c3df79687f119f5b (from 07630d897ef37cad8b79d073d9edc891d5a7bddd)
Author: Marius Gedminas <mgedmin at b4net.lt>
Date:   Fri Aug 31 21:36:37 2007 -0700

    [RANDR] Compare only milliseconds of config time. (Bug #6502)
    
    The timestamp transferred in the X protocol is a 32-bit number of
    milliseconds.
    
    The timestamp stored in the server is a structure that contains two fields:
    months (!) and milliseconds.
    
    When the server passes the config timestamp to the client, it discards the
    months part and sends only the milliseconds part.
    
    When the server receives the config timestamp from the client, it tries to
    guess the "months" part by looking at the current time and then maybe adding
    or
    subtracting one.  The guess is wrong after the server has been running long
    enough (several hours).
    
    I have added two ErrorF calls around the 'if' statement that returns
    RRSetConfigInvalidConfigTimestamp in randr/randr.c and my Xorg.0.log has
    this:
    
      randr request got good config time: 0:-2103495671
    
    for the first few successful xrandr calls, and
    
      randr request failed with RRSetConfigInvalidConfigTime: client passed
      1:-2103495671, server has 0:-2103495671
    
    when it fails.  The server has been running for 8 and a half hours.
    
    The obvious fix would be to ignore the months field and only compare the
    milliseconds.

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 8798b42..811a557 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -766,7 +766,6 @@ ProcRRSetScreenConfig (ClientPtr client)
     pScrPriv = rrGetScrPriv(pScreen);
     
     time = ClientTimeToServerTime(stuff->timestamp);
-    configTime = ClientTimeToServerTime(stuff->configTimestamp);
     
     if (!pScrPriv)
     {
@@ -788,11 +787,15 @@ ProcRRSetScreenConfig (ClientPtr client)
     crtc = output->crtc;
 
     /*
-     * if the client's config timestamp is not the same as the last config
+     * If the client's config timestamp is not the same as the last config
      * timestamp, then the config information isn't up-to-date and
-     * can't even be validated
+     * can't even be validated.
+     *
+     * Note that the client only knows about the milliseconds part of the
+     * timestamp, so using CompareTimeStamps here would cause randr to suddenly
+     * stop working after several hours have passed (freedesktop bug #6502).
      */
-    if (CompareTimeStamps (configTime, pScrPriv->lastConfigTime) != 0)
+    if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
     {
 	rep.status = RRSetConfigInvalidConfigTime;
 	goto sendReply;
diff-tree 07630d897ef37cad8b79d073d9edc891d5a7bddd (from ca82d4bddf235c9b68d51d68636bab40eafb9889)
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 15:16:01 2007 -0700

    Bug #7364: Require renderproto 0.9.3 on 64-bit, and fix build with it.

diff --git a/configure.ac b/configure.ac
index cad85a9..f9c8408 100644
--- a/configure.ac
+++ b/configure.ac
@@ -628,7 +628,14 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.l
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
+# Require updated renderproto for ABI sanity if we're 64-bit.
+if test "$ac_cv_sizeof_unsigned_long" = 8; then
+	RENDERPROTO="[renderproto >= 0.9.3]"
+else
+	RENDERPROTO="renderproto"
+fi
+
+REQUIRED_MODULES="[randrproto >= 1.2] $RENDERPROTO [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc [pixman-1 >= 0.9.5]"
 
 dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
diff --git a/render/picturestr.h b/render/picturestr.h
index 005c588..09a7131 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -24,8 +24,8 @@
 #ifndef _PICTURESTR_H_
 #define _PICTURESTR_H_
 
-#include "glyphstr.h"
 #include "scrnintstr.h"
+#include "glyphstr.h"
 #include "resource.h"
 
 typedef struct _DirectFormat {
diff-tree ca82d4bddf235c9b68d51d68636bab40eafb9889 (from a02db0d500cac20d0f0f107d27c064a175018421)
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 13:00:23 2007 -0700

    Bug #7186: Fix an excessive request size limitation that broke big-requests.
    
    MAXBUFSIZE appears to be a leftover of some previous time.  Instead, just
    use maxBigRequestSize when bigreqs are available (limiting buffers to ~16MB).
    When bigreqs are not available, needed won't be larger than the maximum
    size of a non-bigreqs request (256kB).

diff --git a/os/io.c b/os/io.c
index 835af54..9de75ee 100644
--- a/os/io.c
+++ b/os/io.c
@@ -304,12 +304,14 @@ ReadRequestFromClient(ClientPtr client)
 	 */
 
 	oci->lenLastReq = 0;
-	if (needed > MAXBUFSIZE)
+#ifdef BIGREQS
+	if (needed > maxBigRequestSize << 2)
 	{
 	    /* request is too big for us to handle */
 	    YieldControlDeath();
 	    return -1;
 	}
+#endif
 	if ((gotnow == 0) ||
 	    ((oci->bufptr - oci->buffer + needed) > oci->size))
 	{
diff --git a/os/osdep.h b/os/osdep.h
index 965436d..2d455aa 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -55,9 +55,6 @@ SOFTWARE.
 #define BOTIMEOUT 200 /* in milliseconds */
 #define BUFSIZE 4096
 #define BUFWATERMARK 8192
-#ifndef MAXBUFSIZE
-#define MAXBUFSIZE (1 << 22)
-#endif
 
 #include <X11/Xdmcp.h>
 
diff-tree a02db0d500cac20d0f0f107d27c064a175018421 (from 3f42af8c0ef1e5379bc836f589e0cbee43c02ac5)
Author: Eric Anholt <eric at anholt.net>
Date:   Fri Aug 31 12:24:07 2007 -0700

    Convert servers to using _DEPENDENCIES to ensure proper rebuilds.
    
    This cleans up server Makefile.ams a little bit, but also means that people
    messing with configure.ac need to be careful with whether they put libraries
    in the _LIBS or _SYS_LIBS targets.  Hopefully the comment in configure.ac will
    clarify the issues.

diff --git a/configure.ac b/configure.ac
index 1f3743f..cad85a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,6 +166,9 @@ b = bswap16(a);
 	fi
 fi
 
+AC_CHECK_FUNC([dlopen], [],
+	AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
+
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
@@ -624,13 +627,9 @@ XEXT_INC='-I$(top_srcdir)/Xext'
 XEXT_LIB='$(top_builddir)/Xext/libXext.la'
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
-PIXMAN="[pixman-1 >= 0.9.5]"
-PKG_CHECK_MODULES(PIXMAN, $PIXMAN)
-AC_SUBST(PIXMAN_CFLAGS)
-
 dnl Core modules for most extensions, et al.
 REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto xextproto [xproto >= 7.0.9] xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4.2] [kbproto >= 1.0.3]"
-REQUIRED_LIBS="xfont xau fontenc $PIXMAN"
+REQUIRED_LIBS="xfont xau fontenc [pixman-1 >= 0.9.5]"
 
 dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
 dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
@@ -674,6 +673,49 @@ if test "x$NEED_DBUS" = xyes; then
 fi
 CONFIG_LIB='$(top_builddir)/config/libconfig.a'
 
+AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
+               [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
+                             [have_clock_gettime=no])])
+
+AC_MSG_CHECKING([for a useful monotonic clock ...])
+
+if ! test "x$have_clock_gettime" = xno; then
+    if ! test "x$have_clock_gettime" = xyes; then
+        CLOCK_LIBS="$have_clock_gettime"
+    else
+        CLOCK_LIBS=""
+    fi
+
+    LIBS_SAVE="$LIBS"
+    LIBS="$CLOCK_LIBS"
+
+    AC_RUN_IFELSE([
+#define _POSIX_C_SOURCE 199309L
+#include <time.h>
+
+int main(int argc, char *argv[[]]) {
+    struct timespec tp;
+
+    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+        return 0;
+    else
+        return 1;
+}
+    ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
+       [MONOTONIC_CLOCK="cross compiling"])
+
+    LIBS="$LIBS_SAVE"
+else
+    MONOTONIC_CLOCK=no
+fi
+
+AC_MSG_RESULT([$MONOTONIC_CLOCK])
+
+if test "x$MONOTONIC_CLOCK" = xyes; then
+    AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
+    LIBS="$LIBS $CLOCK_LIBS"
+fi
+
 AM_CONDITIONAL(XV, [test "x$XV" = xyes])
 if test "x$XV" = xyes; then
 	AC_DEFINE(XV, 1, [Support Xv extension])
@@ -759,7 +801,7 @@ AM_CONDITIONAL(AIGLX, test "x$AIGLX" = x
 
 if test "x$GLX_USE_TLS" = xyes -a "x$AIGLX" = xyes; then
 	GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
-	GLX_LIBS="$GLX_LIBS -lpthread"
+	GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
 fi
 AC_SUBST([GLX_DEFINES])
 
@@ -1036,9 +1078,26 @@ CORE_INCS='-I$(top_srcdir)/include -I$(t
 PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
 PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
 
+# Autotools has some unfortunate issues with library handling.  In order to
+# get a server to rebuild when a dependency in the tree is changed, it must
+# be listed in SERVERNAME_DEPENDENCIES.  However, no system libraries may be
+# listed there, or some versions of autotols will break (especially if a -L
+# is required to find the library).  So, we keep two sets of libraries
+# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
+# will go into the _DEPENDENCIES and _LDADD of the server, and
+# NAMESPACE_SYS_LIBS which will go into only the _LDADD.  The
+# NAMESPACEMODULES_LIBS detected from pkgconfig should always go in
+# NAMESPACE_SYS_LIBS.
+#
+# XSERVER_LIBS is the set of in-tree libraries which all servers require.
+# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
+# require.
+#
 XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS}"
-XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}"
-AC_SUBST([SYS_LIBS])
+XSERVER_LIBS="$DIX_LIB $CONFIG_LIB $MI_LIB $OS_LIB"
+XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}"
+AC_SUBST([XSERVER_LIBS])
+AC_SUBST([XSERVER_SYS_LIBS])
 
 # The Xorg binary needs to export symbols so that they can be used from modules
 # Some platforms require extra flags to do this.   gcc should set these flags
@@ -1066,50 +1125,6 @@ case $host_os in
 esac
 AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
 
-AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
-               [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
-                             [have_clock_gettime=no])])
-
-AC_MSG_CHECKING([for a useful monotonic clock ...])
-
-if ! test "x$have_clock_gettime" = xno; then
-    if ! test "x$have_clock_gettime" = xyes; then
-        CLOCK_LIBS="$have_clock_gettime"
-    else
-        CLOCK_LIBS=""
-    fi
-
-    LIBS_SAVE="$LIBS"
-    LIBS="$CLOCK_LIBS"
-
-    AC_RUN_IFELSE([
-#define _POSIX_C_SOURCE 199309L
-#include <time.h>
-
-int main(int argc, char *argv[[]]) {
-    struct timespec tp;
-
-    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
-        return 0;
-    else
-        return 1;
-}
-    ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
-       [MONOTONIC_CLOCK="cross compiling"])
-
-    LIBS="$LIBS_SAVE"
-else
-    MONOTONIC_CLOCK=no
-fi
-
-AC_MSG_RESULT([$MONOTONIC_CLOCK])
-
-if test "x$MONOTONIC_CLOCK" = xyes; then
-    AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
-    XSERVER_LIBS="$XSERVER_LIBS $CLOCK_LIBS"
-    LIBS="$LIBS $CLOCK_LIBS"
-fi
-
 dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
 dnl we need to replicate that here until those can all be fixed
 AC_MSG_CHECKING([if SVR4 needs to be defined])
@@ -1136,8 +1151,6 @@ AH_VERBATIM([X_BYTE_ORDER],[
 #endif
 ])
 
-AC_SUBST([XSERVER_LIBS])
-
 dnl ---------------------------------------------------------------------------
 dnl DDX section.
 dnl ---------------------------------------------------------------------------
@@ -1145,7 +1158,7 @@ dnl ------------------------------------
 dnl DMX DDX
 
 AC_MSG_CHECKING([whether to build Xdmx DDX])
-PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES $PIXMAN], [have_dmx=yes], [have_dmx=no])
+PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no])
 if test "x$DMX" = xauto; then
 	DMX="$have_dmx"
 fi
@@ -1158,8 +1171,12 @@ if test "x$DMX" = xyes; then
 		              modules not found.])
 	fi
 	DMX_INCLUDES="$XEXT_INC $RENDER_INC $XTRAP_INC $RECORD_INC"
-	XDMX_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $CONFIG_LIB $RENDER_LIB $XTRAP_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $OS_LIB $CWRAP_LIB"
+	XDMX_CFLAGS="$DMXMODULES_CFLAGS"
+	XDMX_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $RENDER_LIB $XTRAP_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $CWRAP_LIB"
+	XDMX_SYS_LIBS="$DMXMODULES_LIBS"
+	AC_SUBST([XDMX_CFLAGS])
 	AC_SUBST([XDMX_LIBS])
+	AC_SUBST([XDMX_SYS_LIBS])
 
 dnl USB sources in DMX require <linux/input.h>
 	AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
@@ -1197,8 +1214,10 @@ AC_MSG_RESULT([$XVFB])
 AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])
 
 if test "x$XVFB" = xyes; then
-	XVFB_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS"
+	XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB"
+	XVFB_SYS_LIBS="$XVFBMODULES_LIBS"
 	AC_SUBST([XVFB_LIBS])
+	AC_SUBST([XVFB_SYS_LIBS])
 fi
 
 
@@ -1213,8 +1232,10 @@ AC_MSG_RESULT([$XNEST])
 AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
 
 if test "x$XNEST" = xyes; then
-	XNEST_LIBS="$MI_LIB $CONFIG_LIB $XSERVER_LIBS $FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS"
+	XNEST_LIBS="$CONFIG_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB"
+	XNEST_SYS_LIBS="$XNESTMODULES_LIBS"
 	AC_SUBST([XNEST_LIBS])
+	AC_SUBST([XNEST_SYS_LIBS])
 fi
 
 
@@ -1235,14 +1256,15 @@ AC_MSG_CHECKING([whether to build Xgl DD
 if test "x$XGL" != xno; then
   PKG_CHECK_MODULES([XGLMODULES], [glitz-glx >= 0.4.3], [XGL=yes], [XGL=no])
   AC_SUBST(XGLMODULES_CFLAGS)
-  AC_SUBST(XGLMODULES_LIBS)
 fi
 AC_MSG_RESULT([$XGL])
 AM_CONDITIONAL(XGL, [test "x$XGL" = xyes])
 
 if test "x$XGL" = xyes; then
-	XGL_LIBS="$FB_LIB $MI_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
+	XGL_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB"
+	XGL_SYS_LIBS="$XGLMODULES_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS"
 	AC_SUBST([XGL_LIBS])
+	AC_SUBST([XGL_SYS_LIBS])
 	AC_DEFINE(XGL_MODULAR, 1, [Use loadable XGL modules])
 
 	xglmoduledir="$moduledir/xgl"
@@ -1256,14 +1278,15 @@ AC_MSG_CHECKING([whether to build Xegl D
 if test "x$XEGL" != xno; then
   PKG_CHECK_MODULES([XGLMODULES], [glitz-glx >= 0.4.3], [XEGL=yes], [XEGL=no])
   AC_SUBST(XEGLMODULES_CFLAGS)
-  AC_SUBST(XEGLMODULES_LIBS)
 fi
 AC_MSG_RESULT([$XEGL])
 AM_CONDITIONAL(XEGL, [test "x$XEGL" = xyes])
 
 if test "x$XEGL" = xyes; then
-	XEGL_LIBS="$FB_LIB $MI_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
+	XEGL_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB"
+	XEGL_SYS_LIBS = "$XEGL_SYS_LIBS $XEGLMODULES_LIBS $GLX_SYS_LIBS"
 	AC_SUBST([XEGL_LIBS])
+	AC_SUBST([XEGL_SYS_LIBS])
 fi
 
 dnl Xglx DDX
@@ -1272,20 +1295,17 @@ AC_MSG_CHECKING([whether to build Xglx D
 if test "x$XGLX" != xno; then
   PKG_CHECK_MODULES([XGLXMODULES], [glitz-glx >= 0.4.3 xrender], [XGLX=yes], [XGLX=no])
   AC_SUBST(XGLXMODULES_CFLAGS)
-  AC_SUBST(XGLXMODULES_LIBS)
 fi
 AC_MSG_RESULT([$XGLX])
 AM_CONDITIONAL(XGLX, [test "x$XGLX" = xyes])
 
 if test "x$XGLX" = xyes; then
-	XGLX_LIBS="$FB_LIB $MI_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
+	XGLX_LIBS="$FB_LIB $COMPOSITE_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $MIEXT_LAYER_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB $CWRAP_LIB"
+	XGLX_SYS_LIBS="$XGLX_SYS_LIBS $XGLXMODULES_LIBS $GLX_SYS_LIBS"
 	AC_SUBST([XGLX_LIBS])
+	AC_SUBST([XGLX_SYS_LIBS])
 fi
 
-# XORG_CORE_LIBS is needed even if you're not building the Xorg DDX
-XORG_CORE_LIBS="$DIX_LIB $CONFIG_LIB"
-AC_SUBST([XORG_CORE_LIBS])
-
 xorg_bus_linuxpci=no
 xorg_bus_bsdpci=no
 xorg_bus_ix86pci=no
@@ -1298,15 +1318,13 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
 	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
-	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $OS_LIB"
+	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB"
 
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
-	AC_CHECK_FUNC([dlopen], [], 
-		AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl"))
 
 	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
-	XSERVER_LIBS="$XSERVER_LIBS $PCIACCESS_LIBS"
+	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
 	case $host_os in
@@ -1345,7 +1363,7 @@ return 0;}
 #               LDFLAGS=$save_LDFLAGS
 #               ])
                xorg_cv_AGL_framework=no
-	       DARWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
+	       DARWIN_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
 	       AC_SUBST([DARWIN_LIBS])
                AC_CHECK_LIB([Xplugin],[xp_init],[:])
                AC_SUBST([APPLE_APPLICATIONS_DIR])
@@ -1538,10 +1556,11 @@ return 0;}
 	if test -n "$XORG_MODULES"; then
 	        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
 	        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
-	        XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS"
+	        XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
 	fi
 
 	AC_SUBST([XORG_LIBS])
+	AC_SUBST([XORG_SYS_LIBS])
 	AC_SUBST([XORG_INCS])
 	AC_SUBST([XORG_OS])
 	AC_SUBST([XORG_OS_SUBDIR])
@@ -1623,9 +1642,9 @@ AC_MSG_CHECKING([whether to build Xprint
 AC_MSG_RESULT([$XPRINT])
 
 if test "x$XPRINT" = xyes; then
-	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau $PIXMAN])
+	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau])
 	XPRINT_EXTENSIONS="$XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS"
-	XPRINT_LIBS="$DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS $XPRINT_LIBS"
+	XPRINT_LIBS="$DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MIEXT_DAMAGE_LIB $CWRAP_LIB $XPRINT_LIBS"
 	AC_SUBST([XPRINT_CFLAGS])
 	AC_SUBST([XPRINT_LIBS])
 
@@ -1680,7 +1699,7 @@ if test "x$XWIN" = xauto; then
 		mingw*) XWIN="yes" ;;
 		*) XWIN="no" ;;
 	esac
-	XWIN_LIBS="$FB_LIB $MI_LIB $XEXT_LIB $CONFIG_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $OS_LIB $SHADOW_LIB"
+	XWIN_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $SHADOW_LIB"
 	AC_SUBST([XWIN_LIBS])
 fi
 AC_MSG_RESULT([$XWIN])
@@ -1699,11 +1718,12 @@ if test "x$XWIN" = xyes; then
 			XWIN_SERVER_NAME=Xming
 			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
 			AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
-			XWIN_SYSTEM_LIBS=-lwinsock2
+			XWIN_SYS_LIBS=-lwinsock2
 			;;
 	esac
+	XWIN_SYS_LIBS="$XWIN_SYS_LIBS $(XWINMODULES_LIBS)"
 	AC_SUBST(XWIN_SERVER_NAME)
-	AC_SUBST(XWIN_SYSTEM_LIBS)
+	AC_SUBST(XWIN_SYS_LIBS)
 
 	if test "x$DEBUGGING" = xyes; then
 		AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
@@ -1810,7 +1830,7 @@ if test "$KDRIVE" = yes; then
     if test x"$XSDL" = xyes; then
        # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
        AC_DEFINE(XSDLSERVER,1,[Build Xsdl server])
-       XSDL_LIBS="`sdl-config --libs` $XSERVER_LIBS"
+       XSDL_LIBS="`sdl-config --libs`"
        XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
     fi
 
@@ -1839,7 +1859,7 @@ if test "$KDRIVE" = yes; then
     
     KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
 
-    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
+    KDRIVE_PURE_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB"
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
     case $host_os in
 	*linux*)
@@ -1924,7 +1944,7 @@ AC_ARG_ENABLE(xorgcfg, AS_HELP_STRING([-
 if test x$XORGCFG = xyes ; then
 	PKG_CHECK_MODULES([XORGCFG_DEP], 
 	    [xkbui >= 1.0.2 xkbfile xxf86misc xxf86vm xaw7 xmu xt xpm xext x11])
-	XORGCFG_DEP_CFLAGS="$XORGCFG_DEP_CFLAGS $PIXMAN_CFLAGS"
+	XORGCFG_DEP_CFLAGS="$XORGCFG_DEP_CFLAGS"
 	AC_CHECK_LIB([curses],[waddstr],
 	    [XORGCFG_DEP_LIBS="$XORGCFG_DEP_LIBS -lcurses"; CURSES=yes],
 	    AC_CHECK_LIB([ncurses],[waddstr],
diff --git a/hw/darwin/Makefile.am b/hw/darwin/Makefile.am
index b773910..00811e7 100644
--- a/hw/darwin/Makefile.am
+++ b/hw/darwin/Makefile.am
@@ -56,34 +56,29 @@ Xquartz_SOURCES = \
                   quartz/xpr/x-hook.c \
                   quartz/xpr/x-list.c
 
-XDarwin_LDADD = \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
-		./libdarwinShared.a \
-		./iokit/libiokit.a \
-		$(top_builddir)/miext/shadow/libshadow.la \
-		$(top_builddir)/miext/cw/libcw.la \
-		$(DARWIN_LIBS) \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		@XORG_LIBS@ \
-		$(XSERVER_LIBS)
-
-Xquartz_LDADD = \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
-		./libdarwinShared.a \
-		$(top_builddir)/miext/shadow/libshadow.la \
-		$(top_builddir)/miext/cw/libcw.la \
-		$(DARWIN_LIBS) \
-		$(top_builddir)/miext/rootless/librootless.la \
-		$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		$(top_builddir)/miext/rootless/accel/librlAccel.la \
-		@XORG_LIBS@ \
-		$(XSERVER_LIBS) -lXplugin
+DARWIN_LIBS = \
+	$(top_builddir)/dix/dixfonts.lo \
+	$(top_builddir)/config/libconfig.a \
+	$(top_builddir)/miext/shadow/libshadow.la \
+	$(top_builddir)/miext/cw/libcw.la \
+	@DARWIN_LIBS@ \
+	$(top_builddir)/miext/rootless/librootless.la \
+	$(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
+	$(top_builddir)/miext/rootless/accel/librlAccel.la \
+	./libdarwinShared.a \
+	$(XSERVER_LIBS)
+
+XDARWIN_LIBS = \
+	$(DARWIN_LIBS) \
+	./iokit/libiokit.a
+XQUARTZ_LIBS = \
+	$(DARWIN_LIBS)
+
+XDarwin_DEPENDENCIES = $(XDARWIN_LIBS)
+XDarwin_LDADD = $(XDARWIN_LIBS) $(XSERVER_SYS_LIBS)
+
+Xquartz_DEPENDENCIES = $(XQUARTZ_LIBS)
+Xquartz_LDADD = $(XQUARTZ_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
 
 XDarwin_LDFLAGS =  \
                  -XCClinker -Objc \
@@ -118,22 +113,16 @@ XDarwinApp_SOURCES = \
                 $(top_srcdir)/mi/miinitext.c \
 		$(top_srcdir)/Xi/stubs.c 
 
-XDarwinApp_LDADD = \
-		$(top_builddir)/dix/dixfonts.lo \
-		$(top_builddir)/dix/libdix.la \
-		$(top_builddir)/config/libconfig.a \
-		$(top_builddir)/os/libos.la \
-		./quartz/XApplication.o \
-		./libdarwinShared.a \
-		./quartz/libXQuartz.a \
-		 $(top_builddir)/miext/shadow/libshadow.la \
-		 $(top_builddir)/miext/cw/libcw.la \
-		 $(DARWIN_LIBS) \
-		 $(top_builddir)/miext/rootless/librootless.la \
-		 $(top_builddir)/miext/rootless/safeAlpha/libsafeAlpha.la \
-		 $(top_builddir)/miext/rootless/accel/librlAccel.la \
-		 @XORG_LIBS@ \
-		 $(XSERVER_LIBS)
+XDARWINAPP_LIBS = \
+	$(DARWIN_LIBS) \
+	$(top_builddir)/dix/dixfonts.lo \
+	./quartz/XApplication.o \
+	./libdarwinShared.a \
+	./quartz/libXQuartz.a \
+	$(XSERVER_LIBS)
+
+XDarwinApp_DEPENDENCIES = $(XDARWINAPP_LIBS)
+XDarwinApp_LDADD = $(XDARWINAPP_LIBS) $(XSERVER_SYS_LIBS)
 
 XDarwinApp_LDFLAGS =  \
 		 -XCClinker -Objc \
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 002ea11..8457aea 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -81,13 +81,16 @@ Xdmx_SOURCES = dmx.c \
 #Xdmx_SOURCES += fakecw.c
 #endif
 
+XDMX_LIBS = \
+	@XDMX_LIBS@ \
+	$(GLX_LIBS) \
+        input/libdmxinput.a \
+        config/libdmxconfig.a \
+	$(XSERVER_LIBS)
+
 Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-Xdmx_LDADD = $(XORG_CORE_LIBS) \
-             $(XDMX_LIBS) \
-             $(GLX_LIBS) \
-             input/libdmxinput.a \
-             config/libdmxconfig.a \
-             @DMXMODULES_LIBS@
+Xdmx_DEPENDENCIES= $(XDMX_LIBS)
+Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 # Man page
 appmandir = $(APP_MAN_DIR)
diff --git a/hw/vfb/Makefile.am b/hw/vfb/Makefile.am
index 6842b45..9ceeccc 100644
--- a/hw/vfb/Makefile.am
+++ b/hw/vfb/Makefile.am
@@ -19,12 +19,13 @@ libfbcmap_a_SOURCES = $(top_srcdir)/fb/f
 
 Xvfb_SOURCES = $(SRCS)
 
-Xvfb_LDADD = $(XORG_CORE_LIBS) \
-             $(XVFB_LIBS) \
-             $(XSERVER_LIBS) \
-             $(EXTENSION_LIBS) \
-             $(XVFBMODULES_LIBS) \
-	     libfbcmap.a
+XVFB_LIBS = \
+        @XVFB_LIBS@ \
+	libfbcmap.a \
+	$(XSERVER_LIBS)
+
+Xvfb_LDADD = $(XVFB_LIBS) $(XVFB_SYS_LIBS) $(XSERVER_SYS_LIBS)
+Xvfb_DEPENDENCIES = $(XVFB_LIBS)
 
 # Man page
 include $(top_srcdir)/cpprules.in
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 3ba6adc..511e224 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -48,7 +48,7 @@ osandcommon.c xorg.c:
 DISTCLEANFILES = osandcommon.c xorg.c
 
 XORG_LIBS = \
-            @XORG_CORE_LIBS@ \
+            $(XSERVER_LIBS \
             common/libinit.a \
             loader/libloader.a \
             libosandcommon.la \
@@ -59,14 +59,11 @@ XORG_LIBS = \
 	    ramdac/libramdac.a \
 	    ddc/libddc.a \
 	    i2c/libi2c.a \
+	    dixmods/libxorgxkb.la \
             @XORG_LIBS@
 
-Xorg_DEPENDENCIES = \
-	$(XORG_LIBS)
-
-Xorg_LDADD = $(XORG_LIBS) \
-             @XSERVER_LIBS@ \
-	     dixmods/libxorgxkb.la
+Xorg_DEPENDENCIES = $(XORG_LIBS)
+Xorg_LDADD = $(XORG_LIBS) $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 Xorg_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 
diff --git a/hw/xgl/Makefile.am b/hw/xgl/Makefile.am
index 81484b9..ef9fc0e 100644
--- a/hw/xgl/Makefile.am
+++ b/hw/xgl/Makefile.am
@@ -70,12 +70,14 @@ Xgl_SOURCES = \
 	$(top_srcdir)/Xext/dpmsstubs.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/fb/fbcmap.c
-Xgl_LDADD = \
+
+XGL_LIBS = \
 	libxgl.a \
-	$(XORG_CORE_LIBS) \
-	$(XGL_LIBS) \
-	$(XSERVER_LIBS) \
-	$(EXTENSION_LIBS) -lglitz -ldl
+	@XGL_LIBS@ \
+	$(XSERVER_LIBS)
+
+Xgl_DEPENDENCIES = $(XGL_LIBS)
+Xgl_LDADD = $(XGL_LIBS) $(XSERVER_SYS_LIBS) $(XGL_SYS_LIBS)
 Xgl_programs = Xgl
 
 bin_PROGRAMS = $(Xgl_programs)
diff --git a/hw/xgl/egl/Makefile.am b/hw/xgl/egl/Makefile.am
index 5136e58..8c4e9af 100644
--- a/hw/xgl/egl/Makefile.am
+++ b/hw/xgl/egl/Makefile.am
@@ -24,7 +24,12 @@ libxegl_la_SOURCES = \
 	kinput.c     \
 	evdev.c
 
-Xegl_DEPENDENCIES = @XEGL_LIBS@
+XEGL_LIBS = \
+	@XEGL_LIBS@ \
+	libxegl.la \
+	../libxgl.a \
+	$XSERVER_LIBS
+
 Xegl_LDFLAGS	  = -export-dynamic
 Xegl_SOURCES	  = \
 	xeglinit.c \
@@ -32,14 +37,8 @@ Xegl_SOURCES	  = \
 	$(top_srcdir)/Xext/dpmsstubs.c \
 	$(top_srcdir)/Xi/stubs.c \
 	$(top_srcdir)/fb/fbcmap.c
-Xegl_LDADD = \
-	libxegl.la \
-	../libxgl.a \
-	$(XORG_CORE_LIBS) \
-	$(XEGL_LIBS) \
-	$(XSERVER_LIBS) \
-	$(EXTENSION_LIBS) \
-	$(XGLXMODULES_LIBS)
-Xegl_programs	  = Xegl
 
-bin_PROGRAMS = $(Xegl_programs)
+Xegl_DEPENDENCIES = $(XEGL_LIBS)
+Xegl_LDADD = $(XEGL_LIBS) $(XSERVER_SYS_LIBS) $(XEGL_SYS_LIBS)
+
+bin_PROGRAMS = Xegl
diff --git a/hw/xnest/Makefile.am b/hw/xnest/Makefile.am
index 99dba60..92f840c 100644
--- a/hw/xnest/Makefile.am
+++ b/hw/xnest/Makefile.am
@@ -48,12 +48,15 @@ SRCS =	Args.c \
 libfbcmap_a_SOURCES = $(top_srcdir)/fb/fbcmap_mi.c
 libfbcmap_a_CFLAGS = $(AM_CFLAGS)
 
+XNEST_LIBS = \
+        @XNEST_LIBS@ \
+	libfbcmap.a \
+	$(XSERVER_LIBS)
+
 Xnest_SOURCES = $(SRCS)
 
-Xnest_LDADD = $(XORG_CORE_LIBS) \
-              $(XNEST_LIBS) \
-              $(XNESTMODULES_LIBS) \
-	      libfbcmap.a
+Xnest_DEPENDENCIES = $(XNEST_LIBS)
+Xnest_LDADD = $(XNEST_LIBS) $(XNEST_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 EXTRA_DIST = icon \
              screensaver \
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 57e2010..8aaed8c 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -146,10 +146,12 @@ XWin_SOURCES = $(SRCS)
 INCLUDES = -I$(top_srcdir)/miext/rootless \
            -I$(top_srcdir)/miext/rootless/safeAlpha
 
-XWin_LDADD = $(XORG_CORE_LIBS) \
-	     $(top_builddir)/fb/libfb.la \
-             $(XWIN_LIBS) \
-             $(XWINMODULES_LIBS)
+XWIN_LIBS = \
+	$(top_builddir)/fb/libfb.la \
+	$(XSERVER_LIBS)
+
+XWin_DEPENDENCIES = $(XWIN_LIBS)
+XWin_LDADD = $(XWIN_LIBS) $(XSERVER_SYS_LIBS) $(XWIN_SYS_LIBS)
 
 XWin_LDFLAGS = -mwindows -static
 
diff-tree 3f42af8c0ef1e5379bc836f589e0cbee43c02ac5 (from 0fcde83d94507eadd9f99d4e6a63584b221c989c)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Aug 30 18:22:12 2007 +0930

    config: Use [config/dbus] consistently for error messages.

diff --git a/config/dbus.c b/config/dbus.c
index d437994..c867512 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -139,7 +139,7 @@ add_device(DBusMessage *message, DBusMes
             MALFORMED_MESSAGE();
         options->value = xstrdup(tmp);
         if (!options->value) {
-            ErrorF("[config] couldn't duplicate option!\n");
+            ErrorF("[config/dbus] couldn't duplicate option!\n");
             ret = BadAlloc;
             goto unwind;
         }
@@ -204,7 +204,7 @@ remove_device(DBusMessage *message, DBus
     dbus_message_iter_init_append(reply, &reply_iter);
 
     if (!dbus_message_iter_init(message, &iter)) {
-        ErrorF("[config] failed to init iterator\n");
+        ErrorF("[config/dbus] failed to init iterator\n");
         MALFORMED_MESSAGE();
     }
 
@@ -215,12 +215,12 @@ remove_device(DBusMessage *message, DBus
 
     dev = LookupDeviceIntRec(deviceid);
     if (!dev) {
-        DebugF("[config] bogus device id %d given\n", deviceid);
+        DebugF("[config/dbus] bogus device id %d given\n", deviceid);
         ret = BadMatch;
         goto unwind;
     }
 
-    DebugF("[config] removing device %s (id %d)\n", dev->name, deviceid);
+    DebugF("[config/dbus] removing device %s (id %d)\n", dev->name, deviceid);
 
     /* Call PIE here so we don't try to dereference a device that's
      * already been removed. */
diff-tree 0fcde83d94507eadd9f99d4e6a63584b221c989c (from 87495fc7064d5e0a7575a0713b6895a4172df0fa)
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Thu Aug 30 18:20:20 2007 +0930

    config: return BadValue to caller if add/remove doesn't have parameters.
    
    If message iterator cannot be created, the caller didn't supply any
    parameters. Return BadValue, instead of dying a horrible death while being
    stuck in an endless loop.

diff --git a/config/dbus.c b/config/dbus.c
index c6f4af0..d437994 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -74,11 +74,12 @@ add_device(DBusMessage *message, DBusMes
     int ret, err;
     DeviceIntPtr dev = NULL;
 
+    dbus_message_iter_init_append(reply, &reply_iter);
+
     if (!dbus_message_iter_init(message, &iter)) {
         ErrorF("[config/dbus] couldn't initialise iterator\n");
-        return BadAlloc;
+        MALFORMED_MESSAGE();
     }
-    dbus_message_iter_init_append(reply, &reply_iter);
 
     options = xcalloc(sizeof(*options), 1);
     if (!options) {
@@ -200,11 +201,12 @@ remove_device(DBusMessage *message, DBus
     DeviceIntPtr dev;
     DBusMessageIter iter, reply_iter;
 
+    dbus_message_iter_init_append(reply, &reply_iter);
+
     if (!dbus_message_iter_init(message, &iter)) {
         ErrorF("[config] failed to init iterator\n");
-        return BadAlloc;
+        MALFORMED_MESSAGE();
     }
-    dbus_message_iter_init_append(reply, &reply_iter);
 
     if (!dbus_message_get_args(message, error, DBUS_TYPE_UINT32,
                                &deviceid, DBUS_TYPE_INVALID)) {
diff-tree 87495fc7064d5e0a7575a0713b6895a4172df0fa (from d8ab2353cbd7694b556b7b9d550104dc8c460a1b)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Thu Aug 30 21:57:41 2007 +0100

    Allow yres_virtual to be greater for some kernel fbdev drivers.
    (temporary fix for older fbdev drivers)

diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 00c7752..837d2b1 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -239,7 +239,7 @@ static Bool
 fbdev_modes_equal(struct fb_var_screeninfo *set, struct fb_var_screeninfo *req)
 {
 	return (set->xres_virtual >= req->xres_virtual &&
-		set->yres_virtual == req->yres_virtual &&
+		set->yres_virtual >= req->yres_virtual &&
 		set->bits_per_pixel == req->bits_per_pixel &&
 		set->red.length == req->red.length &&
 		set->green.length == req->green.length &&
diff-tree d8ab2353cbd7694b556b7b9d550104dc8c460a1b (from c2d80529fc7f514d80cf3cbed6f580cb999aca1b)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Aug 30 10:39:53 2007 -0700

    Remove dead xf86GetPciSizeFromOS and xf86GetPciOffsetFromOS.

diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 0432ba9..446b69e 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -57,7 +57,6 @@ libbsd_la_SOURCES = \
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/posix_tty.c \
 	$(srcdir)/../shared/sigio.c \
-	$(srcdir)/../shared/stdPci.c \
 	$(srcdir)/../shared/vidmem.c \
 	bsd_VTsw.c \
 	bsd_init.c \
diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am
index 731ff08..e6543e1 100644
--- a/hw/xfree86/os-support/hurd/Makefile.am
+++ b/hw/xfree86/os-support/hurd/Makefile.am
@@ -6,7 +6,6 @@ libhurd_la_SOURCES = hurd_bell.c hurd_in
 		$(srcdir)/../shared/posix_tty.c \
 		$(srcdir)/../shared/libc_wrapper.c \
 		$(srcdir)/../shared/stdResource.c \
-		$(srcdir)/../shared/stdPci.c \
 		$(srcdir)/../shared/sigiostubs.c \
 		$(srcdir)/../shared/pm_noop.c \
 		$(srcdir)/../shared/kmod_noop.c \
diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c
index 8415aa0..53818f2 100644
--- a/hw/xfree86/os-support/linux/lnx_pci.c
+++ b/hw/xfree86/os-support/linux/lnx_pci.c
@@ -147,69 +147,6 @@ int lnxPciInit(void) {
     return xf86OSLinuxNumPciDevs;
 }
 
-Bool
-xf86GetPciSizeFromOS(PCITAG tag, int index, int* bits)
-{
-    signed PCIADDR_TYPE Size;
-    struct pci_dev *device;
-
-    if (index >= 7)
-        return FALSE;
-    
-    if (!xf86OSLinuxPCIDevs) {
-        xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs();
-    }
-    if (!xf86OSLinuxPCIDevs)
-        return FALSE;
-    
-    for (device = xf86OSLinuxPCIDevs; device; device = device->next) {
-        if (tag == PCI_MAKE_TAG(PCI_MAKE_BUS(device->domain, device->bus),
-				device->dev, device->fn)) {
-            if (device->size[index] != 0) {
-                Size = device->size[index] - ((PCIADDR_TYPE) 1);
-                while (Size & ((PCIADDR_TYPE) 0x01)) {
-                    Size = Size >> ((PCIADDR_TYPE) 1);
-                    (*bits)++;
-                }
-            }
-            return TRUE;
-        }
-    }
-
-    return FALSE;
-}
-
-
-
-#if 0
-/* Query the kvirt address (64bit) of a BAR range from TAG */
-Bool
-xf86GetPciOffsetFromOS(PCITAG tag, int index, unsigned long* bases)
-{
-    struct pci_dev *device;
-
-    if (index >= 7)
-        return FALSE;
-
-    if (!xf86OSLinuxPCIDevs) {
-        xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs();
-    }
-    if (!xf86OSLinuxPCIDevs)
-        return FALSE;
-
-    for (device = xf86OSLinuxPCIDevs; device; device = device->next) {
-        if (tag == PCI_MAKE_TAG(PCI_MAKE_BUS(device->domain, device->bus),
-				device->dev, device->fn)) {
-            /* return the offset for the index requested */
-            *bases = device->offset[index];
-            return TRUE;
-        }
-    }
-
-    return FALSE;
-}
-#endif
-
 /* Query the kvirt address (64bit) of a BAR range from size for a given TAG */
 unsigned long
 xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base)
diff --git a/hw/xfree86/os-support/shared/stdPci.c b/hw/xfree86/os-support/shared/stdPci.c
deleted file mode 100644
index 6777c6a..0000000
--- a/hw/xfree86/os-support/shared/stdPci.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 copyright holder(s)
- * and author(s) 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 copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Privstr.h"
-#include "xf86Pci.h"
-#define NEED_OS_RAC_PROTOS
-#include "xf86_OSlib.h"
-
-#ifndef HAVE_PCI_SIZE_FUNC
-#define xf86StdGetPciSizeFromOS xf86GetPciSizeFromOS
-#endif
-
-Bool
-xf86StdGetPciSizeFromOS(PCITAG tag, int index, int* bits)
-{
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am
index c027d9a..5ed60bc 100644
--- a/hw/xfree86/os-support/solaris/Makefile.am
+++ b/hw/xfree86/os-support/solaris/Makefile.am
@@ -23,7 +23,7 @@ libsolaris_la_SOURCES = sun_bios.c sun_i
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/kmod_noop.c \
 	$(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \
-	$(srcdir)/../shared/stdPci.c $(srcdir)/../shared/stdResource.c \
+	$(srcdir)/../shared/stdResource.c \
 	$(VTSW_SRC)
 nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC)
 
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 1d6b842..abf5a47 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -234,8 +234,6 @@ resPtr xf86StdAccResFromOS(resPtr ret);
 resPtr xf86AccResFromOS(resPtr ret);
 #endif /* NEED_OS_RAC_PROTOS */
 
-extern Bool xf86GetPciSizeFromOS(PCITAG tag, int indx, int* bits);
-extern Bool xf86GetPciOffsetFromOS(PCITAG tag, int indx, unsigned long* bases);
 extern unsigned long xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base);
 
 extern void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
diff-tree c2d80529fc7f514d80cf3cbed6f580cb999aca1b (from 1d11e4bc4ccb169fb23fc18583f0b648f0a6a4e0)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Aug 30 10:20:55 2007 -0700

    Remove the now-dead PciAvoid symbol.

diff --git a/hw/xfree86/common/xf86Resources.h b/hw/xfree86/common/xf86Resources.h
index 97bf817..15bd32c 100644
--- a/hw/xfree86/common/xf86Resources.h
+++ b/hw/xfree86/common/xf86Resources.h
@@ -133,7 +133,5 @@ extern resRange res8514Shared[];
 	{ResExcIoSparse | ResBus, 0x0200, 0x0200},\
         {ResExcMemBlock | ResBus, 0xA0000,0xFFFFF}
 
-extern resRange PciAvoid[];
-
 #define RES_UNDEFINED NULL
 #endif
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index cb2a2b9..7c46e02 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1114,7 +1114,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMVAR(resVgaSparseShared)
     SYMVAR(res8514Exclusive)
     SYMVAR(res8514Shared)
-    SYMVAR(PciAvoid)
 
 #if defined(__powerpc__) && (!defined(NO_INLINE) || defined(Lynx))
     SYMVAR(ioBase)
diff --git a/hw/xfree86/os-support/bsd/bsdResource.c b/hw/xfree86/os-support/bsd/bsdResource.c
index 5868634..fe166c8 100644
--- a/hw/xfree86/os-support/bsd/bsdResource.c
+++ b/hw/xfree86/os-support/bsd/bsdResource.c
@@ -17,8 +17,6 @@
 /* Avoid Imakefile changes */
 #include "bus/Pci.h"
 
-_X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
-
 #ifdef INCLUDE_XF86_NO_DOMAIN
 
 #if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
diff --git a/hw/xfree86/os-support/linux/lnxResource.c b/hw/xfree86/os-support/linux/lnxResource.c
index bb42d8a..67af9db 100644
--- a/hw/xfree86/os-support/linux/lnxResource.c
+++ b/hw/xfree86/os-support/linux/lnxResource.c
@@ -18,14 +18,6 @@
 /* Avoid Imakefile changes */
 #include "bus/Pci.h"
 
-_X_EXPORT resRange PciAvoid[] =
-{
-#if !defined(__sparc__) || !defined(INCLUDE_XF86_NO_DOMAIN)
-    _PCI_AVOID_PC_STYLE,
-#endif
-    _END
-};
-
 #ifdef INCLUDE_XF86_NO_DOMAIN
 
 #ifdef __alpha__
diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c
index 2e5c2cf..7229d55 100644
--- a/hw/xfree86/os-support/shared/stdResource.c
+++ b/hw/xfree86/os-support/shared/stdResource.c
@@ -46,8 +46,6 @@
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
 	defined(__DragonFly__)
 #define xf86StdAccResFromOS xf86AccResFromOS
-
-_X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
 #endif
 
 resPtr
diff-tree 1d11e4bc4ccb169fb23fc18583f0b648f0a6a4e0 (from 45efe85003195bd45501630cef08349abb180c3a)
Author: Egbert Eich <eich at freedesktop.org>
Date:   Thu Aug 30 12:50:21 2007 +0200

    Fixing a misleading comment which could suggest a GPL violation.
    
    The author of the int10 code looked at the VBIOS POSTing code
    in DOSEMU to get some initial idea on how to POST a VBIOS.
    To give credit to the DOSEMU Team for this inspiration a comment
    was added to the code which could suggest that code from the
    GPLed DOSEMU was directly incorporated into this code.
    This patch should clearify the situation.

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 3e1051d..e833426 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -3,8 +3,8 @@
  *   execute BIOS int 10h calls in x86 real mode environment
  *                 Copyright 1999 Egbert Eich
  *
- *   Part of this is based on code taken from DOSEMU
- *   (C) Copyright 1992, ..., 1999 the "DOSEMU-Development-Team"
+ *   Part of this code was inspired  by the VBIOS POSTing code in DOSEMU
+ *   developed by the "DOSEMU-Development-Team"
  */
 
 /*
diff-tree 45efe85003195bd45501630cef08349abb180c3a (from 5aaf00190157114780ab51f7268b396459ed1cad)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug 29 16:05:51 2007 -0700

    Remove stale changelogs from kdrive.

diff --git a/hw/kdrive/ati/ChangeLog b/hw/kdrive/ati/ChangeLog
deleted file mode 100644
index a767128..0000000
--- a/hw/kdrive/ati/ChangeLog
+++ /dev/null
@@ -1,622 +0,0 @@
-2006-02-15  Keith Packard  <keithp at keithp.com>
-
-	* Makefile.am:
-	* ati.c: (ATIMapReg):
-	* ati.h:
-	* ati_cursor.c: (ATIMoveCursor), (ClassicSetCursorColors),
-	(ClassicLoadCursor), (RadeonLoadCursor), (ATIUnloadCursor):
-	Fix kdrive pointer signed/unsigned types.
-
-2006-02-14  Eric Anholt  <anholt at FreeBSD.org>
-
-	* ati_draw.c: (ATIDrawDisable):
-	Remove the waitSync from KdDisableScreen and push it off to drivers'
-	disableAccel hook, which is more correct anyway.  This makes kdrive.c
-	not have any knowledge of kaa, opening the way for using exa from
-	kdrive.
-
-2006-02-09  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: Eric Anholt  <anholt at FreeBSD.org>
-
-	* ati_video.c: (RadeonDisplayVideo):
-	Replace TRI_FAN with RECT_LIST to eliminate tearing
-
-2005-08-07  Keith Packard  <keithp at keithp.com>
-
-	* ati_video.c: (RadeonDisplayVideo):
-	Build with modular X libraries and headers
-
-2005-06-09  Eric Anholt  <anholt at FreeBSD.org>
-
-	* ati.h:
-	* ati_video.c:
-	Axe a few dead fields from the port priv struct and add my name to 
-	the "Copyright" line of the license to ati_video.c that already has my
-	name in the text.
-
-2005-06-09  Eric Anholt  <anholt at FreeBSD.org>
-
-	* ati_dri.c:
-	Perform a warnings sweep on hw/kdrive.  A number of these were my fault,
-	but some come from others.
-
-2005-06-09  Eric Anholt  <anholt at FreeBSD.org>
-
-	* ati.c:
-	* ati.h:
-	* ati_draw.c: (ATIWaitMarker), (ATIGetOffsetPitch),
-	(ATIUploadToScreen), (ATIUploadToScratch), (ATIDrawInit),
-	(ATIDrawEnable):
-	* ati_dri.c: (ATIDRISwapContext):
-	* ati_video.c: (R128DisplayVideo), (RadeonDisplayVideo):
-	- Replace the syncAccel hook in the kdrive structure with a pair of
-	  hooks in the kaa structure: markSync and waitMarker.  The first, if
-	  set, returns a hardware-dependent marker number which can then be
-	  waited for with waitMarker.  If markSync is absent (which is the case
-	  on all drivers currently), waitMarker must wait for idle on any given
-	  marker number.  The intention is to allow for more parallelism when
-	  we get downloading from framebuffer, or more fine-grained idling.
-	- Replace the KdMarkSync/KdCheckSync functions with kaaMarkSync and
-	  kaaWaitSync.  These will need to be refined when KAA starts being
-	  smart about using them.  Merge kpict.c into kasync.c since kasyn.c has
-	  all the rest of these fallback funcs.
-	- Restructure all drivers to initialize a KaaInfo structure by hand
-	  rather than statically in dubious order.
-	- Whack the i810 driver into shape in hopes that it'll work after this
-	  change (it certainly wouldn't have before this).  Doesn't support my
-	  i845 though.
-	- Make a new KXV helper to avoid duplicated code to fill the region
-	  with the necessary color key.  Use it in i810 and mach64 (tested).
-
-2005-02-28  Keith Packard  <keithp at keithp.com>
-
-	* ati_reg.h:
-	Add macrovision register defines
-
-2005-01-24 19:37  anholt
-
-	* ati_dma.c, ati_draw.c, ati_reg.h: Finish converting RB2D_DSTCACHE
-	  to RB3D_DSTCACHE.  Remove an extra pixel cache flush in the idle
-	  function.  Init an extra reg for r200, and annotate the
-	  TCL_BYPASS better.  Also, clean up some style nits from the last
-	  commit.
-
-2005-01-24 18:39  keithp
-
-	* ati.h, ati_draw.c, ati_reg.h, radeon_composite.c: Add tracing.
-	  Hack Radeon cache registers to use 3D addresses.  Works on M6
-
-2005-01-24 17:38  anholt
-
-	* ati_dri.c: Silence a warning about uninitialized variable (though
-	  it would be).
-
-2005-01-20 08:22  anholt
-
-	* ati_dma.c, ati_dma.h, ati_dri.c: Add a set of macros for dealing
-	  with the repeated code to wait for a while reading a
-	  register/attempting DMA.  Now it'll wait for a certain number of
-	  seconds rather than a certain number of times through the loop
-	  before deciding that it's timed out and resetting the hardware.
-	  Also, add more timeout handling, and reset the draw state after
-	  resetting the engine.
-
-2005-01-19 23:28  anholt
-
-	* radeon_composite.c: Use RadeonSwitchTo3D() instead of doing the
-	  WAIT_UNTIL ourselves (RST3D() also does DC_FLUSH, which may be
-	  important).
-
-2005-01-19 23:09  anholt
-
-	* ati_video.c: Add R200 XV support, and make R100 (hopefully) use
-	  linear filtering instead of nearest.	Also, use RadeonSwitchTo3D
-	  instead of doing the WAIT_UNTIL ourselves.
-
-2005-01-19 17:09  anholt
-
-	* ati_dma.c, ati_reg.h: Make R200 PDMA work -- primary queue sizes
-	  are now 9 bits, not 8.
-
-2004-12-22 10:39  anholt
-
-	* ati_draw.c, ati_reg.h, radeon_composite.c: Back out the previous
-	  day's broken R200 "fix" -- the same number of coords are always
-	  emitted.  Fix the real problem, which was not enough regs being
-	  initialized in ati_draw.c.  Fix a typo that was resulting in
-	  alpha coming out as 0 * src or 0 * broken instead of src * 1 or
-	  src * mask.  Assign the blending results to R0, as appears to be
-	  necessary.  Unbreak the dst-alpha-blend-with-no-dst-alpha code.
-	  Yow.	And set the right DMA count for the r200 traps code.
-
-2004-12-21 01:51  anholt
-
-	* ati_draw.c, radeon_composite.c: Fix r200 render (for real this
-	  time?) by setting tex1_comp_cnt right for non-mask rendering.
-	  Reenable it.	Also, R200TexFormats was used instead of R100 in
-	  one place.  Harmless so far, because the formats were in the same
-	  order.
-
-2004-12-21 01:49  anholt
-
-	* ati_dri.c: Whitespace nit.
-
-2004-09-19 20:12  anholt
-
-	* ati_draw.c, ati_reg.h, radeon_composite.c: Fix the R200 Render
-	  code.  Composite and Trapezoids are now supported just as well as
-	  on R100.
-
-2004-09-19 03:57  anholt
-
-	* ati_dri.c, ati_reg.h: Unbreak the AGP DRI case.  That was quite a
-	  pile of broken code.
-
-2004-09-13 23:26  anholt
-
-	* ati.c, ati_reg.h: Add proper PCI/AGP detection, based on Mike
-	  Harris's code for Radeon, but using the MMIO mirror of the bits
-	  instead of config space.
-
-2004-09-12 16:22  anholt
-
-	* ati_draw.c: - Fix a segfault on VT switch with DRI.  Still dies
-	  due to cursor   allocation troubles.	- Move the
-	  RemoveBlockAndWakeupHandlers to match
-	  RegisterBlockAndWakeupHandlers.  - Enable R100 trapezoid
-	  "acceleration" when DRI is working, so that it   can be exposed
-	  and worked on.
-
-2004-09-12 16:01  anholt
-
-	* ati_dri.c: Fix a bad argument missed in the previous commit for
-	  ATIDRIDMA* functions.
-
-2004-09-12 15:21  anholt
-
-	* ati_draw.c: Move the RegisterBlockAndWakeupHandlers to before DRI
-	  initialization.  The change to use that instead of manual
-	  wrapping made the DMA dispatch come after the lock had been
-	  dropped, causing lots of pain.
-
-2004-09-12 13:31  anholt
-
-	* ati.h, ati_dma.c, ati_dri.c: Reset the CCE/CP on engine reset,
-	  and make the ATIDRIDMA functions take a more useful argument.
-
-2004-09-12 13:19  anholt
-
-	* ati_draw.c: Add missing kaa.h include for kaaInitTrapOffsets.
-
-2004-09-12 13:02  anholt
-
-	* ati_dri.c: Fix handling of is_agp.  is_agp is whether the card is
-	  actually AGP, while using_agp should say whether AGP is being
-	  used as part of DMA/DRI.
-
-2004-09-12 12:52  anholt
-
-	* ati_dma.c, ati_dma.h, ati_dri.c: Improve error handling,
-	  especially in the DRI case.  Do some FatalErrors instead of
-	  ErrorFs for things that are really bad, and put limits on some
-	  loops.  Now, sometimes instead of hanging the entire system, we
-	  (mostly-) cleanly drop to console when the card has hung.
-
-2004-09-11 02:28  anholt
-
-	* ati.h, ati_dma.h, ati_draw.c, ati_draw.h, ati_reg.h,
-	  r128_composite.c, radeon_composite.c: - Add disabled WIP
-	  trapezoid code for R128 and R100.  The R128 rendering   is not
-	  doing an add of 1 per triangle like I hoped, and instead seems
-	  to be saturating all the pixels or something.  The R100
-	  acceleration	 renders pretty well, with some gaps.  Note that
-	  both are slower than	 software due to lack of DMA to submit
-	  vertices.  - Mostly fix R128 and Radeon transform support,
-	  including supporting	 bilinear filtering on R128.  Subpixel
-	  offsets are still probably an   issue (reported by rendercheck),
-	  but I want to make 100% sure about my   understanding of the
-	  protocol before changing everybody, including fb.  - Add support
-	  for dst formats without alpha to R128 Composite.  - Remove the
-	  R128 Blend code, which has long outlived its usefulness.    (I
-	  kept it around for one reason: It could be useful for the    w/h
-	  > 1024 case with no mask and a non-src op.  That seems pretty
-	  infrequent and not worth the trouble).
-
-2004-07-24 10:02  keithp
-
-	* ati.c: Check for mmio before restoring crtc/crtc2 pitch registers
-
-2004-07-22 11:17  keithp
-
-	* ati.c, ati.h, ati_cursor.c, ati_reg.h: 2004-07-22  Keith Packard
-	  <keithp at keithp.com>
-
-		  reviewed by: <delete if not using a buddy>
-
-		  * hw/kdrive/ati/ati.c: (ATISetOffscreen), (ATISetPitch),
-		  (ATIRandRSetConfig), (ATIPreserve), (ATIRestore),
-	  (ATIEnable):
-		  * hw/kdrive/ati/ati.h:
-		  * hw/kdrive/ati/ati_cursor.c: (RadeonLoadCursor),
-		  (ATIUnloadCursor), (ATICursorEnable):
-		  * hw/kdrive/ati/ati_reg.h:
-		  Correct pitch so that accelerator can run on 1400x1050
-	  screens.
-		  Add a few more register sets for cursors.
-
-2004-07-19 05:07  anholt
-
-	* radeon_composite.c: Add support for a8b8g8r8 and x8b8g8r8
-	  pictures, which showed up frequently with metacity usage.
-
-2004-07-19 04:42  anholt
-
-	* ati_cursor.c: Breakage in last commit to this file:
-	  pCurPriv->area isn't set up until Enable, these days.
-
-2004-07-19 04:19  anholt
-
-	* ati_draw.c: Set the right number of texture coordinates for r200
-	  Render support (still disabled, needs to be tested).
-
-2004-07-19 04:16  anholt
-
-	* r128_composite.c, radeon_composite.c: - Add Radeon picture
-	  transform support.  - On R128, don't refer to an old Composite's
-	  mask transform when the   current Composite doesn't have a mask.
-	  - Staticize some global variables in r128_composite.c.
-
-2004-07-19 00:53  anholt
-
-	* ati.c, ati.h, ati_cursor.c, ati_draw.c, ati_draw.h: Use the
-	  offscreen memory manager as much as possible to do the
-	  reservation of memory at startup.  Do some drive-by cleanups
-	  while I'm here (sorry!).
-
-2004-07-19 00:20  anholt
-
-	* r128_composite.c: Add support for transforms of textures on R128.
-
-2004-07-03 03:23  anholt
-
-	* r128_composite.c: Clean up Rage 128 composite code.  Now it
-	  composites more operations correctly and is simpler.
-
-2004-06-27 17:48  keithp
-
-	* ati.c, ati.h, ati_cursor.c, ati_draw.c: 2004-06-27  Keith Packard
-	   <keithp at keithp.com>
-
-		  * hw/kdrive/ati/ati.c: (ATICardInit), (ATISetOffscreen),
-		  (ATIScreenInit), (ATIRandRSetConfig), (ATIRandRInit),
-		  (ATIFinishInitScreen), (ATIEnable):
-		  * hw/kdrive/ati/ati.h:
-		  * hw/kdrive/ati/ati_cursor.c: (ATICursorInit):
-		  * hw/kdrive/ati/ati_draw.c: (RadeonSwitchTo2D),
-	  (RadeonSwitchTo3D),
-		  (ATIBlockHandler), (ATIWakeupHandler), (ATIDrawEnable),
-		  (ATIDrawDisable), (ATIDrawFini):
-		  Separate out off-screen allocation from Init.
-		  Fix Enable to update off-screen addresses.
-		  Wrap RandR to update off-screen addresses.
-
-		  * hw/kdrive/fbdev/fbdev.c: (fbdevMapFramebuffer):
-		  Set off_screen_base and memory_size fields correctly.
-
-2004-06-25 21:13  keithp
-
-	* ati.c, ati_cursor.c, ati_draw.c, ati_reg.h: 2004-06-25  Keith
-	  Packard  <keithp at keithp.com>
-
-		  * hw/kdrive/ati/ati.c: (ATIScreenInit):
-		  * hw/kdrive/ati/ati_cursor.c: (ATIMoveCursor),
-		  (ClassicAllocCursorColors), (ClassicSetCursorColors),
-		  (ClassicRecolorCursor), (ClassicLoadCursor),
-	  (RadeonLoadCursor),
-		  (ATIRealizeCursor), (ATISetCursor), (ATICursorEnable),
-		  (ATIRecolorCursor):
-		  * hw/kdrive/ati/ati_draw.c: (ATIDrawFini):
-		  * hw/kdrive/ati/ati_reg.h:
-		  Add ARGB cursor support for Radeon cards.
-
-2004-06-10 12:22  anholt
-
-	* ati_draw.c: - Pass the right pixel mask (all ones) in to
-	  PrepareSolid in the	solid-fill-based composite acceleration.  -
-	  Use a real pixmap when doing an UploadToScratch (For
-	  pDrawable->type   == DRAWABLE_WINDOW, you need to get the backing
-	  pixmap).  - Pass back the x/y offsets from kaaGetOffscreenPixmap
-	  unconditionally, because they'll be used in the scratch case.  -
-	  Turn on the Render acceleration for Rage 128 and Radeon
-	  100-series at   last!
-
-2004-06-10 02:50  anholt
-
-	* ati_draw.c: Align scratch area offsets to the offscreen byte
-	  alignment.
-
-2004-06-10 01:37  anholt
-
-	* ati_dma.c: Oops, testers reported that the last patch actually
-	  didn't work (conflicts occurred), so the R300 PDMA doesn't work.
-	  Disable.
-
-2004-06-09 22:57  anholt
-
-	* ati_dma.c, ati_microcode.c: Bug #242: Fix setup of R300 cards, by
-	  providing R300 CP code from volodya-project and initializing
-	  PDMA.
-
-2004-05-17 13:18  anholt
-
-	* Makefile.am, ati.c, ati.h, ati_cursor.c, ati_dma.c, ati_dma.h,
-	  ati_draw.c, ati_draw.h, ati_dri.c, ati_microcode.c, ati_reg.h,
-	  ati_video.c, r128_composite.c, radeon_composite.c: Overhaul of
-	  the ATI driver: - Add monochrome hardware cursor support.  - Try
-	  to auto-detect AGP support for DRI on Radeons.  And fail.
-	  Detect it properly on R128.  - Set up card for pseudo-DMA if
-	  possible.  Convert 2D rendering   code to prepare DMA packets
-	  only.  Use generic code to decode   DMA packets to MMIO if PDMA
-	  is unavailable.  Add WIP code to   support "real" DMA without DRM
-	  support.  - Dispatch pending DMA commands when the server sleeps.
-	  Otherwise   some things, such as typing in an xterm, wouldn't
-	  show up for a   time.  - Fix Radeon Composite acceleration in
-	  many ways, and add Rage 128	Composite acceleration.  Disable
-	  them both due to   still-not-understood issues they have.  They
-	  fail with In, Out,   AtopReverse, and Xor, and text rendering is
-	  strange.  - Add textured XV support for R100 and Rage 128.  No
-	  brightness/sat   controls, but it does support multiple ports,
-	  and cooperates with	Composite.  - Add WIP code for hostdata
-	  uploads.  - Many cleanups and fixes.
-
-2004-01-24 21:31  anholt
-
-	* ati_dri.c: Disable GLX visuals code on !GLXEXT, and remove a
-	  useless prototype.
-
-2004-01-24 17:30  anholt
-
-	* ati.c, ati.h, ati_dri.c, radeon_composite.c: - Add glx visuals
-	  code based on XFree86's Radeon driver.  - Reserve areas for
-	  back/depth/span when USING_DRI && GLXEXT.  This   would be better
-	  in a TransitionTo3d, but we'd need to work with   the offscreen
-	  memory manager for that.  - Misc. fixes to ati_dri.c for DRI+GLX.
-	  Needs more work still.
-
-2004-01-24 17:16  anholt
-
-	* ati_draw.h: Oops, turn fallback output back off.
-
-2004-01-24 17:04  anholt
-
-	* ati_dri.c: Whitespace cleanup.
-
-2004-01-10 16:10  anholt
-
-	* ati_draw.c, r128_blendtmp.h: Support 1x1 repeat sources in R128's
-	  Blend.
-
-2004-01-09 00:43  anholt
-
-	* ati.c, ati.h, ati_draw.c, ati_draw.h, ati_dri.c: Change PCI ID
-	  information field to be one of r128, r100, r200, r300.  This is
-	  all the information we need so far.  Put that information into
-	  atic, and use it correctly in the code (unlike before).
-
-2004-01-08 12:18  anholt
-
-	* ati_draw.c, radeon_composite.c: Compile fixes for non-DRI case
-	  and for non-C99 compiler.
-
-2004-01-08 00:25  anholt
-
-	* ati.c: Forced commit: Previous commit included the removal of the
-	  8192 scanline limit on offscreen memory in the fbdev case.  I
-	  remember daenzer (who originally put that code in) saying he
-	  wasn't sure of it, and there doesn't seem to be any reason for
-	  that limit given how acceleration is done.
-
-2004-01-08 00:16  anholt
-
-	* ati.c, ati.h, ati_draw.c: - Add a new UploadToScratch kaa hook
-	  for putting the data for a single   pixmap into temporary
-	  offscreen storage.  Subsequent UploadToScratch   may clobber the
-	  data of previous ones.  This allows hardware	 acceleration of
-	  composite operations on glyphs.  - Add a new UploadToScreen kaa
-	  hook for doing the actual moving of	data to framebuffer.  This
-	  would allow us to do things like hostdata   blits or memcpy to
-	  agp and then blit.  - Add an UploadToScreen on ATI which is just
-	  memcpy, but which   will be replaced with a hostdata blit soon.
-	  - Add UploadToScratch on ATI and reserve 64k of scratch space.
-	  This	 provided a 3x speedup of rgb24text on my Radeon.
-
-2004-01-06 18:30  anholt
-
-	* radeon_composite.c: Speed things up slightly by removing Z values
-	  from emitted vertices and by emitting as a tri fan rather than a
-	  tri list.  A rect list would save an additional vertex (out of 4)
-	  per rectangle, but there's no measurable speed difference and the
-	  tri fan may be useful when transforms come into play.
-
-2004-01-04 12:47  anholt
-
-	* ati_draw.c, radeon_composite.c: - Correctly set the texture
-	  coordinate set source for the   second texture unit.	- Re-enable
-	  Radeon's Composite accel now that fonts work	 again.
-
-2004-01-03 03:46  anholt
-
-	* ati_draw.c, radeon_composite.c: - Add more Composite operations,
-	  including Saturate, to   Radeon Composite accel.  I don't 100%
-	  trust that the math	works for Saturate, but I can't tell from
-	  existing information.  - Fix texture pitch fallback checks.  -
-	  Fallback when src or mask have transforms.  - Disable Radeon
-	  Composite accel until the offset thing is fixed.  - Set
-	  offscreenPitch to 64 on Radeon thanks to new information   and a
-	  kaa fix.  Fixes acceleration at width!=1024.
-
-2003-12-31 15:24  anholt
-
-	* radeon_composite.c: Some strange \240 character snuck into the
-	  original commit of this file.
-
-2003-12-30 00:45  anholt
-
-	* ati_drawtmp.h: There's never a copy between different depths.
-	  Remove the check.
-
-2003-12-30 00:23  anholt
-
-	* Makefile.am, ati_draw.c, ati_draw.h, ati_drawtmp.h, ati_reg.h,
-	  radeon_composite.c: - Add new Composite hook for kdrive drivers,
-	  which only ensures that   the pixmaps are offscreen and don't
-	  have alpha maps.  It is the	last case checked before going to
-	  software fallback - Use the new Composite hook in the ati driver
-	  to implement	 acceleration of most Composites that get done in
-	  an xcompmgr	environment on r100 series cards.  It is only
-	  available when using	 the DRM.  There are still some corruption
-	  issues, but the DRI is   still non-default and I need to get this
-	  into version control.
-
-2003-12-29 01:04  anholt
-
-	* Makefile.am: Add dependency lines so that servers are rebuilt
-	  when server libraries are changed.
-
-2003-12-28 22:24  anholt
-
-	* Makefile.am, ati.c, ati.h, ati_draw.c, ati_draw.h, ati_drawtmp.h,
-	  ati_dri.c, ati_dri.h, ati_dripriv.h, ati_reg.h, ati_sarea.h,
-	  ati_stub.c, r128_blendtmp.h, r128_common.h, r128_sarea.h,
-	  radeon_common.h, radeon_sarea.h: Merge dri-0-1-branch to trunk.
-	  Notable changes: - Add libdrm and libdri.  Portions of the DRI
-	  extension are stubbed   out.	- Use the DRM in the ATI driver
-	  when available.  This provides a   minor performance improvement
-	  in x11perf, and opens the possibility   of using the 3d hardware
-	  for acceleration in the future.  - Implement solid fill
-	  acceleration for Composite in KAA.  - Implement Blend hook for
-	  Composite and use it on r128.  - Fix a bug of mine that resulted
-	  in overuse of offscreen memory.  - Fix many miscellaneous bugs in
-	  ATI driver and add PCI IDs.
-
-2003-12-28 21:10  anholt
-
-	* ati_drawtmp.h, r128_blendtmp.h: - Disable libdrm verbosity.  It
-	  isn't important enough yet to make   a run-time flag for it.	-
-	  Fix the (void)atic; tricks to quiet unused variable warnings in
-	  ATI template files.  Mixing statements and variable defines works
-	  in newer compilers, but not pdx's.
-
-2003-12-28 01:16  anholt
-
-	* ati.h, ati_draw.c, ati_draw.h, ati_drawtmp.h, ati_dri.c,
-	  r128_blendtmp.h: - Allow acceleration between same-depth pixmaps,
-	  rather than between	anything and a dst that matched the screen
-	  depth (fixes corruption   for non-screen-depth src and makes more
-	  acceleration possible).  - Add ATI_FALLBACK macro and use it to
-	  allow verbose descriptions of   why hardware acceleration fails.
-	  - Check that src and dst alignment meet requirements of the card
-	  before accelerating.  The BIOS may set up screens that don't
-	  meet	 the requirements.  - Fix the R128 offset alignment (32
-	  bytes, not 8).  - Enable Blend operation even if screen is 24bpp
-	  (it will fail if the	 dest is 24bpp anyway).
-
-2003-12-27 02:46  anholt
-
-	* ati_reg.h, r128_blendtmp.h: Properly initialize texture registers
-	  in Blend.  Fixes problems with blending code such as whiteness in
-	  test-render, or no blending at all.
-
-	  Tested by:	  andersca
-
-2003-12-23 14:29  anholt
-
-	* Makefile.am, ati_draw.c, ati_drawtmp.h, ati_reg.h,
-	  r128_blendtmp.h: - Implement acceleration of Composite on R128
-	  when there is no mask,   no transformation, no repeat, and only
-	  certain ops are used.  - Add debugging output for software
-	  fallbacks for Composite.  - Allow pixmaps in offscreen that don't
-	  match root depth.  - Clean up some mess in ati_reg.h.
-
-	  Many thanks to andersca for a lot of this code.
-
-2003-12-09 21:01  anholt
-
-	* ati_draw.c: Add missing kaaDrawFini to ATI driver.
-
-2003-12-01 14:56  anholt
-
-	* Makefile.am, ati.c, ati.h, ati_draw.c, ati_draw.h, ati_drawtmp.h,
-	  ati_dri.c, ati_dri.h, ati_dripriv.h, ati_reg.h, ati_sarea.h,
-	  ati_stub.c, r128_common.h, r128_sarea.h, radeon_common.h,
-	  radeon_sarea.h: - Initial add of enough of the DRI to create a 2d
-	  driver that uses   the DRM for its acceleration.  - Converted the
-	  ATI driver to use the DRM to execute rendering   commands using
-	  DMA instead of MMIO when available.
-
-2003-11-30 20:33  anholt
-
-	* Makefile.am, ati.c, ati.h, ati_stub.c: - Add fbdev mode-setting
-	  backend to Xati.  It and vesa are compiled   in when available,
-	  with fbdev being used by default.  - Use depth 16 by default when
-	  vesa backend is used.  - Add MMIO defines for PowerPC (should be
-	  in a common location).
-
-	  Many thanks for Michel Daenzer for much of this code.
-
-2003-11-30 19:15  anholt
-
-	* ati.c: Add more RV250 PCI IDs.
-
-2003-11-30 17:46  anholt
-
-	* ati_draw.c: Remove sys/io.h inclusion from some files that didn't
-	  need it, and change asm/io.h to sys/io.h in vga.c, which newer
-	  Linux complains about.
-
-2003-11-25 14:39  anholt
-
-	* ati.c: Add new Radeon 9200 PCI IDs.
-
-2003-11-23 02:12  anholt
-
-	* ati_draw.c: - Fix Radeon offscreen pixmap pitch alignment.  -
-	  Remove usleeps from idle and waitavail code, recommended by
-	  keithp.  - Add a workaround for apparent broken acceleration with
-	  Rage 128 and	 offset alignment with 8-bit acceleration (24-hack
-	  and plain 8-bit).  - Minor cleanup of setup code.
-
-2003-11-22 18:08  anholt
-
-	* ati.c: Add RV250 PCI IDs.
-
-2003-11-19 23:49  anholt
-
-	* ati.c, ati.h, ati_draw.c, ati_reg.h: - Fix a bug in pitch
-	  alignment for offscren pixmaps.  - Add 24-bit acceleration for
-	  Xati using the 8-bit trick from mach64.  - Add offscreen pixmap
-	  support to Xati.
-
-2003-11-19 16:05  anholt
-
-	* ati.c, ati_draw.c: - Fix confusion of depth/bitsPerPixel in
-	  ati_draw.c - Disable acceleration with 24bpp due to apparent
-	  broken acceleration.	  Accel at 24bpp was the cause of the
-	  crashes when people tried to use    any depth over 16.  XFree86
-	  doesn't support 24 either.  - Disable at < 8bpp, too.  - Add the
-	  other Rage 128 PCI IDs.  - Remove unnecessary setting of scissor
-	  registers (only default   scissor gets used).
-
-2003-11-19 00:32  anholt
-
-	* .cvsignore, Makefile.am, ati.c, ati.h, ati_draw.c, ati_reg.h,
-	  ati_stub.c: - Add PCI information (device/vendor id, bus
-	  location) to KdCardAttr   to help with ati, and future DRM
-	  drivers.  - Add new "ati" kdrive driver.  It has ancestry in the
-	  r128 driver	from andersca, but took a detour through being the
-	  WIP SiS 300	driver on the way.  It supports Radeons (tested on
-	  QD VIVO and 7500)   and Rage 128.  Current limitations include
-	  that it requires depth 16   and that the other Rage 128 PCI IDs
-	  aren't included yet.
-
diff --git a/hw/kdrive/neomagic/ChangeLog b/hw/kdrive/neomagic/ChangeLog
deleted file mode 100644
index 4e0788e..0000000
--- a/hw/kdrive/neomagic/ChangeLog
+++ /dev/null
@@ -1,98 +0,0 @@
-2006-02-15  Keith Packard  <keithp at keithp.com>
-
-	* Makefile.am:
-	Add XSERVER_LIBS to build in xorg tree
-
-2005-08-07  Keith Packard  <keithp at keithp.com>
-
-	* neo_draw.c:
-	Build with modular X libraries and headers
-
-2005-06-09  Eric Anholt  <anholt at FreeBSD.org>
-
-	* neo_draw.c:
-	* neomagic.c: (neoScreenInit):
-	Perform a warnings sweep on hw/kdrive.  A number of these were my fault,
-	but some come from others.
-
-2005-06-09  Eric Anholt  <anholt at FreeBSD.org>
-
-	* neo_draw.c: (neoWaitMarker), (neoDrawInit):
-	* neomagic.c:
-	* neomagic.h:
-	- Replace the syncAccel hook in the kdrive structure with a pair of
-	  hooks in the kaa structure: markSync and waitMarker.  The first, if
-	  set, returns a hardware-dependent marker number which can then be
-	  waited for with waitMarker.  If markSync is absent (which is the case
-	  on all drivers currently), waitMarker must wait for idle on any given
-	  marker number.  The intention is to allow for more parallelism when
-	  we get downloading from framebuffer, or more fine-grained idling.
-	- Replace the KdMarkSync/KdCheckSync functions with kaaMarkSync and
-	  kaaWaitSync.  These will need to be refined when KAA starts being
-	  smart about using them.  Merge kpict.c into kasync.c since kasyn.c has
-	  all the rest of these fallback funcs.
-	- Restructure all drivers to initialize a KaaInfo structure by hand
-	  rather than statically in dubious order.
-	- Whack the i810 driver into shape in hopes that it'll work after this
-	  change (it certainly wouldn't have before this).  Doesn't support my
-	  i845 though.
-	- Make a new KXV helper to avoid duplicated code to fill the region
-	  with the necessary color key.  Use it in i810 and mach64 (tested).
-
-2005-02-08  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: <delete if not using a buddy>
-
-	* ChangeLog:
-	* neomagicstub.c: (InitInput):
-
-2005-02-08  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: <delete if not using a buddy>
-
-	* ChangeLog:
-	* neomagicstub.c: (InitInput):
-
-2005-02-08  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: <delete if not using a buddy>
-
-	* ChangeLog:
-	* neomagicstub.c: (InitInput):
-
-2005-02-08  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: <delete if not using a buddy>
-
-	* ChangeLog:
-	* neomagicstub.c: (InitInput):
-
-2005-02-08  Keith Packard  <keithp at keithp.com>
-
-	reviewed by: <delete if not using a buddy>
-
-	* neomagicstub.c: (InitInput):
-
-2004-07-21  Phil Blundell  <pb at nexus.co.uk>
-
-	* Makefile.am (Xneomagic_LDADD): Include -lts if appropriate.
-	Patch from pattieja at bentham.ispvip.biz.
-
-2004-06-07 Franco Catrin L. <fcatrin at tuxpan.com>
-        * Small fix for depth calculation
-
-2004-04-11 Franco Catrin L. <fcatrin at tuxpan.com>
-
-        * Basic bitblt implementation
-        * Fixed width and height calculation in solids
-        * Added ROP (not tested)
-
-2004-04-10 Franco Catrin L. <fcatrin at tuxpan.com>
-
-        * MMIO enabled after switching to new VT
-        * First acceleration function implemented (DrawSolid)
-
-2004-04-06 Franco Catrin L. <fcatrin at tuxpan.com>
-
-        * Returned to a working state.  Brent will
-        continue working on a backend in a separate CVS branch
diff-tree 5aaf00190157114780ab51f7268b396459ed1cad (from 87295b66a972a2bd194a79af6aa4f715018fcded)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug 29 16:05:23 2007 -0700

    Add more generated files to .gitignore.

diff --git a/.gitignore b/.gitignore
index e4b3d31..27132c0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,7 @@ config.log
 config.status
 config.sub
 configure
+configure.lineno
 depcomp
 install-sh
 libtool
@@ -91,6 +92,8 @@ cfb32/cfbzerarcG.c
 cfb32/cfbzerarcX.c
 doc/Xserver.1x
 doc/Xserver.man
+doc/SecurityPolicy.5
+doc/SecurityPolicy.man
 hw/dmx/Xdmx
 hw/dmx/Xdmx.1x
 hw/dmx/config/dmxtodmx
@@ -206,31 +209,58 @@ hw/xfree86/xaa/mf3-xaaBitmap.c
 hw/xfree86/xaa/mf3-xaaStipple.c
 hw/xfree86/xaa/s-xaaDashLine.c
 hw/xfree86/xaa/s-xaaLine.c
+hw/xfree86/xf1bpp/maskbits.c
+hw/xfree86/xf1bpp/mfbbitblt.c
 hw/xfree86/xf1bpp/mfbbltC.c
 hw/xfree86/xf1bpp/mfbbltCI.c
 hw/xfree86/xf1bpp/mfbbltG.c
 hw/xfree86/xf1bpp/mfbbltO.c
 hw/xfree86/xf1bpp/mfbbltX.c
+hw/xfree86/xf1bpp/mfbbres.c
+hw/xfree86/xf1bpp/mfbbresd.c
+hw/xfree86/xf1bpp/mfbclip.c
+hw/xfree86/xf1bpp/mfbcmap.c
+hw/xfree86/xf1bpp/mfbfillarc.c
+hw/xfree86/xf1bpp/mfbfillrct.c
+hw/xfree86/xf1bpp/mfbfillsp.c
+hw/xfree86/xf1bpp/mfbfont.c
+hw/xfree86/xf1bpp/mfbgc.c
+hw/xfree86/xf1bpp/mfbgetsp.c
 hw/xfree86/xf1bpp/mfbigbblak.c
 hw/xfree86/xf1bpp/mfbigbwht.c
+hw/xfree86/xf1bpp/mfbhrzvert.c
+hw/xfree86/xf1bpp/mfbimage.c
+hw/xfree86/xf1bpp/mfbline.c
+hw/xfree86/xf1bpp/mfbmisc.c
 hw/xfree86/xf1bpp/mfbpablack.c
 hw/xfree86/xf1bpp/mfbpainv.c
 hw/xfree86/xf1bpp/mfbpawhite.c
 hw/xfree86/xf1bpp/mfbpgbblak.c
 hw/xfree86/xf1bpp/mfbpgbinv.c
 hw/xfree86/xf1bpp/mfbpgbwht.c
+hw/xfree86/xf1bpp/mfbpixmap.c
 hw/xfree86/xf1bpp/mfbplyblack.c
 hw/xfree86/xf1bpp/mfbplyinv.c
 hw/xfree86/xf1bpp/mfbplywhite.c
+hw/xfree86/xf1bpp/mfbpntwin.c
+hw/xfree86/xf1bpp/mfbpolypnt.c
+hw/xfree86/xf1bpp/mfbpushpxl.c
+hw/xfree86/xf1bpp/mfbscrclse.c
+hw/xfree86/xf1bpp/mfbscrinit.c
 hw/xfree86/xf1bpp/mfbseg.c
+hw/xfree86/xf1bpp/mfbsetsp.c
 hw/xfree86/xf1bpp/mfbteblack.c
 hw/xfree86/xf1bpp/mfbtewhite.c
 hw/xfree86/xf1bpp/mfbtileC.c
 hw/xfree86/xf1bpp/mfbtileG.c
+hw/xfree86/xf1bpp/mfbwindow.c
+hw/xfree86/xf1bpp/mfbzerarc.c
 hw/xfree86/xf4bpp/mfbseg.c
 hw/xfree86/xf8_32bpp/cfbgc32.c
 hw/xfree86/xf8_32bpp/cfbgc8.c
 hw/xfree86/xorg.c
+hw/xfree86/xorg.conf.example
+hw/xfree86/xorg.conf.example.pre
 hw/xnest/Xnest
 hw/xnest/Xnest.1x
 hw/xnest/Xnest.man
diff-tree 87295b66a972a2bd194a79af6aa4f715018fcded (from adf46b57ce6c69ab13a38b09a8104c802d54d052)
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug 29 15:54:32 2007 -0700

    Bug #9629: Remove badly-licensed neomagic kdrive files.
    
    Licensing issues of these files include:
    - They claim to be licensed under the GPL, yet we haven't allowed that in the
      xserver repository in the past.
    - They refer the user to the top of the tree for GPL license text, yet it isn't
      there.
    - They claim to be derived from the (MIT-licensed) ati kdrive code, yet don't
      follow the licensing terms of those files.

diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index 267d772..5803644 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -1,5 +1,5 @@
 if KDRIVEVESA
-VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
+VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga nvidia pm2 r128 \
                smi via
 endif
 
diff --git a/hw/kdrive/neomagic/backend.c b/hw/kdrive/neomagic/backend.c
deleted file mode 100644
index 12fbf03..0000000
--- a/hw/kdrive/neomagic/backend.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Generic card driving functions.
- * Essentially, cascades calls to fbdev and vesa to initialize cards that
- * do not have hardware-specific routines yet. Copied from the ati driver.
- *
- * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
- *
- * This code is licensed under the GPL.  See the file COPYING in the root
- * directory of the sources for details.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "backend.h"
-
-Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend)
-{
-    Bool success = FALSE;
-
-#ifdef KDRIVEVESA
-    if (!success && vesaInitialize(card, &backend->priv.vesa)) {
-        success = TRUE;
-        backend->type = VESA;
-        backend->cardfini = vesaCardFini;
-        backend->scrfini = vesaScreenFini;
-        backend->initScreen = vesaInitScreen;
-        backend->finishInitScreen = vesaFinishInitScreen;
-        backend->createRes = vesaCreateResources;
-        backend->preserve = vesaPreserve;
-        backend->restore = vesaRestore;
-        backend->dpms = vesaDPMS;
-        backend->enable = vesaEnable;
-        backend->disable = vesaDisable;
-        backend->getColors = vesaGetColors;
-        backend->putColors = vesaPutColors;
-    }
-#endif
-#ifdef KDRIVEFBDEV
-    if (!success && fbdevInitialize(card, &backend->priv.fbdev)) {
-        success = TRUE;
-        backend->type = FBDEV;
-        backend->cardfini = fbdevCardFini;
-        backend->scrfini = fbdevScreenFini;
-        backend->initScreen = fbdevInitScreen;
-        backend->finishInitScreen = fbdevFinishInitScreen;
-        backend->createRes = fbdevCreateResources;
-        backend->preserve = fbdevPreserve;
-        backend->restore = fbdevRestore;
-        backend->dpms = fbdevDPMS;
-        backend->enable = fbdevEnable;
-        backend->disable = fbdevDisable;
-        backend->getColors = fbdevGetColors;
-        backend->putColors = fbdevPutColors;
-    }
-#endif
-    return success;
-}
-
-Bool
-backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard)
-{
-    Bool success = FALSE;
-
-#ifdef KDRIVEFBDEV
-    if (backendCard->type == FBDEV) {
-        screen->card->driver = &backendCard->priv.fbdev;
-        success = fbdevScreenInitialize(screen, &backendScreen->fbdev);
-        screen->memory_size = backendCard->priv.fbdev.fix.smem_len;
-        screen->off_screen_base = backendCard->priv.fbdev.var.yres_virtual
-                                * screen->fb[0].byteStride;
-    }
-#endif
-#ifdef KDRIVEVESA
-    if (backendCard->type == VESA) {
-		screen->card->driver = &backendCard->priv.vesa;
-        if (screen->fb[0].depth == 0) {
-            screen->fb[0].depth = 16;
-        }
-        success = vesaScreenInitialize(screen, &backendScreen->vesa);
-    }
-#endif
-    return success;
-}
diff --git a/hw/kdrive/neomagic/backend.h b/hw/kdrive/neomagic/backend.h
deleted file mode 100644
index 33eae26..0000000
--- a/hw/kdrive/neomagic/backend.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Generic card driving functions.
- * Essentially, cascades calls to fbdev and vesa to initialize cards that
- * do not have hardware-specific routines yet. Copied from the ati driver.
- *
- * Copyright (c) 2004 Brent Cook <busterb at mail.utexas.edu>
- *
- * This code is licensed under the GPL.  See the file COPYING in the root
- * directory of the sources for details.
- */
-
-#ifndef _BACKEND_H_
-#define _BACKEND_H_
-#include "kdrive.h"
-
-#ifdef KDRIVEFBDEV
-#include <fbdev.h>
-#endif
-#ifdef KDRIVEVESA
-#include <vesa.h>
-#endif
-
-typedef enum _BackendType {VESA, FBDEV} BackendType;
-
-typedef struct _BackendInfo {
-    // backend info
-    BackendType type;
-
-    // backend internal structures
-    union {
-#ifdef KDRIVEFBDEV
-        FbdevPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-        VesaCardPrivRec vesa;
-#endif
-    } priv;
-
-    // pointers to helper functions for this backend
-    void (*cardfini)(KdCardInfo *);
-    void (*scrfini)(KdScreenInfo *);
-    Bool (*initScreen)(ScreenPtr);
-    Bool (*finishInitScreen)(ScreenPtr pScreen);
-    Bool (*createRes)(ScreenPtr);
-    void (*preserve)(KdCardInfo *);
-    void (*restore)(KdCardInfo *);
-    Bool (*dpms)(ScreenPtr, int);
-    Bool (*enable)(ScreenPtr);
-    void (*disable)(ScreenPtr);
-    void (*getColors)(ScreenPtr, int, int, xColorItem *);
-    void (*putColors)(ScreenPtr, int, int, xColorItem *);
-} BackendInfo;
-
-typedef union _BackendScreen {
-#ifdef KDRIVEFBDEV
-    FbdevScrPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-    VesaScreenPrivRec vesa;
-#endif
-} BackendScreen;
-
-Bool
-backendInitialize(KdCardInfo *card, BackendInfo *backend);
-
-Bool
-backendScreenInitialize(KdScreenInfo *screen, BackendScreen *backendScreen,
-                        BackendInfo *backendCard);
-
-#endif
diff-tree adf46b57ce6c69ab13a38b09a8104c802d54d052 (from 3fe67d23edaae3ddde20cd5f349aa5dfde1d26a3)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 28 10:08:38 2007 -0700

    Replace BSD custom PCI code with a stub implementation thanks to pciaccess.
    
    Note that pciaccess doesn't yet have Net/OpenBSD support, but the relevant
    code should go there instead of disconnected code in the X Server.
    
    While here, remove the now-disabled INCLUDE_XF86_NO_DOMAIN from the headers,
    and un-disable xf8StdAccResFromOS for those OSes without domain support which
    will need it.

diff --git a/configure.ac b/configure.ac
index 6d7db2d..1f3743f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1287,8 +1287,7 @@ XORG_CORE_LIBS="$DIX_LIB $CONFIG_LIB"
 AC_SUBST([XORG_CORE_LIBS])
 
 xorg_bus_linuxpci=no
-xorg_bus_freebsdpci=no
-xorg_bus_netbsdpci=no
+xorg_bus_bsdpci=no
 xorg_bus_ix86pci=no
 xorg_bus_ppcpci=no
 xorg_bus_sparcpci=no
@@ -1397,35 +1396,17 @@ return 0;}
 	  freebsd* | kfreebsd*-gnu)
 	  	XORG_OS="freebsd"
 		XORG_OS_SUBDIR="bsd"
-		case $host_cpu in
-		  i*86)
-			;;
-		  *)
-			xorg_bus_freebsdpci="yes"
-			;;
-		esac
+		xorg_bus_bsdpci="yes"
 		;;
 	  netbsd*)
 	  	XORG_OS="netbsd"
 		XORG_OS_SUBDIR="bsd"
-		case $host_cpu in
-		  i*86|amd64*|x86_64*|ia64*)
-			;;
-		  *)
-			xorg_bus_netbsdpci="yes"
-			;;
-		esac
+		xorg_bus_bsdpci="yes"
 		;;
 	  openbsd*)
 	  	XORG_OS="openbsd"
 		XORG_OS_SUBDIR="bsd"
-		case $host_cpu in
-		  i*86|amd64*|x86_64*|ia64*)
-			;;
-		  *)
-			xorg_bus_freebsdpci="yes"
-			;;
-		esac
+		xorg_bus_bsdpci="yes"
 		;;
 	  solaris*)
 	  	XORG_OS="solaris"
@@ -1495,6 +1476,7 @@ return 0;}
 	  i*86)
                case $host_os in
                  darwin*) ;;
+		 *bsd*) ;;
                  *) xorg_bus_ix86pci=yes ;;
                esac
 		;;
@@ -1513,8 +1495,7 @@ return 0;}
 		;;
 	  x86_64*|amd64*)
 		case $host_os in
-		  darwin*|freebsd*|kfreebsd*-gnu)
-			# FreeBSD uses the system pci interface
+		  darwin*|*bsd*)
 			;;
 		  *)
 			xorg_bus_ix86pci="yes"
@@ -1608,8 +1589,7 @@ return 0;}
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
 AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
-AM_CONDITIONAL([XORG_BUS_FREEBSDPCI], [test "x$xorg_bus_freebsdpci" = xyes])
-AM_CONDITIONAL([XORG_BUS_NETBSDPCI], [test "x$xorg_bus_netbsdpci" = xyes])
+AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_IX86PCI], [test "x$xorg_bus_ix86pci" = xyes])
 AM_CONDITIONAL([XORG_BUS_PPCPCI], [test "x$xorg_bus_ppcpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_SPARCPCI], [test "x$xorg_bus_sparcpci" = xyes])
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index fba6e54..381b992 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -7,12 +7,8 @@ if XORG_BUS_LINUXPCI
 PCI_SOURCES += linuxPci.c
 endif
 
-if XORG_BUS_FREEBSDPCI
-PCI_SOURCES += freebsdPci.c
-endif
-
-if XORG_BUS_NETBSDPCI
-PCI_SOURCES += netbsdPci.c
+if XORG_BUS_BSDPCI
+PCI_SOURCES += bsd_pci.c
 endif
 
 if XORG_BUS_IX86PCI
diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index 31e9023..a34ed99 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -286,21 +286,3 @@ xf86scanpci(void)
 
     return success;
 }
-
-#ifdef INCLUDE_XF86_NO_DOMAIN
-
-_X_EXPORT pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-		    ADDRESS Base, unsigned long Size)
-{
-    return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-}
-
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
-    (void) dev;
-    return 0;
-}
-
-#endif /* INCLUDE_XF86_NO_DOMAIN */
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 632a7a0..bb93260 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -184,35 +184,30 @@
 
 #define PCI_CFGMECH1_MAXDEV	32
 
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
+	defined(__DragonFly__)
+#define ARCH_PCI_INIT bsdPciInit
+#endif
+
+#if !defined(ARCH_PCI_INIT)
 /*
  * Select architecture specific PCI init function
  */
 #if defined(__alpha__)
 # if defined(linux)
 #  define ARCH_PCI_INIT axpPciInit
-# elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-#  define ARCH_PCI_INIT freebsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
-# elif defined(__NetBSD__)
-#  define ARCH_PCI_INIT netbsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__arm__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__hppa__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__ia64__)
 # if defined(linux)
 #  define ARCH_PCI_INIT ia64linuxPciInit
-# elif defined(FreeBSD)
-#  define ARCH_PCI_INIT freebsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
 #elif defined(__i386__) || defined(i386)
@@ -221,70 +216,50 @@
 # else
 #  define ARCH_PCI_INIT ix86PciInit
 # endif
-# define INCLUDE_XF86_NO_DOMAIN
 #elif defined(__mc68000__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__mips__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__powerpc__) || defined(__powerpc64__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN	/* Needs kernel work to remove */
-# elif defined(__FreeBSD__) || defined(__OpenBSD__)
-#  define  ARCH_PCI_INIT freebsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
-# elif defined(__NetBSD__)
-#  define ARCH_PCI_INIT netbsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # else
 #  define ARCH_PCI_INIT ppcPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__s390__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__sh__)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 #elif defined(__sparc__) || defined(sparc)
 # if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
 # elif defined(sun)
 #  define ARCH_PCI_INIT sparcPciInit
-# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
-#  define  ARCH_PCI_INIT freebsdPciInit
-#  define INCLUDE_XF86_NO_DOMAIN
 # endif
 # if !defined(__FreeBSD__) && !defined(linux)
 #  define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
 # endif
 #elif defined(__amd64__) || defined(__amd64)
-# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#  define ARCH_PCI_INIT freebsdPciInit
-# elif defined(linux)
+# if defined(linux)
 #  define ARCH_PCI_INIT linuxPciInit
 # else
 #  define ARCH_PCI_INIT ix86PciInit
 # endif
-# define INCLUDE_XF86_NO_DOMAIN
 #endif
+#endif /* !defined(ARCH_PCI_INIT) */
 
 #ifndef ARCH_PCI_INIT
 #error No PCI support available for this architecture/OS combination
 #endif
 
-#undef INCLUDE_XF86_NO_DOMAIN
-
 extern void ARCH_PCI_INIT(void);
 
 #if defined(XF86SCANPCI_WRAPPER)
diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c
new file mode 100644
index 0000000..bceb108
--- /dev/null
+++ b/hw/xfree86/os-support/bus/bsd_pci.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ *    Eric Anholt <eric at anholt.net>
+ *
+ */
+
+/**
+ * @file bsd_pci.c
+ *
+ * This is a trivial implementation of the remaining PCI support hooks in the
+ * X Server that is unaware of domains.
+ *
+ * Most of even this should go away once drivers are converted and the
+ * old interfaces are confirmed to all be obsolete.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include "compiler.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "Pci.h"
+
+#include "pciaccess.h"
+
+static pciBusFuncs_t bsd_funcs = {
+    .pciAddrBusToHost = pciAddrNOOP,
+};
+
+static pciBusInfo_t bsd_pci = {
+    .configMech = PCI_CFG_MECH_OTHER,
+    .numDevices = 32,
+    .secondary = FALSE,
+    .primary_bus = 0,
+    .funcs = &bsd_funcs,
+    .pciBusPriv = NULL,
+    .bridge = NULL,
+};
+
+_X_EXPORT pointer
+xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
+		    ADDRESS Base, unsigned long Size)
+{
+    return xf86MapVidMem(ScreenNum, Flags, Base, Size);
+}
+
+IOADDRESS
+xf86MapLegacyIO(struct pci_device *dev)
+{
+    (void)dev;
+    return 0;
+}
+
+void
+bsdPciInit(void)
+{
+    pciNumBuses = 1;
+    pciBusInfo[0] = &bsd_pci;
+}
diff --git a/hw/xfree86/os-support/bus/freebsdPci.c b/hw/xfree86/os-support/bus/freebsdPci.c
deleted file mode 100644
index ff11c72..0000000
--- a/hw/xfree86/os-support/bus/freebsdPci.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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, and that the name of Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * 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, and that the name of Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "compiler.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "Pci.h"
-
-#include <sys/pciio.h>
-
-/*
- * freebsd platform specific PCI access functions -- using /dev/pci
- * needs kernel version 2.2.x
- */
-static CARD32 freebsdPciCfgRead(PCITAG tag, int off);
-static void freebsdPciCfgWrite(PCITAG, int off, CARD32 val);
-static void freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
-
-static pciBusFuncs_t freebsdFuncs0 = {
-/* pciReadLong      */	freebsdPciCfgRead,
-/* pciWriteLong     */	freebsdPciCfgWrite,
-/* pciSetBitsLong   */	freebsdPciCfgSetBits,
-/* pciAddrHostToBus */	pciAddrNOOP,
-/* pciAddrBusToHost */	pciAddrNOOP
-};
-
-static pciBusInfo_t freebsdPci0 = {
-/* configMech  */	PCI_CFG_MECH_OTHER,
-/* numDevices  */	32,
-/* secondary   */	FALSE,
-/* primary_bus */	0,
-/* funcs       */	&freebsdFuncs0,
-/* pciBusPriv  */	NULL,
-/* bridge      */	NULL
-};
-
-#if !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-#ifdef __sparc__
-#ifndef ASI_PL
-#define ASI_PL 0x88
-#endif
-#define PCI_CPU(val) ({									\
-int __ret;										\
-__asm__ __volatile__("lduwa [%1] %2, %0" : "=r" (__ret) : "r" (&val), "i" (ASI_PL));	\
-__ret;											\
-})
-#else
-#define PCI_CPU(val)	(((val >> 24) & 0x000000ff) |	\
-			 ((val >>  8) & 0x0000ff00) |	\
-			 ((val <<  8) & 0x00ff0000) |	\
-			 ((val << 24) & 0xff000000))
-#endif
-#else
-#define PCI_CPU(val)	(val)
-#endif
-#else /* ! OpenBSD */
-/* OpenBSD has already the bytes in the right order
-   for all architectures */
-#define PCI_CPU(val)	(val)
-#endif
-
-
-#define BUS(tag) (((tag)>>16)&0xff)
-#define DFN(tag) (((tag)>>8)&0xff)
-
-static int pciFd = -1;
-
-void
-freebsdPciInit()
-{
-	pciFd = open("/dev/pci", O_RDWR);
-	if (pciFd < 0)
-		return;
-
-	pciNumBuses    = 1;
-	pciBusInfo[0]  = &freebsdPci0;
-}
-
-static CARD32
-freebsdPciCfgRead(PCITAG tag, int off)
-{
-	struct pci_io io;
-	int error;
-	io.pi_sel.pc_bus = BUS(tag);
-	io.pi_sel.pc_dev = DFN(tag) >> 3;
-	io.pi_sel.pc_func = DFN(tag) & 7;
-	io.pi_reg = off;
-	io.pi_width = 4;
-	error = ioctl(pciFd, PCIOCREAD, &io);
-	if (error)
-		return ~0;
-	return PCI_CPU(io.pi_data);
-}
-
-static void
-freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val)
-{
-	struct pci_io io;
-	io.pi_sel.pc_bus = BUS(tag);
-	io.pi_sel.pc_dev = DFN(tag) >> 3;
-	io.pi_sel.pc_func = DFN(tag) & 7;
-	io.pi_reg = off;
-	io.pi_width = 4;
-	io.pi_data = PCI_CPU(val);
-	ioctl(pciFd, PCIOCWRITE, &io);
-}
-
-static void
-freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
-{
-	CARD32	val = freebsdPciCfgRead(tag, off);
-	val = (val & ~mask) | (bits & mask);
-	freebsdPciCfgWrite(tag, off, val);
-}
diff --git a/hw/xfree86/os-support/bus/netbsdPci.c b/hw/xfree86/os-support/bus/netbsdPci.c
deleted file mode 100644
index 7603027..0000000
--- a/hw/xfree86/os-support/bus/netbsdPci.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 1994-2003 The XFree86 Project, Inc.  All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * 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 XFREE86 PROJECT 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 XFree86 Project
- * 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 XFree86 Project.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <dev/pci/pciio.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-
-#include "Pci.h"
-
-static CARD32 netbsdPciConfRead(PCITAG, int);
-static void netbsdPciConfWrite(PCITAG, int, CARD32);
-static void netbsdPciSetBits(PCITAG, int, CARD32, CARD32);
-
-static int devpci = -1;
-
-static pciBusFuncs_t netbsdFuncs0 = {
-/* pciReadLong      */	netbsdPciConfRead,
-/* pciWriteLong     */	netbsdPciConfWrite,
-/* pciSetBitsLong   */	netbsdPciSetBits,
-/* pciAddrHostToBus */	pciAddrNOOP,
-/* pciAddrBusToHost */	pciAddrNOOP
-};
-
-static pciBusInfo_t netbsdPci0 = {
-/* configMech  */	PCI_CFG_MECH_OTHER,
-/* numDevices  */	32,
-/* secondary   */	FALSE,
-/* primary_bus */	0,
-/* funcs       */	&netbsdFuncs0,
-/* pciBusPriv  */	NULL,
-/* bridge      */	NULL
-};
-
-void
-netbsdPciInit()
-{
-	struct pciio_businfo pci_businfo;
-
-	devpci = open("/dev/pci0", O_RDWR);
-	if (devpci == -1)
-		FatalError("netbsdPciInit: can't open /dev/pci0\n");
-
-	pciNumBuses    = 1;
-	pciBusInfo[0]  = &netbsdPci0;
-	/* use businfo to get the number of devs */
-	if (ioctl(devpci, PCI_IOC_BUSINFO, &pci_businfo) != 0)
-	    FatalError("netbsdPciInit: not a PCI bus device");
-	netbsdPci0.numDevices = pci_businfo.maxdevs;
-}
-
-static CARD32
-netbsdPciConfRead(PCITAG tag, int reg)
-{
-	struct pciio_bdf_cfgreg bdfr;
-
-	bdfr.bus      = PCI_BUS_FROM_TAG(tag);
-	bdfr.device   = PCI_DEV_FROM_TAG(tag);
-	bdfr.function = PCI_FUNC_FROM_TAG(tag);
-	bdfr.cfgreg.reg = reg;
-
-	if (ioctl(devpci, PCI_IOC_BDF_CFGREAD, &bdfr) == -1)
-		FatalError("netbsdPciConfRead: failed on %d/%d/%d\n",
-		    bdfr.bus, bdfr.device, bdfr.function);
-
-	return (bdfr.cfgreg.val);
-}
-
-static void
-netbsdPciConfWrite(PCITAG tag, int reg, CARD32 val)
-{
-	struct pciio_bdf_cfgreg bdfr;
-
-	bdfr.bus      = PCI_BUS_FROM_TAG(tag);
-	bdfr.device   = PCI_DEV_FROM_TAG(tag);
-	bdfr.function = PCI_FUNC_FROM_TAG(tag);
-	bdfr.cfgreg.reg = reg;
-	bdfr.cfgreg.val = val;
-
-	if (ioctl(devpci, PCI_IOC_BDF_CFGWRITE, &bdfr) == -1)
-		FatalError("netbsdPciConfWrite: failed on %d/%d/%d\n",
-		    bdfr.bus, bdfr.device, bdfr.function);
-}
-
-static void
-netbsdPciSetBits(PCITAG tag, int reg, CARD32 mask, CARD32 bits)
-{
-	CARD32 val;
-
-	val = netbsdPciConfRead(tag, reg);
-	val = (val & ~mask) | (bits & mask);
-	netbsdPciConfWrite(tag, reg, val);
-}
diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c
index 51d1a2a..2e5c2cf 100644
--- a/hw/xfree86/os-support/shared/stdResource.c
+++ b/hw/xfree86/os-support/shared/stdResource.c
@@ -43,14 +43,13 @@
 /* Avoid Imakefile changes */
 #include "bus/Pci.h"
 
-#ifdef USESTDRES
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+	defined(__DragonFly__)
 #define xf86StdAccResFromOS xf86AccResFromOS
 
 _X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
 #endif
 
-#ifdef INCLUDE_XF86_NO_DOMAIN
-
 resPtr
 xf86StdAccResFromOS(resPtr ret)
 {
@@ -117,5 +116,3 @@ xf86StdAccResFromOS(resPtr ret)
     /* XXX add others */
     return ret;
 }
-
-#endif /* INCLUDE_XF86_NO_DOMAIN */
diff-tree 3fe67d23edaae3ddde20cd5f349aa5dfde1d26a3 (from 9e2112b2b56af099a7f380ece9b5c1d25b20cce4)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 27 19:02:41 2007 -0700

    Remove the BusAccWindows resource code which is now unused.
    
    This was a bunch of poorly defined resource ranges per OS/platform combination
    which were supposed to represent what regions could potentially have resources
    allocated into them.

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 1959f79..3dc08f8 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -77,9 +77,6 @@ static resPtr AccReducers = NULL;
 resPtr Acc = NULL;
 resPtr osRes = NULL;
 
-/* allocatable ranges */
-resPtr ResRange = NULL;
-
 /* predefined special resources */
 _X_EXPORT resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
 _X_EXPORT resRange resVgaShared[] = {_VGA_SHARED, _END};
@@ -1366,11 +1363,6 @@ xf86ResourceBrokerInit(void)
 
     osRes = NULL;
 
-    /* Get the addressable ranges */
-    ResRange = xf86BusAccWindowsFromOS();
-    xf86MsgVerb(X_INFO, 3, "Addressable bus resource ranges are\n");
-    xf86PrintResList(3, ResRange);
-
     /* Get the ranges used exclusively by the system */
     osRes = xf86AccResFromOS(osRes);
     xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges:\n");
diff --git a/hw/xfree86/os-support/bsd/bsdResource.c b/hw/xfree86/os-support/bsd/bsdResource.c
index 37749c9..5868634 100644
--- a/hw/xfree86/os-support/bsd/bsdResource.c
+++ b/hw/xfree86/os-support/bsd/bsdResource.c
@@ -24,59 +24,6 @@ _X_EXPORT resRange PciAvoid[] = {_PCI_AV
 #if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
 
 resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    /*
-     * Only allow the upper half of the pci memory range to be used
-     * for allocation. The lower half includes magic regions for DMA.
-     * XXX this is not right for XP1000's and similar where we use the 
-     * region 0x40000000-0xbfffffff for DMA but this only matters if
-     * the bios screws up the pci region mappings.
-     */
-    RANGE(range, 0x80000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#ifdef INCLUDE_UNUSED
-
-resPtr
-xf86IsaBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#endif /* INCLUDE_UNUSED */
-
-resPtr
 xf86AccResFromOS(resPtr ret)
 {
     resRange range;
@@ -118,52 +65,6 @@ xf86AccResFromOS(resPtr ret)
 #elif defined(__powerpc__)
 
 resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#ifdef INCLUDE_UNUSED
-
-resPtr
-xf86IsaBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#endif /* INCLUDE_UNUSED */
-
-resPtr
 xf86AccResFromOS(resPtr ret)
 {
     resRange range;
diff --git a/hw/xfree86/os-support/bus/axpPci.c b/hw/xfree86/os-support/bus/axpPci.c
index e2f086c..c59c068 100644
--- a/hw/xfree86/os-support/bus/axpPci.c
+++ b/hw/xfree86/os-support/bus/axpPci.c
@@ -363,34 +363,6 @@ xf86MapLegacyIO(struct pci_device *dev)
 }
 
 resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    resPtr pRes = NULL;
-    resRange range;
-    int domain;
-
-    for(domain = 0; domain < pciNumDomains; domain++) {
-	if (!xf86DomainInfo[domain]) continue;
-
-	RANGE(range, 0, 0xffffffffUL,
-	      RANGE_TYPE(ResExcMemBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-
-	RANGE(range, 0, 0x0000ffffUL,
-	      RANGE_TYPE(ResExcIoBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);		      
-    }
-
-    return pRes;
-}
-
-resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    return xf86PciBusAccWindowsFromOS();
-}
-
-resPtr
 xf86AccResFromOS(resPtr pRes)
 {
     resRange range;
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index b88fae6..11eb4f9 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -549,49 +549,6 @@ xf86MapLegacyIO(struct pci_device *dev)
 }
 
 resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    struct pci_device *dev;
-    struct pci_device_iterator *iter;
-    resPtr        pRes = NULL;
-    resRange      range;
-
-    iter = pci_id_match_iterator_create(& match_host_bridge);
-    while ((dev = pci_device_next(iter)) != NULL) {
-	const int domain = dev->domain;
-	const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
-
-	RANGE(range, 0, (ADDRESS)(sizes->mem_size - 1),
-	      RANGE_TYPE(ResExcMemBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-
-	RANGE(range, 0, (IOADDRESS)(sizes->io_size - 1),
-	      RANGE_TYPE(ResExcIoBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-
-	/* FIXME: The old code reserved domain 0 for a special purpose.  The
-	 * FIXME: new code just uses whatever domains the kernel tells it,
-	 * FIXME: but there is no way to get a domain < 0.  What should
-	 * FIXME: happen here?
-	 *
-	if (domain <= 0)
-	  break;
-	 */
-    }
-
-    pci_iterator_destroy(iter);
-
-    return pRes;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    return xf86BusAccWindowsFromOS();
-}
-
-
-resPtr
 xf86AccResFromOS(resPtr pRes)
 {
     struct pci_device *dev;
diff --git a/hw/xfree86/os-support/bus/sparcPci.c b/hw/xfree86/os-support/bus/sparcPci.c
index 82b1d89..6f7113f 100644
--- a/hw/xfree86/os-support/bus/sparcPci.c
+++ b/hw/xfree86/os-support/bus/sparcPci.c
@@ -649,54 +649,6 @@ xf86MapLegacyIO(int ScreenNum, int Flags
 }
 
 resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    sparcDomainPtr pDomain;
-    resPtr         pRes = NULL;
-    resRange       range;
-    int            domain;
-
-    for (domain = 1;  domain < pciNumDomains;  domain++) {
-	if (!(pDomain = xf86DomainInfo[domain]))
-	    continue;
-
-	RANGE(range, 0, pDomain->mem_size - 1,
-	      RANGE_TYPE(ResExcMemBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-
-	RANGE(range, 0, pDomain->io_size - 1,
-	      RANGE_TYPE(ResExcIoBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-    }
-
-    return pRes;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    sparcDomainPtr pDomain;
-    resPtr         pRes = NULL;
-    resRange       range;
-    int            domain;
-
-    for (domain = 1;  domain < pciNumDomains;  domain++) {
-	if (!(pDomain = xf86DomainInfo[domain]))
-	    continue;
-
-	RANGE(range, 0, pDomain->mem_size - 1,
-	      RANGE_TYPE(ResExcMemBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-
-	RANGE(range, 0, pDomain->io_size - 1,
-	      RANGE_TYPE(ResExcIoBlock, domain));
-	pRes = xf86AddResToList(pRes, &range, -1);
-    }
-
-    return pRes;
-}
-
-resPtr
 xf86AccResFromOS(resPtr pRes)
 {
     sparcDomainPtr pDomain;
diff --git a/hw/xfree86/os-support/linux/lnxResource.c b/hw/xfree86/os-support/linux/lnxResource.c
index 6f89cdb..bb42d8a 100644
--- a/hw/xfree86/os-support/linux/lnxResource.c
+++ b/hw/xfree86/os-support/linux/lnxResource.c
@@ -31,121 +31,6 @@ _X_EXPORT resRange PciAvoid[] =
 #ifdef __alpha__
 
 resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-    /*
-     * On the Alpha the first 16MB of every 128 Mb segment in
-     * sparse address space are an image of the ISA bus range
-     */
-    if (_bus_base_sparse()) {
-	RANGE(range, 0x00000000, 0x07ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x09000000, 0x0fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x11000000, 0x17ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x19000000, 0x1fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x21000000, 0x27ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x29000000, 0x2fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x31000000, 0x37ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x39000000, 0x3fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x41000000, 0x47ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x49000000, 0x4fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x51000000, 0x57ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x59000000, 0x5fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x61000000, 0x67ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x69000000, 0x6fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x71000000, 0x77ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x79000000, 0x7fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x81000000, 0x87ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x89000000, 0x8fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x91000000, 0x97ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0x99000000, 0x9fffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xa1000000, 0xa7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xa9000000, 0xafffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xb1000000, 0xb7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xb9000000, 0xbfffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xc1000000, 0xc7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xc9000000, 0xcfffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xd1000000, 0xd7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xd9000000, 0xdfffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xe1000000, 0xe7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xe9000000, 0xefffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xf1000000, 0xf7ffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-	RANGE(range, 0xf9000000, 0xffffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-    } else {
-	RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-	ret = xf86AddResToList(ret, &range, -1);
-    }
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#ifdef INCLUDE_UNUSED
-
-resPtr
-xf86IsaBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#endif /* INCLUDE_UNUSED */
-
-resPtr
 xf86AccResFromOS(resPtr ret)
 {
     resRange range;
@@ -193,69 +78,6 @@ xf86AccResFromOS(resPtr ret)
       defined(__s390__) || \
       defined(__hppa__)
 
- /*
-  * XXX this isn't exactly correct but it will get the server working 
-  * for now until we get something better.
-  */
-  
-resPtr
-xf86BusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-#if defined(__sparc__) || defined(__powerpc__)
-    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
-#else
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-#endif
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-resPtr
-xf86PciBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-#if defined(__sparc__) || defined(__powerpc__)
-    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
-#else
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-#endif
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#ifdef INCLUDE_UNUSED
-
-resPtr
-xf86IsaBusAccWindowsFromOS(void)
-{
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-#if defined(__sparc__) || defined(__powerpc__)
-    RANGE(range, 0x00000000, 0x00ffffff, ResExcIoBlock);
-#else
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-#endif
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#endif /* INCLUDE_UNUSED */
-
 resPtr
 xf86AccResFromOS(resPtr ret)
 {
diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c
index 555f805..51d1a2a 100644
--- a/hw/xfree86/os-support/shared/stdResource.c
+++ b/hw/xfree86/os-support/shared/stdResource.c
@@ -44,10 +44,7 @@
 #include "bus/Pci.h"
 
 #ifdef USESTDRES
-#define xf86StdBusAccWindowsFromOS xf86BusAccWindowsFromOS
 #define xf86StdAccResFromOS xf86AccResFromOS
-#define xf86StdPciBusAccWindowsFromOS xf86PciBusAccWindowsFromOS
-#define xf86StdIsaBusAccWindowsFromOS xf86IsaBusAccWindowsFromOS
 
 _X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END};
 #endif
@@ -55,58 +52,6 @@ _X_EXPORT resRange PciAvoid[] = {_PCI_AV
 #ifdef INCLUDE_XF86_NO_DOMAIN
 
 resPtr
-xf86StdBusAccWindowsFromOS(void)
-{
-    /* Fallback is to allow addressing of all memory space */
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    /* Fallback is to allow addressing of all I/O space */
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-resPtr
-xf86StdPciBusAccWindowsFromOS(void)
-{
-    /* Fallback is to allow addressing of all memory space */
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    /* Fallback is to allow addressing of all I/O space */
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#ifdef INCLUDE_UNUSED
-
-resPtr
-xf86StdIsaBusAccWindowsFromOS(void)
-{
-    /* Fallback is to allow addressing of all memory space */
-    resPtr ret = NULL;
-    resRange range;
-
-    RANGE(range, 0x00000000, 0xffffffff, ResExcMemBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-
-    /* Fallback is to allow addressing of all I/O space */
-    RANGE(range, 0x00000000, 0x0000ffff, ResExcIoBlock);
-    ret = xf86AddResToList(ret, &range, -1);
-    return ret;
-}
-
-#endif /* INCLUDE_UNUSED */
-
-resPtr
 xf86StdAccResFromOS(resPtr ret)
 {
     resRange range;
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 6f0391d..1d6b842 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -228,17 +228,9 @@ extern PMClose xf86OSPMOpen(void);
 #ifdef NEED_OS_RAC_PROTOS
 /* RAC-related privs */
 /* internal to os-support layer */
-resPtr xf86StdBusAccWindowsFromOS(void);
-resPtr xf86StdPciAccWindowsFromOS(void);
-resPtr xf86StdIsaAccWindowsFromOS(void);
 resPtr xf86StdAccResFromOS(resPtr ret);
 
 /* available to the common layer */
-resPtr xf86BusAccWindowsFromOS(void);
-resPtr xf86PciBusAccWindowsFromOS(void);
-#ifdef INCLUDE_UNUSED
-resPtr xf86IsaBusAccWindowsFromOS(void);
-#endif
 resPtr xf86AccResFromOS(resPtr ret);
 #endif /* NEED_OS_RAC_PROTOS */
 
diff-tree 9e2112b2b56af099a7f380ece9b5c1d25b20cce4 (from 801c359574d08ff2d6ac75a3325ff522bc862e30)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 27 18:50:34 2007 -0700

    Remove unused xf8GetBlock and xf86GetSparse entry points.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 69d619e..0641074 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -138,12 +138,6 @@ Bool xf86IsEntityPrimary(int entityIndex
 resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
 resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
 void xf86EnterServerState(xf86State state);
-resRange xf86GetBlock(unsigned long type, memType size,
-		      memType window_start, memType window_end,
-		      memType align_mask, resPtr avoid);
-resRange xf86GetSparse(unsigned long type, memType fixed_bits,
-		       memType decode_mask, memType address_mask,
-		       resPtr avoid);
 memType xf86ChkConflict(resRange *rgp, int entityIndex);
 ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
 Bool xf86NoSharedResources(int screenIndex, resType res);
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 537ddf7..1959f79 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -1549,213 +1549,6 @@ RemoveOverlaps(resPtr target, resPtr lis
 #endif
 
 /*
- * Resource request code
- */
-
-#define ALIGN(x,a) ((x) + a) &~(a)
-
-_X_EXPORT resRange 
-xf86GetBlock(unsigned long type, memType size,
-	 memType window_start, memType window_end,
-	 memType align_mask, resPtr avoid)
-{
-    memType min, max, tmp;
-    resRange r = {ResEnd,0,0};
-    resPtr res_range = ResRange;
-    
-    if (!size) return r;
-    if (window_end < window_start || (window_end - window_start) < (size - 1)) {
-	ErrorF("Requesting insufficient memory window!:"
-	       " start: 0x%lx end: 0x%lx size 0x%lx\n",
-	       window_start,window_end,size);
-	return r;
-    }
-    type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResBlock;
-    
-    while (res_range) {
-	if ((type & ResTypeMask) == (res_range->res_type & ResTypeMask)) {
-	    if (res_range->block_begin > window_start)
-		min = res_range->block_begin;
-	    else
-		min = window_start;
-	    if (res_range->block_end < window_end)
-		max = res_range->block_end;
-	    else
-		max = window_end;
-	    min = ALIGN(min,align_mask);
-	    /* do not produce an overflow! */
-	    while (min < max && (max - min) >= (size - 1)) {
-		RANGE(r,min,min + size - 1,type);
-		tmp = ChkConflict(&r,Acc,SETUP);
-		if (!tmp) {
-		    tmp = ChkConflict(&r,avoid,SETUP);
-		    if (!tmp) {
-			return r;
-		    } 
-		}
-		min = ALIGN(tmp,align_mask);
-	    }
-	}
-	res_range = res_range->next;
-    }
-    RANGE(r,0,0,ResEnd);
-    return r;
-}
-
-#define mt_max ~(memType)0
-#define length sizeof(memType) * 8
-/*
- * make_base() -- assign the lowest bits to the bits set in mask.
- *                example: mask 011010 val 0000110 -> 011000 
- */
-static memType
-make_base(memType val, memType mask)
-{
-    int i,j = 0;
-    memType ret = 0
-	;
-    for (i = 0;i<length;i++) {
-	if ((1 << i) & mask) {
-	    ret |= (((val >> j) & 1) << i);
-	    j++;
-	}
-    }
-    return ret;
-}
-
-/*
- * make_base() -- assign the bits set in mask to the lowest bits.
- *                example: mask 011010 , val 010010 -> 000011
- */
-static memType
-unmake_base(memType val, memType mask)
-{
-    int i,j = 0;
-    memType ret = 0;
-    
-    for (i = 0;i<length;i++) {
-	if ((1 << i) & mask) {
-	    ret |= (((val >> i) & 1) << j);
-	    j++;
-	}
-    }
-    return ret;
-}
-
-static memType
-fix_counter(memType val, memType old_mask, memType mask)
-{
-    mask = old_mask & mask;
-    
-    val = make_base(val,old_mask);
-    return unmake_base(val,mask);
-}
-
-_X_EXPORT resRange
-xf86GetSparse(unsigned long type,  memType fixed_bits,
-	  memType decode_mask, memType address_mask, resPtr avoid)
-{
-    resRange r = {ResEnd,0,0};
-    memType new_mask;
-    memType mask1;
-    memType base;
-    memType counter = 0;
-    memType counter1;
-    memType max_counter = ~(memType)0;
-    memType max_counter1;
-    memType conflict = 0;
-    
-    /* for sanity */
-    type = (type & ~(ResExtMask | ResBios | ResEstimated)) | ResSparse;
-
-    /*
-     * a sparse address consists of 3 parts:
-     * fixed_bits:   F bits which hard decoded by the hardware
-     * decode_bits:  D bits which are used to decode address
-     *                 but which may be set by software
-     * address_bits: A bits which are used to address the
-     *                 sparse range.
-     * the decode_mask marks all decode bits while the address_mask
-     * masks out all address_bits:
-     *                F D A
-     * decode_mask:   0 1 0
-     * address_mask:  1 1 0
-     */
-    decode_mask &= address_mask;
-    new_mask = decode_mask;
-
-    /*
-     * We start by setting the decode_mask bits to different values
-     * when a conflict is found the address_mask of the conflicting
-     * resource is returned. We remove those bits from decode_mask
-     * that are also set in the returned address_mask as they always
-     * conflict with resources which use them as address masks.
-     * The resoulting mask is stored in new_mask.
-     * We continue until no conflict is found or until we have
-     * tried all possible settings of new_mask.
-     */
-    while (1) {
-	base = make_base(counter,new_mask) | fixed_bits;
-	RANGE(r,base,address_mask,type);
-	conflict = ChkConflict(&r,Acc,SETUP);
-	if (!conflict) {
-	    conflict = ChkConflict(&r,avoid,SETUP);
-	    if (!conflict) {
-		return r;
-	    }
-	}
-	counter = fix_counter(counter,new_mask,conflict);
-	max_counter = fix_counter(max_counter,new_mask,conflict);
-	new_mask &= conflict;
-	counter ++;
-	if (counter > max_counter) break;
-    }
-    if (!new_mask && (new_mask == decode_mask)) {
-	RANGE(r,0,0,ResEnd);
-	return r;
-    }
-    /*
-     * if we haven't been successful we also try to modify those
-     * bits in decode_mask that are not at the same time set in
-     * new mask. These bits overlap with address_bits of some
-     * resources. If a conflict with a resource of this kind is
-     * found (ie. returned_mask & mask1 != mask1) with
-     * mask1 = decode_mask & ~new_mask we cannot
-     * use our choice of bits in the new_mask part. We try
-     * another choice.
-     */
-    max_counter = fix_counter(mt_max,mt_max,new_mask);
-    mask1 = decode_mask & ~new_mask;
-    max_counter1 = fix_counter(mt_max,mt_max,mask1);
-    counter = 0;
-    
-    while (1) {
-	counter1 = 0;
-	while (1) {
-	    base = make_base(counter1,mask1);
-	    RANGE(r,base,address_mask,type);
-	    conflict = ChkConflict(&r,Acc,SETUP);
-	    if (!conflict) {
-		conflict = ChkConflict(&r,avoid,SETUP);
-		if (!conflict) {
-		    return r;
-		}
-	    }
-	    counter1 ++;
-	    if ((mask1 & conflict) != mask1 || counter1 > max_counter1)
-		break;
-	}
-	counter ++;
-	if (counter > max_counter) break;
-    }
-    RANGE(r,0,0,ResEnd);
-    return r;
-}
-
-#undef length
-#undef mt_max
-
-/*
  * Resource registrarion
  */
 
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 9b8dac8..cb2a2b9 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -333,8 +333,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86IsEntityPrimary)
     SYMFUNC(xf86SetOperatingState)
     SYMFUNC(xf86EnterServerState)
-    SYMFUNC(xf86GetBlock)
-    SYMFUNC(xf86GetSparse)
     SYMFUNC(xf86ChkConflict)
     SYMFUNC(xf86FindScreenForEntity)
     SYMFUNC(xf86RegisterStateChangeNotificationCallback)
diff-tree 801c359574d08ff2d6ac75a3325ff522bc862e30 (from 7d54399cfdaa7f54e28828267a76b89c4e8e798f)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 27 15:46:05 2007 -0700

    Fix fbdevhwstub for pci-rework.

diff --git a/hw/xfree86/fbdevhw/fbdevhwstub.c b/hw/xfree86/fbdevhw/fbdevhwstub.c
index 56ba929..191a6d3 100644
--- a/hw/xfree86/fbdevhw/fbdevhwstub.c
+++ b/hw/xfree86/fbdevhw/fbdevhwstub.c
@@ -1,4 +1,3 @@
-
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -23,13 +22,13 @@ fbdevHWFreeRec(ScrnInfoPtr pScrn)
 
 
 Bool
-fbdevHWProbe(pciVideoPtr pPci, char *device, char **namep)
+fbdevHWProbe(struct pci_device *pPci, char *device, char **namep)
 {
 	return FALSE;
 }
 
 Bool
-fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device)
+fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device)
 {
 	xf86Msg(X_ERROR, "fbdevhw is not available on this platform\n");
 	return FALSE;


More information about the xorg-commit mailing list