(!1654) Xnest: GC: replace XGetImage() by xcb_get_image()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									8eebda19b7
								
							
						
					
					
						commit
						3d3f1f379c
					
				| 
						 | 
				
			
			@ -100,36 +100,35 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 | 
			
		|||
                  (uint8_t*)pImage);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
xnestIgnoreErrorHandler (Display     *dpy,
 | 
			
		||||
                         XErrorEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    return FALSE; /* return value is ignored */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
 | 
			
		||||
              unsigned int format, unsigned long planeMask, char *pImage)
 | 
			
		||||
{
 | 
			
		||||
    XImage *ximage;
 | 
			
		||||
    int length;
 | 
			
		||||
    int (*old_handler)(Display*, XErrorEvent*);
 | 
			
		||||
    xcb_generic_error_t * err = NULL;
 | 
			
		||||
    xcb_get_image_reply_t *reply= xcb_get_image_reply(
 | 
			
		||||
        xnestUpstreamInfo.conn,
 | 
			
		||||
        xcb_get_image(
 | 
			
		||||
            xnestUpstreamInfo.conn,
 | 
			
		||||
            format,
 | 
			
		||||
            xnestDrawable(pDrawable),
 | 
			
		||||
            x, y, w, h, planeMask),
 | 
			
		||||
        &err);
 | 
			
		||||
 | 
			
		||||
    /* we may get BadMatch error when xnest window is minimized */
 | 
			
		||||
    XSync(xnestDisplay, FALSE);
 | 
			
		||||
    old_handler = XSetErrorHandler (xnestIgnoreErrorHandler);
 | 
			
		||||
 | 
			
		||||
    ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
 | 
			
		||||
                       x, y, w, h, planeMask, format);
 | 
			
		||||
    XSetErrorHandler(old_handler);
 | 
			
		||||
 | 
			
		||||
    if (ximage) {
 | 
			
		||||
        length = ximage->bytes_per_line * ximage->height;
 | 
			
		||||
 | 
			
		||||
        memmove(pImage, ximage->data, length);
 | 
			
		||||
 | 
			
		||||
        XDestroyImage(ximage);
 | 
			
		||||
    if (err) {
 | 
			
		||||
        //  badMatch may happeen if the upstream window is currently minimized
 | 
			
		||||
        if (err->error_code != BadMatch)
 | 
			
		||||
            LogMessage(X_WARNING, "xnestGetImage: received error %d\n", err->error_code);
 | 
			
		||||
        free(err);
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!reply) {
 | 
			
		||||
        LogMessage(X_WARNING, "xnestGetImage: received no reply\n");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    memmove(pImage, xcb_get_image_data(reply), xcb_get_image_data_length(reply));
 | 
			
		||||
    free(reply);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static Bool
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue