enable adding devices after removal of a middle device

Allow new devices to be added after a device that _wasn't_ the last on the
list was removed, by ensuring inputInfo.numDevices always increases, and
never decreases.
This commit is contained in:
Daniel Stone 2006-08-07 23:02:17 +03:00 committed by Daniel Stone
parent a31d11a7a8
commit 458c63a841
2 changed files with 8 additions and 19 deletions

View File

@ -96,7 +96,7 @@ int
ProcXListInputDevices(register ClientPtr client) ProcXListInputDevices(register ClientPtr client)
{ {
xListInputDevicesReply rep; xListInputDevicesReply rep;
int numdevs; int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */ int namesize = 1; /* need 1 extra byte for strcpy */
int size = 0; int size = 0;
int total_length; int total_length;
@ -115,12 +115,15 @@ ProcXListInputDevices(register ClientPtr client)
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
AddOtherInputDevices(); AddOtherInputDevices();
numdevs = inputInfo.numDevices;
for (d = inputInfo.devices; d; d = d->next) for (d = inputInfo.devices; d; d = d->next) {
SizeDeviceInfo(d, &namesize, &size); SizeDeviceInfo(d, &namesize, &size);
for (d = inputInfo.off_devices; d; d = d->next) numdevs++;
}
for (d = inputInfo.off_devices; d; d = d->next) {
SizeDeviceInfo(d, &namesize, &size); SizeDeviceInfo(d, &namesize, &size);
numdevs++;
}
total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
devbuf = (char *)xalloc(total_length); devbuf = (char *)xalloc(total_length);

View File

@ -536,7 +536,7 @@ RemoveDevice(DeviceIntPtr dev)
ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer); ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer);
#endif #endif
if (!dev) if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
return BadImplementation; return BadImplementation;
prev = NULL; prev = NULL;
@ -550,13 +550,6 @@ RemoveDevice(DeviceIntPtr dev)
else else
prev->next = next; prev->next = next;
inputInfo.numDevices--;
if (inputInfo.keyboard == tmp)
inputInfo.keyboard = NULL;
else if (inputInfo.pointer == tmp)
inputInfo.pointer = NULL;
ret = Success; ret = Success;
} }
} }
@ -572,13 +565,6 @@ RemoveDevice(DeviceIntPtr dev)
else else
prev->next = next; prev->next = next;
inputInfo.numDevices--;
if (inputInfo.keyboard == tmp)
inputInfo.keyboard = NULL;
else if (inputInfo.pointer == tmp)
inputInfo.pointer = NULL;
ret = Success; ret = Success;
} }
} }