summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Jaeger <ThJaeger@gmail.com>2009-06-14 13:58:39 -0400
committerPeter Hutterer <peter.hutterer@who-t.net>2009-06-22 10:24:47 +1000
commite8ca8fa459eb2eb4d9e9faf294d7172fb4fdb17b (patch)
tree5911bd3310836b60b714333274b5bcf2ddc65775 /src
parentf8b3dc4e1c43140514d20fbc9fddd0f352cbe40b (diff)
reattach: Default to return to VCP/VCK when returnMode is AttachToMaster
Signed-off-by: Thomas Jaeger <ThJaeger@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/hierarchy.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/hierarchy.c b/src/hierarchy.c
index cf0f783..7f35c39 100644
--- a/src/hierarchy.c
+++ b/src/hierarchy.c
@@ -96,8 +96,42 @@ remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
if (r.return_mode == XIAttachToMaster)
{
- r.return_pointer = atoi(argv[2]);
- r.return_keyboard = atoi(argv[3]);
+ r.return_pointer = 0;
+ if (argc >= 3) {
+ info = xi2_find_device_info(dpy, argv[2]);
+ if (!info) {
+ fprintf(stderr, "unable to find device %s\n", argv[2]);
+ return EXIT_FAILURE;
+ }
+
+ r.return_pointer = info->deviceid;
+ }
+
+ r.return_keyboard = 0;
+ if (argc >= 4) {
+ info = xi2_find_device_info(dpy, argv[3]);
+ if (!info) {
+ fprintf(stderr, "unable to find device %s\n", argv[3]);
+ return EXIT_FAILURE;
+ }
+
+ r.return_keyboard = info->deviceid;
+ }
+
+ if (!r.return_pointer || !r.return_keyboard) {
+ int i, ndevices;
+ info = XIQueryDevice(dpy, XIAllMasterDevices, &ndevices);
+ for(i = 0; i < ndevices; i++) {
+ if (info[i].use == XIMasterPointer && !r.return_pointer)
+ r.return_pointer = info[i].deviceid;
+ if (info[i].use == XIMasterKeyboard && !r.return_keyboard)
+ r.return_keyboard = info[i].deviceid;
+ if (r.return_pointer && r.return_keyboard)
+ break;
+ }
+
+ XIFreeDeviceInfo(info);
+ }
}
ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&r, 1);