diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-09-26 13:55:33 +0930 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-09-26 14:00:19 +0930 |
commit | ccef360e5ee6598a0ab722389bdf8d391ff7efee (patch) | |
tree | 8e340450733f8f18382f3d269e0802ccb3a2ad44 | |
parent | db4b03629f690d69320f401b9568d5a861b19f9c (diff) |
Add --delete-prop option.
-rw-r--r-- | man/xinput.man | 5 | ||||
-rw-r--r-- | src/property.c | 43 | ||||
-rw-r--r-- | src/xinput.c | 4 | ||||
-rw-r--r-- | src/xinput.h | 11 |
4 files changed, 63 insertions, 0 deletions
diff --git a/man/xinput.man b/man/xinput.man index 0cad0b3..c9ff46f 100644 --- a/man/xinput.man +++ b/man/xinput.man @@ -69,6 +69,11 @@ are 8, 16, or 32, depending on the property. 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 diff --git a/src/property.c b/src/property.c index d739d6a..d0a4ffc 100644 --- a/src/property.c +++ b/src/property.c @@ -272,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; +} diff --git a/src/xinput.c b/src/xinput.c index ac9c65f..b1cd0a3 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -114,6 +114,10 @@ static entry drivers[] = "<device>", watch_props }, + { "delete-prop", + "<device> <property>", + delete_prop + }, #endif {0, 0, 0 } diff --git a/src/xinput.h b/src/xinput.h index 9b017ba..d7a5104 100644 --- a/src/xinput.h +++ b/src/xinput.h @@ -245,4 +245,15 @@ watch_props( #endif ); +int +delete_prop( +#if NeedFunctionPrototypes + Display* display, + int argc, + char *argv[], + char *prog_name, + char *prog_desc +#endif +); + /* end of xinput.h */ |