When a fd is removed dev->state gets set to device_state_removed,
if the fd then gets re-added before InputThreadDoWork() deals with
the removal, the InputThreadDevice struct gets reused, but its
state would stay device_state_removed, so it would still get removed
on the first InputThreadDoWork() run, resulting in a non functioning
input device.

This commit fixes this by (re-)setting dev->state to device_state_running
when a InputThreadDevice struct gets reused.

This fixes input devices sometimes no longer working after a vt-switch.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 os/inputthread.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/os/inputthread.c b/os/inputthread.c
index 6aa0a9c..ab1559f 100644
--- a/os/inputthread.c
+++ b/os/inputthread.c
@@ -206,6 +206,8 @@ InputThreadRegisterDev(int fd,
     if (dev) {
         dev->readInputProc = readInputProc;
         dev->readInputArgs = readInputArgs;
+        /* Override possible unhandled state == device_state_removed */
+        dev->state = device_state_running;
     } else {
         dev = calloc(1, sizeof(InputThreadDevice));
         if (dev == NULL) {
-- 
2.9.3

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

Reply via email to