---
 xserver/hw/xwin/win.h         |    3 +++
 xserver/hw/xwin/winscrinit.c  |   32 +++++++++++++++++++++++++++-----
 xserver/hw/xwin/winshaddd.c   |    2 +-
 xserver/hw/xwin/winshadddnl.c |    2 +-
 xserver/hw/xwin/winshadgdi.c  |    2 +-
 5 files changed, 33 insertions(+), 8 deletions(-)

Index: xorg-git/xserver/hw/xwin/win.h
===================================================================
--- xorg-git.orig/xserver/hw/xwin/win.h
+++ xorg-git/xserver/hw/xwin/win.h
@@ -314,6 +314,7 @@ typedef Bool (*winReleasePrimarySurfaceP
 
 typedef Bool (*winFinishCreateWindowsWindowProcPtr)(WindowPtr pWin);
 
+typedef Bool (*winCreateScreenResourcesProc)(ScreenPtr);
 
 /* Typedef for DIX wrapper functions */
 typedef int (*winDispatchProcPtr) (ClientPtr);
@@ -564,6 +565,8 @@ typedef struct _winPrivScreenRec
   winCreatePrimarySurfaceProcPtr	pwinCreatePrimarySurface;
   winReleasePrimarySurfaceProcPtr	pwinReleasePrimarySurface;
 
+  winCreateScreenResourcesProc       pwinCreateScreenResources;
+
 #ifdef XWIN_MULTIWINDOW
   /* Window Procedures for MultiWindow mode */
   winFinishCreateWindowsWindowProcPtr	pwinFinishCreateWindowsWindow;
Index: xorg-git/xserver/hw/xwin/winscrinit.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winscrinit.c
+++ xorg-git/xserver/hw/xwin/winscrinit.c
@@ -244,6 +244,25 @@ winScreenInit (int index,
   return TRUE;
 }
 
+static Bool
+winCreateScreenResources(ScreenPtr pScreen)
+{
+  winScreenPriv(pScreen);
+  Bool result;
+
+  result = pScreenPriv->pwinCreateScreenResources(pScreen);
+
+  /* Now the screen bitmap has been wrapped in a pixmap,
+     add that to the Shadow framebuffer */
+  if (!shadowAdd(pScreen, pScreen->devPrivate,
+		 pScreenPriv->pwinShadowUpdate, NULL, 0, 0))
+    {
+      ErrorF ("winCreateScreenResources - shadowAdd () failed\n");
+      return FALSE;
+    }
+
+  return result;
+}
 
 /* See Porting Layer Definition - p. 20 */
 Bool
@@ -427,15 +446,18 @@ winFinishScreenInitFB (int index,
       )
     {
 #if CYGDEBUG
-      winDebug ("winFinishScreenInitFB - Calling shadowInit ()\n");
+      winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n");
 #endif
-      if (!shadowInit (pScreen,
-		       pScreenPriv->pwinShadowUpdate,
-		       NULL))
+      if (!shadowSetup(pScreen))
 	{
-	  ErrorF ("winFinishScreenInitFB - shadowInit () failed\n");
+	  ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n");
 	  return FALSE;
 	}
+
+      /* Wrap CreateScreenResources so we can add the screen pixmap
+         to the Shadow framebuffer after it's been created */
+      pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources;
+      pScreen->CreateScreenResources = winCreateScreenResources;
     }
 
 #ifdef XWIN_MULTIWINDOWEXTWM
Index: xorg-git/xserver/hw/xwin/winshaddd.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winshaddd.c
+++ xorg-git/xserver/hw/xwin/winshaddd.c
@@ -508,7 +508,7 @@ winShadowUpdateDD (ScreenPtr pScreen, 
 {
   winScreenPriv(pScreen);
   winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
-  RegionPtr		damage = &pBuf->damage;
+  RegionPtr		damage = shadowDamage(pBuf);
   HRESULT		ddrval = DD_OK;
   RECT			rcDest, rcSrc;
   POINT			ptOrigin;
Index: xorg-git/xserver/hw/xwin/winshadddnl.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winshadddnl.c
+++ xorg-git/xserver/hw/xwin/winshadddnl.c
@@ -584,7 +584,7 @@ winShadowUpdateDDNL (ScreenPtr pScreen, 
 {
   winScreenPriv(pScreen);
   winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
-  RegionPtr		damage = &pBuf->damage;
+  RegionPtr		damage = shadowDamage(pBuf);
   HRESULT		ddrval = DD_OK;
   RECT			rcDest, rcSrc;
   POINT			ptOrigin;
Index: xorg-git/xserver/hw/xwin/winshadgdi.c
===================================================================
--- xorg-git.orig/xserver/hw/xwin/winshadgdi.c
+++ xorg-git/xserver/hw/xwin/winshadgdi.c
@@ -498,7 +498,7 @@ winShadowUpdateGDI (ScreenPtr pScreen, 
 {
   winScreenPriv(pScreen);
   winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
-  RegionPtr		damage = &pBuf->damage;
+  RegionPtr		damage = shadowDamage(pBuf);
   DWORD			dwBox = REGION_NUM_RECTS (damage);
   BoxPtr		pBox = REGION_RECTS (damage);
   int			x, y, w, h;

-- 

