mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
internal/uidriver/glfw: fix window float enable/disable (#1962)
Closes #1960
This commit is contained in:
parent
c4fbcdd1ae
commit
12c144070f
@ -305,6 +305,7 @@ func (g *game) Draw(screen *ebiten.Image) {
|
|||||||
screen.DrawImage(gophersImage, op)
|
screen.DrawImage(gophersImage, op)
|
||||||
|
|
||||||
wx, wy := ebiten.WindowPosition()
|
wx, wy := ebiten.WindowPosition()
|
||||||
|
ww, wh := ebiten.WindowSize()
|
||||||
minw, minh, maxw, maxh := ebiten.WindowSizeLimits()
|
minw, minh, maxw, maxh := ebiten.WindowSizeLimits()
|
||||||
cx, cy := ebiten.CursorPosition()
|
cx, cy := ebiten.CursorPosition()
|
||||||
tpsStr := "Sync with FPS"
|
tpsStr := "Sync with FPS"
|
||||||
@ -344,12 +345,13 @@ func (g *game) Draw(screen *ebiten.Image) {
|
|||||||
[W] Switch whether to skip clearing the screen
|
[W] Switch whether to skip clearing the screen
|
||||||
%s
|
%s
|
||||||
IsFocused?: %s
|
IsFocused?: %s
|
||||||
Windows Position: (%d, %d)
|
Window Position: (%d, %d)
|
||||||
|
Window Size: (%d, %d)
|
||||||
Window size limitation: (%d, %d) - (%d, %d)
|
Window size limitation: (%d, %d) - (%d, %d)
|
||||||
Cursor: (%d, %d)
|
Cursor: (%d, %d)
|
||||||
TPS: Current: %0.2f / Max: %s
|
TPS: Current: %0.2f / Max: %s
|
||||||
FPS: %0.2f
|
FPS: %0.2f
|
||||||
Device Scale Factor: %0.2f`, msgM, msgR, fg, wx, wy, minw, minh, maxw, maxh, cx, cy, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS(), ebiten.DeviceScaleFactor())
|
Device Scale Factor: %0.2f`, msgM, msgR, fg, wx, wy, ww, wh, minw, minh, maxw, maxh, cx, cy, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS(), ebiten.DeviceScaleFactor())
|
||||||
ebitenutil.DebugPrint(screen, msg)
|
ebitenutil.DebugPrint(screen, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ type UserInterface struct {
|
|||||||
sizeCallback glfw.SizeCallback
|
sizeCallback glfw.SizeCallback
|
||||||
closeCallback glfw.CloseCallback
|
closeCallback glfw.CloseCallback
|
||||||
framebufferSizeCallback glfw.FramebufferSizeCallback
|
framebufferSizeCallback glfw.FramebufferSizeCallback
|
||||||
|
defaultFramebufferSizeCallback glfw.FramebufferSizeCallback
|
||||||
framebufferSizeCallbackCh chan struct{}
|
framebufferSizeCallbackCh chan struct{}
|
||||||
|
|
||||||
t thread.Thread
|
t thread.Thread
|
||||||
@ -821,7 +822,16 @@ event:
|
|||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.SetFramebufferSizeCallback(glfw.ToFramebufferSizeCallback(nil))
|
if u.defaultFramebufferSizeCallback == 0 {
|
||||||
|
// When the window gets resized (either by manual window resize or a window
|
||||||
|
// manager), glfw sends a framebuffer size callback which we need to handle (#1960).
|
||||||
|
// This event is the only way to handle the size change at least on i3 window manager.
|
||||||
|
u.defaultFramebufferSizeCallback = glfw.ToFramebufferSizeCallback(func(_ *glfw.Window, w, h int) {
|
||||||
|
u.setWindowSizeInDIP(w, h, u.isFullscreen())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
window.SetFramebufferSizeCallback(u.defaultFramebufferSizeCallback)
|
||||||
|
|
||||||
close(u.framebufferSizeCallbackCh)
|
close(u.framebufferSizeCallbackCh)
|
||||||
u.framebufferSizeCallbackCh = nil
|
u.framebufferSizeCallbackCh = nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user