]> diplodocus.org Git - xorg-xinput/commitdiff
Add --delete-prop option.
authorPeter Hutterer <peter.hutterer@redhat.com>
Fri, 26 Sep 2008 04:25:33 +0000 (13:55 +0930)
committerPeter Hutterer <peter.hutterer@redhat.com>
Fri, 26 Sep 2008 04:30:19 +0000 (14:00 +0930)
man/xinput.man
src/property.c
src/xinput.c
src/xinput.h

index 0cad0b300795dcd43dedf1559cc5480ce05ccffa..c9ff46f0ffb069ce8186da0572af4871dab797a6 100644 (file)
@@ -69,6 +69,11 @@ are 8, 16, or 32, depending on the property.
 Prints to standard out when property changes occur.
 .PP
 .TP 8
 Prints to standard out when property changes occur.
 .PP
 .TP 8
+.B xinput delete-prop \fIdevice_name\fP \fIproperty\fP
+Delete the property from the device.
+.PP
+.PP
+.TP 8
 .B xinput test [-proximity] \fIdevice_name\fP
 Register all extended events from \fIdevice_name\fP and enter an endless
 loop displaying events received. If the -proximity is given, ProximityIn
 .B xinput test [-proximity] \fIdevice_name\fP
 Register all extended events from \fIdevice_name\fP and enter an endless
 loop displaying events received. If the -proximity is given, ProximityIn
index d739d6a79c7d8101416e94d0ca2cccfd16cd1789..d0a4ffc31f9d1d5f7779e07e6c664140278160a7 100644 (file)
@@ -272,3 +272,46 @@ int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
 
     XCloseDevice(dpy, dev);
 }
 
     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;
+}
index ac9c65f99bc988fa3f7fec8fa45190062c0f12ff..b1cd0a3b2dff0f99b1a9e7142e6c586c2ce12412 100644 (file)
@@ -114,6 +114,10 @@ static entry drivers[] =
       "<device>",
       watch_props
     },
       "<device>",
       watch_props
     },
+    { "delete-prop",
+      "<device> <property>",
+      delete_prop
+    },
 #endif
     {0, 0, 0
     }
 #endif
     {0, 0, 0
     }
index 9b017bab7b5cf820c94eebf5d1f58ed44a7d781e..d7a5104a57f9dac62f7e5a3f0f034606a17ac771 100644 (file)
@@ -245,4 +245,15 @@ watch_props(
 #endif
 );
 
 #endif
 );
 
+int
+delete_prop(
+#if NeedFunctionPrototypes
+                Display*       display,
+                int            argc,
+                char           *argv[],
+                char           *prog_name,
+                char           *prog_desc
+#endif
+);
+
 /* end of xinput.h */
 /* end of xinput.h */