If the caller doesn't sync when it should, process all events regardless
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 1 Jul 2013 05:30:49 +0000 (15:30 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 2 Jul 2013 00:58:57 +0000 (10:58 +1000)
libevdev needs to maintain the correct state of the device, even if the caller
decides to drop all delta events after a SYN_DROPPED.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
libevdev/libevdev.c

index d326c8d7b7322c6830532156527156fdded0a332..590e2d627823df75804967065c08e4e0c3f36132 100644 (file)
@@ -548,10 +548,12 @@ int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_e
                                return rc;
                }
        } else if (dev->need_sync) {
-               /* FIXME: still need to call update_state for all events
-                * here, otherwise the library has the wrong view of the
-                * device too */
-               queue_shift_multiple(dev, dev->queue_nsync, NULL);
+               struct input_event e;
+
+               /* call update_state for all events here, otherwise the library has the wrong view
+                  of the device too */
+               while (queue_shift(dev, &e) == 0)
+                       update_state(dev, &e);
        }
 
        /* FIXME: check for O_NONBLOCK and if not set, skip if we have an