]> diplodocus.org Git - xorg-xinput/blobdiff - src/property.c
Require inputproto 1.9.99.5
[xorg-xinput] / src / property.c
index 269fecca5d28626c2489c75860fc407ace89f459..d0a4ffc31f9d1d5f7779e07e6c664140278160a7 100644 (file)
@@ -37,7 +37,6 @@
 static void
 print_property(Display *dpy, XDevice* dev, Atom property)
 {
-    XIPropertyInfo      *propinfo;
     Atom                act_type;
     char                *name;
     int                 act_format;
@@ -45,14 +44,10 @@ print_property(Display *dpy, XDevice* dev, Atom property)
     unsigned char       *data, *ptr;
     int                 j;
 
-    propinfo = XQueryDeviceProperty(dpy, dev, property);
-    if (!propinfo)
-        return;
-
     name = XGetAtomName(dpy, property);
-    printf("\t%s:\t", name);
+    printf("\t%s (%d):\t", name, property);
 
-    if (XGetDeviceProperty(dpy, dev, property, 0, 1000, False, False,
+    if (XGetDeviceProperty(dpy, dev, property, 0, 1000, False,
                            AnyPropertyType, &act_type, &act_format,
                            &nitems, &bytes_after, &data) == Success)
     {
@@ -101,26 +96,6 @@ print_property(Display *dpy, XDevice* dev, Atom property)
     } else
         printf("\tFetch failure\n");
 
-    if (propinfo->pending || propinfo->range || propinfo->immutable || propinfo->fromClient)
-    {
-        printf("\t\t%s%s%s%s", ((propinfo->pending) ? "[pending]" : ""),
-                                  ((propinfo->range)   ? "[range]" : ""),
-                                  ((propinfo->immutable) ? "[immutable]" : ""),
-                                  ((propinfo->fromClient) ? "[client]" : ""));
-        printf("\n");
-    }
-
-    if (propinfo->num_values)
-    {
-        long *values = propinfo->values;
-        printf("\t\tvalid values: ");
-        while(values && propinfo->num_values--)
-            printf("%ld ", *values++);
-        printf("\n");
-    }
-
-    XFree(propinfo);
-
 }
 
 int list_props(Display *dpy, int argc, char** argv, char* name, char *desc)
@@ -215,6 +190,8 @@ set_int_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
 
     if (!is_atom)
         prop = XInternAtom(dpy, name, False);
+    else
+        prop = atoi(name);
 
     nelements = argc - 3;
     format    = atoi(argv[2]);
@@ -257,6 +234,8 @@ int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
     XEvent      ev;
     XDevicePropertyNotifyEvent *dpev;
     char        *name;
+    int         type_prop;
+    XEventClass cls_prop;
 
     if (list_props(dpy, argc, argv, n, desc) != EXIT_SUCCESS)
         return EXIT_FAILURE;
@@ -275,17 +254,17 @@ int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
         return EXIT_FAILURE;
     }
 
-    XiSelectEvent(dpy, DefaultRootWindow(dpy), NULL,
-                  XI_DevicePropertyNotifyMask);
+    DevicePropertyNotify(dev, type_prop, cls_prop);
+    XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &cls_prop, 1);
 
     while(1)
     {
         XNextEvent(dpy, &ev);
 
         dpev = (XDevicePropertyNotifyEvent*)&ev;
-        if (dpev->type != GenericEvent &&
-            dpev->type != XI_DevicePropertyNotify)
+        if (dpev->type != type_prop)
             continue;
+
         name = XGetAtomName(dpy, dpev->atom);
         printf("Property '%s' changed.\n", name);
         print_property(dpy, dev, dpev->atom);
@@ -293,3 +272,46 @@ int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
 
     XCloseDevice(dpy, dev);
 }
+
+int delete_prop(Display *dpy, int argc, char** argv, char* n, char *desc)
+{
+    XDevice     *dev;
+    XDeviceInfo *info;
+    char        *name;
+    int         i;
+    Bool        is_atom = True;
+    Atom        prop;
+
+    info = find_device_info(dpy, argv[0], False);
+    if (!info)
+    {
+        fprintf(stderr, "unable to find device %s\n", argv[0]);
+        return EXIT_FAILURE;
+    }
+
+    dev = XOpenDevice(dpy, info->id);
+    if (!dev)
+    {
+        fprintf(stderr, "unable to open device '%s'\n", info->name);
+        return EXIT_FAILURE;
+    }
+
+    name = argv[1];
+
+    for(i = 0; i < strlen(name); i++) {
+       if (!isdigit(name[i])) {
+            is_atom = False;
+           break;
+       }
+    }
+
+    if (!is_atom)
+        prop = XInternAtom(dpy, name, False);
+    else
+        prop = atoi(name);
+
+    XDeleteDeviceProperty(dpy, dev, prop);
+
+    XCloseDevice(dpy, dev);
+    return EXIT_SUCCESS;
+}