mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix dark titlebar on Windows 10 17763
This commit is contained in:
parent
c170a86189
commit
f71ce9afdf
1 changed files with 12 additions and 19 deletions
|
@ -587,12 +587,14 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||||
const auto empty = native ? nullptr : L" ";
|
const auto empty = native ? nullptr : L" ";
|
||||||
Dlls::SetWindowTheme(ps_hWnd, empty, empty);
|
Dlls::SetWindowTheme(ps_hWnd, empty, empty);
|
||||||
QApplication::setStyle(QStyleFactory::create(u"Windows"_q));
|
QApplication::setStyle(QStyleFactory::create(u"Windows"_q));
|
||||||
|
#if 0
|
||||||
} else if (!Platform::IsDarkModeSupported()/*
|
} else if (!Platform::IsDarkModeSupported()/*
|
||||||
|| (!Dlls::AllowDarkModeForApp && !Dlls::SetPreferredAppMode)
|
|| (!Dlls::AllowDarkModeForApp && !Dlls::SetPreferredAppMode)
|
||||||
|| !Dlls::AllowDarkModeForWindow
|
|| !Dlls::AllowDarkModeForWindow
|
||||||
|| !Dlls::RefreshImmersiveColorPolicyState
|
|| !Dlls::RefreshImmersiveColorPolicyState
|
||||||
|| !Dlls::FlushMenuThemes*/) {
|
|| !Dlls::FlushMenuThemes*/) {
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
} else if (!native) {
|
} else if (!native) {
|
||||||
Dlls::SetWindowTheme(ps_hWnd, nullptr, nullptr);
|
Dlls::SetWindowTheme(ps_hWnd, nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
|
@ -606,31 +608,22 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||||
|
|
||||||
const auto updateStyle = [&] {
|
const auto updateStyle = [&] {
|
||||||
static const auto kSystemVersion = QOperatingSystemVersion::current();
|
static const auto kSystemVersion = QOperatingSystemVersion::current();
|
||||||
if (kSystemVersion.microVersion() < 18362) {
|
if (kSystemVersion.microVersion() >= 18875 && Dlls::SetWindowCompositionAttribute) {
|
||||||
SetPropW(
|
|
||||||
ps_hWnd,
|
|
||||||
L"UseImmersiveDarkModeColors",
|
|
||||||
reinterpret_cast<HANDLE>(static_cast<INT_PTR>(darkValue)));
|
|
||||||
} else if (Dlls::SetWindowCompositionAttribute) {
|
|
||||||
Dlls::WINDOWCOMPOSITIONATTRIBDATA data = {
|
Dlls::WINDOWCOMPOSITIONATTRIBDATA data = {
|
||||||
Dlls::WINDOWCOMPOSITIONATTRIB::WCA_USEDARKMODECOLORS,
|
Dlls::WINDOWCOMPOSITIONATTRIB::WCA_USEDARKMODECOLORS,
|
||||||
&darkValue,
|
&darkValue,
|
||||||
sizeof(darkValue)
|
sizeof(darkValue)
|
||||||
};
|
};
|
||||||
Dlls::SetWindowCompositionAttribute(ps_hWnd, &data);
|
Dlls::SetWindowCompositionAttribute(ps_hWnd, &data);
|
||||||
} else if (Dlls::DwmSetWindowAttribute) {
|
} else if (kSystemVersion.microVersion() >= 17763 && Dlls::DwmSetWindowAttribute) {
|
||||||
static constexpr auto DWMWA_USE_IMMERSIVE_DARK_MODE_0 = DWORD(19);
|
static const auto DWMWA_USE_IMMERSIVE_DARK_MODE = (kSystemVersion.microVersion() >= 18985)
|
||||||
static constexpr auto DWMWA_USE_IMMERSIVE_DARK_MODE = DWORD(20);
|
? DWORD(20)
|
||||||
const auto set = [&](DWORD attribute) {
|
: DWORD(19);
|
||||||
return Dlls::DwmSetWindowAttribute(
|
Dlls::DwmSetWindowAttribute(
|
||||||
ps_hWnd,
|
ps_hWnd,
|
||||||
attribute,
|
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||||
&darkValue,
|
&darkValue,
|
||||||
sizeof(darkValue));
|
sizeof(darkValue));
|
||||||
};
|
|
||||||
if (FAILED(set(DWMWA_USE_IMMERSIVE_DARK_MODE))) {
|
|
||||||
set(DWMWA_USE_IMMERSIVE_DARK_MODE_0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue