Module: wine Branch: master Commit: 4c6a40977998c0aa7f9f5fa26021b5c5a4d3520c URL: http://source.winehq.org/git/wine.git/?a=commit;h=4c6a40977998c0aa7f9f5fa260...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Dec 5 22:47:31 2011 +0100
winex11: Use an X11 error handler to catch BadMatch errors from XGetImage.
---
dlls/winex11.drv/bitblt.c | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index c1df77a..9830327 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -582,6 +582,12 @@ int main() #endif /* BITBLT_TEST */
+/* handler for XGetImage BadMatch errors */ +static int XGetImage_handler( Display *dpy, XErrorEvent *event, void *arg ) +{ + return (event->request_code == X_GetImage && event->error_code == BadMatch); +} + /*********************************************************************** * BITBLT_GetDstArea * @@ -1423,16 +1429,23 @@ DWORD X11DRV_GetImage( PHYSDEV dev, HBITMAP hbitmap, BITMAPINFO *info, } else { - Pixmap pixmap; + X11DRV_expect_error( gdi_display, XGetImage_handler, NULL ); + image = XGetImage( gdi_display, physdev->drawable, + physdev->dc_rect.left + x, physdev->dc_rect.top + y, + width, height, AllPlanes, ZPixmap ); + if (X11DRV_check_error()) + { + /* use a temporary pixmap to avoid the BadMatch error */ + Pixmap pixmap;
- wine_tsx11_lock(); - /* use a temporary pixmap to avoid BadMatch errors */ - pixmap = XCreatePixmap( gdi_display, root_window, width, height, depth ); - XCopyArea( gdi_display, physdev->drawable, pixmap, get_bitmap_gc(depth), - physdev->dc_rect.left + x, physdev->dc_rect.top + y, width, height, 0, 0 ); - image = XGetImage( gdi_display, pixmap, 0, 0, width, height, AllPlanes, ZPixmap ); - XFreePixmap( gdi_display, pixmap ); - wine_tsx11_unlock(); + wine_tsx11_lock(); + pixmap = XCreatePixmap( gdi_display, root_window, width, height, depth ); + XCopyArea( gdi_display, physdev->drawable, pixmap, get_bitmap_gc(depth), + physdev->dc_rect.left + x, physdev->dc_rect.top + y, width, height, 0, 0 ); + image = XGetImage( gdi_display, pixmap, 0, 0, width, height, AllPlanes, ZPixmap ); + XFreePixmap( gdi_display, pixmap ); + wine_tsx11_unlock(); + } } if (!image) return ERROR_OUTOFMEMORY;