[PATCH 2/2] When re-opening evdev, set the fd before trying to grab
Keith Packard
keithp at keithp.com
Sat Feb 22 01:44:38 PST 2014
If we try to grab the evdev device before we've set the new file
descriptor, libevdev_grab returns -EFAULT, which causes DeviceOn to
fail.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
src/eventcomm.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 35167bb..b8a2dc5 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -195,20 +195,6 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
struct eventcomm_proto_data *proto_data =
(struct eventcomm_proto_data *) priv->proto_data;
- if (para->grab_event_device) {
- /* Try to grab the event device so that data don't leak to /dev/input/mice */
- int ret;
-
- ret = libevdev_grab(proto_data->evdev, LIBEVDEV_GRAB);
- if (ret < 0) {
- xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
- -ret);
- return FALSE;
- }
- }
-
- proto_data->need_grab = FALSE;
-
if (libevdev_get_fd(proto_data->evdev) != -1) {
struct input_event ev;
@@ -225,6 +211,20 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
libevdev_set_fd(proto_data->evdev, pInfo->fd);
+ if (para->grab_event_device) {
+ /* Try to grab the event device so that data don't leak to /dev/input/mice */
+ int ret;
+
+ ret = libevdev_grab(proto_data->evdev, LIBEVDEV_GRAB);
+ if (ret < 0) {
+ xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
+ -ret);
+ return FALSE;
+ }
+ }
+
+ proto_data->need_grab = FALSE;
+
InitializeTouch(pInfo);
return TRUE;
--
1.9.0
More information about the xorg-devel
mailing list