mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/uidriver/glfw: Bug fix: Unregister SetSize callback when undecorate the window
Closes #1586
This commit is contained in:
parent
f5a4216434
commit
c88ee0d0ad
@ -1362,3 +1362,20 @@ func (u *UserInterface) restore() {
|
||||
w, h := u.window.GetSize()
|
||||
u.setWindowSize(w, h, u.isFullscreen())
|
||||
}
|
||||
|
||||
func (u *UserInterface) setDecorated(decorated bool) {
|
||||
// SetAttrib with glfw.Decorated invokes the SetSize callback but the callback must not be called in the game's Update (#1586).
|
||||
// SetSize callback is invoked in the limited situations like just after restoring from the fullscreen mode.
|
||||
if u.unregisterWindowSetSizeCallback() {
|
||||
defer u.registerWindowSetSizeCallback()
|
||||
}
|
||||
v := glfw.False
|
||||
if decorated {
|
||||
v = glfw.True
|
||||
}
|
||||
u.window.SetAttrib(glfw.Decorated, v)
|
||||
|
||||
// Just after restoring from the fullscreen mode, the window's size might be a wrong value on Windows.
|
||||
// This was the cause to invoke SetSize callback unexpectedly. This sounds like a GLFW's issue, but this is not confirmed.
|
||||
// As the window size should not be changed, setWindowSize doesn't have to be called anyway.
|
||||
}
|
||||
|
@ -51,14 +51,10 @@ func (w *window) SetDecorated(decorated bool) {
|
||||
return nil
|
||||
}
|
||||
|
||||
v := glfw.False
|
||||
if decorated {
|
||||
v = glfw.True
|
||||
}
|
||||
w.ui.window.SetAttrib(glfw.Decorated, v)
|
||||
w.ui.setDecorated(decorated)
|
||||
|
||||
// The title can be lost when the decoration is gone. Recover this.
|
||||
if v == glfw.True {
|
||||
if decorated {
|
||||
w.ui.window.SetTitle(w.ui.title)
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user