libghostty: handle non-monotonic selection times in SelectionGesture

We expect monotonic time but since this is libghostty-exposed we need to 
be more careful about guarding what we accept. This also practically makes
it easier to integrate with various languages.

Compare the two instants first and treat backwards timestamps like any
other failed repeat. The next press becomes a fresh single-click anchor,
and a regression test covers the reset behavior.
This commit is contained in:
Mitchell Hashimoto
2026-05-27 13:56:49 -07:00
parent 4e2d7c314b
commit 0e93fbfe76
4 changed files with 72 additions and 63 deletions

View File

@@ -477,7 +477,8 @@ typedef enum GHOSTTY_ENUM_TYPED {
* Optional monotonic event time in nanoseconds: uint64_t*.
*
* If unset, press treats the event as untimed and only single-click behavior
* is available.
* is available. If a repeat press provides a time earlier than the previous
* press, the repeat sequence resets.
*/
GHOSTTY_SELECTION_GESTURE_EVENT_OPT_TIME_NS = 3,