timestamps.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. .. _timestamps:
  2. ==============================================================================
  3. Timestamps
  4. ==============================================================================
  5. .. _event_timestamps:
  6. ------------------------------------------------------------------------------
  7. Event timestamps
  8. ------------------------------------------------------------------------------
  9. Most libinput events provide a timestamp in millisecond and/or microsecond
  10. resolution. These timestamp usually increase monotonically, but libinput
  11. does not guarantee that this always the case. In other words, it is possible
  12. to receive an event with a timestamp earlier than the previous event.
  13. For example, if a touchpad has :ref:`tapping` enabled, a button event may have a
  14. lower timestamp than an event from a different device. Tapping requires the
  15. use of timeouts to detect multi-finger taps and/or :ref:`tapndrag`.
  16. Consider the following event sequences from a touchpad and a mouse:
  17. ::
  18. Time Touchpad Mouse
  19. ---------------------------------
  20. t1 finger down
  21. t2 finger up
  22. t3 movement
  23. t4 tap timeout
  24. For this event sequence, the first event to be sent to a caller is in
  25. response to the mouse movement: an event of type
  26. **LIBINPUT_EVENT_POINTER_MOTION** with the timestamp t3.
  27. Once the timeout expires at t4, libinput generates an event of
  28. **LIBINPUT_EVENT_POINTER_BUTTON** (press) with a timestamp t1 and an event
  29. **LIBINPUT_EVENT_POINTER_BUTTON** (release) with a timestamp t2.
  30. Thus, the caller gets events with timestamps in the order t3, t1, t2,
  31. despite t3 > t2 > t1.
  32. libinput timestamps use **CLOCK_MONOTONIC**.