[PATCH evdev 2/8] Comment odd EVIOCGRAB behaviour and reshuffle conditions a bit.

Peter Hutterer peter.hutterer at who-t.net
Sun May 23 17:57:42 PDT 2010


The reason for this rather weird approach is to ungrab immediately after
getting a successful grab. Evdev shouldn't be hogging the device if nothing
is done with it.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 6f1a646..27c28cb 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1768,12 +1768,17 @@ EvdevProbe(InputInfoPtr pInfo)
     int ignore_abs = 0, ignore_rel = 0;
     EvdevPtr pEvdev = pInfo->private;
 
-    if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
+    /* If grabDevice is set, ungrab immediately since we only want to grab
+     * between DEVICE_ON and DEVICE_OFF. If we never get DEVICE_ON, don't
+     * hold a grab. */
+    if (pEvdev->grabDevice)
+    {
+        if (ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
             xf86Msg(X_ERROR, "Grab failed. Device already configured?\n");
             return 1;
-    } else if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0)) {
-        xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
-               strerror(errno));
+        } else if (ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
+            xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
+                    strerror(errno));
     }
 
     /* Trinary state for ignoring axes:
-- 
1.7.0.1



More information about the xorg-devel mailing list