From b3363b1716fbbb2af1b33b9bdd7a13f72016283d Mon Sep 17 00:00:00 2001 From: quou Date: Thu, 9 Jan 2025 21:55:09 +1100 Subject: smooth resizing on windows --- app.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app.cpp b/app.cpp index 6628e0e..cb90f63 100644 --- a/app.cpp +++ b/app.cpp @@ -419,7 +419,23 @@ struct App_Internal { } }; +static void win32_on_resize(HWND window, UINT msg, UINT_PTR timer, DWORD time) { + RECT rect; + int nw, nh; + App* app = (App*)GetWindowLongPtr(window, GWLP_USERDATA); + if (!app) return; + GetClientRect(window, &rect); + nw = rect.right - rect.left; + nh = rect.bottom - rect.top; + if (nw != app->w && nh != app->h) + app->on_resize(); + app->end(); + app->begin(); + app->on_update(); +} + static LRESULT CALLBACK win32_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + RECT rect; App* app = (App*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (!app) return DefWindowProc(hwnd, msg, wparam, lparam); switch (msg) { @@ -431,6 +447,13 @@ static LRESULT CALLBACK win32_event_callback(HWND hwnd, UINT msg, WPARAM wparam, app->h = (lparam >> 16) & 0xffff; app->on_resize(); return 0; + case WM_ENTERSIZEMOVE: + SetTimer(hwnd, 0, 10, win32_on_resize); + return 0; + case WM_EXITSIZEMOVE: + KillTimer(hwnd, 0); + app->end(); + return 0; case WM_MOUSEMOVE: app->mx = lparam & 0xffff; app->my = (lparam >> 16) & 0xffff; -- cgit v1.2.3-54-g00ecf