dix/devices: add devices in proper forward order

Add devices in forward order with the normal linked list convention.
Previously, AddInputDevice would add all the devices in reverse order to
off_devices, before they were added again in reverse order to devices with
EnableDevice.
This just makes both work in forward order, which provides the ordering as
you'd expect when hotplugging devices (i.e. adds them to the head, not the
tail).
This commit is contained in:
Daniel Stone 2006-10-15 20:01:01 +03:00 committed by Daniel Stone
parent ec35e7198d
commit fc9b5f84b2

View File

@ -86,7 +86,7 @@ int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
DeviceIntPtr
AddInputDevice(DeviceProc deviceProc, Bool autoStart)
{
register DeviceIntPtr dev;
register DeviceIntPtr dev, *prev; /* not a typo */
if (inputInfo.numDevices >= MAX_DEVICES)
return (DeviceIntPtr)NULL;
@ -130,8 +130,12 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->devPrivates = NULL;
dev->unwrapProc = NULL;
dev->coreEvents = TRUE;
dev->next = inputInfo.off_devices;
inputInfo.off_devices = dev;
for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
;
*prev = dev;
dev->next = NULL;
return dev;
}
@ -151,8 +155,12 @@ EnableDevice(register DeviceIntPtr dev)
return FALSE;
}
*prev = dev->next;
dev->next = inputInfo.devices;
inputInfo.devices = dev;
for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
;
*prev = dev;
dev->next = NULL;
return TRUE;
}