Lines Matching +full:int +full:- +full:property
29 #include <dix-config.h>
43 #include "xserver-properties.h"
185 send_property_event(DeviceIntPtr dev, Atom property, int what) in send_property_event() argument
187 int state = (what == XIPropertyDeleted) ? PropertyDelete : PropertyNewValue; in send_property_event()
190 .deviceid = dev->id, in send_property_event()
192 .atom = property, in send_property_event()
200 .deviceid = dev->id, in send_property_event()
202 .property = property, in send_property_event()
212 static int
213 list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return) in list_atoms()
217 int nprops = 0; in list_atoms()
219 for (prop = dev->properties.properties; prop; prop = prop->next) in list_atoms()
228 for (prop = dev->properties.properties; prop; prop = prop->next, a++) in list_atoms()
229 *a = prop->propertyName; in list_atoms()
237 static int
238 get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, in get_property() argument
239 BOOL delete, int offset, int length, in get_property()
240 int *bytes_after, Atom *type_return, int *format, int *nitems, in get_property()
241 int *length_return, char **data) in get_property()
244 int rc; in get_property()
248 if (!ValidAtom(property)) { in get_property()
249 client->errorValue = property; in get_property()
253 client->errorValue = delete; in get_property()
258 client->errorValue = type; in get_property()
262 for (prop = dev->properties.properties; prop; prop = prop->next) in get_property()
263 if (prop->propertyName == property) in get_property()
275 rc = XIGetDeviceProperty(dev, property, &prop_value); in get_property()
277 client->errorValue = property; in get_property()
282 property information, but not the data. */ in get_property()
284 if (((type != prop_value->type) && (type != AnyPropertyType))) { in get_property()
285 *bytes_after = prop_value->size; in get_property()
286 *format = prop_value->format; in get_property()
289 *type_return = prop_value->type; in get_property()
294 n = (prop_value->format / 8) * prop_value->size; /* size (bytes) of prop */ in get_property()
301 client->errorValue = offset; in get_property()
305 len = min(n - ind, 4 * length); in get_property()
307 *bytes_after = n - (ind + len); in get_property()
308 *format = prop_value->format; in get_property()
310 if (prop_value->format) in get_property()
311 *nitems = len / (prop_value->format / 8); in get_property()
314 *type_return = prop_value->type; in get_property()
316 *data = (char *) prop_value->data + ind; in get_property()
321 static int
322 check_change_property(ClientPtr client, Atom property, Atom type, int format, in check_change_property() argument
323 int mode, int nitems) in check_change_property()
327 client->errorValue = mode; in check_change_property()
331 client->errorValue = format; in check_change_property()
335 if (!ValidAtom(property)) { in check_change_property()
336 client->errorValue = property; in check_change_property()
340 client->errorValue = type; in check_change_property()
347 static int
348 change_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, in change_property() argument
349 int format, int mode, int len, void *data) in change_property()
351 int rc = Success; in change_property()
353 rc = XIChangeDeviceProperty(dev, property, type, format, mode, len, data, in change_property()
356 client->errorValue = property; in change_property()
370 int i; in XIGetKnownProperty()
393 int i; in XIResetProperties()
400 * Convert the given property's value(s) into @nelem_return integer values and
402 * values in the property, @nelem_return is set to the number of values in the
403 * property.
412 * BadLength ... @buff is NULL but @nelem_return is non-zero.
414 * @param val The property value
419 _X_EXPORT int
420 XIPropToInt(XIPropertyValuePtr val, int *nelem_return, int **buf_return) in XIPropToInt()
422 int i; in XIPropToInt()
423 int *buf; in XIPropToInt()
425 if (val->type != XA_INTEGER) in XIPropToInt()
430 switch (val->format) { in XIPropToInt()
442 buf = calloc(val->size, sizeof(int)); in XIPropToInt()
446 *nelem_return = val->size; in XIPropToInt()
448 else if (val->size < *nelem_return) in XIPropToInt()
449 *nelem_return = val->size; in XIPropToInt()
451 for (i = 0; i < val->size && i < *nelem_return; i++) { in XIPropToInt()
452 switch (val->format) { in XIPropToInt()
454 buf[i] = ((CARD8 *) val->data)[i]; in XIPropToInt()
457 buf[i] = ((CARD16 *) val->data)[i]; in XIPropToInt()
460 buf[i] = ((CARD32 *) val->data)[i]; in XIPropToInt()
469 * Convert the given property's value(s) into @nelem_return float values and
471 * values in the property, @nelem_return is set to the number of values in the
472 * property.
482 * BadLength ... @buff is NULL but @nelem_return is non-zero.
484 * @param val The property value
489 _X_EXPORT int
490 XIPropToFloat(XIPropertyValuePtr val, int *nelem_return, float **buf_return) in XIPropToFloat()
492 int i; in XIPropToFloat()
495 if (!val->type || val->type != XIGetKnownProperty(XATOM_FLOAT)) in XIPropToFloat()
498 if (val->format != 32) in XIPropToFloat()
506 buf = calloc(val->size, sizeof(float)); in XIPropToFloat()
510 *nelem_return = val->size; in XIPropToFloat()
512 else if (val->size < *nelem_return) in XIPropToFloat()
513 *nelem_return = val->size; in XIPropToFloat()
515 for (i = 0; i < val->size && i < *nelem_return; i++) in XIPropToFloat()
516 buf[i] = ((float *) val->data)[i]; in XIPropToFloat()
521 /* Registers a new property handler on the given device and returns a unique
523 * property handler again.
528 int (*SetProperty) (DeviceIntPtr dev, in XIRegisterPropertyHandler()
529 Atom property, in XIRegisterPropertyHandler() argument
532 int (*GetProperty) (DeviceIntPtr dev, in XIRegisterPropertyHandler()
533 Atom property), in XIRegisterPropertyHandler() argument
534 int (*DeleteProperty) (DeviceIntPtr dev, in XIRegisterPropertyHandler()
535 Atom property)) in XIRegisterPropertyHandler()
543 new_handler->id = XIPropHandlerID++; in XIRegisterPropertyHandler()
544 new_handler->SetProperty = SetProperty; in XIRegisterPropertyHandler()
545 new_handler->GetProperty = GetProperty; in XIRegisterPropertyHandler()
546 new_handler->DeleteProperty = DeleteProperty; in XIRegisterPropertyHandler()
547 new_handler->next = dev->properties.handlers; in XIRegisterPropertyHandler()
548 dev->properties.handlers = new_handler; in XIRegisterPropertyHandler()
550 return new_handler->id; in XIRegisterPropertyHandler()
558 curr = dev->properties.handlers; in XIUnregisterPropertyHandler()
559 while (curr && curr->id != id) { in XIUnregisterPropertyHandler()
561 curr = curr->next; in XIUnregisterPropertyHandler()
568 dev->properties.handlers = curr->next; in XIUnregisterPropertyHandler()
570 prev->next = curr->next; in XIUnregisterPropertyHandler()
576 XICreateDeviceProperty(Atom property) in XICreateDeviceProperty() argument
584 prop->next = NULL; in XICreateDeviceProperty()
585 prop->propertyName = property; in XICreateDeviceProperty()
586 prop->value.type = None; in XICreateDeviceProperty()
587 prop->value.format = 0; in XICreateDeviceProperty()
588 prop->value.size = 0; in XICreateDeviceProperty()
589 prop->value.data = NULL; in XICreateDeviceProperty()
590 prop->deletable = TRUE; in XICreateDeviceProperty()
596 XIFetchDeviceProperty(DeviceIntPtr dev, Atom property) in XIFetchDeviceProperty() argument
600 for (prop = dev->properties.properties; prop; prop = prop->next) in XIFetchDeviceProperty()
601 if (prop->propertyName == property) in XIFetchDeviceProperty()
609 free(prop->value.data); in XIDestroyDeviceProperty()
613 /* This function destroys all of the device's property-related stuff,
624 for (prop = device->properties.properties; prop; prop = next) { in XIDeleteAllDeviceProperties()
625 next = prop->next; in XIDeleteAllDeviceProperties()
626 send_property_event(device, prop->propertyName, XIPropertyDeleted); in XIDeleteAllDeviceProperties()
630 device->properties.properties = NULL; in XIDeleteAllDeviceProperties()
633 curr_handler = device->properties.handlers; in XIDeleteAllDeviceProperties()
635 next_handler = curr_handler->next; in XIDeleteAllDeviceProperties()
640 device->properties.handlers = NULL; in XIDeleteAllDeviceProperties()
643 int
644 XIDeleteDeviceProperty(DeviceIntPtr device, Atom property, Bool fromClient) in XIDeleteDeviceProperty() argument
647 int rc = Success; in XIDeleteDeviceProperty()
649 for (prev = &device->properties.properties; (prop = *prev); in XIDeleteDeviceProperty()
650 prev = &(prop->next)) in XIDeleteDeviceProperty()
651 if (prop->propertyName == property) in XIDeleteDeviceProperty()
657 if (fromClient && !prop->deletable) in XIDeleteDeviceProperty()
660 /* Ask handlers if we may delete the property */ in XIDeleteDeviceProperty()
661 if (device->properties.handlers) { in XIDeleteDeviceProperty()
662 XIPropertyHandlerPtr handler = device->properties.handlers; in XIDeleteDeviceProperty()
665 if (handler->DeleteProperty) in XIDeleteDeviceProperty()
666 rc = handler->DeleteProperty(device, prop->propertyName); in XIDeleteDeviceProperty()
669 handler = handler->next; in XIDeleteDeviceProperty()
675 *prev = prop->next; in XIDeleteDeviceProperty()
676 send_property_event(device, prop->propertyName, XIPropertyDeleted); in XIDeleteDeviceProperty()
683 int
684 XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type, in XIChangeDeviceProperty() argument
685 int format, int mode, unsigned long len, in XIChangeDeviceProperty()
689 int size_in_bytes; in XIChangeDeviceProperty()
694 int rc; in XIChangeDeviceProperty()
698 /* first see if property already exists */ in XIChangeDeviceProperty()
699 prop = XIFetchDeviceProperty(dev, property); in XIChangeDeviceProperty()
701 prop = XICreateDeviceProperty(property); in XIChangeDeviceProperty()
707 prop_value = &prop->value; in XIChangeDeviceProperty()
709 /* To append or prepend to a property the request format and type in XIChangeDeviceProperty()
710 must match those of the already defined property. The in XIChangeDeviceProperty()
714 if ((format != prop_value->format) && (mode != PropModeReplace)) in XIChangeDeviceProperty()
716 if ((prop_value->type != type) && (mode != PropModeReplace)) in XIChangeDeviceProperty()
722 total_len = prop_value->size + len; in XIChangeDeviceProperty()
744 (prop_value->size * size_in_bytes)); in XIChangeDeviceProperty()
750 (prop_value->size * size_in_bytes)); in XIChangeDeviceProperty()
756 memcpy((char *) old_data, (char *) prop_value->data, in XIChangeDeviceProperty()
757 prop_value->size * size_in_bytes); in XIChangeDeviceProperty()
759 if (dev->properties.handlers) { in XIChangeDeviceProperty()
767 handler = dev->properties.handlers; in XIChangeDeviceProperty()
769 if (handler->SetProperty) { in XIChangeDeviceProperty()
771 rc = handler->SetProperty(dev, prop->propertyName, in XIChangeDeviceProperty()
781 handler = handler->next; in XIChangeDeviceProperty()
786 free(prop_value->data); in XIChangeDeviceProperty()
794 prop->next = dev->properties.properties; in XIChangeDeviceProperty()
795 dev->properties.properties = prop; in XIChangeDeviceProperty()
800 send_property_event(dev, prop->propertyName, in XIChangeDeviceProperty()
807 int
808 XIGetDeviceProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value) in XIGetDeviceProperty() argument
810 XIPropertyPtr prop = XIFetchDeviceProperty(dev, property); in XIGetDeviceProperty()
811 int rc; in XIGetDeviceProperty()
818 /* If we can, try to update the property value first */ in XIGetDeviceProperty()
819 if (dev->properties.handlers) { in XIGetDeviceProperty()
820 XIPropertyHandlerPtr handler = dev->properties.handlers; in XIGetDeviceProperty()
823 if (handler->GetProperty) { in XIGetDeviceProperty()
824 rc = handler->GetProperty(dev, prop->propertyName); in XIGetDeviceProperty()
830 handler = handler->next; in XIGetDeviceProperty()
834 *value = &prop->value; in XIGetDeviceProperty()
838 int
839 XISetDevicePropertyDeletable(DeviceIntPtr dev, Atom property, Bool deletable) in XISetDevicePropertyDeletable() argument
841 XIPropertyPtr prop = XIFetchDeviceProperty(dev, property); in XISetDevicePropertyDeletable()
846 prop->deletable = deletable; in XISetDevicePropertyDeletable()
850 int
855 int natoms; in ProcXListDeviceProperties()
857 int rc = Success; in ProcXListDeviceProperties()
862 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); in ProcXListDeviceProperties()
873 .sequenceNumber = client->sequence, in ProcXListDeviceProperties()
880 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; in ProcXListDeviceProperties()
887 int
893 int totalSize; in ProcXChangeDeviceProperty()
894 int rc; in ProcXChangeDeviceProperty()
899 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); in ProcXChangeDeviceProperty()
903 rc = check_change_property(client, stuff->property, stuff->type, in ProcXChangeDeviceProperty()
904 stuff->format, stuff->mode, stuff->nUnits); in ProcXChangeDeviceProperty()
906 len = stuff->nUnits; in ProcXChangeDeviceProperty()
907 if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq)))) in ProcXChangeDeviceProperty()
910 totalSize = len * (stuff->format / 8); in ProcXChangeDeviceProperty()
913 rc = change_property(client, dev, stuff->property, stuff->type, in ProcXChangeDeviceProperty()
914 stuff->format, stuff->mode, len, (void *) &stuff[1]); in ProcXChangeDeviceProperty()
918 int
923 int rc; in ProcXDeleteDeviceProperty()
927 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); in ProcXDeleteDeviceProperty()
931 if (!ValidAtom(stuff->property)) { in ProcXDeleteDeviceProperty()
932 client->errorValue = stuff->property; in ProcXDeleteDeviceProperty()
936 rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE); in ProcXDeleteDeviceProperty()
940 int
945 int length; in ProcXGetDeviceProperty()
946 int rc, format, nitems, bytes_after; in ProcXGetDeviceProperty()
952 if (stuff->delete) in ProcXGetDeviceProperty()
954 rc = dixLookupDevice(&dev, stuff->deviceid, client, in ProcXGetDeviceProperty()
955 stuff->delete ? DixSetPropAccess : DixGetPropAccess); in ProcXGetDeviceProperty()
959 rc = get_property(client, dev, stuff->property, stuff->type, in ProcXGetDeviceProperty()
960 stuff->delete, stuff->longOffset, stuff->longLength, in ProcXGetDeviceProperty()
969 .sequenceNumber = client->sequence, in ProcXGetDeviceProperty()
975 .deviceid = dev->id in ProcXGetDeviceProperty()
978 if (stuff->delete && (reply.bytesAfter == 0)) in ProcXGetDeviceProperty()
979 send_property_event(dev, stuff->property, XIPropertyDeleted); in ProcXGetDeviceProperty()
986 client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; in ProcXGetDeviceProperty()
989 client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; in ProcXGetDeviceProperty()
992 client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; in ProcXGetDeviceProperty()
998 /* delete the Property */ in ProcXGetDeviceProperty()
999 if (stuff->delete && (reply.bytesAfter == 0)) { in ProcXGetDeviceProperty()
1002 for (prev = &dev->properties.properties; (prop = *prev); in ProcXGetDeviceProperty()
1003 prev = &prop->next) { in ProcXGetDeviceProperty()
1004 if (prop->propertyName == stuff->property) { in ProcXGetDeviceProperty()
1005 *prev = prop->next; in ProcXGetDeviceProperty()
1014 int _X_COLD
1020 swaps(&stuff->length); in SProcXListDeviceProperties()
1024 int _X_COLD
1030 swaps(&stuff->length); in SProcXChangeDeviceProperty()
1031 swapl(&stuff->property); in SProcXChangeDeviceProperty()
1032 swapl(&stuff->type); in SProcXChangeDeviceProperty()
1033 swapl(&stuff->nUnits); in SProcXChangeDeviceProperty()
1037 int _X_COLD
1043 swaps(&stuff->length); in SProcXDeleteDeviceProperty()
1044 swapl(&stuff->property); in SProcXDeleteDeviceProperty()
1048 int _X_COLD
1054 swaps(&stuff->length); in SProcXGetDeviceProperty()
1055 swapl(&stuff->property); in SProcXGetDeviceProperty()
1056 swapl(&stuff->type); in SProcXGetDeviceProperty()
1057 swapl(&stuff->longOffset); in SProcXGetDeviceProperty()
1058 swapl(&stuff->longLength); in SProcXGetDeviceProperty()
1065 SRepXListDeviceProperties(ClientPtr client, int size, in SRepXListDeviceProperties()
1068 swaps(&rep->sequenceNumber); in SRepXListDeviceProperties()
1069 swapl(&rep->length); in SRepXListDeviceProperties()
1070 swaps(&rep->nAtoms); in SRepXListDeviceProperties()
1076 SRepXGetDeviceProperty(ClientPtr client, int size, in SRepXGetDeviceProperty()
1079 swaps(&rep->sequenceNumber); in SRepXGetDeviceProperty()
1080 swapl(&rep->length); in SRepXGetDeviceProperty()
1081 swapl(&rep->propertyType); in SRepXGetDeviceProperty()
1082 swapl(&rep->bytesAfter); in SRepXGetDeviceProperty()
1083 swapl(&rep->nItems); in SRepXGetDeviceProperty()
1089 int
1094 int natoms; in ProcXIListProperties()
1096 int rc = Success; in ProcXIListProperties()
1101 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); in ProcXIListProperties()
1112 .sequenceNumber = client->sequence, in ProcXIListProperties()
1119 client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; in ProcXIListProperties()
1126 int
1129 int rc; in ProcXIChangeProperty()
1131 int totalSize; in ProcXIChangeProperty()
1138 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); in ProcXIChangeProperty()
1142 rc = check_change_property(client, stuff->property, stuff->type, in ProcXIChangeProperty()
1143 stuff->format, stuff->mode, stuff->num_items); in ProcXIChangeProperty()
1144 len = stuff->num_items; in ProcXIChangeProperty()
1145 if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq))) in ProcXIChangeProperty()
1148 totalSize = len * (stuff->format / 8); in ProcXIChangeProperty()
1151 rc = change_property(client, dev, stuff->property, stuff->type, in ProcXIChangeProperty()
1152 stuff->format, stuff->mode, len, (void *) &stuff[1]); in ProcXIChangeProperty()
1156 int
1160 int rc; in ProcXIDeleteProperty()
1166 rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); in ProcXIDeleteProperty()
1170 if (!ValidAtom(stuff->property)) { in ProcXIDeleteProperty()
1171 client->errorValue = stuff->property; in ProcXIDeleteProperty()
1175 rc = XIDeleteDeviceProperty(dev, stuff->property, TRUE); in ProcXIDeleteProperty()
1179 int
1185 int length; in ProcXIGetProperty()
1186 int rc, format, nitems, bytes_after; in ProcXIGetProperty()
1191 if (stuff->delete) in ProcXIGetProperty()
1193 rc = dixLookupDevice(&dev, stuff->deviceid, client, in ProcXIGetProperty()
1194 stuff->delete ? DixSetPropAccess : DixGetPropAccess); in ProcXIGetProperty()
1198 rc = get_property(client, dev, stuff->property, stuff->type, in ProcXIGetProperty()
1199 stuff->delete, stuff->offset, stuff->len, in ProcXIGetProperty()
1208 .sequenceNumber = client->sequence, in ProcXIGetProperty()
1216 if (length && stuff->delete && (reply.bytes_after == 0)) in ProcXIGetProperty()
1217 send_property_event(dev, stuff->property, XIPropertyDeleted); in ProcXIGetProperty()
1224 client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; in ProcXIGetProperty()
1227 client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; in ProcXIGetProperty()
1230 client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; in ProcXIGetProperty()
1236 /* delete the Property */ in ProcXIGetProperty()
1237 if (stuff->delete && (reply.bytes_after == 0)) { in ProcXIGetProperty()
1240 for (prev = &dev->properties.properties; (prop = *prev); in ProcXIGetProperty()
1241 prev = &prop->next) { in ProcXIGetProperty()
1242 if (prop->propertyName == stuff->property) { in ProcXIGetProperty()
1243 *prev = prop->next; in ProcXIGetProperty()
1253 int _X_COLD
1259 swaps(&stuff->length); in SProcXIListProperties()
1260 swaps(&stuff->deviceid); in SProcXIListProperties()
1264 int _X_COLD
1270 swaps(&stuff->length); in SProcXIChangeProperty()
1271 swaps(&stuff->deviceid); in SProcXIChangeProperty()
1272 swapl(&stuff->property); in SProcXIChangeProperty()
1273 swapl(&stuff->type); in SProcXIChangeProperty()
1274 swapl(&stuff->num_items); in SProcXIChangeProperty()
1278 int _X_COLD
1284 swaps(&stuff->length); in SProcXIDeleteProperty()
1285 swaps(&stuff->deviceid); in SProcXIDeleteProperty()
1286 swapl(&stuff->property); in SProcXIDeleteProperty()
1290 int _X_COLD
1296 swaps(&stuff->length); in SProcXIGetProperty()
1297 swaps(&stuff->deviceid); in SProcXIGetProperty()
1298 swapl(&stuff->property); in SProcXIGetProperty()
1299 swapl(&stuff->type); in SProcXIGetProperty()
1300 swapl(&stuff->offset); in SProcXIGetProperty()
1301 swapl(&stuff->len); in SProcXIGetProperty()
1306 SRepXIListProperties(ClientPtr client, int size, xXIListPropertiesReply * rep) in SRepXIListProperties()
1308 swaps(&rep->sequenceNumber); in SRepXIListProperties()
1309 swapl(&rep->length); in SRepXIListProperties()
1310 swaps(&rep->num_properties); in SRepXIListProperties()
1316 SRepXIGetProperty(ClientPtr client, int size, xXIGetPropertyReply * rep) in SRepXIGetProperty()
1318 swaps(&rep->sequenceNumber); in SRepXIGetProperty()
1319 swapl(&rep->length); in SRepXIGetProperty()
1320 swapl(&rep->type); in SRepXIGetProperty()
1321 swapl(&rep->bytes_after); in SRepXIGetProperty()
1322 swapl(&rep->num_items); in SRepXIGetProperty()