On 13 Apr 2005 11:59:02 +0200, you wrote: > > > > What am I doing wrong here? > > Nothing, there's no way to avoid the race. You just need to ignore the > BadMatch error in that case.
Right, here is the next try: Changelog: dlls/x11drv : dib.c In X11DRV_DIB_SetImageBits avoid BadMatch errors when calling XGetSubImage. Rein.
--- wine/dlls/x11drv/dib.c 2005-04-13 08:55:39.000000000 +0200 +++ mywine/dlls/x11drv/dib.c 2005-04-13 13:24:10.000000000 +0200 @@ -3484,6 +3484,41 @@ static void X11DRV_DIB_GetImageBits_32( } } +static int XGetSubImageErrorHandler(Display *dpy, XErrorEvent *event, void *arg) +{ + return 1; +} +/*********************************************************************** + * X11DRV_DIB_SetImageBits_GetSubImage + * + * Helper for X11DRV_DIB_SetImageBits + */ +static void X11DRV_DIB_SetImageBits_GetSubImage( + const X11DRV_DIB_IMAGEBITS_DESCR *descr, XImage *bmpImage) +{ + /* compressed bitmaps may contain gaps in them. So make a copy + * of the existing pixels first */ + RECT bmprc = { descr->xDest, descr->yDest, + descr->xDest + descr->width , descr->yDest + descr->height}; + RECT rc; + int fail; + + GetRgnBox( descr->physDev->region, &rc ); + /* convert from dc to drawable origin */ + OffsetRect( &rc, descr->physDev->org.x, descr->physDev->org.y); + /* clip visible rect with bitmap */ + if( IntersectRect( &rc, &rc, &bmprc)){ + X11DRV_expect_error( gdi_display,XGetSubImageErrorHandler, NULL ); + XGetSubImage( gdi_display, descr->drawable, rc.left, rc.top, + rc.right - rc.left, rc.bottom - rc.top, AllPlanes, + ZPixmap, bmpImage, + descr->xSrc + rc.left - bmprc.left, + descr->ySrc + rc.top - bmprc.top); + fail = X11DRV_check_error(); + if( fail) TRACE( "XGetSubImage failed\n"); + } +} + /*********************************************************************** * X11DRV_DIB_SetImageBits * @@ -3526,10 +3561,7 @@ static int X11DRV_DIB_SetImageBits( cons break; case 4: if (descr->compression) { - XGetSubImage( gdi_display, descr->drawable, descr->xDest, descr->yDest, - descr->width, descr->height, AllPlanes, ZPixmap, - bmpImage, descr->xSrc, descr->ySrc ); - + X11DRV_DIB_SetImageBits_GetSubImage( descr, bmpImage); X11DRV_DIB_SetImageBits_RLE4( descr->lines, descr->bits, descr->infoWidth, descr->width, descr->xSrc, (int *)(descr->colorMap), @@ -3542,9 +3574,7 @@ static int X11DRV_DIB_SetImageBits( cons break; case 8: if (descr->compression) { - XGetSubImage( gdi_display, descr->drawable, descr->xDest, descr->yDest, - descr->width, descr->height, AllPlanes, ZPixmap, - bmpImage, descr->xSrc, descr->ySrc ); + X11DRV_DIB_SetImageBits_GetSubImage( descr, bmpImage); X11DRV_DIB_SetImageBits_RLE8( descr->lines, descr->bits, descr->infoWidth, descr->width, descr->xSrc, (int *)(descr->colorMap),