From 65c9cd1b2b42572fb1bb433e59d681d208fc9824 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 3 Aug 2024 08:57:54 -0700 Subject: [PATCH] standardize default double tap delay constants --- internal/driver/glfw/driver_desktop.go | 3 +++ internal/driver/glfw/driver_web.go | 4 +++- internal/driver/glfw/driver_windows.go | 4 +--- internal/driver/glfw/driver_xdg.go | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/driver/glfw/driver_desktop.go b/internal/driver/glfw/driver_desktop.go index 273b689249..e82885b37c 100644 --- a/internal/driver/glfw/driver_desktop.go +++ b/internal/driver/glfw/driver_desktop.go @@ -10,6 +10,7 @@ import ( "runtime" "sync" "syscall" + "time" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/internal/painter" @@ -21,6 +22,8 @@ import ( "fyne.io/fyne/v2/theme" ) +const desktopDefaultDoubleTapDelay = 300 * time.Millisecond + var ( systrayIcon fyne.Resource setup sync.Once diff --git a/internal/driver/glfw/driver_web.go b/internal/driver/glfw/driver_web.go index 4e606ddd79..a00f39cb1d 100644 --- a/internal/driver/glfw/driver_web.go +++ b/internal/driver/glfw/driver_web.go @@ -8,6 +8,8 @@ import ( "fyne.io/fyne/v2" ) +const webDefaultDoubleTapDelay = 300 * time.Millisecond + func (d *gLDriver) SetSystemTrayMenu(m *fyne.Menu) { // no-op for mobile apps using this driver } @@ -20,5 +22,5 @@ func setDisableScreenBlank(disable bool) { } func (g *gLDriver) DoubleTapDelay() time.Duration { - return 300 * time.Millisecond + return webDefaultDoubleTapDelay } diff --git a/internal/driver/glfw/driver_windows.go b/internal/driver/glfw/driver_windows.go index 4752ed2fc7..34d9d4a8b8 100644 --- a/internal/driver/glfw/driver_windows.go +++ b/internal/driver/glfw/driver_windows.go @@ -72,12 +72,10 @@ func setDisableScreenBlank(disable bool) { syscall.Syscall(executionState.Addr(), 1, uintptr(uType), 0, 0) } -const defaultDoubleTapDelay = 300 * time.Millisecond - func (g *gLDriver) DoubleTapDelay() time.Duration { // https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdoubleclicktime if getDoubleClickTime == nil { - return defaultDoubleTapDelay + return desktopDefaultDoubleTapDelay } r1, _, _ := syscall.Syscall(getDoubleClickTime.Addr(), 0, 0, 0, 0) return time.Duration(uint64(r1) * uint64(time.Millisecond)) diff --git a/internal/driver/glfw/driver_xdg.go b/internal/driver/glfw/driver_xdg.go index 78db60a2b2..2e84a0208a 100644 --- a/internal/driver/glfw/driver_xdg.go +++ b/internal/driver/glfw/driver_xdg.go @@ -46,5 +46,5 @@ func setDisableScreenBlank(disable bool) { } func (g *gLDriver) DoubleTapDelay() time.Duration { - return 300 * time.Millisecond + return desktopDefaultDoubleTapDelay }