summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2009-10-29 00:40:48 +0600
committerPeter Hutterer <peter.hutterer@who-t.net>2009-11-03 13:25:35 +1000
commit171dc59ec52cda3d73bbb3ed8091904c124011bb (patch)
treeff4b882b43581947d5ca66be017e5c0084dc763c
parent9ed5acec417f683102c0f52138a5d52131604c3c (diff)
kdrive: Grab evdev mouse/keyboard devices when X server is active
Input events are directed to both vt and input devices by default. Unless input devices are grabbed, keyboard events fill it vt buffers and cause spontaneous wakeups in kernel tty layer when buffers are full. Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit 662594aeff9d1767316f08600949c73ac5060d18)
-rw-r--r--hw/kdrive/linux/evdev.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
index f6017ba51..096a2ddc3 100644
--- a/hw/kdrive/linux/evdev.c
+++ b/hw/kdrive/linux/evdev.c
@@ -243,7 +243,9 @@ EvdevPtrEnable (KdPointerInfo *pi)
if (fd < 0)
return BadMatch;
-
+ if (ioctl (fd, EVIOCGRAB, 1) < 0)
+ perror ("Grabbing evdev mouse device failed");
+
if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
{
perror ("EVIOCGBIT 0");
@@ -335,6 +337,10 @@ EvdevPtrDisable (KdPointerInfo *pi)
return;
KdUnregisterFd (pi, ke->fd, TRUE);
+
+ if (ioctl (ke->fd, EVIOCGRAB, 0) < 0)
+ perror ("Ungrabbing evdev mouse device failed");
+
xfree (ke);
pi->driverPrivate = 0;
}
@@ -425,6 +431,9 @@ EvdevKbdEnable (KdKeyboardInfo *ki)
if (fd < 0)
return BadMatch;
+ if (ioctl (fd, EVIOCGRAB, 1) < 0)
+ perror ("Grabbing evdev keyboard device failed");
+
if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0) {
perror ("EVIOCGBIT 0");
close (fd);
@@ -496,6 +505,10 @@ EvdevKbdDisable (KdKeyboardInfo *ki)
return;
KdUnregisterFd (ki, ke->fd, TRUE);
+
+ if (ioctl (ke->fd, EVIOCGRAB, 0) < 0)
+ perror ("Ungrabbing evdev keyboard device failed");
+
xfree (ke);
ki->driverPrivate = 0;
}