From cf3dbc8d8829e4cca6167707a87e2096091789ed Mon Sep 17 00:00:00 2001 From: reuk Date: Fri, 16 Jan 2026 16:51:13 +0000 Subject: [PATCH] UpdateRegion: Validate window on receiving NULLREGION This fixes a bug where opening a foreground window could occasionally prevent background windows from repainting. The symptom seems to be caused by the system repeatedly sending WM_PAINT messages to the foreground window and ignoring the background window. It seems that the system will repeatedly call WM_PAINT until the entire region has been validated - even if that region is null. --- modules/juce_graphics/native/juce_DirectX_windows.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/native/juce_DirectX_windows.cpp b/modules/juce_graphics/native/juce_DirectX_windows.cpp index be8b59c7cc..ccbd6caef9 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.cpp +++ b/modules/juce_graphics/native/juce_DirectX_windows.cpp @@ -375,9 +375,15 @@ void UpdateRegion::findRECTAndValidate (HWND windowHandle) const ScopeGuard regionDeleter { [&] { DeleteObject (regionHandle); } }; const auto regionType = GetUpdateRgn (windowHandle, regionHandle, false); - if (regionType == ERROR || regionType == NULLREGION) + if (regionType == ERROR) return; + if (regionType == NULLREGION) + { + ValidateRect (windowHandle, nullptr); + return; + } + const auto requiredBytes = GetRegionData (regionHandle, 0, nullptr); block.ensureSize (requiredBytes);