internal/ui: bug fix: DeviceScaleFactor was not concurrent-safe before the main loop

Updates #1575
Closes #2042
This commit is contained in:
Hajime Hoshi 2022-03-29 00:27:42 +09:00
parent 2d912a2387
commit 07d6419dc6

View File

@ -86,6 +86,7 @@ type userInterfaceImpl struct {
// These values are not changed after initialized. // These values are not changed after initialized.
// TODO: the fullscreen size should be updated when the initial window position is changed? // TODO: the fullscreen size should be updated when the initial window position is changed?
initMonitor *glfw.Monitor initMonitor *glfw.Monitor
initDeviceScaleFactor float64
initFullscreenWidthInDIP int initFullscreenWidthInDIP int
initFullscreenHeightInDIP int initFullscreenHeightInDIP int
@ -175,6 +176,7 @@ func initialize() error {
} }
theUI.initMonitor = m theUI.initMonitor = m
theUI.initDeviceScaleFactor = theUI.deviceScaleFactor(m)
// GetVideoMode must be called from the main thread, then call this here and record // GetVideoMode must be called from the main thread, then call this here and record
// initFullscreen{Width,Height}InDIP. // initFullscreen{Width,Height}InDIP.
v := m.GetVideoMode() v := m.GetVideoMode()
@ -612,7 +614,7 @@ func (u *userInterfaceImpl) SetCursorShape(shape CursorShape) {
func (u *userInterfaceImpl) DeviceScaleFactor() float64 { func (u *userInterfaceImpl) DeviceScaleFactor() float64 {
if !u.isRunning() { if !u.isRunning() {
return u.deviceScaleFactor(u.currentMonitor()) return u.initDeviceScaleFactor
} }
f := 0.0 f := 0.0