From 04f254556d485c57c936cc026754b4448fbfb322 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 17 Nov 2022 10:24:45 +0800 Subject: [PATCH] minor tweaks Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- src/core/framelesshelper_win.cpp | 4 +++- src/core/utils_linux.cpp | 9 ++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index e4a040e..fd40469 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -87,6 +87,7 @@ FRAMELESSHELPER_STRING_CONSTANT(DestroyWindow) "no need to worry. But if you really need the snap layout feature, please add a manifest file to your application and " "explicitly declare Windows 11 compatibility in it. If you just want to hide this error message, please use the " "FramelessConfig class to officially disable the snap layout feature for Windows 11."; +[[maybe_unused]] static constexpr const char kD3DWorkaroundEnvVar[] = "FRAMELESSHELPER_USE_D3D_WORKAROUND"; struct Win32HelperData { @@ -891,7 +892,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // of the upper-left non-client area. It's confirmed that this issue exists // from Windows 7 to Windows 10. Not tested on Windows 11 yet. Don't know // whether it exists on Windows XP to Windows Vista or not. - *result = ((static_cast(wParam) == FALSE) ? 0 : WVR_REDRAW); + const bool needD3DWorkaround = (qEnvironmentVariableIntValue(kD3DWorkaroundEnvVar) != 0); + *result = (((static_cast(wParam) == FALSE) || needD3DWorkaround) ? 0 : WVR_REDRAW); return true; } case WM_NCHITTEST: { diff --git a/src/core/utils_linux.cpp b/src/core/utils_linux.cpp index f82b1c4..55ddc03 100644 --- a/src/core/utils_linux.cpp +++ b/src/core/utils_linux.cpp @@ -26,7 +26,6 @@ #include "framelessconfig_p.h" #include "framelessmanager.h" #include "framelessmanager_p.h" -#include #include #include #include @@ -79,7 +78,8 @@ using Display = struct _XDisplay; [[maybe_unused]] static constexpr const char GTK_THEME_NAME_ENV_VAR[] = "GTK_THEME"; [[maybe_unused]] static constexpr const char GTK_THEME_NAME_PROP[] = "gtk-theme-name"; [[maybe_unused]] static constexpr const char GTK_THEME_PREFER_DARK_PROP[] = "gtk-application-prefer-dark-theme"; -FRAMELESSHELPER_STRING_CONSTANT2(GTK_THEME_DARK_REGEX, "[:-]dark") + +FRAMELESSHELPER_STRING_CONSTANT(dark) FRAMELESSHELPER_BYTEARRAY_CONSTANT(rootwindow) FRAMELESSHELPER_BYTEARRAY_CONSTANT(x11screen) @@ -474,10 +474,9 @@ bool Utils::shouldAppsUseDarkMode_linux() it's mainly used for easy debugging, so it should be possible to use it to override any other settings. */ - static const QRegularExpression darkRegex(kGTK_THEME_DARK_REGEX, QRegularExpression::CaseInsensitiveOption); const QString envThemeName = qEnvironmentVariable(GTK_THEME_NAME_ENV_VAR); if (!envThemeName.isEmpty()) { - return darkRegex.match(envThemeName).hasMatch(); + return envThemeName.contains(kdark, Qt::CaseInsensitive); } /* @@ -497,7 +496,7 @@ bool Utils::shouldAppsUseDarkMode_linux() */ const QString curThemeName = gtkSetting(GTK_THEME_NAME_PROP); if (!curThemeName.isEmpty()) { - return darkRegex.match(curThemeName).hasMatch(); + return curThemeName.contains(kdark, Qt::CaseInsensitive); } return false;