Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up WASM platform lookups #5519

Merged
merged 6 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/driver/glfw/device_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ func (*glDevice) SystemScaleForWindow(w fyne.Window) float32 {

return scaleAuto
}

func isMacOSRuntime() bool {
return runtime.GOOS == "darwin"
}
17 changes: 11 additions & 6 deletions internal/driver/glfw/device_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ package glfw

import (
"regexp"
"strings"
"syscall/js"

"fyne.io/fyne/v2"
)

var isMobile = regexp.MustCompile("Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile")

var navigator = js.Global().Get("navigator")
var userAgent = navigator.Get("userAgent").String()
var mobileCheck = isMobile.MatchString(userAgent)
var (
isMobile = regexp.MustCompile("Android|iPhone|iPad|iPod").
MatchString(js.Global().Get("navigator").Get("userAgent").String())
isMacOS = strings.Contains(js.Global().Get("window").Get("navigator").Get("platform").String(), "Mac")
)

func (*glDevice) IsMobile() bool {
return mobileCheck
return isMobile
}

func (*glDevice) SystemScaleForWindow(w fyne.Window) float32 {
// Get the scale information from the web browser directly
return float32(js.Global().Get("devicePixelRatio").Float())
}

func isMacOSRuntime() bool {
return isMacOS // Value depends on which OS the browser is running on.
}
10 changes: 0 additions & 10 deletions internal/driver/glfw/shortcuts_other.go

This file was deleted.

14 changes: 0 additions & 14 deletions internal/driver/glfw/shortcuts_wasm.go

This file was deleted.

Loading