internal/ui: refactoring

This commit is contained in:
Hajime Hoshi 2022-02-10 19:31:38 +09:00
parent 35b9dd0846
commit f1987cae10
2 changed files with 6 additions and 6 deletions

View File

@ -105,6 +105,9 @@ func (w *Window) IsMaximized() bool {
if !w.ui.isRunning() {
return w.ui.isInitWindowMaximized()
}
if !w.IsResizable() {
return false
}
var v bool
w.ui.t.Call(func() {
v = w.ui.window.GetAttrib(glfw.Maximized) == glfw.True
@ -113,6 +116,9 @@ func (w *Window) IsMaximized() bool {
}
func (w *Window) Maximize() {
// Do not allow maximizing the window when the window is not resizable.
// On Windows, it is possible to restore the window from being maximized by mouse-dragging,
// and this can be an unexpected behavior.
if !w.IsResizable() {
panic("ui: a window to maximize must be resizable")
}

View File

@ -217,9 +217,6 @@ func SetWindowFloating(float bool) {
//
// MaximizeWindow is concurrent-safe.
func MaximizeWindow() {
if !IsWindowResizable() {
panic("ebiten: a window to maximize must be resizable")
}
ui.Get().Window().Maximize()
}
@ -231,9 +228,6 @@ func MaximizeWindow() {
//
// IsWindowMaximized is concurrent-safe.
func IsWindowMaximized() bool {
if !IsWindowResizable() {
return false
}
return ui.Get().Window().IsMaximized()
}