mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +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()
|
w, h := u.window.GetSize()
|
||||||
u.setWindowSize(w, h, u.isFullscreen())
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
v := glfw.False
|
w.ui.setDecorated(decorated)
|
||||||
if decorated {
|
|
||||||
v = glfw.True
|
|
||||||
}
|
|
||||||
w.ui.window.SetAttrib(glfw.Decorated, v)
|
|
||||||
|
|
||||||
// The title can be lost when the decoration is gone. Recover this.
|
// 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)
|
w.ui.window.SetTitle(w.ui.title)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user