[PATCH] reattach: Default to return to VCP/VCK when returnMode is AttachToMaster

Thomas Jaeger ThJaeger at gmail.com
Sun Jun 14 10:58:39 PDT 2009


Signed-off-by: Thomas Jaeger <ThJaeger at gmail.com>
---
 src/hierarchy.c |   39 +++++++++++++++++++++++++++++++++++++--
 src/xinput.c    |    2 +-
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/hierarchy.c b/src/hierarchy.c
index cf0f783..18c6710 100644
--- a/src/hierarchy.c
+++ b/src/hierarchy.c
@@ -96,8 +96,43 @@ 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]);
+	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;
+	} else {
+	    int i, ndevices;
+	    info = XIQueryDevice(dpy, XIAllDevices, &ndevices);
+	    for(i = 0; i < ndevices; i++)
+		if (info[i].use == XIMasterPointer) {
+		    r.return_pointer = info[i].deviceid;
+		    break;
+		}
+	    XIFreeDeviceInfo(info);
+	}
+
+	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;
+	} else {
+	    int i, ndevices;
+	    info = XIQueryDevice(dpy, XIAllDevices, &ndevices);
+	    for(i = 0; i < ndevices; i++)
+		if (info[i].use == XIMasterKeyboard) {
+		    r.return_keyboard = info[i].deviceid;
+		    break;
+		}
+	    XIFreeDeviceInfo(info);
+	}
     }
 
     ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&r, 1);
diff --git a/src/xinput.c b/src/xinput.c
index 007fe2c..7c47c3c 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -87,7 +87,7 @@ static entry drivers[] =
       create_master
     },
     { "remove-master",
-      "<id> [returnMode (dflt:Floating)] [returnPointer] [returnKeyboard]",
+      "<id> [returnMode (dflt:Floating, AttachToMaster)] [returnPointer] [returnKeyboard]",
       remove_master
     },
     { "reattach",
-- 
1.6.3.1


--------------020105080704000405080302
Content-Type: text/x-patch;
 name="0001-reattach-Default-to-return-to-VCP-VCK-2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0001-reattach-Default-to-return-to-VCP-VCK-2.patch"



More information about the xorg-devel mailing list