(!1654) Xnest: replace XGetWindowAttributes() by xcb_get_geometry()
Use xcb function instead of Xlib, and also spare one additional (unused) request. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
		
							parent
							
								
									0775a1dcb2
								
							
						
					
					
						commit
						5bd0415613
					
				| 
						 | 
				
			
			@ -149,7 +149,6 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
 | 
			
		|||
    int numVisuals, numDepths;
 | 
			
		||||
    int i, j, depthIndex;
 | 
			
		||||
    unsigned long valuemask;
 | 
			
		||||
    XWindowAttributes gattributes;
 | 
			
		||||
    VisualID defaultVisual;
 | 
			
		||||
    int rootDepth;
 | 
			
		||||
    miPointerScreenPtr PointPriv;
 | 
			
		||||
| 
						 | 
				
			
			@ -265,9 +264,9 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
 | 
			
		|||
    rootDepth = visuals[xnestDefaultVisualIndex].nplanes;
 | 
			
		||||
 | 
			
		||||
    if (xnestParentWindow != 0) {
 | 
			
		||||
        XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes);
 | 
			
		||||
        xnestGeometry.width = gattributes.width;
 | 
			
		||||
        xnestGeometry.height = gattributes.height;
 | 
			
		||||
        xRectangle r = xnest_get_geometry(xnestUpstreamInfo.conn, xnestParentWindow);
 | 
			
		||||
        xnestGeometry.width = r.width;
 | 
			
		||||
        xnestGeometry.height = r.height;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* myNum */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -292,3 +292,29 @@ void xnest_get_pointer_control(
 | 
			
		|||
    *threshold = reply->threshold;
 | 
			
		||||
    free(reply);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
xRectangle xnest_get_geometry(xcb_connection_t *conn, uint32_t window)
 | 
			
		||||
{
 | 
			
		||||
    xcb_generic_error_t *err = NULL;
 | 
			
		||||
    xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(
 | 
			
		||||
        xnestUpstreamInfo.conn,
 | 
			
		||||
        xcb_get_geometry(xnestUpstreamInfo.conn, window),
 | 
			
		||||
        &err);
 | 
			
		||||
 | 
			
		||||
    if (err) {
 | 
			
		||||
        ErrorF("failed getting window attributes for %d: %d\n", window, err->error_code);
 | 
			
		||||
        free(err);
 | 
			
		||||
        return (xRectangle) { 0 };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!reply) {
 | 
			
		||||
        ErrorF("failed getting window attributes for %d: no reply\n", window);
 | 
			
		||||
        return (xRectangle) { 0 };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return (xRectangle) {
 | 
			
		||||
        .x = reply->x,
 | 
			
		||||
        .y = reply->y,
 | 
			
		||||
        .width = reply->width,
 | 
			
		||||
        .height = reply->height };
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,4 +43,6 @@ xcb_get_keyboard_mapping_reply_t *xnest_get_keyboard_mapping(xcb_connection_t *c
 | 
			
		|||
 | 
			
		||||
void xnest_get_pointer_control(xcb_connection_t *conn, int *acc_num, int *acc_den, int *threshold);
 | 
			
		||||
 | 
			
		||||
xRectangle xnest_get_geometry(xcb_connection_t *conn, uint32_t window);
 | 
			
		||||
 | 
			
		||||
#endif /* __XNEST__XCB_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue