summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@redhat.com>2008-10-16 15:23:06 +1030
committerPeter Hutterer <peter.hutterer@redhat.com>2008-10-23 17:14:49 +1030
commite9dd721e2dd24e9bdc5092bcc0bbe94a2ac065ff (patch)
tree7cfad2b83828ac971845714fb9e07ef6afae0486
parentcab104fd9e508030db623bae2eb70bd5dd1bf450 (diff)
Add option "GrabDevice", don't grab the device by default.
We now have the matching code in the server to set the console to RAW mode and don't need to grab the devices anymore. This is an updated version of e8534d47c8524ac081c2e3e6ebaabe4c6b274a18, which was reverted in 6dc41991557fa55a9e2f5aaf0fe40c70a08d41fd. (cherry picked from commit 4912e2aa7f867a86d383010023b8426c881fb3b0)
-rw-r--r--man/evdev.man8
-rw-r--r--src/evdev.c19
-rw-r--r--src/evdev.h2
3 files changed, 22 insertions, 7 deletions
diff --git a/man/evdev.man b/man/evdev.man
index 899ca71..9d336fc 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -11,6 +11,7 @@ evdev \- Generic Linux input driver
.BI " Option \*qDevice\*q \*q" devpath \*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
@@ -145,6 +146,13 @@ waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
.TP 7
.BI "Option \*qInvertY\*q \*q" Bool \*q
Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
+.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 SUPPORTED PROPERTIES
The following properties are provided by the
diff --git a/src/evdev.c b/src/evdev.c
index 865b451..1a664ac 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -979,7 +979,7 @@ EvdevOn(DeviceIntPtr device)
pInfo = device->public.devicePrivate;
pEvdev = pInfo->private;
- if (pInfo->fd != -1 && !pEvdev->kernel24 &&
+ if (pInfo->fd != -1 && pEvdev->grabDevice &&
(rc = ioctl(pInfo->fd, EVIOCGRAB, (void *)1)))
{
xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
@@ -1028,7 +1028,7 @@ EvdevProc(DeviceIntPtr device, int what)
case DEVICE_OFF:
if (pInfo->fd != -1)
{
- 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);
@@ -1177,17 +1177,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);
}
@@ -1263,7 +1265,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 {
@@ -1348,6 +1350,11 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
+ /* Grabbing the event device stops in-kernel event forwarding. In other
+ words, it disables rfkill and the "Macintosh mouse button emulation".
+ Note that this needs a server that sets the console to RAW mode. */
+ pEvdev->grabDevice = xf86CheckBoolOption(dev->commonOptions, "GrabDevice", 0);
+
pEvdev->noXkb = noXkbExtension; /* parse the XKB options during kbd setup */
EvdevInitButtonMapping(pInfo);
diff --git a/src/evdev.h b/src/evdev.h
index 515ed59..c2f614a 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -57,7 +57,7 @@ typedef struct {
typedef struct {
const char *device;
- 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;