Windows QPA: Correctly respond to WM_ERASEBKGND

According to Microsoft Docs [1], applications should
return non-zero in response to WM_ERASEBKGND if it
processes the message and erases the background and
that's indeed the case for Qt.

Although I can't see any visual difference, this patch
obeys the official documentation at least.

[1] https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-erasebkgnd

Change-Id: I8aa0bfb25259013bfc2ca4074f05a97c7865159c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 5d129426765871912b4f0b4ba77eef4b338d00a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Yuhang Zhao 2021-12-04 13:56:17 +08:00 committed by Qt Cherry-pick Bot
parent fd02b117d6
commit 79d6450526
3 changed files with 6 additions and 4 deletions

View File

@ -1268,7 +1268,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::GeometryChangingEvent:
return platformWindow->QWindowsWindow::handleGeometryChanging(&msg);
case QtWindows::ExposeEvent:
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam, result);
case QtWindows::NonClientMouseEvent:
if ((d->m_systemInfo & QWindowsContext::SI_SupportsPointer) && platformWindow->frameStrutEventsEnabled())
return sessionManagerInteractionBlocked() || d->m_pointerHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);

View File

@ -2157,10 +2157,12 @@ static inline bool isSoftwareGl()
}
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
WPARAM, LPARAM)
WPARAM, LPARAM, LRESULT *result)
{
if (message == WM_ERASEBKGND) // Backing store - ignored.
if (message == WM_ERASEBKGND) { // Backing store - ignored.
*result = 1;
return true;
}
// QTBUG-75455: Suppress WM_PAINT sent to invisible windows when setting WS_EX_LAYERED
if (!window()->isVisible() && (GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_LAYERED) != 0)
return false;

View File

@ -313,7 +313,7 @@ public:
void setStyle(unsigned s) const;
void setExStyle(unsigned s) const;
bool handleWmPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
bool handleWmPaint(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result);
void handleMoved();
void handleResized(int wParam);