static void deletefree(void *currblock) { int listcounter = 0; size_t size = GETSIZE(HEADER(currblock)); for (;(listcounter < LISTS - 1) && (size > 1); listcounter++) { size >>= 1; } if (PREVFREE(currblock) != NULL) { if (NEXTFREE(currblock) != NULL) { SETPTR(NEXTPTR(PREVFREE(currblock)), NEXTFREE(currblock)); SETPTR(PREVPTR(NEXTFREE(currblock)), PREVFREE(currblock)); } else { SETPTR(NEXTPTR(PREVFREE(currblock)), NULL); free_lists[listcounter] = PREVFREE(currblock); } } else { if (NEXTFREE(currblock) != NULL) { SETPTR(PREVPTR(NEXTFREE(currblock)), NULL); } else { free_lists[listcounter] = NULL; } } return; }
int XQueryColor( register Display *dpy, Colormap cmap, XColor *def) /* RETURN */ { xrgb color; xQueryColorsReply rep; register xQueryColorsReq *req; unsigned long val = def->pixel; /* needed for macro below */ LockDisplay(dpy); GetReqExtra(QueryColors, 4, req); /* a pixel (CARD32) is 4 bytes */ req->cmap = cmap; OneDataCard32 (dpy, NEXTPTR(req,xQueryColorsReq), val); if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) { _XRead(dpy, (char *)&color, (long) SIZEOF(xrgb)); def->red = color.red; def->blue = color.blue; def->green = color.green; def->flags = DoRed | DoGreen | DoBlue; } UnlockDisplay(dpy); SyncHandle(); return 1; }
int XRemoveHost ( register Display *dpy, XHostAddress *host) { register xChangeHostsReq *req; register int length; XServerInterpretedAddress *siAddr; int addrlen; if (host->family == FamilyServerInterpreted) { siAddr = (XServerInterpretedAddress *) host->address; addrlen = siAddr->typelength + siAddr->valuelength + 1; } else { addrlen = host->length; } length = (addrlen + 3) & ~0x3; /* round up */ LockDisplay(dpy); GetReqExtra (ChangeHosts, length, req); req->mode = HostDelete; req->hostFamily = host->family; req->hostLength = addrlen; if (host->family == FamilyServerInterpreted) { char *dest = (char *) NEXTPTR(req,xChangeHostsReq); memcpy(dest, siAddr->type, siAddr->typelength); dest[siAddr->typelength] = '\0'; memcpy(dest + siAddr->typelength + 1,siAddr->value,siAddr->valuelength); } else { memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, addrlen); } UnlockDisplay(dpy); SyncHandle(); return 1; }
int XLowerWindow( Display *dpy, Window w) { register xConfigureWindowReq *req; unsigned long val = Below; /* needed for macro */ LockDisplay(dpy); GetReqExtra(ConfigureWindow, 4, req); req->window = w; req->mask = CWStackMode; OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val); UnlockDisplay(dpy); SyncHandle(); return 1; }
int XSetWindowBorderWidth( Display *dpy, Window w, unsigned int width) { unsigned long lwidth = width; /* must be CARD32 */ register xConfigureWindowReq *req; LockDisplay(dpy); GetReqExtra(ConfigureWindow, 4, req); req->window = w; req->mask = CWBorderWidth; OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), lwidth); UnlockDisplay(dpy); SyncHandle(); return 1; }
int XMapRaised ( register Display *dpy, Window w) { register xConfigureWindowReq *req; register xResourceReq *req2; unsigned long val = Above; /* needed for macro */ LockDisplay(dpy); GetReqExtra(ConfigureWindow, 4, req); req->window = w; req->mask = CWStackMode; OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val); GetResReq (MapWindow, w, req2); UnlockDisplay(dpy); SyncHandle(); return 1; }
int XMoveResizeWindow( register Display *dpy, Window w, int x, int y, unsigned int width, unsigned int height) { register xConfigureWindowReq *req; LockDisplay(dpy); GetReqExtra(ConfigureWindow, 16, req); req->window = w; req->mask = CWX | CWY | CWWidth | CWHeight; #ifdef MUSTCOPY { long lx = x, ly = y; unsigned long lwidth = width, lheight = height; dpy->bufptr -= 16; Data32 (dpy, (long *) &lx, 4); /* order must match values of */ Data32 (dpy, (long *) &ly, 4); /* CWX, CWY, CWWidth, and CWHeight */ Data32 (dpy, (long *) &lwidth, 4); Data32 (dpy, (long *) &lheight, 4); } #else { register CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xConfigureWindowReq); *valuePtr++ = x; *valuePtr++ = y; *valuePtr++ = width; *valuePtr = height; } #endif /* MUSTCOPY */ UnlockDisplay(dpy); SyncHandle(); return 1; }
static void insertfree(void *currblock, size_t size) { int listcounter = 0; void *search_currblock = currblock; void *insert_currblock = NULL; for(;(listcounter < LISTS - 1) && (size > 1); listcounter++) { size >>= 1; } search_currblock = free_lists[listcounter]; while ((search_currblock != NULL) && (size > GETSIZE(HEADER(search_currblock)))) { insert_currblock = search_currblock; search_currblock = PREVFREE(search_currblock); } if (search_currblock != NULL) { if (insert_currblock != NULL) { SETPTR(PREVPTR(currblock), search_currblock); SETPTR(NEXTPTR(search_currblock), currblock); SETPTR(NEXTPTR(currblock), insert_currblock); SETPTR(PREVPTR(insert_currblock), currblock); } else { SETPTR(PREVPTR(currblock), search_currblock); SETPTR(NEXTPTR(search_currblock), currblock); SETPTR(NEXTPTR(currblock), NULL); free_lists[listcounter] = currblock; } } else { if (insert_currblock != NULL) { SETPTR(PREVPTR(currblock), NULL); SETPTR(NEXTPTR(currblock), insert_currblock); SETPTR(PREVPTR(insert_currblock), currblock); } else { SETPTR(PREVPTR(currblock), NULL); SETPTR(NEXTPTR(currblock), NULL); free_lists[listcounter] = currblock; } } return; }
if ( (req->reqType == X_PolySegment) && (req->drawable == d) && (req->gc == gc->gid) && ((dpy->bufptr + SIZEOF(xSegment)) <= dpy->bufmax) && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ? wsize : zsize)) ) { req->length += SIZEOF(xSegment) >> 2; segment = (xSegment *) dpy->bufptr; dpy->bufptr += SIZEOF(xSegment); } else { GetReqExtra (PolySegment, SIZEOF(xSegment), req); req->drawable = d; req->gc = gc->gid; segment = (xSegment *) NEXTPTR(req,xPolySegmentReq); } segment->x1 = x1; segment->y1 = y1; segment->x2 = x2; segment->y2 = y2; UnlockDisplay(dpy); SyncHandle(); } return 1; }
req->length += SIZEOF(xArc) >> 2; #ifndef MUSTCOPY arc = (xArc *) dpy->bufptr; dpy->bufptr += SIZEOF(xArc); #endif /* not MUSTCOPY */ } else { GetReqExtra(PolyFillArc, SIZEOF(xArc), req); req->drawable = d; req->gc = gc->gid; #ifdef MUSTCOPY dpy->bufptr -= SIZEOF(xArc); #else arc = (xArc *) NEXTPTR(req,xPolyFillArcReq); #endif /* MUSTCOPY */ } arc->x = x; arc->y = y; arc->width = width; arc->height = height; arc->angle1 = angle1; arc->angle2 = angle2; #ifdef MUSTCOPY Data (dpy, (char *) arc, len); #endif /* MUSTCOPY */ } UnlockDisplay(dpy);