internal/ui: bug fix: the screen size must be initialized first even when the canvas is unfocused

Closes #3034
This commit is contained in:
Hajime Hoshi 2024-07-04 16:12:43 +09:00
parent 126af1420f
commit 3a18b32cbd

View File

@ -337,10 +337,6 @@ func (u *UserInterface) updateImpl(force bool) error {
return err
}
if !u.onceUpdateCalled {
u.updateScreenSize()
}
// TODO: If DeviceScaleFactor changes, call updateScreenSize.
// Now there is not a good way to detect the change.
// See also https://crbug.com/123694.
@ -373,6 +369,11 @@ func (u *UserInterface) needsUpdate() bool {
}
func (u *UserInterface) loopGame() error {
// Initialize the screen size first (#3033).
// If ebiten.SetRunnableOnUnfocused(false) and the canvas is not focused,
// suspended() returns true and the update routine cannot start.
u.updateScreenSize()
errCh := make(chan error, 1)
reqStopAudioCh := make(chan struct{})
resStopAudioCh := make(chan struct{})