Don't grab devices unless specified through the config options.

Grabbing event devices stops in-kernel event forwarding, most notably rfkill
and the "Macintosh mouse button emulation" device. Let's not do that.

Option "GrabDevice" forces grabbing the device.
master
Peter Hutterer 18 years ago
parent 555f5a7cbf
commit e8534d47c8
  1. 8
      man/evdev.man
  2. 35
      src/evdev.c
  3. 2
      src/evdev.h

@ -12,6 +12,7 @@ evdev \- Generic Linux input driver
.BI " Option \*qPath\*q \*q" path \*q
.BI " Option \*qEmulate3Buttons\*q \*q" True \*q
.BI " Option \*qEmulate3Timeout\*q \*q" 50 \*q
.BI " Option \*qGrabDevice\*q \*q" False \*q
\ \ ...
.B EndSection
.fi
@ -120,6 +121,13 @@ emulation mode. Button number
is mapped to the negative Y axis motion and button number
.I N2
is mapped to the positive Y axis motion. Default: "4 5"
.TP 7
.BI "Option \*qGrabDevice\*q \*q" boolean \*q
Force a grab on the event device. Doing so will ensure that no other driver
can initialise the same device and it will also stop the device from sending
events to /dev/kbd or /dev/input/mice. Events from this device will not be
sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).
Default disabled.
.SH AUTHORS
Kristian Høgsberg.
.SH "SEE ALSO"

@ -942,23 +942,24 @@ EvdevProc(DeviceIntPtr device, int what)
return EvdevInit(device);
case DEVICE_ON:
if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)1))
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1))
{
xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
strerror(errno));
if (errno != ENODEV)
if (errno == ENODEV)
return !Success;
}
xf86AddEnabledDevice(pInfo);
if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
{
xf86AddEnabledDevice(pInfo);
if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
{
EvdevMBEmuPreInit(pInfo);
EvdevWheelEmuPreInit(pInfo);
}
device->public.on = TRUE;
EvdevMBEmuPreInit(pInfo);
EvdevWheelEmuPreInit(pInfo);
}
device->public.on = TRUE;
break;
case DEVICE_OFF:
if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
strerror(errno));
xf86RemoveEnabledDevice(pInfo);
@ -982,17 +983,19 @@ EvdevProbe(InputInfoPtr pInfo)
long rel_bitmask[NBITS(REL_MAX)];
long abs_bitmask[NBITS(ABS_MAX)];
int i, has_axes, has_keys, num_buttons;
int kernel24 = 0;
EvdevPtr pEvdev = pInfo->private;
if (ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
if (errno == EINVAL) {
/* keyboards are unsafe in 2.4 */
pEvdev->kernel24 = 1;
kernel24 = 1;
pEvdev->grabDevice = 0;
} else {
xf86Msg(X_ERROR, "Grab failed. Device already configured?\n");
return 1;
}
} else {
} else if (pEvdev->grabDevice) {
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
}
@ -1068,7 +1071,7 @@ EvdevProbe(InputInfoPtr pInfo)
}
if (has_keys) {
if (pEvdev->kernel24) {
if (kernel24) {
xf86Msg(X_INFO, "%s: Kernel < 2.6 is too old, ignoring keyboard\n",
pInfo->name);
} else {
@ -1152,6 +1155,10 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
return NULL;
}
/* Grabbing the event device stops in-kernel event forwarding. In other
words, it disables rfkill and the "Macintosh mouse button emulation". */
pEvdev->grabDevice = xf86CheckBoolOption(dev->commonOptions, "GrabDevice", 0);
EvdevInitButtonMapping(pInfo);
pEvdev->noXkb = noXkbExtension;

@ -50,7 +50,7 @@ typedef struct {
} WheelAxis, *WheelAxisPtr;
typedef struct {
int kernel24;
int grabDevice; /* grab the event device? */
int screen;
int min_x, min_y, max_x, max_y;
int abs_x, abs_y, old_x, old_y;

Loading…
Cancel
Save