diff --git a/gesture/gesture.go b/gesture/gesture.go index cf761f1d..7bb18022 100644 --- a/gesture/gesture.go +++ b/gesture/gesture.go @@ -25,8 +25,8 @@ import ( "gioui.org/unit" ) -// The duration is somewhat arbitrary. -const doubleClickDuration = 200 * time.Millisecond +// 400 ms is GTK's default gtk-double-click-time. +const doubleClickDuration = 400 * time.Millisecond // Hover detects the hover gesture for a pointer area. type Hover struct { diff --git a/gesture/gesture_test.go b/gesture/gesture_test.go index ce6403fe..516f4161 100644 --- a/gesture/gesture_test.go +++ b/gesture/gesture_test.go @@ -66,6 +66,16 @@ func TestMouseClicks(t *testing.T) { 100*time.Millisecond+doubleClickDuration+1), clicks: []int{1, 1}, }, + { + label: "double click 300ms apart", + events: mouseClickEvents(100*time.Millisecond, 400*time.Millisecond), + clicks: []int{1, 2}, + }, + { + label: "two single clicks 500ms apart", + events: mouseClickEvents(100*time.Millisecond, 600*time.Millisecond), + clicks: []int{1, 1}, + }, } { t.Run(tc.label, func(t *testing.T) { var click Click