diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2010-04-01 15:35:34 +0100 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-05-14 11:33:51 +1000 |
commit | 26c8ad96bed67087f89439ec595e928e7f5c8a9c (patch) | |
tree | 1afaf68609f00000ea02d1bb1ba64400ca8c4519 /src | |
parent | 19751d021524ee7237704b6158947c26aad4e8c5 (diff) |
Warn and fail if a device name is ambiguous.
The XI1 path bails out if the user specifies a device by name and there
is more than one device, but the XI2 path previously just silently chose
the first one. This patch makes it fail outright.
Signed-off-by: Will Thompson <will.thompson@collabora.co.uk>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/xinput.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/xinput.c b/src/xinput.c index 149662d..6989ef3 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -236,6 +236,7 @@ XIDeviceInfo* xi2_find_device_info(Display *display, char *name) { XIDeviceInfo *info; + XIDeviceInfo *found = NULL; int ndevices; Bool is_id = True; int i, id = -1; @@ -257,12 +258,20 @@ xi2_find_device_info(Display *display, char *name) if ((is_id && info[i].deviceid == id) || (!is_id && strcmp(info[i].name, name) == 0)) { - return &info[i]; + if (found) { + fprintf(stderr, + "Warning: There are multiple devices named '%s'.\n" + "To ensure the correct one is selected, please use " + "the device ID instead.\n\n", name); + XIFreeDeviceInfo(info); + return NULL; + } else { + found = &info[i]; + } } } - XIFreeDeviceInfo(info); - return NULL; + return found; } #endif |