From b5da6e709d835de8920d11516143a7c01c7c2aa7 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 21 May 2022 17:10:21 +0400 Subject: [PATCH] Make window resize less lagged on Windows --- ui/platform/win/ui_window_win.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ui/platform/win/ui_window_win.cpp b/ui/platform/win/ui_window_win.cpp index 5286e27..97c38e5 100644 --- a/ui/platform/win/ui_window_win.cpp +++ b/ui/platform/win/ui_window_win.cpp @@ -242,6 +242,18 @@ void WindowHelper::setNativeFrame(bool enabled) { updateMargins(); updateWindowFrameColors(); fixMaximizedWindow(); + SetWindowPos( + _handle, + 0, + 0, + 0, + 0, + 0, + SWP_FRAMECHANGED + | SWP_NOMOVE + | SWP_NOSIZE + | SWP_NOZORDER + | SWP_NOACTIVATE); } void WindowHelper::initialShadowUpdate() { @@ -405,17 +417,14 @@ bool WindowHelper::handleNativeEvent( } return true; case WM_NCCALCSIZE: { - if (_title->isHidden()) { + if (_title->isHidden() || !wParam) { return false; } WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); if (GetWindowPlacement(_handle, &wp) && (wp.showCmd == SW_SHOWMAXIMIZED)) { - const auto params = (LPNCCALCSIZE_PARAMS)lParam; - const auto r = (wParam == TRUE) - ? ¶ms->rgrc[0] - : (LPRECT)lParam; + const auto r = &((LPNCCALCSIZE_PARAMS)lParam)->rgrc[0]; const auto hMonitor = MonitorFromPoint( { (r->left + r->right) / 2, (r->top + r->bottom) / 2 }, MONITOR_DEFAULTTONEAREST); @@ -435,8 +444,10 @@ bool WindowHelper::handleNativeEvent( } } } + if (result) *result = 0; + } else { + if (result) *result = WVR_REDRAW; } - if (result) *result = 0; return true; }