mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
internal/uidriver/glfw: initialize the callback at init
This commit is contained in:
parent
a19bbd3b09
commit
80f178b5e8
@ -822,23 +822,6 @@ event:
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
}
|
||||
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) {
|
||||
if u.isFullscreen() {
|
||||
return
|
||||
}
|
||||
|
||||
// The framebuffer size is always scaled by the device scale factor (#1975).
|
||||
// See also the implementation in uiContext.updateOffscreen.
|
||||
s := u.deviceScaleFactor(u.currentMonitor())
|
||||
ww := int(float64(w) / s)
|
||||
wh := int(float64(h) / s)
|
||||
u.setWindowSizeInDIP(ww, wh, u.isFullscreen())
|
||||
})
|
||||
}
|
||||
window.SetFramebufferSizeCallback(u.defaultFramebufferSizeCallback)
|
||||
|
||||
close(u.framebufferSizeCallbackCh)
|
||||
@ -922,6 +905,23 @@ func (u *UserInterface) init() error {
|
||||
u.window.Maximize()
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if u.isFullscreen() {
|
||||
return
|
||||
}
|
||||
|
||||
// The framebuffer size is always scaled by the device scale factor (#1975).
|
||||
// See also the implementation in uiContext.updateOffscreen.
|
||||
s := u.deviceScaleFactor(u.currentMonitor())
|
||||
ww := int(float64(w) / s)
|
||||
wh := int(float64(h) / s)
|
||||
u.setWindowSizeInDIP(ww, wh, u.isFullscreen())
|
||||
})
|
||||
u.window.SetFramebufferSizeCallback(u.defaultFramebufferSizeCallback)
|
||||
|
||||
u.window.SetTitle(u.title)
|
||||
u.window.Show()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user