internal/uidriver/glfw: Clear the device scale cache when monitors are changed

This commit is contained in:
Hajime Hoshi 2021-09-15 13:04:38 +09:00
parent f665abc8d4
commit ec2f823420
2 changed files with 12 additions and 2 deletions

View File

@ -37,11 +37,20 @@ func GetAt(x, y int) float64 {
}
s := impl(x, y)
cache[pos{x, y}] = s
return s
}
// TODO: Provide a way to invalidate the cache, or move the cache.
// CelarCache clears the cache.
// This should be called when monitors are changed by connecting or disconnecting.
func ClearCache() {
// TODO: This should be called not only when monitors are changed but also a monitor's scales are changed.
// The device scale can vary even for the same monitor.
// The only known case is when the application works on macOS, with OpenGL, with a wider screen mode,
// and in the fullscreen mode (#1573).
return s
m.Lock()
defer m.Unlock()
for k := range cache {
delete(cache, k)
}
}

View File

@ -232,6 +232,7 @@ func updateMonitors() {
})
}
clearVideoModeScaleCache()
devicescale.ClearCache()
}
func ensureMonitors() []*monitor {