win: minor tweaks

This commit is contained in:
Yuhang Zhao 2023-09-28 18:06:47 +08:00
parent 27a9e0857c
commit 8f98ab865c
4 changed files with 11 additions and 6 deletions

View File

@ -779,7 +779,8 @@ using ACCENT_STATE = enum ACCENT_STATE
using ACCENT_FLAG = enum ACCENT_FLAG using ACCENT_FLAG = enum ACCENT_FLAG
{ {
ACCENT_NONE = 0, ACCENT_NONE = 0,
ACCENT_ENABLE_LUMINOSITY = 1 << 1, ACCENT_ENABLE_ACRYLIC = 1,
ACCENT_ENABLE_MICA = 1 << 1,
ACCENT_ENABLE_BORDER_LEFT = 1 << 5, ACCENT_ENABLE_BORDER_LEFT = 1 << 5,
ACCENT_ENABLE_BORDER_TOP = 1 << 6, ACCENT_ENABLE_BORDER_TOP = 1 << 6,
ACCENT_ENABLE_BORDER_RIGHT = 1 << 7, ACCENT_ENABLE_BORDER_RIGHT = 1 << 7,
@ -790,8 +791,8 @@ using ACCENT_FLAG = enum ACCENT_FLAG
using ACCENT_POLICY = struct ACCENT_POLICY using ACCENT_POLICY = struct ACCENT_POLICY
{ {
ACCENT_STATE AccentState; DWORD AccentState;
ACCENT_FLAG AccentFlags; DWORD AccentFlags;
DWORD dwGradientColor; // #AABBGGRR DWORD dwGradientColor; // #AABBGGRR
DWORD dwAnimationId; DWORD dwAnimationId;
}; };

View File

@ -252,9 +252,11 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
// Windows, which means only the top level windows can be scaled to the correct // Windows, which means only the top level windows can be scaled to the correct
// size, we of course don't want such thing from happening. // size, we of course don't want such thing from happening.
std::ignore = Utils::fixupChildWindowsDpiMessage(windowId); std::ignore = Utils::fixupChildWindowsDpiMessage(windowId);
#if 0 // Conflicts with our blur mode setting.
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) { if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
std::ignore = Utils::updateFramebufferTransparency(windowId); std::ignore = Utils::updateFramebufferTransparency(windowId);
} }
#endif
if (WindowsVersionHelper::isWin10RS1OrGreater()) { if (WindowsVersionHelper::isWin10RS1OrGreater()) {
// Tell DWM we may need dark theme non-client area (title bar & frame border). // Tell DWM we may need dark theme non-client area (title bar & frame border).
FramelessHelperEnableThemeAware(); FramelessHelperEnableThemeAware();
@ -1267,11 +1269,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
} }
} }
#if 0 // Conflicts with our blur mode setting.
if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) { if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) {
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) { if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
std::ignore = Utils::updateFramebufferTransparency(windowId); std::ignore = Utils::updateFramebufferTransparency(windowId);
} }
} }
#endif
const bool wallpaperChanged = ((uMsg == WM_SETTINGCHANGE) && (wParam == SPI_SETDESKWALLPAPER)); const bool wallpaperChanged = ((uMsg == WM_SETTINGCHANGE) && (wParam == SPI_SETDESKWALLPAPER));
bool systemThemeChanged = ((uMsg == WM_THEMECHANGED) || (uMsg == WM_SYSCOLORCHANGE) bool systemThemeChanged = ((uMsg == WM_THEMECHANGED) || (uMsg == WM_SYSCOLORCHANGE)

View File

@ -575,7 +575,7 @@ quint32 Utils::defaultScreenDpi()
QColor Utils::getAccentColor() QColor Utils::getAccentColor()
{ {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
return QGuiApplication::palette().color(QPalette::AccentColor); return QGuiApplication::palette().color(QPalette::Accent);
#else // (QT_VERSION < QT_VERSION_CHECK(6, 6, 0)) #else // (QT_VERSION < QT_VERSION_CHECK(6, 6, 0))
# ifdef Q_OS_WINDOWS # ifdef Q_OS_WINDOWS
return getAccentColor_windows(); return getAccentColor_windows();

View File

@ -2454,13 +2454,13 @@ bool Utils::setBlurBehindWindowEnabled(const WId windowId, const BlurMode mode,
SecureZeroMemory(&policy, sizeof(policy)); SecureZeroMemory(&policy, sizeof(policy));
if (blurMode == BlurMode::Windows_Acrylic) { if (blurMode == BlurMode::Windows_Acrylic) {
policy.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND; policy.AccentState = ACCENT_ENABLE_ACRYLICBLURBEHIND;
policy.AccentFlags = ACCENT_ENABLE_LUMINOSITY; policy.AccentFlags = ACCENT_ENABLE_ACRYLIC; // Mica: ACCENT_ENABLE_MICA | ACCENT_ENABLE_BORDER
const auto gradientColor = [&color]() -> QColor { const auto gradientColor = [&color]() -> QColor {
if (color.isValid()) { if (color.isValid()) {
return color; return color;
} }
QColor clr = ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultSystemDarkColor : kDefaultSystemLightColor); QColor clr = ((FramelessManager::instance()->systemTheme() == SystemTheme::Dark) ? kDefaultSystemDarkColor : kDefaultSystemLightColor);
clr.setAlphaF(0.9f); clr.setAlphaF(0.5f);
return clr; return clr;
}(); }();
// This API expects the #AABBGGRR format. // This API expects the #AABBGGRR format.