From cf4778df740f7a5f68d26841dbda4d2f09b17148 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 16 Apr 2025 19:51:45 +0200 Subject: [PATCH] UI: Remove Initial Win32 White Flash During Startup On the Windows platform we get an initial bright white flash during startup, before we start drawing on our canvas. This PR changes that initial color to a mid-grey that is much less noticeable. After this initial fill is done we then clear the background brush so Windows will not use it later and slow down resizing by adding extra WM_PAINT messages and fills. Pull Request: https://projects.blender.org/blender/blender/pulls/137488 --- intern/ghost/intern/GHOST_SystemWin32.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cc b/intern/ghost/intern/GHOST_SystemWin32.cc index 149c0a4fbe2..8e55da166c5 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cc +++ b/intern/ghost/intern/GHOST_SystemWin32.cc @@ -622,7 +622,7 @@ GHOST_TSuccess GHOST_SystemWin32::init() #ifdef INW32_COMPISITING (HBRUSH)CreateSolidBrush #endif - (0x00000000); + (HBRUSH) GetStockObject(DKGRAY_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = L"GHOST_WindowClass"; @@ -2245,6 +2245,18 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, uint msg, WPARAM wParam, /* An application sends the WM_ERASEBKGND message when the window background must be * erased (for example, when a window is resized). The message is sent to prepare an * invalidated portion of a window for painting. */ + { + HBRUSH bgBrush = (HBRUSH)GetClassLongPtr(hwnd, GCLP_HBRBACKGROUND); + if (bgBrush) { + RECT rect; + GetClientRect(hwnd, &rect); + FillRect((HDC)(wParam), &rect, bgBrush); + /* Clear the backround brush after the initial fill as we don't + * need or want any default Windows fill behavior on redraw. */ + SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG_PTR) nullptr); + } + break; + } case WM_NCPAINT: /* An application sends the WM_NCPAINT message to a window * when its frame must be painted. */