dix: Ensure enough memory for ClassesChangedEvent for a new device.

Before we enable the device through the driver, we size it up and make sure
that the events in the event list contain enough bytes for a possible
ClassesChangedEvent lateron.
This commit is contained in:
Peter Hutterer 2008-02-03 10:25:15 +10:30
parent 74628d6397
commit 750d702676

View File

@ -206,6 +206,10 @@ EnableDevice(DeviceIntPtr dev)
DeviceIntRec dummyDev;
DeviceIntPtr other;
devicePresenceNotify ev;
int namelen = 0; /* dummy */
int evsize = sizeof(xEvent);
int listlen;
EventListPtr evlist;
for (prev = &inputInfo.off_devices;
*prev && (*prev != dev);
@ -238,6 +242,18 @@ EnableDevice(DeviceIntPtr dev)
}
}
/* Before actually enabling the device, we need to make sure the event
* list's events have enough memory for a ClassesChangedEvent from the
* device
*/
SizeDeviceInfo(dev, &namelen, &evsize);
listlen = GetEventList(&evlist);
OsBlockSignals();
SetMinimumEventSize(evlist, listlen, evsize);
OsReleaseSignals();
if ((*prev != dev) || !dev->inited ||
((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
ErrorF("[dix] couldn't enable device %d\n", dev->id);