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

Peter Dons Tychsen donpedro at tdcadsl.dk
Sun Jun 17 19:25:30 CDT 2007


Hello Wine.

Here is a small patch to fix a no-no in X11DRV_DIB_GetImageBits().

Bug: XShmGetImage() uses the bmpImage variable to calculate how much
data is to be fetched from the pixmap. If the bmpImage is larger than
the available data in capture, then XShmGetImage() call will therefore
fail, and will spam the user with X errors in the console (not Wine
output). Therefore this patch checks too see if this is the case. If it
is, the function falls back on XGetSubImage() to do the work.

Why XGetSubImage() is not always used i do not know, but presumably it
is because XShmGetImage() is faster. Anyway, now it works for all cases.

This patch fixes apps which like to use large bitmaps for small
captures. Not a common thing, but it happens (and is valid).
Usually the app will crash without this fix.

/Pedro, Denmark

BTW: I use Wine allot, and i would just like to say THANKS!

>From e30374f6d88b65ae25b7e58d04d49142924c4292 Mon Sep 17 00:00:00 2001
From: Peter Dons Tychsen <donpedro at dhcppc2.(none)>
Date: Wed, 6 Jun 2007 02:27:31 +0200
Subject: [PATCH] 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


-------------- next part --------------
An embedded message was scrubbed...
From: Peter Dons Tychsen <donpedro at tdcadsl.dk>
Subject: Patch: Fix X11DRV_DIB_GetImageBits() when target bitmaps are
	larger than fetched area.
Date: Wed, 06 Jun 2007 02:44:21 +0200
Size: 3521
Url: http://www.winehq.org/pipermail/wine-patches/attachments/20070618/145e8c9f/attachment.mht


More information about the wine-patches mailing list