internal/uidriver/glfw: Bug fix: Return a tentative scale when glfw.GetPrmaryMonitor returns 1

Updates #1878
This commit is contained in:
Hajime Hoshi 2021-11-24 22:35:08 +09:00
parent 0e63ab5d78
commit 7a850a15a9

View File

@ -699,6 +699,12 @@ func (u *UserInterface) DeviceScaleFactor() float64 {
// deviceScaleFactor must be called from the main thread.
func (u *UserInterface) deviceScaleFactor(monitor *glfw.Monitor) float64 {
// It is rare, but monitor can be nil when glfw.GetPrimaryMonitor returns nil.
// In this case, return 1 as a tentative scale (#1878).
if monitor == nil {
return 1
}
mx, my := monitor.GetPos()
return devicescale.GetAt(mx, my)
}