fdddc05
From 7e80526c1ce53d7228680ac403bf89d3874d198f Mon Sep 17 00:00:00 2001
fdddc05
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel@daenzer.net>
fdddc05
Date: Fri, 23 Apr 2010 15:54:28 +0200
fdddc05
Subject: [PATCH] DRI2: Fix handling of redirected pixmaps
fdddc05
fdddc05
There's a problem with this change (and potentially in DRI2SwapEvent()
fdddc05
even before it): at least the pixmaps backing redirected windows still
fdddc05
have ->drawable.id == 0. This can result in weird behaviour with a GLX
fdddc05
compositing manager, e.g. when running the same app twice in a row: the
fdddc05
second window will show a static snapshot of the first one, because the
fdddc05
compositing manager gets the DRI2 front buffer from the first, since
fdddc05
destroyed window.
fdddc05
---
fdddc05
 glx/glxdri2.c             |    2 +-
fdddc05
 hw/xfree86/dri2/dri2.c    |    5 ++++-
fdddc05
 hw/xfree86/dri2/dri2.h    |    2 +-
fdddc05
 hw/xfree86/dri2/dri2ext.c |    2 +-
fdddc05
 4 files changed, 7 insertions(+), 4 deletions(-)
fdddc05
fdddc05
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
fdddc05
index bde519a..a70bc97 100644
fdddc05
--- a/glx/glxdri2.c
fdddc05
+++ b/glx/glxdri2.c
fdddc05
@@ -457,7 +457,7 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
fdddc05
     private->base.waitGL	= __glXDRIdrawableWaitGL;
fdddc05
     private->base.waitX		= __glXDRIdrawableWaitX;
fdddc05
 
fdddc05
-    if (DRI2CreateDrawable(pDraw)) {
fdddc05
+    if (DRI2CreateDrawable(pDraw, drawId)) {
fdddc05
 	    xfree(private);
fdddc05
 	    return NULL;
fdddc05
     }
fdddc05
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
fdddc05
index 63bef28..5d02378 100644
fdddc05
--- a/hw/xfree86/dri2/dri2.c
fdddc05
+++ b/hw/xfree86/dri2/dri2.c
fdddc05
@@ -105,11 +105,14 @@ DRI2GetDrawable(DrawablePtr pDraw)
fdddc05
 }
fdddc05
 
fdddc05
 int
fdddc05
-DRI2CreateDrawable(DrawablePtr pDraw)
fdddc05
+DRI2CreateDrawable(DrawablePtr pDraw, XID id)
fdddc05
 {
fdddc05
     DRI2DrawablePtr pPriv;
fdddc05
     int rc;
fdddc05
 
fdddc05
+    if (!pDraw->id)
fdddc05
+       pDraw->id = id;
fdddc05
+
fdddc05
     rc = dixLookupResourceByType((pointer *) &pPriv, pDraw->id,
fdddc05
 				 dri2DrawableRes, NULL, DixReadAccess);
fdddc05
     if (rc == Success || rc != BadValue)
fdddc05
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
fdddc05
index 1c8626b..4b7a65c 100644
fdddc05
--- a/hw/xfree86/dri2/dri2.h
fdddc05
+++ b/hw/xfree86/dri2/dri2.h
fdddc05
@@ -193,7 +193,7 @@ extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
fdddc05
 
fdddc05
 extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
fdddc05
 
fdddc05
-extern _X_EXPORT int DRI2CreateDrawable(DrawablePtr pDraw);
fdddc05
+extern _X_EXPORT int DRI2CreateDrawable(DrawablePtr pDraw, XID id);
fdddc05
 
fdddc05
 extern _X_EXPORT void DRI2DestroyDrawable(DrawablePtr pDraw);
fdddc05
 
fdddc05
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
fdddc05
index 1ac4a5f..35dac47 100644
fdddc05
--- a/hw/xfree86/dri2/dri2ext.c
fdddc05
+++ b/hw/xfree86/dri2/dri2ext.c
fdddc05
@@ -167,7 +167,7 @@ ProcDRI2CreateDrawable(ClientPtr client)
fdddc05
 		       &pDrawable, &status))
fdddc05
 	return status;
fdddc05
 
fdddc05
-    status = DRI2CreateDrawable(pDrawable);
fdddc05
+    status = DRI2CreateDrawable(pDrawable, stuff->drawable);
fdddc05
     if (status != Success)
fdddc05
 	return status;
fdddc05
 
fdddc05
-- 
fdddc05
1.6.6.1
fdddc05