mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/ui: refactoring: separate updateSize into updateSize and outsideSize
This commit is contained in:
parent
2480871155
commit
7eff5cbd4a
@ -747,7 +747,8 @@ func (u *userInterfaceImpl) registerWindowSetSizeCallback() {
|
|||||||
u.setWindowSizeInDIP(w, h, u.isFullscreen())
|
u.setWindowSizeInDIP(w, h, u.isFullscreen())
|
||||||
}
|
}
|
||||||
|
|
||||||
outsideWidth, outsideHeight := u.updateSize()
|
u.updateSize()
|
||||||
|
outsideWidth, outsideHeight := u.outsideSize()
|
||||||
deviceScaleFactor := u.deviceScaleFactor(u.currentMonitor())
|
deviceScaleFactor := u.deviceScaleFactor(u.currentMonitor())
|
||||||
|
|
||||||
// In the game's update, u.t.Call might be called.
|
// In the game's update, u.t.Call might be called.
|
||||||
@ -970,34 +971,37 @@ func (u *userInterfaceImpl) init() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userInterfaceImpl) updateSize() (float64, float64) {
|
func (u *userInterfaceImpl) updateSize() {
|
||||||
ww, wh := u.windowWidthInDIP, u.windowHeightInDIP
|
ww, wh := u.windowWidthInDIP, u.windowHeightInDIP
|
||||||
u.setWindowSizeInDIP(ww, wh, u.isFullscreen())
|
u.setWindowSizeInDIP(ww, wh, u.isFullscreen())
|
||||||
|
}
|
||||||
|
|
||||||
var w, h float64
|
func (u *userInterfaceImpl) outsideSize() (float64, float64) {
|
||||||
if u.isFullscreen() && !u.isNativeFullscreen() {
|
if u.isFullscreen() && !u.isNativeFullscreen() {
|
||||||
// On Linux, the window size is not reliable just after making the window
|
// On Linux, the window size is not reliable just after making the window
|
||||||
// fullscreened. Use the monitor size.
|
// fullscreened. Use the monitor size.
|
||||||
// On macOS's native fullscreen, the window's size returns a more precise size
|
// On macOS's native fullscreen, the window's size returns a more precise size
|
||||||
// reflecting the adjustment of the view size (#1745).
|
// reflecting the adjustment of the view size (#1745).
|
||||||
|
var w, h float64
|
||||||
if m := u.currentMonitor(); m != nil {
|
if m := u.currentMonitor(); m != nil {
|
||||||
v := m.GetVideoMode()
|
v := m.GetVideoMode()
|
||||||
ww, wh := v.Width, v.Height
|
ww, wh := v.Width, v.Height
|
||||||
w = u.dipFromGLFWMonitorPixel(float64(ww), m)
|
w = u.dipFromGLFWMonitorPixel(float64(ww), m)
|
||||||
h = u.dipFromGLFWMonitorPixel(float64(wh), m)
|
h = u.dipFromGLFWMonitorPixel(float64(wh), m)
|
||||||
}
|
}
|
||||||
} else if u.window.GetAttrib(glfw.Iconified) == glfw.True {
|
return w, h
|
||||||
w = float64(u.windowWidthInDIP)
|
}
|
||||||
h = float64(u.windowHeightInDIP)
|
|
||||||
} else {
|
if u.window.GetAttrib(glfw.Iconified) == glfw.True {
|
||||||
|
return float64(u.windowWidthInDIP), float64(u.windowHeightInDIP)
|
||||||
|
}
|
||||||
|
|
||||||
// Instead of u.windowWidthInDIP and u.windowHeightInDIP, use the actual window size
|
// Instead of u.windowWidthInDIP and u.windowHeightInDIP, use the actual window size
|
||||||
// here. On Windows, the specified size at SetSize and the actual window size might
|
// here. On Windows, the specified size at SetSize and the actual window size might
|
||||||
// not match (#1163).
|
// not match (#1163).
|
||||||
ww, wh := u.window.GetSize()
|
ww, wh := u.window.GetSize()
|
||||||
w = u.dipFromGLFWPixel(float64(ww), u.currentMonitor())
|
w := u.dipFromGLFWPixel(float64(ww), u.currentMonitor())
|
||||||
h = u.dipFromGLFWPixel(float64(wh), u.currentMonitor())
|
h := u.dipFromGLFWPixel(float64(wh), u.currentMonitor())
|
||||||
}
|
|
||||||
|
|
||||||
return w, h
|
return w, h
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1053,7 +1057,8 @@ func (u *userInterfaceImpl) update() (float64, float64, error) {
|
|||||||
// Also, when toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
|
// Also, when toggling to fullscreen, vsync state might be reset unexpectedly (#1787).
|
||||||
u.updateVsync()
|
u.updateVsync()
|
||||||
|
|
||||||
outsideWidth, outsideHeight := u.updateSize()
|
u.updateSize()
|
||||||
|
outsideWidth, outsideHeight := u.outsideSize()
|
||||||
|
|
||||||
if u.fpsMode != FPSModeVsyncOffMinimum {
|
if u.fpsMode != FPSModeVsyncOffMinimum {
|
||||||
// TODO: Updating the input can be skipped when clock.Update returns 0 (#1367).
|
// TODO: Updating the input can be skipped when clock.Update returns 0 (#1367).
|
||||||
|
Loading…
Reference in New Issue
Block a user