On Sat, Jun 20, 2009 at 10:53:49AM -0400, Thomas Jaeger wrote: > > minor nitpick: the loop condition should include the checks for > > r.return_pointer and r.return_keyboard so we can break early when we have > > found them. > > (which btw. is always after the VCK in the current implementation, the > > server > > guarantees VCP and VCK are always there and they have the lowest device > > ids. not that the protocol requires this, but might be interesting to know) > > Done, although performance is really not something we need to worry > about here.
sure, might as well get it right in the first place though. > From a25ed91b3c08f3e8e46c0a23ea61e905b86c16c7 Mon Sep 17 00:00:00 2001 > From: Thomas Jaeger <[email protected]> > Date: Sun, 14 Jun 2009 13:58:39 -0400 > Subject: [PATCH] reattach: Default to return to VCP/VCK when returnMode is > AttachToMaster > > Signed-off-by: Thomas Jaeger <[email protected]> > --- > src/hierarchy.c | 38 ++++++++++++++++++++++++++++++++++++-- > src/xinput.c | 2 +- > 2 files changed, 37 insertions(+), 3 deletions(-) > > diff --git a/src/hierarchy.c b/src/hierarchy.c > index cf0f783..b69b98c 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 (return_pointer && return_keyboard) ^^ your compiler must be better than mine. :) > + 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", I just noticed this hunk is wrong, shouldn't be in there. The default return mode is still "floating" (for better or worse). The new behaviour should be documented in the man page, which I just noticed doesn't exist for these options yet. fixed up the build error, removed the last hunk. Pushed as e8ca8fa459eb2eb4d9e9faf294d7172fb4fdb17b. Cheers, Peter _______________________________________________ xorg-devel mailing list [email protected] http://lists.x.org/mailman/listinfo/xorg-devel
