mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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)
|
||||
|
||||
wx, wy := ebiten.WindowPosition()
|
||||
ww, wh := ebiten.WindowSize()
|
||||
minw, minh, maxw, maxh := ebiten.WindowSizeLimits()
|
||||
cx, cy := ebiten.CursorPosition()
|
||||
tpsStr := "Sync with FPS"
|
||||
@ -344,12 +345,13 @@ func (g *game) Draw(screen *ebiten.Image) {
|
||||
[W] Switch whether to skip clearing the screen
|
||||
%s
|
||||
IsFocused?: %s
|
||||
Windows Position: (%d, %d)
|
||||
Window Position: (%d, %d)
|
||||
Window Size: (%d, %d)
|
||||
Window size limitation: (%d, %d) - (%d, %d)
|
||||
Cursor: (%d, %d)
|
||||
TPS: Current: %0.2f / Max: %s
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -104,10 +104,11 @@ type UserInterface struct {
|
||||
input Input
|
||||
iwindow window
|
||||
|
||||
sizeCallback glfw.SizeCallback
|
||||
closeCallback glfw.CloseCallback
|
||||
framebufferSizeCallback glfw.FramebufferSizeCallback
|
||||
framebufferSizeCallbackCh chan struct{}
|
||||
sizeCallback glfw.SizeCallback
|
||||
closeCallback glfw.CloseCallback
|
||||
framebufferSizeCallback glfw.FramebufferSizeCallback
|
||||
defaultFramebufferSizeCallback glfw.FramebufferSizeCallback
|
||||
framebufferSizeCallbackCh chan struct{}
|
||||
|
||||
t thread.Thread
|
||||
m sync.RWMutex
|
||||
@ -821,7 +822,16 @@ event:
|
||||
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)
|
||||
u.framebufferSizeCallbackCh = nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user