I've noticed that in the Windows port of GLFW3, the _glfwInputFramebufferSize and _glfwInputWindowSize are called regardless of the current windows size. Also, the window width/height is not store in the win32 structure. This might cause repeated calls to the callback.
I suggest to change the win32_window.c code as follows.
case WM_SIZE:
{
const GLFWbool iconified = wParam == SIZE_MINIMIZED;
const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
(window->win32.maximized &&
wParam != SIZE_RESTORED);
const int width = LOWORD(lParam);
const int height = HIWORD(lParam);
if (_glfw.win32.disabledCursorWindow == window)
updateClipRect(window);
if (window->win32.iconified != iconified)
_glfwInputWindowIconify(window, iconified);
if (window->win32.maximized != maximized)
_glfwInputWindowMaximize(window, maximized);
if (window->win32.width != width || window->win32.height != height) {
_glfwInputFramebufferSize(window, width, height);
_glfwInputWindowSize(window, width, height);
}
if (window->monitor && window->win32.iconified != iconified)
{
if (iconified)
releaseMonitor(window);
else
{
acquireMonitor(window);
fitToMonitor(window);
}
}
window->win32.iconified = iconified;
window->win32.maximized = maximized;
window->win32.width = width;
window->win32.height = height;
return 0;
}
This will potentially break code, someone may rely on this behaviour.
This will potentially break code, someone may rely on this behaviour.
You might be right, but since the window structure features the width/height fields and they aren't initialized in the Windows porting I suspect this was just a (minor) oversight.
OK, I see now that X11 handles this since a7ff236 and Cocoa - since 1fe319d (#1085).
I think Windows could use the same trick.
Do you have any scenario where this event could be called when size didn't change?
Yes. In fact, I was encountering the issue in a project of mine where I initially opened a 1x1 hidden window, then resize it to a proper (calculated) size, and finally displaying it.
With this sequence of operations, after the size of the window has been set, the callback would be called twice (the first time after the resizing, and a second time when displaying it).
Most helpful comment
OK, I see now that X11 handles this since a7ff236 and Cocoa - since 1fe319d (#1085).
I think Windows could use the same trick.
Do you have any scenario where this event could be called when size didn't change?