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
							
								
									d3d0ffe0cf
								
							
						
					
					
						commit
						0836bd402f
					
				| 
						 | 
					@ -99,36 +99,35 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 | 
				
			||||||
                  (uint8_t*)pImage);
 | 
					                  (uint8_t*)pImage);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					 | 
				
			||||||
xnestIgnoreErrorHandler (Display     *dpy,
 | 
					 | 
				
			||||||
                         XErrorEvent *event)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    return FALSE; /* return value is ignored */
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
 | 
					xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
 | 
				
			||||||
              unsigned int format, unsigned long planeMask, char *pImage)
 | 
					              unsigned int format, unsigned long planeMask, char *pImage)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    XImage *ximage;
 | 
					    xcb_generic_error_t * err = NULL;
 | 
				
			||||||
    int length;
 | 
					    xcb_get_image_reply_t *reply= xcb_get_image_reply(
 | 
				
			||||||
    int (*old_handler)(Display*, XErrorEvent*);
 | 
					        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 */
 | 
					    if (err) {
 | 
				
			||||||
    XSync(xnestDisplay, FALSE);
 | 
					        //  badMatch may happeen if the upstream window is currently minimized
 | 
				
			||||||
    old_handler = XSetErrorHandler (xnestIgnoreErrorHandler);
 | 
					        if (err->error_code != BadMatch)
 | 
				
			||||||
 | 
					            LogMessage(X_WARNING, "xnestGetImage: received error %d\n", err->error_code);
 | 
				
			||||||
    ximage = XGetImage(xnestDisplay, xnestDrawable(pDrawable),
 | 
					        free(err);
 | 
				
			||||||
                       x, y, w, h, planeMask, format);
 | 
					        return;
 | 
				
			||||||
    XSetErrorHandler(old_handler);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (ximage) {
 | 
					 | 
				
			||||||
        length = ximage->bytes_per_line * ximage->height;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        memmove(pImage, ximage->data, length);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        XDestroyImage(ximage);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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
 | 
					static Bool
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue