]> diplodocus.org Git - xorg-xinput/blob - src/property.c
Require inputproto 1.9.99.12
[xorg-xinput] / src / property.c
1 /*
2 * Copyright 2007 Peter Hutterer
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation.
9 *
10 * The above copyright notice and this permission notice shall be included
11 * in all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
17 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19 * OTHER DEALINGS IN THE SOFTWARE.
20 *
21 * Except as contained in this notice, the name of the author shall
22 * not be used in advertising or otherwise to promote the sale, use or
23 * other dealings in this Software without prior written authorization
24 * from the author.
25 *
26 */
27
28 #include <ctype.h>
29 #include <string.h>
30 #include <stdlib.h>
31 #include <stdint.h>
32 #include <X11/Xatom.h>
33 #include <X11/extensions/XIproto.h>
34
35 #include "xinput.h"
36
37 static Atom parse_atom(Display *dpy, char *name) {
38 Bool is_atom = True;
39 int i;
40
41 for (i = 0; name[i] != '\0'; i++) {
42 if (!isdigit(name[i])) {
43 is_atom = False;
44 break;
45 }
46 }
47
48 if (is_atom)
49 return atoi(name);
50 else
51 return XInternAtom(dpy, name, False);
52 }
53
54 static void
55 print_property(Display *dpy, XDevice* dev, Atom property)
56 {
57 Atom act_type;
58 char *name;
59 int act_format;
60 unsigned long nitems, bytes_after;
61 unsigned char *data, *ptr;
62 int j, done = False, size;
63
64 name = XGetAtomName(dpy, property);
65 printf("\t%s (%ld):\t", name, property);
66
67 if (XGetDeviceProperty(dpy, dev, property, 0, 1000, False,
68 AnyPropertyType, &act_type, &act_format,
69 &nitems, &bytes_after, &data) == Success)
70 {
71 Atom float_atom = XInternAtom(dpy, "FLOAT", True);
72
73 ptr = data;
74
75 if (nitems == 0)
76 printf("<no items>");
77
78 switch(act_format)
79 {
80 case 8: size = sizeof(char); break;
81 case 16: size = sizeof(short); break;
82 case 32: size = sizeof(long); break;
83 }
84
85 for (j = 0; j < nitems; j++)
86 {
87 switch(act_type)
88 {
89 case XA_INTEGER:
90 switch(act_format)
91 {
92 case 8:
93 printf("%d", *((char*)ptr));
94 break;
95 case 16:
96 printf("%d", *((short*)ptr));
97 break;
98 case 32:
99 printf("%ld", *((long*)ptr));
100 break;
101 }
102 break;
103 case XA_STRING:
104 if (act_format != 8)
105 {
106 printf("Unknown string format.\n");
107 done = True;
108 break;
109 }
110 printf("\"%s\"", ptr);
111 j += strlen((char*)ptr); /* The loop's j++ jumps over the
112 terminating 0 */
113 ptr += strlen((char*)ptr); /* ptr += size below jumps over
114 the terminating 0 */
115 break;
116 case XA_ATOM:
117 {
118 Atom a = *(Atom*)ptr;
119 printf("\"%s\" (%d)",
120 (a) ? XGetAtomName(dpy, a) : "None",
121 (int)a);
122 break;
123 }
124 default:
125 if (float_atom != None && act_type == float_atom)
126 {
127 printf("%f", *((float*)ptr));
128 break;
129 }
130
131 printf("\t... of unknown type %s\n",
132 XGetAtomName(dpy, act_type));
133 done = True;
134 break;
135 }
136
137 ptr += size;
138
139 if (done == True)
140 break;
141 if (j < nitems - 1)
142 printf(", ");
143 }
144 printf("\n");
145 XFree(data);
146 } else
147 printf("\tFetch failure\n");
148
149 }
150
151 static int
152 list_props_xi1(Display *dpy, int argc, char** argv, char* name, char *desc)
153 {
154 XDeviceInfo *info;
155 XDevice *dev;
156 int i;
157 int nprops;
158 Atom *props;
159
160 if (argc == 0)
161 {
162 fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
163 return EXIT_FAILURE;
164 }
165
166 for (i = 0; i < argc; i++)
167 {
168 info = find_device_info(dpy, argv[i], False);
169 if (!info)
170 {
171 fprintf(stderr, "unable to find device %s\n", argv[i]);
172 continue;
173 }
174
175 dev = XOpenDevice(dpy, info->id);
176 if (!dev)
177 {
178 fprintf(stderr, "unable to open device '%s'\n", info->name);
179 continue;
180 }
181
182 props = XListDeviceProperties(dpy, dev, &nprops);
183 if (!nprops)
184 {
185 printf("Device '%s' does not report any properties.\n", info->name);
186 continue;
187 }
188
189 printf("Device '%s':\n", info->name);
190 while(nprops--)
191 {
192 print_property(dpy, dev, props[nprops]);
193 }
194
195 XFree(props);
196 XCloseDevice(dpy, dev);
197 }
198 return EXIT_SUCCESS;
199 }
200
201 int
202 set_int_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
203 {
204 XDeviceInfo *info;
205 XDevice *dev;
206 Atom prop;
207 char *name;
208 int i;
209 char *data;
210 int format, nelements = 0;
211
212 if (argc < 3)
213 {
214 fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
215 return EXIT_FAILURE;
216 }
217
218 info = find_device_info(dpy, argv[0], False);
219 if (!info)
220 {
221 fprintf(stderr, "unable to find device %s\n", argv[0]);
222 return EXIT_FAILURE;
223 }
224
225 dev = XOpenDevice(dpy, info->id);
226 if (!dev)
227 {
228 fprintf(stderr, "unable to open device %s\n", argv[0]);
229 return EXIT_FAILURE;
230 }
231
232 name = argv[1];
233
234 prop = parse_atom(dpy, name);
235
236 nelements = argc - 3;
237 format = atoi(argv[2]);
238 if (format != 8 && format != 16 && format != 32)
239 {
240 fprintf(stderr, "Invalid format %d\n", format);
241 return EXIT_FAILURE;
242 }
243
244 data = calloc(nelements, sizeof(long));
245 for (i = 0; i < nelements; i++)
246 {
247 switch(format)
248 {
249 case 8:
250 *(((char*)data) + i) = atoi(argv[3 + i]);
251 break;
252 case 16:
253 *(((short*)data) + i) = atoi(argv[3 + i]);
254 break;
255 case 32:
256 *(((long*)data) + i) = atoi(argv[3 + i]);
257 break;
258 }
259 }
260
261 XChangeDeviceProperty(dpy, dev, prop, XA_INTEGER, format, PropModeReplace,
262 (unsigned char*)data, nelements);
263
264 free(data);
265 XCloseDevice(dpy, dev);
266 return EXIT_SUCCESS;
267 }
268
269 int
270 set_float_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
271 {
272 XDeviceInfo *info;
273 XDevice *dev;
274 Atom prop, float_atom;
275 char *name;
276 int i;
277 long *data;
278 int nelements = 0;
279 char* endptr;
280
281 if (argc < 2)
282 {
283 fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
284 return EXIT_FAILURE;
285 }
286
287 info = find_device_info(dpy, argv[0], False);
288 if (!info)
289 {
290 fprintf(stderr, "unable to find device %s\n", argv[0]);
291 return EXIT_FAILURE;
292 }
293
294 dev = XOpenDevice(dpy, info->id);
295 if (!dev)
296 {
297 fprintf(stderr, "unable to open device %s\n", argv[0]);
298 return EXIT_FAILURE;
299 }
300
301 name = argv[1];
302
303 prop = parse_atom(dpy, name);
304
305 nelements = argc - 2;
306
307 float_atom = XInternAtom(dpy, "FLOAT", False);
308
309 if (float_atom == (Atom)0)
310 {
311 fprintf(stderr, "no FLOAT atom present in server\n");
312 return EXIT_FAILURE;
313 }
314
315 if (sizeof(float) != 4)
316 {
317 fprintf(stderr, "sane FP required\n");
318 return EXIT_FAILURE;
319 }
320
321 data = calloc(nelements, sizeof(long));
322 for (i = 0; i < nelements; i++)
323 {
324 *((float*)(data + i)) = strtod(argv[2 + i], &endptr);
325 if(endptr == argv[2 + i]){
326 fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
327 return EXIT_FAILURE;
328 }
329 }
330
331 XChangeDeviceProperty(dpy, dev, prop, float_atom, 32, PropModeReplace,
332 (unsigned char*)data, nelements);
333
334 free(data);
335 XCloseDevice(dpy, dev);
336 return EXIT_SUCCESS;
337 }
338
339
340 int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
341 {
342 XDevice *dev;
343 XDeviceInfo *info;
344 XEvent ev;
345 XDevicePropertyNotifyEvent *dpev;
346 char *name;
347 int type_prop;
348 XEventClass cls_prop;
349
350 if (list_props(dpy, argc, argv, n, desc) != EXIT_SUCCESS)
351 return EXIT_FAILURE;
352
353 info = find_device_info(dpy, argv[0], False);
354 if (!info)
355 {
356 fprintf(stderr, "unable to find device %s\n", argv[0]);
357 return EXIT_FAILURE;
358 }
359
360 dev = XOpenDevice(dpy, info->id);
361 if (!dev)
362 {
363 fprintf(stderr, "unable to open device '%s'\n", info->name);
364 return EXIT_FAILURE;
365 }
366
367 DevicePropertyNotify(dev, type_prop, cls_prop);
368 XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &cls_prop, 1);
369
370 while(1)
371 {
372 XNextEvent(dpy, &ev);
373
374 dpev = (XDevicePropertyNotifyEvent*)&ev;
375 if (dpev->type != type_prop)
376 continue;
377
378 name = XGetAtomName(dpy, dpev->atom);
379 printf("Property '%s' changed.\n", name);
380 print_property(dpy, dev, dpev->atom);
381 }
382
383 XCloseDevice(dpy, dev);
384 }
385
386 static int
387 delete_prop_xi1(Display *dpy, int argc, char** argv, char* n, char *desc)
388 {
389 XDevice *dev;
390 XDeviceInfo *info;
391 char *name;
392 Atom prop;
393
394 info = find_device_info(dpy, argv[0], False);
395 if (!info)
396 {
397 fprintf(stderr, "unable to find device %s\n", argv[0]);
398 return EXIT_FAILURE;
399 }
400
401 dev = XOpenDevice(dpy, info->id);
402 if (!dev)
403 {
404 fprintf(stderr, "unable to open device '%s'\n", info->name);
405 return EXIT_FAILURE;
406 }
407
408 name = argv[1];
409
410 prop = parse_atom(dpy, name);
411
412 XDeleteDeviceProperty(dpy, dev, prop);
413
414 XCloseDevice(dpy, dev);
415 return EXIT_SUCCESS;
416 }
417
418 int
419 set_atom_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
420 {
421 XDeviceInfo *info;
422 XDevice *dev;
423 Atom prop;
424 char *name;
425 int i, j;
426 Bool is_atom;
427 Atom *data;
428 int nelements = 0;
429
430 if (argc < 3)
431 {
432 fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
433 return EXIT_FAILURE;
434 }
435
436 info = find_device_info(dpy, argv[0], False);
437 if (!info)
438 {
439 fprintf(stderr, "unable to find device %s\n", argv[0]);
440 return EXIT_FAILURE;
441 }
442
443 dev = XOpenDevice(dpy, info->id);
444 if (!dev)
445 {
446 fprintf(stderr, "unable to open device %s\n", argv[0]);
447 return EXIT_FAILURE;
448 }
449
450 name = argv[1];
451
452 prop = parse_atom(dpy, name);
453
454 nelements = argc - 2;
455 data = calloc(nelements, sizeof(Atom));
456 for (i = 0; i < nelements; i++)
457 {
458 is_atom = True;
459 name = argv[2 + i];
460 for(j = 0; j < strlen(name); j++) {
461 if (!isdigit(name[j])) {
462 is_atom = False;
463 break;
464 }
465 }
466
467 if (!is_atom)
468 data[i] = XInternAtom(dpy, name, False);
469 else
470 {
471 data[i] = atoi(name);
472 XFree(XGetAtomName(dpy, data[i]));
473 }
474 }
475
476 XChangeDeviceProperty(dpy, dev, prop, XA_ATOM, 32, PropModeReplace,
477 (unsigned char*)data, nelements);
478
479 free(data);
480 XCloseDevice(dpy, dev);
481 return EXIT_SUCCESS;
482 }
483
484 static int
485 set_prop_xi1(Display *dpy, int argc, char **argv, char *n, char *desc)
486 {
487 XDeviceInfo *info;
488 XDevice *dev;
489 Atom prop;
490 Atom type;
491 char *name;
492 int i;
493 Atom float_atom;
494 int format, nelements = 0;
495 unsigned long act_nitems, bytes_after;
496 char *endptr;
497 union {
498 unsigned char *c;
499 short *s;
500 long *l;
501 Atom *a;
502 } data;
503
504 if (argc < 3)
505 {
506 fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
507 return EXIT_FAILURE;
508 }
509
510 info = find_device_info(dpy, argv[0], False);
511 if (!info)
512 {
513 fprintf(stderr, "unable to find device %s\n", argv[0]);
514 return EXIT_FAILURE;
515 }
516
517 dev = XOpenDevice(dpy, info->id);
518 if (!dev)
519 {
520 fprintf(stderr, "unable to open device %s\n", argv[0]);
521 return EXIT_FAILURE;
522 }
523
524 name = argv[1];
525
526 prop = parse_atom(dpy, name);
527
528 if (prop == None) {
529 fprintf(stderr, "invalid property %s\n", name);
530 return EXIT_FAILURE;
531 }
532
533 float_atom = XInternAtom(dpy, "FLOAT", False);
534
535 nelements = argc - 2;
536 if (XGetDeviceProperty(dpy, dev, prop, 0, 0, False, AnyPropertyType,
537 &type, &format, &act_nitems, &bytes_after, &data.c)
538 != Success) {
539 fprintf(stderr, "failed to get property type and format for %s\n", name);
540 return EXIT_FAILURE;
541 }
542
543 XFree(data.c);
544
545 if (type == None) {
546 fprintf(stderr, "property %s doesn't exist\n", name);
547 return EXIT_FAILURE;
548 }
549
550 data.c = calloc(nelements, sizeof(long));
551
552 for (i = 0; i < nelements; i++)
553 {
554 if (type == XA_INTEGER) {
555 switch (format)
556 {
557 case 8:
558 data.c[i] = atoi(argv[2 + i]);
559 break;
560 case 16:
561 data.s[i] = atoi(argv[2 + i]);
562 break;
563 case 32:
564 data.l[i] = atoi(argv[2 + i]);
565 break;
566 default:
567 fprintf(stderr, "unexpected size for property %s", name);
568 return EXIT_FAILURE;
569 }
570 } else if (type == float_atom) {
571 if (format != 32) {
572 fprintf(stderr, "unexpected format %d for property %s\n",
573 format, name);
574 return EXIT_FAILURE;
575 }
576 *(float *)(data.l + i) = strtod(argv[2 + i], &endptr);
577 if (endptr == argv[2 + i]) {
578 fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
579 return EXIT_FAILURE;
580 }
581 } else if (type == XA_ATOM) {
582 if (format != 32) {
583 fprintf(stderr, "unexpected format %d for property %s\n",
584 format, name);
585 return EXIT_FAILURE;
586 }
587 data.a[i] = parse_atom(dpy, argv[2 + i]);
588 } else {
589 fprintf(stderr, "unexpected type for property %s\n", name);
590 return EXIT_FAILURE;
591 }
592 }
593
594 XChangeDeviceProperty(dpy, dev, prop, type, format, PropModeReplace,
595 data.c, nelements);
596 free(data.c);
597 XCloseDevice(dpy, dev);
598 return EXIT_SUCCESS;
599 }
600
601 #if HAVE_XI2
602 static void
603 print_property_xi2(Display *dpy, int deviceid, Atom property)
604 {
605 Atom act_type;
606 char *name;
607 int act_format;
608 unsigned long nitems, bytes_after;
609 unsigned char *data, *ptr;
610 int j, done = False;
611
612 name = XGetAtomName(dpy, property);
613 printf("\t%s (%ld):\t", name, property);
614
615 if (XIGetProperty(dpy, deviceid, property, 0, 1000, False,
616 AnyPropertyType, &act_type, &act_format,
617 &nitems, &bytes_after, &data) == Success)
618 {
619 Atom float_atom = XInternAtom(dpy, "FLOAT", True);
620
621 ptr = data;
622
623 if (nitems == 0)
624 printf("<no items>");
625
626 for (j = 0; j < nitems; j++)
627 {
628 switch(act_type)
629 {
630 case XA_INTEGER:
631 switch(act_format)
632 {
633 case 8:
634 printf("%d", *((int8_t*)ptr));
635 break;
636 case 16:
637 printf("%d", *((int16_t*)ptr));
638 break;
639 case 32:
640 printf("%d", *((int32_t*)ptr));
641 break;
642 }
643 break;
644 case XA_STRING:
645 if (act_format != 8)
646 {
647 printf("Unknown string format.\n");
648 done = True;
649 break;
650 }
651 printf("\"%s\"", ptr);
652 j += strlen((char*)ptr); /* The loop's j++ jumps over the
653 terminating 0 */
654 ptr += strlen((char*)ptr); /* ptr += size below jumps over
655 the terminating 0 */
656 break;
657 case XA_ATOM:
658 {
659 Atom a = *(Atom*)ptr;
660 printf("\"%s\" (%d)",
661 (a) ? XGetAtomName(dpy, a) : "None",
662 (int)a);
663 break;
664 }
665 break;
666 default:
667 if (float_atom != None && act_type == float_atom)
668 {
669 printf("%f", *((float*)ptr));
670 break;
671 }
672
673 printf("\t... of unknown type %s\n",
674 XGetAtomName(dpy, act_type));
675 done = True;
676 break;
677 }
678
679 ptr += act_format/8;
680
681 if (done == True)
682 break;
683 if (j < nitems - 1)
684 printf(", ");
685 }
686 printf("\n");
687 XFree(data);
688 } else
689 printf("\tFetch failure\n");
690
691 }
692
693 static int
694 list_props_xi2(Display *dpy, int argc, char** argv, char* name, char *desc)
695 {
696 XIDeviceInfo *info;
697 int i;
698 int nprops;
699 Atom *props;
700
701 if (argc == 0)
702 {
703 fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
704 return EXIT_FAILURE;
705 }
706
707 for (i = 0; i < argc; i++)
708 {
709 info = xi2_find_device_info(dpy, argv[i]);
710 if (!info)
711 {
712 fprintf(stderr, "unable to find device %s\n", argv[i]);
713 continue;
714 }
715
716 props = XIListProperties(dpy, info->deviceid, &nprops);
717 if (!nprops)
718 {
719 printf("Device '%s' does not report any properties.\n", info->name);
720 continue;
721 }
722
723 printf("Device '%s':\n", info->name);
724 while(nprops--)
725 {
726 print_property_xi2(dpy, info->deviceid, props[nprops]);
727 }
728
729 XFree(props);
730 }
731 return EXIT_SUCCESS;
732 }
733
734 static int
735 delete_prop_xi2(Display *dpy, int argc, char** argv, char* n, char *desc)
736 {
737 XIDeviceInfo *info;
738 char *name;
739 Atom prop;
740
741 info = xi2_find_device_info(dpy, argv[0]);
742 if (!info)
743 {
744 fprintf(stderr, "unable to find device %s\n", argv[0]);
745 return EXIT_FAILURE;
746 }
747
748 name = argv[1];
749
750 prop = parse_atom(dpy, name);
751
752 XIDeleteProperty(dpy, info->deviceid, prop);
753
754 return EXIT_SUCCESS;
755 }
756
757 static int
758 set_prop_xi2(Display *dpy, int argc, char **argv, char *n, char *desc)
759 {
760 XIDeviceInfo *info;
761 Atom prop;
762 Atom type;
763 char *name;
764 int i;
765 Atom float_atom;
766 int format, nelements = 0;
767 unsigned long act_nitems, bytes_after;
768 char *endptr;
769 union {
770 unsigned char *c;
771 int16_t *s;
772 int32_t *l;
773 } data;
774
775 if (argc < 3)
776 {
777 fprintf(stderr, "Usage: xinput %s %s\n", n, desc);
778 return EXIT_FAILURE;
779 }
780
781 info = xi2_find_device_info(dpy, argv[0]);
782 if (!info)
783 {
784 fprintf(stderr, "unable to find device %s\n", argv[0]);
785 return EXIT_FAILURE;
786 }
787
788 name = argv[1];
789
790 prop = parse_atom(dpy, name);
791
792 if (prop == None) {
793 fprintf(stderr, "invalid property %s\n", name);
794 return EXIT_FAILURE;
795 }
796
797 float_atom = XInternAtom(dpy, "FLOAT", False);
798
799 nelements = argc - 2;
800 if (XIGetProperty(dpy, info->deviceid, prop, 0, 0, False, AnyPropertyType,
801 &type, &format, &act_nitems, &bytes_after, &data.c)
802 != Success) {
803 fprintf(stderr, "failed to get property type and format for %s\n", name);
804 return EXIT_FAILURE;
805 }
806
807 XFree(data.c);
808
809 if (type == None) {
810 fprintf(stderr, "property %s doesn't exist\n", name);
811 return EXIT_FAILURE;
812 }
813
814 data.c = calloc(nelements, sizeof(int32_t));
815
816 for (i = 0; i < nelements; i++)
817 {
818 if (type == XA_INTEGER) {
819 switch (format)
820 {
821 case 8:
822 data.c[i] = atoi(argv[2 + i]);
823 break;
824 case 16:
825 data.s[i] = atoi(argv[2 + i]);
826 break;
827 case 32:
828 data.l[i] = atoi(argv[2 + i]);
829 break;
830 default:
831 fprintf(stderr, "unexpected size for property %s", name);
832 return EXIT_FAILURE;
833 }
834 } else if (type == float_atom) {
835 if (format != 32) {
836 fprintf(stderr, "unexpected format %d for property %s\n",
837 format, name);
838 return EXIT_FAILURE;
839 }
840 *(float *)(data.l + i) = strtod(argv[2 + i], &endptr);
841 if (endptr == argv[2 + i]) {
842 fprintf(stderr, "argument %s could not be parsed\n", argv[2 + i]);
843 return EXIT_FAILURE;
844 }
845 } else if (type == XA_ATOM) {
846 if (format != 32) {
847 fprintf(stderr, "unexpected format %d for property %s\n",
848 format, name);
849 return EXIT_FAILURE;
850 }
851 data.l[i] = parse_atom(dpy, argv[2 + i]);
852 } else {
853 fprintf(stderr, "unexpected type for property %s\n", name);
854 return EXIT_FAILURE;
855 }
856 }
857
858 XIChangeProperty(dpy, info->deviceid, prop, type, format, PropModeReplace,
859 data.c, nelements);
860 free(data.c);
861 return EXIT_SUCCESS;
862 }
863 #endif
864
865 int list_props(Display *display, int argc, char *argv[], char *name,
866 char *desc)
867 {
868 #ifdef HAVE_XI2
869 if (xinput_version(display) == XI_2_Major)
870 return list_props_xi2(display, argc, argv, name, desc);
871 #endif
872 return list_props_xi1(display, argc, argv, name, desc);
873
874 }
875
876 int delete_prop(Display *display, int argc, char *argv[], char *name,
877 char *desc)
878 {
879 #ifdef HAVE_XI2
880 if (xinput_version(display) == XI_2_Major)
881 return delete_prop_xi2(display, argc, argv, name, desc);
882 #endif
883 return delete_prop_xi1(display, argc, argv, name, desc);
884
885 }
886
887 int set_prop(Display *display, int argc, char *argv[], char *name,
888 char *desc)
889 {
890 #ifdef HAVE_XI2
891 if (xinput_version(display) == XI_2_Major)
892 return set_prop_xi2(display, argc, argv, name, desc);
893 #endif
894 return set_prop_xi1(display, argc, argv, name, desc);
895 }