[PATCH v2 xf86-input-libinput] Drain the fd after opening
Peter Hutterer
peter.hutterer at who-t.net
Wed Dec 16 17:25:53 PST 2015
Make sure we don't send any events that may have been enqueued before we
initialized ourselves. Specifically, if we're using systemd-logind the fd
remains open when we disable/enable the device, allowing events to queue up on
the fd. These events are then replayed once the device is re-opened.
This is not the case when VT-switching, in that case logind closes the fd for
us.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- check the fd before calling xf86FlushInput, otherwise we mess up errno
src/xf86libinput.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index ee2165a..7008fac 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -1175,7 +1175,12 @@ open_restricted(const char *path, int flags, void *data)
}
fd = xf86OpenSerial(pInfo->options);
- return fd < 0 ? -errno : fd;
+ if (fd < 0)
+ return -errno;
+
+ xf86FlushInput(fd);
+
+ return fd;
}
static void
--
2.5.0
More information about the xorg-devel
mailing list