devicescale: Bug fix: the active window can't be passed to ReleaseDC

This commit is contained in:
Hajime Hoshi 2018-10-03 04:16:28 +09:00
parent 02a2fc2d44
commit 11d23bafa9

View File

@ -145,7 +145,6 @@ func getFromLogPixelSx() float64 {
if err != nil {
panic(err)
}
defer releaseDC(0, dc)
// Note that GetDeviceCaps with LOGPIXELSX always returns a same value for any monitors
// even if multiple monitors are used.
@ -154,6 +153,10 @@ func getFromLogPixelSx() float64 {
panic(err)
}
if err := releaseDC(0, dc); err != nil {
panic(err)
}
return float64(dpi) / 96
}
@ -173,9 +176,9 @@ func impl() float64 {
}
// The window is not initialized yet when w == 0.
if w == 0 {
// TODO: Use the primary monitor instead.
return getFromLogPixelSx()
}
defer releaseDC(0, w)
m, err := monitorFromWindow(w, monitorDefaultToNearest)
if err != nil {