mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 16:40:41 +08:00

* [v3-Windows] New DIP system for Enhanced High DPI Monitor Support * Update changelog * Remove asset middleware * Remove SetThreadDpiAwarenessContext() * Fix macOS build. * Fill missing screens fields (linux, darwin) * Skip DPI transformation on unsupported platforms * Simplify distanceFromRectSquared() * Update v3/pkg/application/screenmanager.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Lea Anthony <lea.anthony@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
//go:build windows
|
|
|
|
package w32
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
var (
|
|
modshcore = syscall.NewLazyDLL("shcore.dll")
|
|
|
|
procGetDpiForMonitor = modshcore.NewProc("GetDpiForMonitor")
|
|
procSetProcessDpiAwareness = modshcore.NewProc("SetProcessDpiAwareness")
|
|
)
|
|
|
|
func HasSetProcessDpiAwarenessFunc() bool {
|
|
err := procSetProcessDpiAwareness.Find()
|
|
return err == nil
|
|
}
|
|
|
|
func SetProcessDpiAwareness(val uint) error {
|
|
status, r, err := procSetProcessDpiAwareness.Call(uintptr(val))
|
|
if status != S_OK {
|
|
return fmt.Errorf("procSetProcessDpiAwareness failed %d: %v %v", status, r, err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func HasGetDPIForMonitorFunc() bool {
|
|
err := procGetDpiForMonitor.Find()
|
|
return err == nil
|
|
}
|
|
|
|
func GetDPIForMonitor(hmonitor HMONITOR, dpiType MONITOR_DPI_TYPE, dpiX *UINT, dpiY *UINT) uintptr {
|
|
ret, _, _ := procGetDpiForMonitor.Call(
|
|
hmonitor,
|
|
uintptr(dpiType),
|
|
uintptr(unsafe.Pointer(dpiX)),
|
|
uintptr(unsafe.Pointer(dpiY)))
|
|
|
|
return ret
|
|
}
|
|
|
|
func GetNotificationFlyoutBounds() (*RECT, error) {
|
|
var rect RECT
|
|
res, _, err := procSystemParametersInfo.Call(SPI_GETNOTIFYWINDOWRECT, 0, uintptr(unsafe.Pointer(&rect)), 0)
|
|
if res == 0 {
|
|
_ = err
|
|
return nil, err
|
|
}
|
|
return &rect, nil
|
|
}
|