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.hutte...@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

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to