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>
xi2_find_device_info(Display *display, char *name)
{
XIDeviceInfo *info;
xi2_find_device_info(Display *display, char *name)
{
XIDeviceInfo *info;
+ XIDeviceInfo *found = NULL;
int ndevices;
Bool is_id = True;
int i, id = -1;
int ndevices;
Bool is_id = True;
int i, id = -1;
if ((is_id && info[i].deviceid == id) ||
(!is_id && strcmp(info[i].name, name) == 0))
{
if ((is_id && info[i].deviceid == id) ||
(!is_id && strcmp(info[i].name, name) == 0))
{
+ 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;