mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
fix: create platform specific init
This commit is contained in:
parent
b5b92c4afa
commit
401ebee719
3 changed files with 36 additions and 19 deletions
21
app.go
21
app.go
|
|
@ -1,7 +1,6 @@
|
|||
package wails
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
|
@ -67,28 +66,12 @@ func CreateApp(optionalConfig ...*AppConfig) *App {
|
|||
result.config.DisableInspector = true
|
||||
}
|
||||
|
||||
// If running windows, do a hidpi fix
|
||||
if runtime.GOOS == "windows" {
|
||||
err := SetProcessDPIAware()
|
||||
if err != nil {
|
||||
result.log.Fatalf(err.Error())
|
||||
}
|
||||
}
|
||||
// Platform specific init
|
||||
platformInit()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// SetProcessDPIAware via user32.dll
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware
|
||||
// Also, thanks Jack Mordaunt! https://github.com/wailsapp/wails/issues/293
|
||||
func SetProcessDPIAware() error {
|
||||
status, r, err := syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
|
||||
if status == 0 {
|
||||
return fmt.Errorf("exit status %d: %v %v", status, r, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run the app
|
||||
func (a *App) Run() error {
|
||||
|
||||
|
|
|
|||
7
app_other.go
Normal file
7
app_other.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// +build +linux +darwin !windows
|
||||
|
||||
package wails
|
||||
|
||||
func platformInit() {
|
||||
|
||||
}
|
||||
27
app_windows.go
Normal file
27
app_windows.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// +build windows !linux !darwin
|
||||
|
||||
package wails
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func platformInit() {
|
||||
err := SetProcessDPIAware()
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// SetProcessDPIAware via user32.dll
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware
|
||||
// Also, thanks Jack Mordaunt! https://github.com/wailsapp/wails/issues/293
|
||||
func SetProcessDPIAware() error {
|
||||
status, r, err := syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
|
||||
if status == 0 {
|
||||
return fmt.Errorf("exit status %d: %v %v", status, r, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue