winex11 - Fix X11DRV_DIB_GetImageBits() when target bitmaps are larger than fetched area

Peter Dons Tychsen donpedro at tdcadsl.dk
Sun Jun 17 19:52:23 CDT 2007


Hello again.

Ups.. resending this as the first one was crappy.
It had multiple copies of the patch, and my email was gobbled in patch.

Terribly sorry about that,

>From 8b3e7a47b162ad81ad2a1172279897db563ef147 Mon Sep 17 00:00:00 2001
From: Peter Dons Tychsen <donpedro at tdcadsl.dk>
Date: Mon, 18 Jun 2007 02:46:13 +0200
Subject: Fixed X11DRV_DIB_GetImageBits() to be able to handle bitmap
targets which are larger than the area being fetched when XShmGetImage()
is being used

---
 dlls/winex11.drv/dib.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
index c921034..f0ecd56 100644
--- a/dlls/winex11.drv/dib.c
+++ b/dlls/winex11.drv/dib.c
@@ -3602,6 +3602,12 @@ static int X11DRV_DIB_GetImageBits( const
X11DRV_DIB_IMAGEBITS_DESCR *descr )
     int lines = descr->lines >= 0 ? descr->lines : -descr->lines;
     XImage *bmpImage;
 
+#ifdef HAVE_LIBXXSHM
+    Window root;
+    int x, y;
+    unsigned int width, height, border_width, depth;
+#endif
+
     wine_tsx11_lock();
    if (descr->image)
         bmpImage = descr->image;
@@ -3618,7 +3624,17 @@ static int X11DRV_DIB_GetImageBits( const
X11DRV_DIB_IMAGEBITS_DESCR *descr )
     }
 
 #ifdef HAVE_LIBXXSHM
-    if (descr->image && descr->useShm)
+
+    if(descr->image && descr->useShm)
+    {
+	XGetGeometry(gdi_display, descr->drawable, &root, &x, &y, &width,
&height, &border_width, &depth);
+        TRACE("XGetGeometry(), width=%i, heigth=%i\n", width, height);
+    }
+    
+    /* We must not call XShmGetImage() with a bitmap which is bigger
than the avilable area.
+       If we do, XShmGetImage() will fail (X exception), as it checks
for this internally. */
+    if((descr->image && descr->useShm) && (bmpImage->width <= (width -
descr->xSrc)) 
+      && (bmpImage->height <= (height - descr->ySrc)))
     {
         int saveRed, saveGreen, saveBlue;
 
-- 
1.5.0.6





More information about the wine-patches mailing list