From f1987cae100c9c1e7aaefa2084edfb68c022af5b Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 10 Feb 2022 19:31:38 +0900 Subject: [PATCH] internal/ui: refactoring --- internal/ui/window_glfw.go | 6 ++++++ window.go | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/ui/window_glfw.go b/internal/ui/window_glfw.go index b22620e0d..60cb2b7f6 100644 --- a/internal/ui/window_glfw.go +++ b/internal/ui/window_glfw.go @@ -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") } diff --git a/window.go b/window.go index 67e0f0a0f..a6272d03e 100644 --- a/window.go +++ b/window.go @@ -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() }