From 568e98ef1c908ce4130494563400be52645cb6a6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 15 Sep 2023 02:53:35 +0900 Subject: [PATCH] internal/ui: bug fix: call setOrigWindowPos on entering fullscreen Closes #2757 --- internal/ui/ui_glfw.go | 7 +++++++ internal/ui/ui_glfw_darwin.go | 1 + 2 files changed, 8 insertions(+) diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index f9227802c..cda3a2b75 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -1461,6 +1461,13 @@ func (u *userInterfaceImpl) setWindowSizeInDIP(width, height int, callSetSize bo u.updateWindowSizeLimits() } +// setOrigWindowPosWithCurrentPos must be called from the main thread. +func (u *userInterfaceImpl) setOrigWindowPosWithCurrentPos() { + if x, y := u.origWindowPos(); x == invalidPos || y == invalidPos { + u.setOrigWindowPos(u.window.GetPos()) + } +} + // setFullscreen must be called from the main thread. func (u *userInterfaceImpl) setFullscreen(fullscreen bool) { if u.isFullscreen() == fullscreen { diff --git a/internal/ui/ui_glfw_darwin.go b/internal/ui/ui_glfw_darwin.go index 4e1b169b7..689b58997 100644 --- a/internal/ui/ui_glfw_darwin.go +++ b/internal/ui/ui_glfw_darwin.go @@ -123,6 +123,7 @@ func init() { Cmd: sel_windowWillEnterFullScreen, Fn: func(id objc.ID, cmd objc.SEL, notification objc.ID) { theUI.disableWindowSizeLimits() + theUI.setOrigWindowPosWithCurrentPos() pushResizableState(id, cocoa.NSNotification{ID: notification}.Object()) }, },