Disable devices before removing, remove unrecoverable devices.

This commit is contained in:
Peter Hutterer 2007-04-24 22:52:33 +09:30
parent c7e2ba0c9b
commit 09436fb7c3
3 changed files with 23 additions and 3 deletions

View File

@ -577,6 +577,7 @@ RemoveDevice(DeviceIntPtr dev)
return BadImplementation; return BadImplementation;
deviceid = dev->id; deviceid = dev->id;
DisableDevice(dev);
prev = NULL; prev = NULL;
for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) { for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {

View File

@ -771,11 +771,30 @@ xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
* Device will be moved to the off_devices list, but it will still be there * Device will be moved to the off_devices list, but it will still be there
* until you really clean up after it. * until you really clean up after it.
* Notifies the client about an inactive device. * Notifies the client about an inactive device.
*
* @param panic True if device is unrecoverable and needs to be removed.
*/ */
_X_EXPORT void _X_EXPORT void
xf86DisableDevice(DeviceIntPtr dev) xf86DisableDevice(DeviceIntPtr dev, Bool panic)
{
devicePresenceNotify ev;
DeviceIntRec dummyDev;
if(!panic)
{ {
DisableDevice(dev); DisableDevice(dev);
} else
{
ev.type = DevicePresenceNotify;
ev.time = currentTime.milliseconds;
ev.devchange = DeviceUnrecoverable;
ev.deviceid = dev->id;
dummyDev.id = 0;
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
(xEvent *) &ev, 1);
DeleteInputDeviceRequest(dev);
}
} }
/** /**

View File

@ -187,7 +187,7 @@ void xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval,
void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum); void xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum);
void xf86AddEnabledDevice(InputInfoPtr pInfo); void xf86AddEnabledDevice(InputInfoPtr pInfo);
void xf86RemoveEnabledDevice(InputInfoPtr pInfo); void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
void xf86DisableDevice(DeviceIntPtr dev); void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
void xf86EnableDevice(DeviceIntPtr dev); void xf86EnableDevice(DeviceIntPtr dev);
/* xf86Helper.c */ /* xf86Helper.c */