/* can only call when display is locked. */ void _XSetClipRectangles ( register Display *dpy, GC gc, int clip_x_origin, int clip_y_origin, XRectangle *rectangles, int n, int ordering) { register xSetClipRectanglesReq *req; register long len; unsigned long dirty; register _XExtension *ext; GetReq (SetClipRectangles, req); req->gc = gc->gid; req->xOrigin = gc->values.clip_x_origin = clip_x_origin; req->yOrigin = gc->values.clip_y_origin = clip_y_origin; req->ordering = ordering; len = ((long)n) << 1; SetReqLen(req, len, 1); len <<= 2; Data16 (dpy, (short *) rectangles, len); gc->rects = 1; dirty = gc->dirty & ~(GCClipMask | GCClipXOrigin | GCClipYOrigin); gc->dirty = GCClipMask | GCClipXOrigin | GCClipYOrigin; /* call out to any extensions interested */ for (ext = dpy->ext_procs; ext; ext = ext->next) if (ext->flush_GC) (*ext->flush_GC)(dpy, gc, &ext->codes); gc->dirty = dirty; }
void XRenderAddGlyphs (Display *dpy, GlyphSet glyphset, _Xconst Glyph *gids, _Xconst XGlyphInfo *glyphs, int nglyphs, _Xconst char *images, int nbyte_images) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); xRenderAddGlyphsReq *req; long len; if (nbyte_images & 3) nbyte_images += 4 - (nbyte_images & 3); RenderSimpleCheckExtension (dpy, info); LockDisplay(dpy); GetReq(RenderAddGlyphs, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderAddGlyphs; req->glyphset = glyphset; req->nglyphs = nglyphs; len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2; SetReqLen(req, len, len); Data32 (dpy, (long *) gids, nglyphs * 4); Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo)); Data (dpy, images, nbyte_images); UnlockDisplay(dpy); SyncHandle(); }
void XRRConfigureProviderProperty (Display *dpy, RRProvider provider, Atom property, Bool pending, Bool range, int num_values, long *values) { XExtDisplayInfo *info = XRRFindDisplay(dpy); xRRConfigureProviderPropertyReq *req; long len; RRSimpleCheckExtension (dpy, info); LockDisplay(dpy); GetReq (RRConfigureProviderProperty, req); req->reqType = info->codes->major_opcode; req->randrReqType = X_RRConfigureProviderProperty; req->provider = provider; req->property = property; req->pending = pending; req->range = range; len = num_values; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); len = (long)num_values << 2; Data32 (dpy, values, len); } /* else force BadLength */ UnlockDisplay(dpy); SyncHandle(); }
Picture XRenderCreateConicalGradient(Display *dpy, const XConicalGradient *gradient, const XFixed *stops, const XRenderColor *colors, int nStops) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); Picture pid; xRenderCreateConicalGradientReq *req; long len; RenderCheckExtension (dpy, info, 0); LockDisplay(dpy); GetReq(RenderCreateConicalGradient, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderCreateConicalGradient; req->pid = pid = XAllocID(dpy); req->center.x = gradient->center.x; req->center.y = gradient->center.y; req->angle = gradient->angle; req->nStops = nStops; len = (long) nStops * 3; SetReqLen (req, len, 6); DataInt32(dpy, stops, nStops * 4); Data16(dpy, colors, nStops * 8); UnlockDisplay(dpy); SyncHandle(); return pid; }
int XFillArcs( register Display *dpy, Drawable d, GC gc, XArc *arcs, int n_arcs) { register xPolyFillArcReq *req; long len; int n; LockDisplay(dpy); FlushGC(dpy, gc); while (n_arcs) { GetReq(PolyFillArc, req); req->drawable = d; req->gc = gc->gid; n = n_arcs; len = ((long)n) * arc_scale; if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) { n = (dpy->max_request_size - req->length) / arc_scale; len = ((long)n) * arc_scale; } SetReqLen(req, len, len); len <<= 2; /* watch out for macros... */ Data16 (dpy, (short *) arcs, len); n_arcs -= n; arcs += n; } UnlockDisplay(dpy); SyncHandle(); return 1; }
Status XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time, Cursor cursor, int grab_mode, int paired_device_mode, Bool owner_events, XIEventMask *mask) { xXIGrabDeviceReq *req; xXIGrabDeviceReply reply; char* buff; int len; XExtDisplayInfo *extinfo = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) return (NoSuchExtension); if (mask->mask_len > INT_MAX - 3 || (mask->mask_len + 3)/4 >= 0xffff) { reply.status = BadValue; goto out; } /* mask->mask_len is in bytes, but we need 4-byte units on the wire, * and they need to be padded with 0 */ len = (mask->mask_len + 3)/4; buff = calloc(4, len); if (!buff) { reply.status = BadAlloc; goto out; } GetReq(XIGrabDevice, req); req->reqType = extinfo->codes->major_opcode; req->ReqType = X_XIGrabDevice; req->deviceid = deviceid; req->grab_window = grab_window; req->time = time; req->grab_mode = grab_mode; req->paired_device_mode = paired_device_mode; req->owner_events = owner_events; req->mask_len = len; req->cursor = cursor; memcpy(buff, mask->mask, mask->mask_len); SetReqLen(req, len, len); Data(dpy, buff, len * 4); free(buff); if (_XReply(dpy, (xReply *)&reply, 0, xTrue) == 0) reply.status = GrabSuccess; out: UnlockDisplay(dpy); SyncHandle(); return reply.status; }
int XvPutImage ( Display *dpy, XvPortID port, Drawable d, GC gc, XvImage *image, int src_x, int src_y, unsigned int src_w, unsigned int src_h, int dest_x, int dest_y, unsigned int dest_w, unsigned int dest_h ){ XExtDisplayInfo *info = xv_find_display(dpy); xvPutImageReq *req; int len; XvCheckExtension(dpy, info, XvBadExtension); LockDisplay(dpy); FlushGC(dpy, gc); XvGetReq(PutImage, req); req->port = port; req->drawable = d; req->gc = gc->gid; req->id = image->id; req->src_x = src_x; req->src_y = src_y; req->src_w = src_w; req->src_h = src_h; req->drw_x = dest_x; req->drw_y = dest_y; req->drw_w = dest_w; req->drw_h = dest_h; req->width = image->width; req->height = image->height; len = (image->data_size + 3) >> 2; SetReqLen(req, len, len); /* Yes it's kindof lame that we are sending the whole thing, but for video all of it may be needed even if displaying only a subsection, and I don't want to go through the trouble of creating subregions to send */ Data(dpy, (char *)image->data, image->data_size); UnlockDisplay(dpy); SyncHandle(); return Success; }
int XISelectEvents(Display* dpy, Window win, XIEventMask* masks, int num_masks) { XIEventMask *current; xXISelectEventsReq *req; xXIEventMask mask; int i; int len = 0; int r = Success; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, info) == -1) { r = NoSuchExtension; goto out; } GetReq(XISelectEvents, req); req->reqType = info->codes->major_opcode; req->ReqType = X_XISelectEvents; req->win = win; req->num_masks = num_masks; /* get the right length */ for (i = 0; i < num_masks; i++) { len++; current = &masks[i]; len += (current->mask_len + 3)/4; } SetReqLen(req, len, len); for (i = 0; i < num_masks; i++) { char *buff; current = &masks[i]; mask.deviceid = current->deviceid; mask.mask_len = (current->mask_len + 3)/4; /* masks.mask_len is in bytes, but we need 4-byte units on the wire, * and they need to be padded with 0 */ buff = calloc(1, mask.mask_len * 4); memcpy(buff, current->mask, current->mask_len); Data32(dpy, &mask, sizeof(xXIEventMask)); Data(dpy, buff, mask.mask_len * 4); free(buff); } out: UnlockDisplay(dpy); SyncHandle(); return r; }
void XRenderFillRectangles (Display *dpy, int op, Picture dst, _Xconst XRenderColor *color, _Xconst XRectangle *rectangles, int n_rects) { XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); xRenderFillRectanglesReq *req; long len; int n; RenderSimpleCheckExtension (dpy, info); LockDisplay(dpy); while (n_rects) { GetReq(RenderFillRectangles, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderFillRectangles; req->op = op; req->dst = dst; req->color.red = color->red; req->color.green = color->green; req->color.blue = color->blue; req->color.alpha = color->alpha; n = n_rects; len = ((long)n) << 1; if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) { n = (dpy->max_request_size - req->length) >> 1; len = ((long)n) << 1; } SetReqLen(req, len, len); len <<= 2; /* watch out for macros... */ Data16 (dpy, (short *) rectangles, len); n_rects -= n; rectangles += n; }
static void _XQueryColors( register Display *dpy, Colormap cmap, XColor *defs, /* RETURN */ int ncolors) { register int i; xrgb *color; xQueryColorsReply rep; long nbytes; register xQueryColorsReq *req; GetReq(QueryColors, req); req->cmap = cmap; SetReqLen(req, ncolors, ncolors); /* each pixel is a CARD32 */ for (i = 0; i < ncolors; i++) Data32 (dpy, (long *)&defs[i].pixel, 4L); /* XXX this isn't very efficient */ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) { if ((color = (xrgb *) Xmalloc((unsigned) (nbytes = (long) ncolors * SIZEOF(xrgb))))) { _XRead(dpy, (char *) color, nbytes); for (i = 0; i < ncolors; i++) { register XColor *def = &defs[i]; register xrgb *rgb = &color[i]; def->red = rgb->red; def->green = rgb->green; def->blue = rgb->blue; def->flags = DoRed | DoGreen | DoBlue; } Xfree((char *)color); } else _XEatData(dpy, (unsigned long) nbytes); } }
void XRenderFreeGlyphs (Display *dpy, GlyphSet glyphset, _Xconst Glyph *gids, int nglyphs) { XExtDisplayInfo *info = XRenderFindDisplay (dpy); xRenderFreeGlyphsReq *req; long len; RenderSimpleCheckExtension (dpy, info); LockDisplay(dpy); GetReq(RenderFreeGlyphs, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderFreeGlyphs; len = nglyphs; SetReqLen(req, len, len); len <<= 2; Data32 (dpy, (long *) gids, len); UnlockDisplay(dpy); SyncHandle(); }
static void _XRenderSetPictureClipRectangles (Display *dpy, XRenderExtDisplayInfo *info, Picture picture, int xOrigin, int yOrigin, _Xconst XRectangle *rects, int n) { xRenderSetPictureClipRectanglesReq *req; long len; GetReq (RenderSetPictureClipRectangles, req); req->reqType = info->codes->major_opcode; req->renderReqType = X_RenderSetPictureClipRectangles; req->picture = picture; req->xOrigin = xOrigin; req->yOrigin = yOrigin; len = ((long) n) << 1; SetReqLen (req, len, 1); len <<= 2; Data16 (dpy, (short *) rects, len); }
int XDrawArcs( register Display *dpy, Drawable d, GC gc, XArc *arcs, int n_arcs) { register xPolyArcReq *req; register long len; LockDisplay(dpy); FlushGC(dpy, gc); GetReq(PolyArc,req); req->drawable = d; req->gc = gc->gid; len = ((long)n_arcs) * arc_scale; SetReqLen(req, len, 1); len <<= 2; /* watch out for macros... */ Data16 (dpy, (short *) arcs, len); UnlockDisplay(dpy); SyncHandle(); return 1; }
Status XeviGetVisualInfo( register Display *dpy, VisualID *visual, int n_visual, ExtendedVisualInfo **evi_return, int *n_info_return) { XExtDisplayInfo *info = find_display (dpy); register xEVIGetVisualInfoReq *req; xEVIGetVisualInfoReply rep; int sz_info, sz_xInfo, sz_conflict, sz_xConflict; VisualID32 *temp_conflict, *temp_visual, *xConflictPtr; VisualID *conflict; xExtendedVisualInfo *temp_xInfo; XVisualInfo *vinfo; register ExtendedVisualInfo *infoPtr; register xExtendedVisualInfo *xInfoPtr; register int n_data, visualIndex, vinfoIndex; Bool isValid; XeviCheckExtension (dpy, info, 0); if (!n_info_return || !evi_return) { return BadValue; } *n_info_return = 0; *evi_return = NULL; vinfo = XGetVisualInfo(dpy, 0, NULL, &sz_info); if (!vinfo) { return BadValue; } if (!n_visual || !visual) { /* copy the all visual */ temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * sz_info); n_visual = 0; for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) if (notInList(temp_visual, n_visual, vinfo[vinfoIndex].visualid)) temp_visual[n_visual++] = vinfo[vinfoIndex].visualid; } else { /* check if the visual is valid */ for (visualIndex = 0; visualIndex < n_visual; visualIndex++) { isValid = False; for (vinfoIndex = 0; vinfoIndex < sz_info; vinfoIndex++) { if (visual[visualIndex] == vinfo[vinfoIndex].visualid) { isValid = True; break; } } if (!isValid) { XFree(vinfo); return BadValue; } } temp_visual = (VisualID32 *)Xmalloc(sz_VisualID32 * n_visual); for (visualIndex = 0; visualIndex < n_visual; visualIndex++) temp_visual[visualIndex] = visual[visualIndex]; } XFree(vinfo); LockDisplay(dpy); GetReq(EVIGetVisualInfo, req); req->reqType = info->codes->major_opcode; req->xeviReqType = X_EVIGetVisualInfo; req->n_visual = n_visual; SetReqLen(req, n_visual, 1); Data(dpy, (char *)temp_visual, n_visual * sz_VisualID32); if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); Xfree(temp_visual); return BadAccess; } Xfree(temp_visual); if ((rep.n_info < 65536) && (rep.n_conflicts < 65536)) { sz_info = rep.n_info * sizeof(ExtendedVisualInfo); sz_xInfo = rep.n_info * sz_xExtendedVisualInfo; sz_conflict = rep.n_conflicts * sizeof(VisualID); sz_xConflict = rep.n_conflicts * sz_VisualID32; *evi_return = Xmalloc(sz_info + sz_conflict); temp_xInfo = Xmalloc(sz_xInfo); temp_conflict = Xmalloc(sz_xConflict); } else { sz_xInfo = sz_xConflict = 0; *evi_return = NULL; temp_xInfo = NULL; temp_conflict = NULL; } if (!*evi_return || !temp_xInfo || !temp_conflict) { _XEatDataWords(dpy, rep.length); UnlockDisplay(dpy); SyncHandle(); if (*evi_return) { Xfree(*evi_return); *evi_return = NULL; } if (temp_xInfo) Xfree(temp_xInfo); if (temp_conflict) Xfree(temp_conflict); return BadAlloc; } _XRead(dpy, (char *)temp_xInfo, sz_xInfo); _XRead(dpy, (char *)temp_conflict, sz_xConflict); UnlockDisplay(dpy); SyncHandle(); infoPtr = *evi_return; xInfoPtr = temp_xInfo; xConflictPtr = temp_conflict; n_data = rep.n_info; conflict = (VisualID *)(infoPtr + n_data); while (n_data-- > 0) { infoPtr->core_visual_id = xInfoPtr->core_visual_id; infoPtr->screen = xInfoPtr->screen; infoPtr->level = xInfoPtr->level; infoPtr->transparency_type = xInfoPtr->transparency_type; infoPtr->transparency_value = xInfoPtr->transparency_value; infoPtr->min_hw_colormaps = xInfoPtr->min_hw_colormaps; infoPtr->max_hw_colormaps = xInfoPtr->max_hw_colormaps; infoPtr->num_colormap_conflicts = xInfoPtr->num_colormap_conflicts; infoPtr->colormap_conflicts = conflict; conflict += infoPtr->num_colormap_conflicts; infoPtr++; xInfoPtr++; } n_data = rep.n_conflicts; conflict = (VisualID *)(infoPtr); while (n_data-- > 0) *conflict++ = *xConflictPtr++; Xfree(temp_xInfo); Xfree(temp_conflict); *n_info_return = rep.n_info; return Success; }
void XChangeDeviceProperty(Display* dpy, XDevice* dev, Atom property, Atom type, int format, int mode, _Xconst unsigned char *data, int nelements) { xChangeDevicePropertyReq *req; int len; XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release, info) == -1) return; GetReq(ChangeDeviceProperty, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeDeviceProperty; req->deviceid = dev->device_id; req->property = property; req->type = type; req->mode = mode; if (nelements < 0) { req->nUnits = 0; req->format = 0; /* ask for garbage, get garbage */ } else { req->nUnits = nelements; req->format = format; } switch (req->format) { case 8: len = ((long)nelements + 3) >> 2; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); Data (dpy, (_Xconst char *)data, nelements); } /* else force BadLength */ break; case 16: len = ((long)nelements + 1) >> 1; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); len = (long)nelements << 1; Data16 (dpy, (_Xconst short *) data, len); } /* else force BadLength */ break; case 32: len = nelements; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); len = (long)nelements << 2; Data32 (dpy, (_Xconst long *) data, len); } /* else force BadLength */ break; default: /* BadValue will be generated */ ; } UnlockDisplay(dpy); SyncHandle(); }
void XRRChangeProviderProperty (Display *dpy, RRProvider provider, Atom property, Atom type, int format, int mode, _Xconst unsigned char *data, int nelements) { XExtDisplayInfo *info = XRRFindDisplay(dpy); xRRChangeProviderPropertyReq *req; long len; RRSimpleCheckExtension (dpy, info); LockDisplay(dpy); GetReq (RRChangeProviderProperty, req); req->reqType = info->codes->major_opcode; req->randrReqType = X_RRChangeProviderProperty; req->provider = provider; req->property = property; req->type = type; req->mode = mode; if (nelements < 0) { req->nUnits = 0; req->format = 0; /* ask for garbage, get garbage */ } else { req->nUnits = nelements; req->format = format; } switch (req->format) { case 8: len = ((long)nelements + 3) >> 2; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); Data (dpy, (char *)data, nelements); } /* else force BadLength */ break; case 16: len = ((long)nelements + 1) >> 1; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); len = (long)nelements << 1; Data16 (dpy, (short *) data, len); } /* else force BadLength */ break; case 32: len = nelements; if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) { SetReqLen(req, len, len); len = (long)nelements << 2; Data32 (dpy, (long *) data, len); } /* else force BadLength */ break; default: /* BadValue will be generated */ ; } UnlockDisplay(dpy); SyncHandle(); }