internal/ui: rename origPos -> origWindowPos

This commit is contained in:
Hajime Hoshi 2022-04-08 15:59:16 +09:00
parent 352d332097
commit 90070c09fe
5 changed files with 23 additions and 23 deletions

View File

@ -63,8 +63,8 @@ type userInterfaceImpl struct {
maxWindowHeightInDIP int maxWindowHeightInDIP int
running uint32 running uint32
origPosX int origWindowPosX int
origPosY int origWindowPosY int
runnableOnUnfocused bool runnableOnUnfocused bool
fpsMode FPSModeType fpsMode FPSModeType
iconImages []image.Image iconImages []image.Image
@ -130,8 +130,8 @@ func init() {
minWindowHeightInDIP: glfw.DontCare, minWindowHeightInDIP: glfw.DontCare,
maxWindowWidthInDIP: glfw.DontCare, maxWindowWidthInDIP: glfw.DontCare,
maxWindowHeightInDIP: glfw.DontCare, maxWindowHeightInDIP: glfw.DontCare,
origPosX: invalidPos, origWindowPosX: invalidPos,
origPosY: invalidPos, origWindowPosY: invalidPos,
initCursorMode: CursorModeVisible, initCursorMode: CursorModeVisible,
initWindowDecorated: true, initWindowDecorated: true,
initWindowPositionXInDIP: invalidPos, initWindowPositionXInDIP: invalidPos,
@ -1238,8 +1238,8 @@ func (u *userInterfaceImpl) minimumWindowWidth() int {
func (u *userInterfaceImpl) setWindowSizeInDIPImpl(width, height int, fullscreen bool) { func (u *userInterfaceImpl) setWindowSizeInDIPImpl(width, height int, fullscreen bool) {
if fullscreen { if fullscreen {
if x, y := u.origPos(); x == invalidPos || y == invalidPos { if x, y := u.origWindowPos(); x == invalidPos || y == invalidPos {
u.setOrigPos(u.window.GetPos()) u.setOrigWindowPos(u.window.GetPos())
} }
if u.isNativeFullscreenAvailable() { if u.isNativeFullscreenAvailable() {
@ -1274,7 +1274,7 @@ func (u *userInterfaceImpl) setWindowSizeInDIPImpl(width, height int, fullscreen
u.swapBuffers() u.swapBuffers()
} }
if x, y := u.origPos(); x != invalidPos && y != invalidPos { if x, y := u.origWindowPos(); x != invalidPos && y != invalidPos {
u.window.SetPos(x, y) u.window.SetPos(x, y)
// Dirty hack for macOS (#703). Rendering doesn't work correctly with one SetPos, but // Dirty hack for macOS (#703). Rendering doesn't work correctly with one SetPos, but
// work with two or more SetPos. // work with two or more SetPos.
@ -1282,7 +1282,7 @@ func (u *userInterfaceImpl) setWindowSizeInDIPImpl(width, height int, fullscreen
u.window.SetPos(x+1, y) u.window.SetPos(x+1, y)
u.window.SetPos(x, y) u.window.SetPos(x, y)
} }
u.setOrigPos(invalidPos, invalidPos) u.setOrigWindowPos(invalidPos, invalidPos)
} }
// Set the window size after the position. The order matters. // Set the window size after the position. The order matters.
@ -1561,7 +1561,7 @@ func (u *userInterfaceImpl) setWindowPositionInDIP(x, y int, monitor *glfw.Monit
xf := u.dipToGLFWPixel(float64(x), monitor) xf := u.dipToGLFWPixel(float64(x), monitor)
yf := u.dipToGLFWPixel(float64(y), monitor) yf := u.dipToGLFWPixel(float64(y), monitor)
if x, y := u.adjustWindowPosition(mx+int(xf), my+int(yf), monitor); u.isFullscreen() { if x, y := u.adjustWindowPosition(mx+int(xf), my+int(yf), monitor); u.isFullscreen() {
u.setOrigPos(x, y) u.setOrigWindowPos(x, y)
} else { } else {
u.window.SetPos(x, y) u.window.SetPos(x, y)
} }
@ -1579,21 +1579,21 @@ func (u *userInterfaceImpl) setWindowTitle(title string) {
u.window.SetTitle(title) u.window.SetTitle(title)
} }
func (u *userInterfaceImpl) origPos() (int, int) { func (u *userInterfaceImpl) origWindowPos() (int, int) {
if x, y, ok := u.origPosByOS(); ok { if x, y, ok := u.origWindowPosByOS(); ok {
return x, y return x, y
} }
return u.origPosX, u.origPosY return u.origWindowPosX, u.origWindowPosY
} }
func (u *userInterfaceImpl) setOrigPos(x, y int) { func (u *userInterfaceImpl) setOrigWindowPos(x, y int) {
// TODO: The original position should be updated at a 'PosCallback'. // TODO: The original position should be updated at a 'PosCallback'.
if u.setOrigPosByOS(x, y) { if u.setOrigWindowPosByOS(x, y) {
return return
} }
u.origPosX = x u.origWindowPosX = x
u.origPosY = y u.origWindowPosY = y
} }
// forceToRefreshIfNeeded forces to refresh the framebuffer by resizing the window quickly. // forceToRefreshIfNeeded forces to refresh the framebuffer by resizing the window quickly.

View File

@ -390,7 +390,7 @@ func initializeWindowAfterCreation(w *glfw.Window) {
C.initializeWindow(C.uintptr_t(w.GetCocoaWindow())) C.initializeWindow(C.uintptr_t(w.GetCocoaWindow()))
} }
func (u *userInterfaceImpl) origPosByOS() (int, int, bool) { func (u *userInterfaceImpl) origWindowPosByOS() (int, int, bool) {
if !u.isNativeFullscreen() { if !u.isNativeFullscreen() {
return invalidPos, invalidPos, true return invalidPos, invalidPos, true
} }
@ -402,7 +402,7 @@ func (u *userInterfaceImpl) origPosByOS() (int, int, bool) {
return x, y, true return x, y, true
} }
func (u *userInterfaceImpl) setOrigPosByOS(x, y int) bool { func (u *userInterfaceImpl) setOrigWindowPosByOS(x, y int) bool {
if !u.isNativeFullscreen() { if !u.isNativeFullscreen() {
return true return true
} }

View File

@ -233,10 +233,10 @@ func initializeWindowAfterCreation(w *glfw.Window) {
// For more details, see the discussion in #1829. // For more details, see the discussion in #1829.
} }
func (u *userInterfaceImpl) origPosByOS() (int, int, bool) { func (u *userInterfaceImpl) origWindowPosByOS() (int, int, bool) {
return 0, 0, false return 0, 0, false
} }
func (u *userInterfaceImpl) setOrigPosByOS(x, y int) bool { func (u *userInterfaceImpl) setOrigWindowPosByOS(x, y int) bool {
return false return false
} }

View File

@ -244,10 +244,10 @@ func (u *userInterfaceImpl) setWindowResizingModeForOS(mode WindowResizingMode)
func initializeWindowAfterCreation(w *glfw.Window) { func initializeWindowAfterCreation(w *glfw.Window) {
} }
func (u *userInterfaceImpl) origPosByOS() (int, int, bool) { func (u *userInterfaceImpl) origWindowPosByOS() (int, int, bool) {
return 0, 0, false return 0, 0, false
} }
func (u *userInterfaceImpl) setOrigPosByOS(x, y int) bool { func (u *userInterfaceImpl) setOrigWindowPosByOS(x, y int) bool {
return false return false
} }

View File

@ -169,7 +169,7 @@ func (w *Window) Position() (int, int) {
w.ui.t.Call(func() { w.ui.t.Call(func() {
var wx, wy int var wx, wy int
if w.ui.isFullscreen() { if w.ui.isFullscreen() {
wx, wy = w.ui.origPos() wx, wy = w.ui.origWindowPos()
} else { } else {
wx, wy = w.ui.window.GetPos() wx, wy = w.ui.window.GetPos()
} }