mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-21 15:47:38 +00:00
Support Windows 11 rounded corners and themeable title bar.
This commit is contained in:
parent
de2bad51d3
commit
844fd58a97
@ -1370,6 +1370,7 @@ if (WIN32)
|
||||
/DELAYLOAD:gdiplus.dll
|
||||
/DELAYLOAD:version.dll
|
||||
/DELAYLOAD:dwmapi.dll
|
||||
/DELAYLOAD:uxtheme.dll
|
||||
/DELAYLOAD:crypt32.dll
|
||||
/DELAYLOAD:bcrypt.dll
|
||||
/DELAYLOAD:imm32.dll
|
||||
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "mainwindow.h"
|
||||
#include "base/crc32hash.h"
|
||||
#include "base/platform/win/base_windows_wrl.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
#include "core/application.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/localstorage.h"
|
||||
@ -34,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <Shobjidl.h>
|
||||
#include <shellapi.h>
|
||||
#include <WtsApi32.h>
|
||||
#include <dwmapi.h>
|
||||
|
||||
#include <windows.ui.viewmanagement.h>
|
||||
#include <UIViewSettingsInterop.h>
|
||||
@ -401,11 +403,9 @@ void MainWindow::initHook() {
|
||||
}
|
||||
|
||||
void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||
if (!Dlls::SetWindowTheme) {
|
||||
return;
|
||||
} else if (!IsWindows8OrGreater()) {
|
||||
if (!IsWindows8OrGreater()) {
|
||||
const auto empty = native ? nullptr : L" ";
|
||||
Dlls::SetWindowTheme(ps_hWnd, empty, empty);
|
||||
SetWindowTheme(ps_hWnd, empty, empty);
|
||||
QApplication::setStyle(QStyleFactory::create(u"Windows"_q));
|
||||
#if 0
|
||||
} else if (!Platform::IsDarkModeSupported()/*
|
||||
@ -416,7 +416,7 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||
return;
|
||||
#endif
|
||||
} else if (!native) {
|
||||
Dlls::SetWindowTheme(ps_hWnd, nullptr, nullptr);
|
||||
SetWindowTheme(ps_hWnd, nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -435,13 +435,13 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||
sizeof(darkValue)
|
||||
};
|
||||
Dlls::SetWindowCompositionAttribute(ps_hWnd, &data);
|
||||
} else if (kSystemVersion.microVersion() >= 17763 && Dlls::DwmSetWindowAttribute) {
|
||||
static const auto DWMWA_USE_IMMERSIVE_DARK_MODE = (kSystemVersion.microVersion() >= 18985)
|
||||
} else if (kSystemVersion.microVersion() >= 17763) {
|
||||
static const auto kDWMWA_USE_IMMERSIVE_DARK_MODE = (kSystemVersion.microVersion() >= 18985)
|
||||
? DWORD(20)
|
||||
: DWORD(19);
|
||||
Dlls::DwmSetWindowAttribute(
|
||||
DwmSetWindowAttribute(
|
||||
ps_hWnd,
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
kDWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
&darkValue,
|
||||
sizeof(darkValue));
|
||||
}
|
||||
@ -457,7 +457,7 @@ void MainWindow::validateWindowTheme(bool native, bool night) {
|
||||
|
||||
//const auto updateWindowTheme = [&] {
|
||||
// const auto set = [&](LPCWSTR name) {
|
||||
// return Dlls::SetWindowTheme(ps_hWnd, name, nullptr);
|
||||
// return SetWindowTheme(ps_hWnd, name, nullptr);
|
||||
// };
|
||||
// if (!night || FAILED(set(L"DarkMode_Explorer"))) {
|
||||
// set(L"Explorer");
|
||||
|
@ -36,13 +36,12 @@ SafeIniter::SafeIniter() {
|
||||
LOAD_SYMBOL(LibShell32, SHChangeNotify);
|
||||
LOAD_SYMBOL(LibShell32, SetCurrentProcessExplicitAppUserModelID);
|
||||
|
||||
const auto LibUxTheme = LoadLibrary(L"uxtheme.dll");
|
||||
LOAD_SYMBOL(LibUxTheme, SetWindowTheme);
|
||||
//if (IsWindows10OrGreater()) {
|
||||
// static const auto kSystemVersion = QOperatingSystemVersion::current();
|
||||
// static const auto kMinor = kSystemVersion.minorVersion();
|
||||
// static const auto kBuild = kSystemVersion.microVersion();
|
||||
// if (kMinor > 0 || (kMinor == 0 && kBuild >= 17763)) {
|
||||
// const auto LibUxTheme = LoadLibrary(L"uxtheme.dll");
|
||||
// if (kBuild < 18362) {
|
||||
// LOAD_SYMBOL(LibUxTheme, AllowDarkModeForApp, 135);
|
||||
// } else {
|
||||
@ -62,9 +61,6 @@ SafeIniter::SafeIniter() {
|
||||
LOAD_SYMBOL(LibPropSys, PropVariantToString);
|
||||
LOAD_SYMBOL(LibPropSys, PSStringFromPropertyKey);
|
||||
|
||||
const auto LibDwmApi = LoadLibrary(L"dwmapi.dll");
|
||||
LOAD_SYMBOL(LibDwmApi, DwmSetWindowAttribute);
|
||||
|
||||
const auto LibPsApi = LoadLibrary(L"psapi.dll");
|
||||
LOAD_SYMBOL(LibPsApi, GetProcessMemoryInfo);
|
||||
|
||||
|
@ -24,12 +24,6 @@ namespace Dlls {
|
||||
|
||||
void CheckLoadedModules();
|
||||
|
||||
// UXTHEME.DLL
|
||||
inline HRESULT(__stdcall *SetWindowTheme)(
|
||||
HWND hWnd,
|
||||
LPCWSTR pszSubAppName,
|
||||
LPCWSTR pszSubIdList);
|
||||
|
||||
//inline void(__stdcall *RefreshImmersiveColorPolicyState)();
|
||||
//
|
||||
//inline BOOL(__stdcall *AllowDarkModeForApp)(BOOL allow);
|
||||
@ -94,14 +88,6 @@ inline HRESULT(__stdcall *PSStringFromPropertyKey)(
|
||||
_Out_writes_(cch) LPWSTR psz,
|
||||
_In_ UINT cch);
|
||||
|
||||
// DWMAPI.DLL
|
||||
|
||||
inline HRESULT(__stdcall *DwmSetWindowAttribute)(
|
||||
HWND hwnd,
|
||||
DWORD dwAttribute,
|
||||
_In_reads_bytes_(cbAttribute) LPCVOID pvAttribute,
|
||||
DWORD cbAttribute);
|
||||
|
||||
// PSAPI.DLL
|
||||
|
||||
inline BOOL(__stdcall *GetProcessMemoryInfo)(
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 40fc5b35f005d14b7216d956051a55429d984065
|
||||
Subproject commit a827d9436e9ca258dfdfb9b67ef1ad917c13c5b5
|
2
cmake
2
cmake
@ -1 +1 @@
|
||||
Subproject commit f3a611c82bfee860f950d5ca6563d8d68262b38d
|
||||
Subproject commit c4c2bf4bada5207570a78fa3541907a1e9e7bda5
|
Loading…
Reference in New Issue
Block a user