diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-07-18 11:59:02 -0400 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-07-18 11:59:02 -0400 |
commit | 60d89764b808153808a6bfd0f29144cc9a9a08a2 (patch) | |
tree | 058837c4ca5b5c8fa1ee85964eec0cc1308badae | |
parent | 2ecc9dc044a81092728c7c14eaeb792cd5102ce5 (diff) |
allow toggling of core event sending
Allow toggling sending of core events from extension devices with
-c (disable) and +c (enable).
-rw-r--r-- | xsetpointer.c | 46 | ||||
-rw-r--r-- | xsetpointer.man | 4 |
2 files changed, 39 insertions, 11 deletions
diff --git a/xsetpointer.c b/xsetpointer.c index 2a95917..064e581 100644 --- a/xsetpointer.c +++ b/xsetpointer.c @@ -59,20 +59,28 @@ StrCaseCmp(char *s1, char *s2) int main(int argc, char * argv[]) { - int loop, num_extensions, num_devices; - char **extensions; - XDeviceInfo *devices; - Display *dpy; - int list = 0; + int loop, num_extensions, num_devices; + char **extensions; + XDeviceInfo *devices; + XDeviceCoreControl corectl; + Display *dpy; + int list = 0, core = 0; + XDevice *device; - if (argc != 2) { - fprintf(stderr, "usage : %s (-l | <device name>)\n", argv[0]); + if (argc < 2 || argc > 3) { + fprintf(stderr, "usage : %s (-l | -c | +c ) <device name>)\n", argv[0]); exit(1); } if (strcmp(argv[1], "-l") == 0) { list = 1; } + else if (strcmp(argv[1], "-c") == 0) { + core = 1; + } + else if (strcmp(argv[1], "+c") == 0) { + core = 2; + } dpy = XOpenDisplay(NULL); @@ -117,13 +125,31 @@ main(int argc, char * argv[]) break; } } + else if (core) { + if (argc == 3 && devices[loop].name && + StrCaseCmp(devices[loop].name, argv[2]) == 0) { +#ifdef DEBUG + fprintf(stderr, "opening device %s\n", + devices[loop].name ? devices[loop].name : "<noname>"); +#endif + device = XOpenDevice(dpy, devices[loop].id); + if (device) { + corectl.status = (core - 1); + XChangeDeviceControl(dpy, device, DEVICE_CORE, + (XDeviceControl *)&corectl); + exit(0); + } + else { + fprintf(stderr, "error opening device\n"); + exit(1); + } + } + } else { if ((argc == 2) && devices[loop].name && (StrCaseCmp(devices[loop].name, argv[1]) == 0)) if (devices[loop].use == IsXExtensionDevice) { - XDevice *device; - #ifdef DEBUG fprintf(stderr, "opening device %s\n", devices[loop].name ? devices[loop].name : "<noname>"); @@ -150,7 +176,7 @@ main(int argc, char * argv[]) exit(1); } - if (list) { + if (list || core) { exit(0); } else { diff --git a/xsetpointer.man b/xsetpointer.man index 0d90beb..c75666f 100644 --- a/xsetpointer.man +++ b/xsetpointer.man @@ -10,6 +10,8 @@ xsetpointer \- set an X Input device as the main pointer .I device-name .SH DESCRIPTION Xsetpointer sets an XInput device as the main pointer. When called with -the \-l flag it lists the available devices. +the \-l flag it lists the available devices. When called with the -c/+c +flag, it toggles the sending of core input events, for servers which +implement a virtual core pointer; -c disables core events, and +c enables. .SH AUTHOR Frederic Lepied |