Skip to content

Commit

Permalink
internal/devicescale: Fallback to simpler logic when trying to get DP…
Browse files Browse the repository at this point in the history
…I from monitor and failing (hajimehoshi#1600)

Closes hajimehoshi#1612
  • Loading branch information
corfe83 authored and hajimehoshi committed Apr 21, 2021
1 parent ab1eb1a commit ea06454
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/devicescale/impl_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ func impl(x, y int) float64 {
// do this with Cgo. Use MonitorFromRect instead.
m, err := monitorFromRect(&lprc, monitorDefaultToNearest)
if err != nil {
panic(err)
// monitorFromRect can fail in some environments (#1612)
return getFromLogPixelSx()
}

dpiX := uint32(0)
dpiY := uint32(0) // Passing dpiY is needed even though this is not used, or GetDpiForMonitor returns an error.
if err := getDpiForMonitor(m, mdtEffectiveDpi, &dpiX, &dpiY); err != nil {
panic(err)
// getDpiForMonitor can fail in some environments (#1612)
return getFromLogPixelSx()
}
runtime.KeepAlive(dpiY)

Expand Down

0 comments on commit ea06454

Please sign in to comment.