mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
ui: Reserve window position before entering fullscreen-mode (#267)
This commit is contained in:
parent
b569eb9c5a
commit
5dbfafb200
@ -40,6 +40,8 @@ type userInterface struct {
|
|||||||
funcs chan func()
|
funcs chan func()
|
||||||
running bool
|
running bool
|
||||||
sizeChanged bool
|
sizeChanged bool
|
||||||
|
origPosX int
|
||||||
|
origPosY int
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +74,8 @@ func initialize() error {
|
|||||||
window: window,
|
window: window,
|
||||||
funcs: make(chan func()),
|
funcs: make(chan func()),
|
||||||
sizeChanged: true,
|
sizeChanged: true,
|
||||||
|
origPosX: -1,
|
||||||
|
origPosY: -1,
|
||||||
}
|
}
|
||||||
u.window.MakeContextCurrent()
|
u.window.MakeContextCurrent()
|
||||||
glfw.SwapInterval(1)
|
glfw.SwapInterval(1)
|
||||||
@ -347,6 +351,7 @@ func (u *userInterface) setScreenSize(width, height int, scale float64, fullscre
|
|||||||
m := glfw.GetPrimaryMonitor()
|
m := glfw.GetPrimaryMonitor()
|
||||||
v := m.GetVideoMode()
|
v := m.GetVideoMode()
|
||||||
if u.fullscreen {
|
if u.fullscreen {
|
||||||
|
u.origPosX, u.origPosY = window.GetPos()
|
||||||
window.SetMonitor(m, 0, 0, v.Width, v.Height, v.RefreshRate)
|
window.SetMonitor(m, 0, 0, v.Width, v.Height, v.RefreshRate)
|
||||||
} else {
|
} else {
|
||||||
window.SetMonitor(nil, 0, 0, 16, 16, v.RefreshRate)
|
window.SetMonitor(nil, 0, 0, 16, 16, v.RefreshRate)
|
||||||
@ -366,6 +371,10 @@ func (u *userInterface) setScreenSize(width, height int, scale float64, fullscre
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Reverted from fullscreen
|
||||||
|
if u.origPosX >= 0 && u.origPosY >= 0 {
|
||||||
|
window.SetPos(u.origPosX, u.origPosY)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: Rename this variable?
|
// TODO: Rename this variable?
|
||||||
u.sizeChanged = true
|
u.sizeChanged = true
|
||||||
|
Loading…
Reference in New Issue
Block a user