devicescale: Refactoring

This commit is contained in:
Hajime Hoshi 2019-05-05 18:09:49 +09:00
parent ea284d86fd
commit 836e320b6b

View File

@ -46,21 +46,21 @@ var (
) )
func init() { func init() {
go scaleUpdater() // Run as goroutine. Will keep the desktop scale up to date.
} // This can be removed once the scale change event is implemented in GLFW 3.3
//
func impl(x, y int) float64 { // TODO: Now the value is cached, isn't this loop needed?
return math.Float64frombits(atomic.LoadUint64(&cachedScale)) go func() {
}
// run as goroutine. Will keep the desktop scale up to date.
// This can be removed once the scale change event is implemented in GLFW 3.3
func scaleUpdater() {
for { for {
s := getscale(0, 0) s := getscale(0, 0)
atomic.StoreUint64(&cachedScale, math.Float64bits(s)) atomic.StoreUint64(&cachedScale, math.Float64bits(s))
time.Sleep(cacheUpdateWait) time.Sleep(cacheUpdateWait)
} }
}()
}
func impl(x, y int) float64 {
return math.Float64frombits(atomic.LoadUint64(&cachedScale))
} }
func currentDesktop() desktop { func currentDesktop() desktop {