diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 88111a306..df2b23ed0 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -147,7 +147,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; @@ -263,9 +262,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 */ diff --git a/hw/xnest/xcb.c b/hw/xnest/xcb.c index 39d868dd6..57dcd4cdf 100644 --- a/hw/xnest/xcb.c +++ b/hw/xnest/xcb.c @@ -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 }; +} diff --git a/hw/xnest/xnest-xcb.h b/hw/xnest/xnest-xcb.h index 410145a18..7b03811e3 100644 --- a/hw/xnest/xnest-xcb.h +++ b/hw/xnest/xnest-xcb.h @@ -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 */