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 b4f87f9651
commit 73bf7a0939

View File

@ -697,6 +697,12 @@ func (u *UserInterface) DeviceScaleFactor() float64 {
// deviceScaleFactor must be called from the main thread. // deviceScaleFactor must be called from the main thread.
func (u *UserInterface) deviceScaleFactor(monitor *glfw.Monitor) float64 { 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() mx, my := monitor.GetPos()
return devicescale.GetAt(mx, my) return devicescale.GetAt(mx, my)
} }