Skip to content

Commit

Permalink
internal/ui: bug fix: DeviceScaleFactor was not concurrent-safe befor…
Browse files Browse the repository at this point in the history
…e the main loop

Updates hajimehoshi#1575
Closes hajimehoshi#2042
  • Loading branch information
hajimehoshi committed Mar 28, 2022
1 parent 2d912a2 commit 07d6419
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/ui/ui_glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 07d6419

Please sign in to comment.