diff --git a/internal/uidriver/glfw/ui.go b/internal/uidriver/glfw/ui.go index 824314f7a..63ef1c722 100644 --- a/internal/uidriver/glfw/ui.go +++ b/internal/uidriver/glfw/ui.go @@ -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()