From b3dbfdd59782e801fc5bb5e5df3ed71ae4ec2866 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 5 Dec 2022 09:42:17 +0100 Subject: [PATCH] Windows: Reduce warning output when creating a new window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends f32aa06f4f925e9a14db1bf76918358480b98b6a, which called setDarkBorderToWindow with false when creating a window if windows is not running in dark mode. This generates warning messages on Windows 10. We don't have to call the setter at all unless we want dark mode frames, so skip it if we'd call it with 'false', as that is the default anyway. At the same time, use categorized logging for these messages; they are not the result of application developers doing something wrong, and are only interesting when analysing specific issues. Change-Id: If80028d71cc2cd9d6dd380976e00b736741287cb Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/windows/qwindowswindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index aa3422c5b5..325e240889 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -926,8 +926,8 @@ QWindowsWindowData return result; } - QWindowsWindow::setDarkBorderToWindow(result.hwnd, QWindowsContext::isDarkMode() - && shouldApplyDarkFrame(w)); + if (QWindowsContext::isDarkMode() && shouldApplyDarkFrame(w)) + QWindowsWindow::setDarkBorderToWindow(result.hwnd, true); if (mirrorParentWidth != 0) { context->obtainedPos.setX(mirrorParentWidth - context->obtainedSize.width() @@ -3161,7 +3161,7 @@ static bool queryDarkBorder(HWND hwnd) SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &result, sizeof(result))) || SUCCEEDED(DwmGetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &result, sizeof(result))); if (!ok) - qWarning("%s: Unable to retrieve dark window border setting.", __FUNCTION__); + qCWarning(lcQpaWindow, "%s: Unable to retrieve dark window border setting.", __FUNCTION__); return result == TRUE; } @@ -3172,7 +3172,7 @@ bool QWindowsWindow::setDarkBorderToWindow(HWND hwnd, bool d) SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &darkBorder, sizeof(darkBorder))) || SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &darkBorder, sizeof(darkBorder))); if (!ok) - qWarning("%s: Unable to set dark window border.", __FUNCTION__); + qCWarning(lcQpaWindow, "%s: Unable to set %s window border.", __FUNCTION__, d ? "dark" : "light"); return ok; }