summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-25 13:19:30 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-25 13:21:43 +0200
commitb8825d1e179c46fc0cfb5ffa2bfed6eaf755c5d7 (patch)
tree8f23f1117144b066af35911c21d08929a9b30cd1
parentMerge pull request #635 from zx2c4-forks/scrolltable (diff)
downloadwireguard-windows-b8825d1e179c46fc0cfb5ffa2bfed6eaf755c5d7.tar.xz
wireguard-windows-b8825d1e179c46fc0cfb5ffa2bfed6eaf755c5d7.zip
form: abuse DPI handling for icon scaling better
Since Windows 7 and Windows 8 assume that the second parameter to GetSystemMetricsForDpi is always DPI(), it's wrong to pass it a constant 96. So instead we abuse the DPI handling a bit differently, determining the scale based on the output.
-rw-r--r--form.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/form.go b/form.go
index 974b50f8..29f06ed5 100644
--- a/form.go
+++ b/form.go
@@ -522,18 +522,17 @@ func (fb *FormBase) SetIcon(icon Image) error {
if icon != nil {
dpi := fb.DPI()
size96dpi := icon.Size()
- scale := float64(dpi) / float64(size96dpi.Height)
- smallHeight96dpi := int(win.GetSystemMetricsForDpi(win.SM_CYSMICON, 96))
- smallDPI := int(math.Round(float64(smallHeight96dpi) * scale))
+ smallHeight := int(win.GetSystemMetricsForDpi(win.SM_CYSMICON, uint32(dpi)))
+ smallDPI := int(math.Round(float64(smallHeight) / float64(size96dpi.Height) * 96.0))
smallIcon, err := iconCache.Icon(icon, smallDPI)
if err != nil {
return err
}
hIconSmall = uintptr(smallIcon.handleForDPI(smallDPI))
- bigHeight96dpi := int(win.GetSystemMetricsForDpi(win.SM_CYICON, 96))
- bigDPI := int(math.Round(float64(bigHeight96dpi) * scale))
+ bigHeight := int(win.GetSystemMetricsForDpi(win.SM_CYICON, uint32(dpi)))
+ bigDPI := int(math.Round(float64(bigHeight) / float64(size96dpi.Height) * 96.0))
bigIcon, err := iconCache.Icon(icon, bigDPI)
if err != nil {
return err