void XNVCTRLSetTargetAttribute ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, int value ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlSetAttributeReq *req; XNVCTRLSimpleCheckExtension (dpy, info); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); LockDisplay (dpy); GetReq (nvCtrlSetAttribute, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlSetAttribute; req->target_type = target_type; req->target_id = target_id; req->display_mask = display_mask; req->attribute = attribute; req->value = value; UnlockDisplay (dpy); SyncHandle (); }
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; }
Bool XNVCTRLQueryValidTargetAttributeValues ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, NVCTRLAttributeValidValuesRec *values ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryValidAttributeValuesReply rep; xnvCtrlQueryValidAttributeValuesReq *req; Bool exists; if (!values) return False; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); LockDisplay (dpy); GetReq (nvCtrlQueryValidAttributeValues, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryValidAttributeValues; req->target_type = target_type; req->target_id = target_id; req->display_mask = display_mask; req->attribute = attribute; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return False; } exists = rep.flags; values->type = rep.attr_type; if (rep.attr_type == ATTRIBUTE_TYPE_RANGE) { values->u.range.min = rep.min; values->u.range.max = rep.max; } if (rep.attr_type == ATTRIBUTE_TYPE_INT_BITS) { values->u.bits.ints = rep.bits; } values->permissions = rep.perms; UnlockDisplay (dpy); SyncHandle (); return exists; }
Bool XNVCTRLQueryValidTargetAttributeValues ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, NVCTRLAttributeValidValuesRec *values ) { XExtDisplayInfo *info = find_display(dpy); Bool exists; uintptr_t flags; if (!values) return False; if (!XextHasExtension(info)) return False; XNVCTRLCheckExtension(dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); flags = version_flags(dpy,info); if (!(flags & NVCTRL_EXT_EXISTS)) return False; if (flags & NVCTRL_EXT_64_BIT_ATTRIBUTES) { exists = XNVCTRLQueryValidTargetAttributeValues64(dpy, info, target_type, target_id, display_mask, attribute, values); } else { exists = XNVCTRLQueryValidTargetAttributeValues32(dpy, info, target_type, target_id, display_mask, attribute, values); } return exists; }
Bool XNVCTRLQueryTargetAttribute ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, int *value ) { XExtDisplayInfo *info = find_display (dpy); xnvCtrlQueryAttributeReply rep; xnvCtrlQueryAttributeReq *req; Bool exists; if(!XextHasExtension(info)) return False; XNVCTRLCheckExtension (dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); LockDisplay (dpy); GetReq (nvCtrlQueryAttribute, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlQueryAttribute; req->target_type = target_type; req->target_id = target_id; req->display_mask = display_mask; req->attribute = attribute; if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) { UnlockDisplay (dpy); SyncHandle (); return False; } if (value) *value = rep.value; exists = rep.flags; UnlockDisplay (dpy); SyncHandle (); return exists; }
Bool XNVCTRLStringOperation ( Display *dpy, int target_type, int target_id, unsigned int display_mask, unsigned int attribute, char *pIn, char **ppOut ) { XExtDisplayInfo *info = find_display(dpy); xnvCtrlStringOperationReq *req; xnvCtrlStringOperationReply rep; Bool ret; int inSize, outSize, length, slop; if (!XextHasExtension(info)) return False; if (!ppOut) return False; *ppOut = NULL; XNVCTRLCheckExtension(dpy, info, False); XNVCTRLCheckTargetData(dpy, info, &target_type, &target_id); if (pIn) { inSize = strlen(pIn) + 1; } else { inSize = 0; } LockDisplay(dpy); GetReq(nvCtrlStringOperation, req); req->reqType = info->codes->major_opcode; req->nvReqType = X_nvCtrlStringOperation; req->target_type = target_type; req->target_id = target_id; req->display_mask = display_mask; req->attribute = attribute; req->length += ((inSize + 3) & ~3) >> 2; req->num_bytes = inSize; if (pIn) { Data(dpy, pIn, inSize); } if (!_XReply (dpy, (xReply *) &rep, 0, False)) { UnlockDisplay(dpy); SyncHandle(); return False; } length = rep.length; outSize = rep.num_bytes; slop = outSize & 3; if (outSize) *ppOut = (char *) Xmalloc(outSize); if (!*ppOut) { _XEatData(dpy, length); } else { _XRead(dpy, (char *) *ppOut, outSize); if (slop) _XEatData(dpy, 4-slop); } ret = rep.ret; UnlockDisplay(dpy); SyncHandle(); return ret; }