ui: Remove 'fullscreen' member variable

This commit is contained in:
Hajime Hoshi 2017-08-12 18:31:16 +09:00
parent b186bc1e94
commit 783e57d3f2

View File

@ -37,7 +37,6 @@ type userInterface struct {
scale float64 scale float64
deviceScale float64 deviceScale float64
glfwScale float64 glfwScale float64
fullscreen bool
fullscreenScale float64 fullscreenScale float64
funcs chan func() funcs chan func()
running bool running bool
@ -190,7 +189,7 @@ func SetScreenSize(width, height int) bool {
} }
r := false r := false
_ = u.runOnMainThread(func() error { _ = u.runOnMainThread(func() error {
r = u.setScreenSize(width, height, u.scale, u.fullscreen) r = u.setScreenSize(width, height, u.scale, u.fullscreen())
return nil return nil
}) })
return r return r
@ -203,7 +202,7 @@ func SetScreenScale(scale float64) bool {
} }
r := false r := false
_ = u.runOnMainThread(func() error { _ = u.runOnMainThread(func() error {
r = u.setScreenSize(u.width, u.height, scale, u.fullscreen) r = u.setScreenSize(u.width, u.height, scale, u.fullscreen())
return nil return nil
}) })
return r return r
@ -222,17 +221,19 @@ func ScreenScale() float64 {
return s return s
} }
func (u *userInterface) fullscreen() bool {
if !u.isRunning() {
panic("not reached")
}
return u.window.GetMonitor() != nil
}
func IsFullscreen() bool { func IsFullscreen() bool {
u := currentUI u := currentUI
if !u.isRunning() { if !u.isRunning() {
return u.isInitFullscreen() return u.isInitFullscreen()
} }
f := false return u.fullscreen()
_ = u.runOnMainThread(func() error {
f = u.fullscreen
return nil
})
return f
} }
func SetFullscreen(fullscreen bool) { func SetFullscreen(fullscreen bool) {
@ -359,7 +360,7 @@ func (u *userInterface) glfwSize() (int, int) {
} }
func (u *userInterface) getScale() float64 { func (u *userInterface) getScale() float64 {
if !u.fullscreen { if !u.fullscreen() {
return u.scale return u.scale
} }
if u.fullscreenScale == 0 { if u.fullscreenScale == 0 {
@ -473,7 +474,7 @@ func (u *userInterface) swapBuffers() {
} }
func (u *userInterface) setScreenSize(width, height int, scale float64, fullscreen bool) bool { func (u *userInterface) setScreenSize(width, height int, scale float64, fullscreen bool) bool {
if u.width == width && u.height == height && u.scale == scale && u.fullscreen == fullscreen { if u.width == width && u.height == height && u.scale == scale && u.fullscreen() == fullscreen {
return false return false
} }
@ -499,9 +500,7 @@ func (u *userInterface) setScreenSize(width, height int, scale float64, fullscre
// swap buffers here before SetSize is called. // swap buffers here before SetSize is called.
u.swapBuffers() u.swapBuffers()
u.fullscreen = fullscreen if fullscreen {
if u.fullscreen {
if u.origPosX < 0 && u.origPosY < 0 { if u.origPosX < 0 && u.origPosY < 0 {
u.origPosX, u.origPosY = u.window.GetPos() u.origPosX, u.origPosY = u.window.GetPos()
} }