Skip to content

Commit

Permalink
standardize default double tap delay constants
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Aug 3, 2024
1 parent 66829eb commit 65c9cd1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions internal/driver/glfw/driver_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"runtime"
"sync"
"syscall"
"time"

"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/internal/painter"
Expand All @@ -21,6 +22,8 @@ import (
"fyne.io/fyne/v2/theme"
)

const desktopDefaultDoubleTapDelay = 300 * time.Millisecond

var (
systrayIcon fyne.Resource
setup sync.Once
Expand Down
4 changes: 3 additions & 1 deletion internal/driver/glfw/driver_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -20,5 +22,5 @@ func setDisableScreenBlank(disable bool) {
}

func (g *gLDriver) DoubleTapDelay() time.Duration {
return 300 * time.Millisecond
return webDefaultDoubleTapDelay
}
4 changes: 1 addition & 3 deletions internal/driver/glfw/driver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/glfw/driver_xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ func setDisableScreenBlank(disable bool) {
}

func (g *gLDriver) DoubleTapDelay() time.Duration {
return 300 * time.Millisecond
return desktopDefaultDoubleTapDelay
}

0 comments on commit 65c9cd1

Please sign in to comment.