From 07d6419dc658eaf1fc61e85815a0d709223b06d2 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 29 Mar 2022 00:27:42 +0900 Subject: [PATCH] internal/ui: bug fix: DeviceScaleFactor was not concurrent-safe before the main loop Updates #1575 Closes #2042 --- internal/ui/ui_glfw.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 9deacf7bc..ae9317d2a 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -86,6 +86,7 @@ type userInterfaceImpl struct { // These values are not changed after initialized. // TODO: the fullscreen size should be updated when the initial window position is changed? initMonitor *glfw.Monitor + initDeviceScaleFactor float64 initFullscreenWidthInDIP int initFullscreenHeightInDIP int @@ -175,6 +176,7 @@ func initialize() error { } theUI.initMonitor = m + theUI.initDeviceScaleFactor = theUI.deviceScaleFactor(m) // GetVideoMode must be called from the main thread, then call this here and record // initFullscreen{Width,Height}InDIP. v := m.GetVideoMode() @@ -612,7 +614,7 @@ func (u *userInterfaceImpl) SetCursorShape(shape CursorShape) { func (u *userInterfaceImpl) DeviceScaleFactor() float64 { if !u.isRunning() { - return u.deviceScaleFactor(u.currentMonitor()) + return u.initDeviceScaleFactor } f := 0.0