Bool SDL_NAME(XF86DGAGetViewPortSize)( Display* dpy, int screen, int *width, int *height ){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetViewPortSizeReply rep; xXF86DGAGetViewPortSizeReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAGetViewPortSize, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetViewPortSize; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *width = rep.width; *height = rep.height; UnlockDisplay(dpy); SyncHandle(); return True; }
Bool SDL_NAME(XF86DGAQueryDirectVideo)( Display *dpy, int screen, int *flags ){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAQueryDirectVideoReply rep; xXF86DGAQueryDirectVideoReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAQueryDirectVideo, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAQueryDirectVideo; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *flags = rep.flags; UnlockDisplay(dpy); SyncHandle(); return True; }
/* * XdbeGetBackBufferAttributes - * This function returns the attributes associated with the specified * buffer. */ XdbeBackBufferAttributes *XdbeGetBackBufferAttributes( Display *dpy, XdbeBackBuffer buffer) { XExtDisplayInfo *info = find_display(dpy); register xDbeGetBackBufferAttributesReq *req; xDbeGetBackBufferAttributesReply rep; XdbeBackBufferAttributes *attr; DbeCheckExtension(dpy, info, (XdbeBackBufferAttributes *)NULL); if (!(attr = (XdbeBackBufferAttributes *)Xmalloc(sizeof(XdbeBackBufferAttributes)))) { return NULL; } LockDisplay(dpy); DbeGetReq(DbeGetBackBufferAttributes, req, info); req->buffer = buffer; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return NULL; } attr->window = rep.attributes; UnlockDisplay (dpy); SyncHandle (); return attr; }
static GLboolean getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) { xGLXGetVisualConfigsReq *req; __GLXscreenConfigs *psc; xGLXGetVisualConfigsReply reply; LockDisplay(dpy); psc = priv->screenConfigs + screen; psc->visuals = NULL; GetReq(GLXGetVisualConfigs, req); req->reqType = priv->majorOpcode; req->glxCode = X_GLXGetVisualConfigs; req->screen = screen; if (!_XReply(dpy, (xReply *) & reply, 0, False)) goto out; psc->visuals = createConfigsFromProperties(dpy, reply.numVisuals, reply.numProps, screen, GL_FALSE); out: UnlockDisplay(dpy); return psc->visuals != NULL; }
const char * XFixesGetCursorName (Display *dpy, Cursor cursor, Atom *atom) { XFixesExtDisplayInfo *info = XFixesFindDisplay (dpy); xXFixesGetCursorNameReq *req; xXFixesGetCursorNameReply rep; char *name; XFixesCheckExtension (dpy, info, 0); if (info->major_version < 2) return 0; LockDisplay (dpy); GetReq (XFixesGetCursorName, req); req->reqType = info->codes->major_opcode; req->xfixesReqType = X_XFixesGetCursorName; req->cursor = cursor; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return 0; } *atom = rep.atom; if ((name = (char *) Xmalloc(rep.nbytes+1))) { _XReadPad(dpy, name, (long)rep.nbytes); name[rep.nbytes] = '\0'; } else { _XEatData(dpy, (unsigned long) (rep.nbytes + 3) & ~3); name = (char *) NULL; } UnlockDisplay(dpy); SyncHandle(); return(name); }
/* * XdbeQueryExtension - * Sets major_version_return and minor_verion_return to the major and * minor DBE protocol version supported by the server. If the DBE * library is compatible with the version returned by the server, this * function returns non-zero. If dpy does not support the DBE * extension, or if there was an error during communication with the * server, or if the server and library protocol versions are * incompatible, this functions returns zero. No other Xdbe functions * may be called before this function. If a client violates this rule, * the effects of all subsequent Xdbe calls are undefined. */ Status XdbeQueryExtension ( Display *dpy, int *major_version_return, int *minor_version_return) { XExtDisplayInfo *info = find_display (dpy); xDbeGetVersionReply rep; register xDbeGetVersionReq *req; if (!XextHasExtension (info)) return (Status)0; /* failure */ LockDisplay (dpy); DbeGetReq (DbeGetVersion, req, info); req->majorVersion = DBE_MAJOR_VERSION; req->minorVersion = DBE_MINOR_VERSION; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return (Status)0; /* failure */ } *major_version_return = rep.majorVersion; *minor_version_return = rep.minorVersion; UnlockDisplay (dpy); SyncHandle (); if (*major_version_return != DBE_MAJOR_VERSION) return (Status)0; /* failure */ else return (Status)1; /* success */ }
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; }
Status XPanoramiXQueryVersion( Display *dpy, int *major_version_return, int *minor_version_return ) { XExtDisplayInfo *info = find_display (dpy); xPanoramiXQueryVersionReply rep; register xPanoramiXQueryVersionReq *req; PanoramiXCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (PanoramiXQueryVersion, req); req->reqType = info->codes->major_opcode; req->panoramiXReqType = X_PanoramiXQueryVersion; req->clientMajor = PANORAMIX_MAJOR_VERSION; req->clientMinor = PANORAMIX_MINOR_VERSION; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return 0; } *major_version_return = rep.majorVersion; *minor_version_return = rep.minorVersion; UnlockDisplay (dpy); SyncHandle (); return 1; }
Bool XTranslateCoordinates( register Display *dpy, Window src_win, Window dest_win, int src_x, int src_y, int *dst_x, int *dst_y, Window *child) { register xTranslateCoordsReq *req; xTranslateCoordsReply rep; LockDisplay(dpy); GetReq(TranslateCoords, req); req->srcWid = src_win; req->dstWid = dest_win; req->srcX = src_x; req->srcY = src_y; if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) { UnlockDisplay(dpy); SyncHandle(); return(False); } *child = rep.child; *dst_x = cvtINT16toInt (rep.dstX); *dst_y = cvtINT16toInt (rep.dstY); UnlockDisplay(dpy); SyncHandle(); return ((int)rep.sameScreen); }
int video_card_memory_size_ATI() { XExtDisplayInfo* info; Display* dpy; int size; dpy = XOpenDisplay(NULL); //glXGetCurrentDisplay(); info = find_display_fglx(dpy); if (XextHasExtension(info)) { xFGLGetDriverDataReq* req; xFGLGetDriverDataReply rep; GetReq(FGLGetDriverData, req); // fill in the request structure req->reqType = info->codes->major_opcode; // calculate size of request structure in 4 byte units req->length = (sizeof(*req)+3) / 4; req->fireglReqType = X_FGLGetDriverData; req->screen = DefaultScreen(dpy); // carry out the extension function and wait for reply // 3rd parameter, called "extra": number of extra 32 bit words // reply structures must be multiple of 4 with a minimum of 32 bytes #ifdef __ia64__ //SGI prism crashes in the _XReply() call, need to track this down //the firegl cards actually have 256MB of RAM, so return that. SyncHandle(); return 256; #endif if (!_XReply(dpy, (xReply *)&rep, (sizeof(rep) - 32) / 4, xFalse)) { SyncHandle(); return 0; } switch (rep.usVideoRam) { // DriverData.ulVideoRam is the contents of mmCONFIG_MEMSIZE shr 16 case 0x1000: size = 256; break; case 0x800: size = 128; break; case 0x400: size = 64; break; case 0x200: size = 32; break; default: size = 0; } SyncHandle(); } else { return 0; } return size; }
Bool DRI2QueryVersion(Display * dpy, int *major, int *minor) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); xDRI2QueryVersionReply rep; xDRI2QueryVersionReq *req; XextCheckExtension(dpy, info, dri2ExtensionName, False); LockDisplay(dpy); GetReq(DRI2QueryVersion, req); req->reqType = info->codes->major_opcode; req->dri2ReqType = X_DRI2QueryVersion; req->majorVersion = DRI2_MAJOR; req->minorVersion = DRI2_MINOR; if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *major = rep.majorVersion; *minor = rep.minorVersion; UnlockDisplay(dpy); SyncHandle(); return True; }
Bool DRI2Authenticate(Display * dpy, XID window, drm_magic_t magic) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); xDRI2AuthenticateReq *req; xDRI2AuthenticateReply rep; XextCheckExtension(dpy, info, dri2ExtensionName, False); LockDisplay(dpy); GetReq(DRI2Authenticate, req); req->reqType = info->codes->major_opcode; req->dri2ReqType = X_DRI2Authenticate; req->window = window; req->magic = magic; if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } UnlockDisplay(dpy); SyncHandle(); return rep.authenticated; }
Status XResQueryVersion( Display *dpy, int *major_version_return, int *minor_version_return ) { XExtDisplayInfo *info = find_display (dpy); xXResQueryVersionReply rep; xXResQueryVersionReq *req; XResCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (XResQueryVersion, req); req->reqType = info->codes->major_opcode; req->XResReqType = X_XResQueryVersion; req->client_major = XRES_MAJOR_VERSION; req->client_minor = XRES_MINOR_VERSION; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return 0; } *major_version_return = rep.server_major; *minor_version_return = rep.server_minor; UnlockDisplay (dpy); SyncHandle (); return 1; }
Status XResQueryClientPixmapBytes ( Display *dpy, XID xid, unsigned long *bytes ) { XExtDisplayInfo *info = find_display (dpy); xXResQueryClientPixmapBytesReq *req; xXResQueryClientPixmapBytesReply rep; *bytes = 0; XResCheckExtension (dpy, info, 0); LockDisplay (dpy); GetReq (XResQueryClientPixmapBytes, req); req->reqType = info->codes->major_opcode; req->XResReqType = X_XResQueryClientPixmapBytes; req->xid = xid; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return 0; } #ifdef LONG64 *bytes = (rep.bytes_overflow * 4294967295) + rep.bytes; #else *bytes = rep.bytes_overflow ? 0xffffffff : rep.bytes; #endif UnlockDisplay (dpy); SyncHandle (); return 1; }
/** * Read new data in the image structure. * * @param dpy X11 display to grab from * @param d * @param image Image where the grab will be put * @param x Top-Left grabbing rectangle horizontal coordinate * @param y Top-Left grabbing rectangle vertical coordinate * @return 0 if error, !0 if successful */ static int xget_zpixmap(Display *dpy, Drawable d, XImage *image, int x, int y) { xGetImageReply rep; xGetImageReq *req; long nbytes; if (!image) return 0; LockDisplay(dpy); GetReq(GetImage, req); /* First set up the standard stuff in the request */ req->drawable = d; req->x = x; req->y = y; req->width = image->width; req->height = image->height; req->planeMask = (unsigned int)AllPlanes; req->format = ZPixmap; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.length) { UnlockDisplay(dpy); SyncHandle(); return 0; } nbytes = (long)rep.length << 2; _XReadPad(dpy, image->data, nbytes); UnlockDisplay(dpy); SyncHandle(); return 1; }
Bool SDL_NAME(XF86DGAGetVideoLL)( Display* dpy, int screen, int *offset, int *width, int *bank_size, int *ram_size ){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAGetVideoLLReply rep; xXF86DGAGetVideoLLReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAGetVideoLL, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAGetVideoLL; req->screen = screen; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *offset = /*(char *)*/rep.offset; *width = rep.width; *bank_size = rep.bank_size; *ram_size = rep.ram_size; UnlockDisplay(dpy); SyncHandle(); return True; }
Bool SDL_NAME(XF86DGAViewPortChanged)( Display *dpy, int screen, int n ){ XExtDisplayInfo *info = SDL_NAME(xdga_find_display) (dpy); xXF86DGAViewPortChangedReply rep; xXF86DGAViewPortChangedReq *req; XF86DGACheckExtension (dpy, info, False); LockDisplay(dpy); GetReq(XF86DGAViewPortChanged, req); req->reqType = info->codes->major_opcode; req->dgaReqType = X_XF86DGAViewPortChanged; req->screen = screen; req->n = n; if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } UnlockDisplay(dpy); SyncHandle(); return rep.result; }
Status XIGetFocus(Display *dpy, int deviceid, Window *focus_return) { xXIGetFocusReq *req; xXIGetFocusReply reply; XExtDisplayInfo *extinfo = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1) return (NoSuchExtension); GetReq(XIGetFocus, req); req->reqType = extinfo->codes->major_opcode; req->ReqType = X_XIGetFocus; req->deviceid = deviceid; if (!_XReply(dpy, (xReply*) &reply, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } *focus_return = reply.focus; UnlockDisplay(dpy); SyncHandle(); return Success; }
int XEGetStatisticsRequest(XETC *tc, XETrapGetStatsRep *ret) { int status = True; Display *dpy = tc->dpy; CARD32 X_XTrap = tc->extOpcode; xXTrapReq *reqptr; xXTrapGetStatsReply rep; status = XEFlushConfig(tc); /* Flushout any pending configuration first */ if (status == True) { LockDisplay(dpy); GetReq(XTrap,reqptr); reqptr->minor_opcode = XETrap_GetStatistics; /* to support comm. w/ V3.1 extensions */ #ifndef CRAY if (tc->protocol == 31) { /* this is the way we used to do it which breaks Cray's */ #ifndef VECTORED_EVENTS int numlongs = (1060-sizeof(xReply)+sizeof(long)-1)/sizeof(long); #else int numlongs = (1544-sizeof(xReply)+sizeof(long)-1)/sizeof(long); #endif status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue); if (status == True) { /* need to shift it back into the data struct */ xXTrapGetStatsReply tmp; tmp = rep; memcpy(&(rep.data),&(tmp.pad0), sizeof(rep.data)); } } else #endif /* CRAY */ { /* this is the way we do it for V3.2 */ int numbytes = SIZEOF(xXTrapGetStatsReply) - SIZEOF(xReply); status = _XReply(dpy, (xReply *)&rep, 0, xFalse); if (status == True) { status = _XRead(dpy, (char *)&rep.data, numbytes); } } SyncHandle(); UnlockDisplay(dpy); memcpy(ret,&(rep.data),sizeof(XETrapGetStatsRep)); } return(status); }
DRI2Buffer * DRI2GetBuffersWithFormat(Display * dpy, XID drawable, int *width, int *height, unsigned int *attachments, int count, int *outCount) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); xDRI2GetBuffersReply rep; xDRI2GetBuffersReq *req; DRI2Buffer *buffers; xDRI2Buffer repBuffer; CARD32 *p; int i; XextCheckExtension(dpy, info, dri2ExtensionName, False); LockDisplay(dpy); GetReqExtra(DRI2GetBuffers, count * (4 * 2), req); req->reqType = info->codes->major_opcode; req->dri2ReqType = X_DRI2GetBuffersWithFormat; req->drawable = drawable; req->count = count; p = (CARD32 *) & req[1]; for (i = 0; i < (count * 2); i++) p[i] = attachments[i]; if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { fprintf(stderr, "GetBuffersWithFormat fails\n"); UnlockDisplay(dpy); SyncHandle(); return NULL; } *width = rep.width; *height = rep.height; *outCount = rep.count; buffers = Xmalloc(rep.count * sizeof buffers[0]); if (buffers == NULL) { _XEatData(dpy, rep.count * sizeof repBuffer); UnlockDisplay(dpy); SyncHandle(); return NULL; } for (i = 0; i < rep.count; i++) { _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer); buffers[i].attachment = repBuffer.attachment; buffers[i].name = repBuffer.name; buffers[i].pitch = repBuffer.pitch; buffers[i].cpp = repBuffer.cpp; buffers[i].flags = repBuffer.flags; } UnlockDisplay(dpy); SyncHandle(); return buffers; }
Bool XNVCTRLQueryTargetBinaryData ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, unsigned char **ptr, int *len ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryBinaryDataReply rep; xnvCtrlQueryBinaryDataReq *req; Bool exists; int length, numbytes, slop; if (!ptr) return False; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); LockDisplay (dpy); GetReq (nvCtrlQueryBinaryData, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryBinaryData; req->target_type = target_type; req->target_id = target_id; req->display_mask = display_mask; req->attribute = attribute; if (!_XReply (dpy, (xReply *) &rep, 0, False)) { UnlockDisplay (dpy); SyncHandle (); return False; } length = rep.length; numbytes = rep.n; slop = numbytes & 3; exists = rep.flags; if (exists) { *ptr = (unsigned char *) Xmalloc(numbytes); } if (!exists || !*ptr) { _XEatData(dpy, length); UnlockDisplay (dpy); SyncHandle (); return False; } else { _XRead(dpy, (char *) *ptr, numbytes); if (slop) _XEatData(dpy, 4-slop); } if (len) *len = numbytes; UnlockDisplay (dpy); SyncHandle (); return exists; }
Screen * XpGetScreenOfContext ( Display *dpy, XPContext print_context ) { xPrintGetContextScreenReq *req; xPrintGetContextScreenReply rep; XExtensionVersion *ext; XExtDisplayInfo *info = (XExtDisplayInfo *) xp_find_display (dpy); int i; Screen *checkScr; Screen *screen; int ok; if (XpCheckExtInit(dpy, XP_DONT_CHECK) == -1) return ( (Screen *) NULL ); /* No such extension */ LockDisplay (dpy); GetReq(PrintGetContextScreen,req); req->reqType = info->codes->major_opcode; req->printReqType = X_PrintGetContextScreen; req->printContext = print_context; if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay(dpy); SyncHandle(); return ( (Screen *) NULL ); /* No such extension */ } /* * Pull rootWindow ID and convert to the corresponding * Screen rec. */ ok = False; for ( i = 0; i < XScreenCount(dpy); i++ ) { checkScr = XScreenOfDisplay(dpy, i); if ( XRootWindowOfScreen( checkScr ) == (Window) rep.rootWindow ) { ok = True; break; } } if (!ok) checkScr = (Screen *) NULL; UnlockDisplay(dpy); SyncHandle(); return ( (Screen *) checkScr ); }
Status _xvmc_create_subpicture ( Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture, int *priv_count, CARD32 **priv_data ) { XExtDisplayInfo *info = xvmc_find_display(dpy); xvmcCreateSubpictureReply rep; xvmcCreateSubpictureReq *req; *priv_count = 0; *priv_data = NULL; XvMCCheckExtension (dpy, info, BadImplementation); LockDisplay (dpy); XvMCGetReq (CreateSubpicture, req); subpicture->subpicture_id = XAllocID(dpy); subpicture->context_id = context->context_id; req->subpicture_id = subpicture->subpicture_id; req->context_id = subpicture->context_id; req->xvimage_id = subpicture->xvimage_id; req->width = subpicture->width; req->height = subpicture->height; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return BadImplementation; } subpicture->width = rep.width_actual; subpicture->height = rep.height_actual; subpicture->num_palette_entries = rep.num_palette_entries; subpicture->entry_bytes = rep.entry_bytes; subpicture->component_order[0] = rep.component_order[0]; subpicture->component_order[1] = rep.component_order[1]; subpicture->component_order[2] = rep.component_order[2]; subpicture->component_order[3] = rep.component_order[3]; if(rep.length) { *priv_data = Xmalloc(rep.length << 2); if(*priv_data) { _XRead(dpy, (char*)(*priv_data), rep.length << 2); *priv_count = rep.length; } else _XEatData(dpy, rep.length << 2); } UnlockDisplay (dpy); SyncHandle (); return Success; }
int XEGetCurrentRequest(XETC *tc, XETrapGetCurRep *ret) { int status = True; Display *dpy = tc->dpy; CARD32 X_XTrap = tc->extOpcode; xXTrapReq *reqptr; xXTrapGetCurReply rep; int numlongs = (SIZEOF(xXTrapGetCurReply) - SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32); status = XEFlushConfig(tc); /* Flushout any pending configuration first */ if (status == True) { LockDisplay(dpy); GetReq(XTrap,reqptr); reqptr->minor_opcode = XETrap_GetCurrent; /* to support comm. w/ V3.1 extensions */ if (tc->protocol == 31) { char tmp[284]; /* need space for the big *old* reply */ numlongs = (284-sizeof(xReply)+sizeof(long)-1)/sizeof(long); status = _XReply(dpy,(xReply *)tmp,numlongs,xTrue); memcpy(&rep,tmp,sizeof(rep)); /* move just what's needed */ } else { status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue); } SyncHandle(); UnlockDisplay(dpy); memcpy((char *)ret->state_flags,rep.data_state_flags,2); memcpy((char *)ret->config.flags.valid,rep.data_config_flags_valid,4); memcpy((char *)ret->config.flags.data,rep.data_config_flags_data,4); memcpy((char *)ret->config.flags.req,rep.data_config_flags_req, XETrapMaxRequest); memcpy((char *)ret->config.flags.event,rep.data_config_flags_event, XETrapMaxEvent); ret->config.max_pkt_size=rep.data_config_max_pkt_size; ret->config.cmd_key=rep.data_config_cmd_key; } return(status); }
Bool XNVCTRLQueryStringAttribute ( Display *dpy, int screen, unsigned int display_mask, unsigned int attribute, char **ptr ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryStringAttributeReply rep; xnvCtrlQueryStringAttributeReq *req; Bool exists; int length, numbytes, slop; if (!ptr) return False; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); LockDisplay (dpy); GetReq (nvCtrlQueryStringAttribute, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryStringAttribute; req->screen = screen; req->display_mask = display_mask; req->attribute = attribute; if (!_XReply (dpy, (xReply *) &rep, 0, False)) { UnlockDisplay (dpy); SyncHandle (); return False; } length = rep.length; numbytes = rep.n; slop = numbytes & 3; *ptr = (char *) Xmalloc(numbytes); if (! *ptr) { _XEatData(dpy, length); UnlockDisplay (dpy); SyncHandle (); return False; } else { _XRead(dpy, (char *) *ptr, numbytes); if (slop) _XEatData(dpy, 4-slop); } exists = rep.flags; UnlockDisplay (dpy); SyncHandle (); return exists; }
Bool _vdp_DRI2Connect(Display * dpy, XID window, char **driverName, char **deviceName) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); xDRI2ConnectReply rep; xDRI2ConnectReq *req; XextCheckExtension(dpy, info, dri2ExtensionName, False); LockDisplay(dpy); GetReq(DRI2Connect, req); req->reqType = info->codes->major_opcode; req->dri2ReqType = X_DRI2Connect; req->window = window; req->driverType = DRI2DriverVDPAU; if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return False; } if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) { UnlockDisplay(dpy); SyncHandle(); return False; } *driverName = Xmalloc(rep.driverNameLength + 1); if (*driverName == NULL) { _XEatData(dpy, ((rep.driverNameLength + 3) & ~3) + ((rep.deviceNameLength + 3) & ~3)); UnlockDisplay(dpy); SyncHandle(); return False; } _XReadPad(dpy, *driverName, rep.driverNameLength); (*driverName)[rep.driverNameLength] = '\0'; *deviceName = Xmalloc(rep.deviceNameLength + 1); if (*deviceName == NULL) { Xfree(*driverName); _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3)); UnlockDisplay(dpy); SyncHandle(); return False; } _XReadPad(dpy, *deviceName, rep.deviceNameLength); (*deviceName)[rep.deviceNameLength] = '\0'; UnlockDisplay(dpy); SyncHandle(); return True; }
Bool XNVCTRLQueryDDCCIBlockLutOperation ( Display *dpy, int screen, unsigned int display_mask, unsigned int color, // NV_CTRL_DDCCI_RED_LUT, NV_CTRL_DDCCI_GREEN_LUT, NV_CTRL_DDCCI_BLUE_LUT unsigned int offset, unsigned int size, unsigned int **value ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryDDCCIBlockLutOperationReply rep; xnvCtrlQueryDDCCIBlockLutOperationReq *req; Bool exists; int length, slop; char *ptr; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); LockDisplay (dpy); GetReq (nvCtrlQueryDDCCIBlockLutOperation, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryDDCCIBlockLutOperation; req->screen = screen; req->display_mask = display_mask; req->color=color; req->offset=offset; req->size=size; if (!_XReply (dpy, (xReply *) &rep, 0, False)) { UnlockDisplay (dpy); SyncHandle (); return False; } length = rep.length; slop = rep.num_bytes & 3; ptr = (char *) Xmalloc(rep.num_bytes); if (! ptr) { _XEatData(dpy, length); UnlockDisplay (dpy); SyncHandle (); return False; } else { _XRead(dpy, (char *) ptr, rep.num_bytes); if (slop) _XEatData(dpy, 4-slop); } exists = rep.flags; if(exists) { *value=(unsigned int *)ptr; } UnlockDisplay (dpy); SyncHandle (); return exists; }
XRRPropertyInfo * XRRQueryProviderProperty (Display *dpy, RRProvider provider, Atom property) { XExtDisplayInfo *info = XRRFindDisplay(dpy); xRRQueryProviderPropertyReply rep; xRRQueryProviderPropertyReq *req; unsigned int rbytes, nbytes; XRRPropertyInfo *prop_info; RRCheckExtension (dpy, info, NULL); LockDisplay (dpy); GetReq (RRQueryProviderProperty, req); req->reqType = info->codes->major_opcode; req->randrReqType = X_RRQueryProviderProperty; req->provider = provider; req->property = property; if (!_XReply (dpy, (xReply *) &rep, 0, xFalse)) { UnlockDisplay (dpy); SyncHandle (); return NULL; } if (rep.length < ((INT_MAX / sizeof(long)) - sizeof (XRRPropertyInfo))) { rbytes = sizeof (XRRPropertyInfo) + (rep.length * sizeof (long)); nbytes = rep.length << 2; prop_info = Xmalloc (rbytes); } else prop_info = NULL; if (prop_info == NULL) { _XEatDataWords (dpy, rep.length); UnlockDisplay (dpy); SyncHandle (); return NULL; } prop_info->pending = rep.pending; prop_info->range = rep.range; prop_info->immutable = rep.immutable; prop_info->num_values = rep.length; if (rep.length != 0) { prop_info->values = (long *) (prop_info + 1); _XRead32 (dpy, prop_info->values, nbytes); } else { prop_info->values = NULL; } UnlockDisplay (dpy); SyncHandle (); return prop_info; }
XTimeCoord *XGetMotionEvents( register Display *dpy, Window w, Time start, Time stop, int *nEvents) /* RETURN */ { xGetMotionEventsReply rep; register xGetMotionEventsReq *req; XTimeCoord *tc = NULL; long nbytes; LockDisplay(dpy); GetReq(GetMotionEvents, req); req->window = w; /* XXX is this right for all machines? */ req->start = start; req->stop = stop; if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (NULL); } if (rep.nEvents) { if (! (tc = (XTimeCoord *) Xmalloc( (unsigned) (nbytes = (long) rep.nEvents * sizeof(XTimeCoord))))) { _XEatData (dpy, (unsigned long) nbytes); UnlockDisplay(dpy); SyncHandle(); return (NULL); } } *nEvents = rep.nEvents; nbytes = SIZEOF (xTimecoord); { register XTimeCoord *tcptr; register int i; xTimecoord xtc; for (i = rep.nEvents, tcptr = tc; i > 0; i--, tcptr++) { _XRead (dpy, (char *) &xtc, nbytes); tcptr->time = xtc.time; tcptr->x = cvtINT16toShort (xtc.x); tcptr->y = cvtINT16toShort (xtc.y); } } UnlockDisplay(dpy); SyncHandle(); return (tc); }
/* XXXAlternative: Instead of getting the manufacturer string from the server, * get the manufacturer Id instead, and have controller_manufacturer assigned * to a static string that would not need to be malloc'ed and freed. */ Bool XNVCTRLQueryDDCCIDisplayControllerType ( Display *dpy, int screen, unsigned int display_mask, unsigned char **controller_manufacturer, unsigned int *controller_type ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryDDCCIDisplayControllerTypeReply rep; xnvCtrlQueryDDCCIDisplayControllerTypeReq *req; Bool exists; int length, numbytes, slop; char *ptr; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); LockDisplay (dpy); GetReq (nvCtrlQueryDDCCIDisplayControllerType, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryDDCCIDisplayControllerType; req->screen = screen; req->display_mask = display_mask; if (!_XReply (dpy, (xReply *) &rep, 0, False)) { UnlockDisplay (dpy); SyncHandle (); return False; } length = rep.length; numbytes = rep.size; slop = numbytes & 3; ptr = (char *) Xmalloc(numbytes); if (! ptr) { _XEatData(dpy, length); UnlockDisplay (dpy); SyncHandle (); return False; } else { _XRead(dpy, (char *) ptr, numbytes); if (slop) _XEatData(dpy, 4-slop); } exists = rep.flags; if(exists) { *controller_type=rep.controller_type; *controller_manufacturer=ptr; } UnlockDisplay (dpy); SyncHandle (); return exists; }