diff --git a/new_editor/app/Application.cpp b/new_editor/app/Application.cpp index 44cba9c6..ca48087b 100644 --- a/new_editor/app/Application.cpp +++ b/new_editor/app/Application.cpp @@ -957,6 +957,7 @@ LRESULT CALLBACK Application::WndProc(HWND hwnd, UINT message, WPARAM wParam, LP Application* application = Host::WindowMessageDispatcher::GetApplicationFromWindow(hwnd); if (application != nullptr && Host::WindowMessageDispatcher::TryDispatch( + hwnd, *application, message, wParam, diff --git a/new_editor/app/Host/WindowMessageDispatcher.cpp b/new_editor/app/Host/WindowMessageDispatcher.cpp index 1dd005cc..56f19a6d 100644 --- a/new_editor/app/Host/WindowMessageDispatcher.cpp +++ b/new_editor/app/Host/WindowMessageDispatcher.cpp @@ -45,11 +45,23 @@ bool WindowMessageDispatcher::TryHandleNonClientCreate( } bool WindowMessageDispatcher::TryDispatch( + HWND hwnd, Application& application, UINT message, WPARAM wParam, LPARAM lParam, LRESULT& outResult) { + const auto renderAndValidateWindow = [&application, hwnd]() { + if (!application.m_renderReady) { + return; + } + + application.RenderFrame(); + if (hwnd != nullptr && IsWindow(hwnd)) { + ValidateRect(hwnd, nullptr); + } + }; + switch (message) { case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT && application.ApplyCurrentCursor()) { @@ -64,9 +76,7 @@ bool WindowMessageDispatcher::TryDispatch( application.OnDpiChanged( static_cast(LOWORD(wParam)), *reinterpret_cast(lParam)); - if (application.m_renderReady) { - application.RenderFrame(); - } + renderAndValidateWindow(); outResult = 0; return true; case WM_ENTERSIZEMOVE: @@ -75,9 +85,7 @@ bool WindowMessageDispatcher::TryDispatch( return true; case WM_EXITSIZEMOVE: application.OnExitSizeMove(); - if (application.m_renderReady) { - application.RenderFrame(); - } + renderAndValidateWindow(); outResult = 0; return true; case WM_SIZE: @@ -85,9 +93,7 @@ bool WindowMessageDispatcher::TryDispatch( application.OnResize( static_cast(LOWORD(lParam)), static_cast(HIWORD(lParam))); - if (application.m_renderReady) { - application.RenderFrame(); - } + renderAndValidateWindow(); } outResult = 0; return true; diff --git a/new_editor/app/Host/WindowMessageDispatcher.h b/new_editor/app/Host/WindowMessageDispatcher.h index 4ec1b7aa..5b930606 100644 --- a/new_editor/app/Host/WindowMessageDispatcher.h +++ b/new_editor/app/Host/WindowMessageDispatcher.h @@ -21,6 +21,7 @@ public: LPARAM lParam, LRESULT& outResult); static bool TryDispatch( + HWND hwnd, Application& application, UINT message, WPARAM wParam,