Status XQueryTree(Display * display, Window w, Window * root_return, Window * parent_return, Window ** children_return, unsigned int *nchildren_return) { *root_return = GR_ROOT_WINDOW_ID; GrQueryTree(w, (GR_WINDOW_ID *) parent_return, (GR_WINDOW_ID **) children_return, (int*) nchildren_return); return 1; }
int XMapSubwindows(Display *dpy, Window w) { GR_WINDOW_ID parent; GR_WINDOW_ID *child, *cp; int i, nchild; GrQueryTree(w, &parent, &child, &nchild); cp = child; for (i=0; i<nchild; ++i) GrMapWindow(*cp++); free(child); return 1; }
static void GrQueryTreeWrapper(void *r) { nxQueryTreeReq *req = r; GR_WINDOW_ID parentid; GR_WINDOW_ID * children; GR_COUNT nchildren; GrQueryTree(req->windowid, &parentid, &children, &nchildren); GsWriteType(current_fd, GrNumQueryTree); GsWrite(current_fd, &parentid, sizeof(parentid)); GsWrite(current_fd, &nchildren, sizeof(nchildren)); if (nchildren) { GsWrite(current_fd, children, nchildren * sizeof(GR_WINDOW_ID)); free(children); } }
/* Calculate Visible region of root window. */ int CalcRootVisible(void) { GR_REGION_ID covered; GR_REGION_ID visible; GR_WINDOW_ID parent; GR_WINDOW_ID *children; GR_COUNT nChildren; GR_COUNT wx; GR_RECT rect; GR_WINDOW_INFO info; /* Get children of root. */ GrQueryTree(GR_ROOT_WINDOW_ID, &parent, &children, &nChildren); /* For each mapped child, add the window rectangle to the covered region. */ covered = GrNewRegion(); for (wx=0; wx<nChildren; wx++) { GrGetWindowInfo(children[wx], &info); if (info.unmapcount == 0) { rect.x = info.x; rect.y = info.y; rect.width = info.width; rect.height = info.height; GrUnionRectWithRegion(covered, &rect); } } free(children); /* Subtract the covered region from the root window region. */ visible = GrNewRegion(); rect.x = 0; rect.y = 0; rect.width = display_width; rect.height = display_height; GrUnionRectWithRegion(visible, &rect); GrSubtractRegion(visible, visible, covered); GrDestroyRegion(covered); /* Save visible region globally. */ if (rootVisible) GrDestroyRegion(rootVisible); rootVisible = visible; /* Mark all roaches visible. */ for (wx=0; wx<curRoaches; wx++) roaches[wx].hidden = 0; return 0; }