Skip to content

Commit

Permalink
uidriver/glfw: Bug fix: Set the correct window size when going back f…
Browse files Browse the repository at this point in the history
…rom fullscreen
  • Loading branch information
hajimehoshi committed Sep 21, 2020
1 parent 3fc328d commit ee52c88
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions internal/uidriver/glfw/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,23 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
u.swapBuffers()
}
} else {
// On Windows, giving a too small width doesn't call a callback (#165).
// To prevent hanging up, return asap if the width is too small.
// 126 is an arbitrary number and I guess this is small enough.
minWindowWidth := int(u.toGLFWPixel(126))
if u.window.GetAttrib(glfw.Decorated) == glfw.False {
minWindowWidth = 1
}
if width < minWindowWidth {
width = minWindowWidth
}

if u.window.GetMonitor() != nil {
if u.Graphics().IsGL() {
// When OpenGL is used, swapping buffer is enough to solve the image-lag
// issue (#1004). Rather, recreating window destroys GPU resources.
// TODO: This might not work when vsync is disabled.
u.window.SetMonitor(nil, 0, 0, 16, 16, 0)
u.window.SetMonitor(nil, 0, 0, width, height, 0)
glfw.PollEvents()
u.swapBuffers()
} else {
Expand All @@ -990,17 +1001,6 @@ func (u *UserInterface) setWindowSize(width, height int, fullscreen bool) {
}
}

// On Windows, giving a too small width doesn't call a callback (#165).
// To prevent hanging up, return asap if the width is too small.
// 126 is an arbitrary number and I guess this is small enough.
minWindowWidth := int(u.toGLFWPixel(126))
if u.window.GetAttrib(glfw.Decorated) == glfw.False {
minWindowWidth = 1
}
if width < minWindowWidth {
width = minWindowWidth
}

if u.origPosX != invalidPos && u.origPosY != invalidPos {
x := u.origPosX
y := u.origPosY
Expand Down

0 comments on commit ee52c88

Please sign in to comment.