Bug#504536: Fix available
It happens that evdev 2.0 is brain damaged. It opens required file
descriptor once X server is started, closes it after logoff and never
opens it again. So evdev is hardly usable on all archs.
Patch to fix this is attached. I'm going to raise this bug severity to RC.
--
Max
diff -urpN xserver-xorg-input-evdev-2.0.3/src/evdev.c xserver-xorg-input-evdev-2.0.3-fixed/src/evdev.c
--- xserver-xorg-input-evdev-2.0.3/src/evdev.c 2008-11-05 04:20:25.000000000 +0300
+++ xserver-xorg-input-evdev-2.0.3-fixed/src/evdev.c 2008-11-05 04:24:12.000000000 +0300
@@ -831,6 +831,7 @@ EvdevProc(DeviceIntPtr device, int what)
{
InputInfoPtr pInfo;
EvdevPtr pEvdev;
+ const char* devicePath = 0;
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
@@ -838,6 +839,26 @@ EvdevProc(DeviceIntPtr device, int what)
switch (what)
{
case DEVICE_INIT:
+ devicePath = xf86CheckStrOption(pInfo->conf_idev->commonOptions, "Path", NULL);
+
+ if (!devicePath)
+ devicePath = xf86CheckStrOption(pInfo->conf_idev->commonOptions, "Device", NULL);
+
+ if (!devicePath) {
+ xf86Msg(X_ERROR, "%s: No device specified.\n", pInfo->name);
+ return !Success;
+ }
+
+ do {
+ pInfo->fd = open(devicePath, O_RDWR, 0);
+ }
+ while (pInfo->fd < 0 && errno == EINTR);
+
+ if(pInfo->fd < 0) {
+ xf86Msg(X_ERROR, "Unable to open evdev device \"%s\".\n", devicePath);
+ return !Success;
+ }
+
return EvdevInit(device);
case DEVICE_ON:
@@ -854,17 +875,21 @@ EvdevProc(DeviceIntPtr device, int what)
break;
case DEVICE_OFF:
- if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
- xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
- strerror(errno));
- xf86RemoveEnabledDevice(pInfo);
- EvdevMBEmuFinalize(pInfo);
- device->public.on = FALSE;
- break;
-
case DEVICE_CLOSE:
- xf86Msg(X_INFO, "%s: Close\n", pInfo->name);
- close(pInfo->fd);
+ if(device->public.on == TRUE) {
+ if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
+ xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
+ strerror(errno));
+ xf86RemoveEnabledDevice(pInfo);
+ EvdevMBEmuFinalize(pInfo);
+ device->public.on = FALSE;
+ }
+
+ if(what == DEVICE_CLOSE) {
+ xf86Msg(X_INFO, "%s: Close\n", pInfo->name);
+ close(pInfo->fd);
+ pInfo->fd = -1;
+ }
break;
}
@@ -1071,6 +1096,9 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr
return NULL;
}
+ close(pInfo->fd);
+ pInfo->fd = -1;
+
return pInfo;
}
Reply to: