Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Commit 84d2468

Browse files
committed
update
1 parent 974f30a commit 84d2468

22 files changed

+191
-112
lines changed

Common/Api.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ bool Api::InteractiveIO::OutputToConsole(
171171
char input{ };
172172
do
173173
{
174-
input = getchar();
174+
input = static_cast<char>(getchar());
175175
if (input == 'Y' || input == 'y')
176176
{
177177
return true;
@@ -271,7 +271,7 @@ bool Api::IsStartAllBackTakingOver(std::wstring_view part)
271271
if (part.empty() || !_wcsicmp(part.data(), L"Tooltip"))
272272
{
273273
auto immersiveTooltips{ wil::reg::try_get_value_dword(HKEY_CURRENT_USER, L"SOFTWARE\\StartIsBack", L"NoDarkTooltips") };
274-
if (immersiveTooltips && immersiveTooltips.value() == 0)
274+
if (immersiveTooltips && immersiveTooltips.value() == 1)
275275
{
276276
return false;
277277
}

Common/HookHelper.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace TranslucentFlyouts::HookHelper::Detours
2424
offset = exception_pointers->ExceptionRecord->ExceptionInformation[1];
2525
return EXCEPTION_EXECUTE_HANDLER;
2626
};
27-
size_t offset = -1;
27+
size_t offset{ static_cast<size_t>(-1) };
2828
__try { vtable_function(&FakeVtableContainer); }
2929
__except (exception_handler(offset, GetExceptionInformation())) {}
3030

@@ -728,7 +728,7 @@ void HookHelper::HwndRef::Clear(HWND hWnd, std::wstring_view propNamespace, std:
728728
void HookHelper::HwndRef::ClearAll(HWND hWnd, std::wstring_view propNamespace)
729729
{
730730
auto propNameShort{ std::format(L"{}.{}.{}", HwndProp::propPrefix, propNamespace, propPrefix) };
731-
EnumPropsExW(hWnd, [](HWND hwnd, LPWSTR lpString, HANDLE hData, ULONG_PTR lParam)
731+
EnumPropsExW(hWnd, [](HWND hwnd, LPWSTR lpString, HANDLE, ULONG_PTR lParam)
732732
{
733733
if (HIWORD(lpString) && wcsstr(lpString, (*reinterpret_cast<std::wstring*>(lParam)).c_str()))
734734
{
@@ -751,7 +751,7 @@ void HookHelper::HwndProp::Unset(HWND hWnd, std::wstring_view propNamespace, std
751751
void HookHelper::HwndProp::ClearAll(HWND hWnd, std::wstring_view propNamespace)
752752
{
753753
auto propNameShort{ std::format(L"{}.{}", propPrefix, propNamespace) };
754-
EnumPropsExW(hWnd, [](HWND hwnd, LPWSTR lpString, HANDLE hData, ULONG_PTR lParam)
754+
EnumPropsExW(hWnd, [](HWND hwnd, LPWSTR lpString, HANDLE, ULONG_PTR lParam)
755755
{
756756
if (HIWORD(lpString) && wcsstr(lpString, (*reinterpret_cast<std::wstring*>(lParam)).c_str()))
757757
{

Common/RegHelper.hpp

+30-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ namespace TranslucentFlyouts
2020
std::wstring keyName{ root };
2121
maxFallThrough += 1;
2222

23+
#ifdef _DEBUG
24+
OutputDebugStringW(std::format(L"GetValueInternal = Begin\n", keyName).c_str());
25+
#endif
2326
if (!keyTree.empty())
2427
{
2528
for (size_t i{ 1 }; i <= keyTree.size(); i++)
@@ -35,6 +38,9 @@ namespace TranslucentFlyouts
3538
}
3639
}
3740

41+
#ifdef _DEBUG
42+
OutputDebugStringW(std::format(L"GetValueInternal: {}\n", keyName).c_str());
43+
#endif
3844
if constexpr (reverse)
3945
{
4046
value = wil::reg::try_get_value<T>(HKEY_LOCAL_MACHINE, keyName.c_str(), valueName.data());
@@ -67,6 +73,10 @@ namespace TranslucentFlyouts
6773
}
6874
else
6975
{
76+
77+
#ifdef _DEBUG
78+
OutputDebugStringW(std::format(L"GetValueInternal - {}\n", keyName).c_str());
79+
#endif
7080
if constexpr (reverse)
7181
{
7282
value = wil::reg::try_get_value<T>(HKEY_LOCAL_MACHINE, keyName.c_str(), valueName.data());
@@ -96,6 +106,9 @@ namespace TranslucentFlyouts
96106
}
97107
}
98108
}
109+
#ifdef _DEBUG
110+
OutputDebugStringW(std::format(L"GetValueInternal = End\n", keyName).c_str());
111+
#endif
99112

100113
return value;
101114
}
@@ -107,20 +120,27 @@ namespace TranslucentFlyouts
107120
std::wstring keyName{ root };
108121
maxFallThrough += 1;
109122

123+
#ifdef _DEBUG
124+
OutputDebugStringW(std::format(L"SetValueInternal = Begin\n", keyName).c_str());
125+
#endif
110126
if (!keyTree.empty())
111127
{
112-
for (size_t index{ 0 }; index < keyTree.size(); index++)
128+
for (size_t i{ 1 }; i <= keyTree.size(); i++)
113129
{
114130
keyName = root;
115-
for (size_t i{ keyTree.size() - 1 }; i >= index && maxFallThrough > 0; i--, maxFallThrough--)
131+
for (size_t j{ 1 }; j <= keyTree.size() - i + 1 && maxFallThrough >= 0; j++, maxFallThrough--)
116132
{
117-
if (!keyTree[i].empty())
133+
auto index{ keyTree.size() - j };
134+
if (!keyTree[index].empty())
118135
{
119136
keyName += L"\\";
120-
keyName += keyTree[i];
137+
keyName += keyTree[index];
121138
}
122139
}
123140

141+
#ifdef _DEBUG
142+
OutputDebugStringW(std::format(L"SetValueInternal - {}\n", keyName).c_str());
143+
#endif
124144
if constexpr (reverse)
125145
{
126146
if (FAILED(wil::reg::set_value_nothrow<T>(HKEY_LOCAL_MACHINE, keyName.c_str(), valueName.data(), value)))
@@ -142,6 +162,9 @@ namespace TranslucentFlyouts
142162
}
143163
else
144164
{
165+
#ifdef _DEBUG
166+
OutputDebugStringW(std::format(L"SetValueInternal - {}\n", keyName).c_str());
167+
#endif
145168
if constexpr (reverse)
146169
{
147170
if (FAILED(wil::reg::set_value_nothrow<T>(HKEY_LOCAL_MACHINE, keyName.c_str(), valueName.data(), value)))
@@ -158,6 +181,9 @@ namespace TranslucentFlyouts
158181
}
159182
}
160183
}
184+
#ifdef _DEBUG
185+
OutputDebugStringW(std::format(L"SetValueInternal = End\n", keyName).c_str());
186+
#endif
161187

162188
return S_OK;
163189
}

Common/SystemHelper.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ namespace TranslucentFlyouts::SystemHelper
6666
UCHAR SEHValidationPolicy : 2;
6767
UCHAR CurDirDevicesSkippedForDlls : 2;
6868
UCHAR Reserved : 2;
69+
#pragma warning(suppress : 4201)
6970
};
7071
};
7172
USHORT CyclesPerYield;
@@ -82,6 +83,7 @@ namespace TranslucentFlyouts::SystemHelper
8283
{
8384
UCHAR ArchStartedInEl2 : 1;
8485
UCHAR QcSlIsSupported : 1;
86+
#pragma warning(suppress : 4201)
8587
};
8688
};
8789
UCHAR Reserved12[2];
@@ -102,6 +104,7 @@ namespace TranslucentFlyouts::SystemHelper
102104
ULONG DbgMultiUsersInSessionSku : 1;
103105
ULONG DbgStateSeparationEnabled : 1;
104106
ULONG SpareBits : 21;
107+
#pragma warning(suppress : 4201)
105108
} DUMMYSTRUCTNAME2;
106109
} DUMMYUNIONNAME2;
107110
ULONG DataFlagsPad[1];
@@ -118,6 +121,7 @@ namespace TranslucentFlyouts::SystemHelper
118121
{
119122
ULONG ReservedTickCountOverlay[3];
120123
ULONG TickCountPad[1];
124+
#pragma warning(suppress : 4201)
121125
} DUMMYSTRUCTNAME;
122126
} DUMMYUNIONNAME3;
123127
ULONG Cookie;
@@ -149,6 +153,7 @@ namespace TranslucentFlyouts::SystemHelper
149153
{
150154
UCHAR QpcBypassEnabled;
151155
UCHAR QpcShift;
156+
#pragma warning(suppress : 4201)
152157
};
153158
};
154159
LARGE_INTEGER TimeZoneBiasEffectiveStart;

Common/ThemeHelper.hpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22
#include "Utils.hpp"
3+
#pragma warning(push)
4+
#pragma warning(disable : 4505)
35

46
namespace TranslucentFlyouts
57
{
@@ -21,14 +23,14 @@ namespace TranslucentFlyouts
2123
s_actualSetSystemVisualStyle(themeFileName, colorScheme, canonicalName, 0);
2224
}
2325

24-
static bool IsHighContrast()
26+
__forceinline bool IsHighContrast()
2527
{
2628
HIGHCONTRASTW hc{sizeof(hc)};
2729
SystemParametersInfoW(SPI_GETHIGHCONTRAST, sizeof(HIGHCONTRAST), &hc, 0);
2830
return hc.dwFlags & HCF_HIGHCONTRASTON;
2931
}
3032

31-
static bool ShouldAppsUseDarkMode()
33+
__forceinline bool ShouldAppsUseDarkMode()
3234
{
3335
static const auto s_actualShouldAppsUseDarkMode{reinterpret_cast<bool(WINAPI*)()>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(132)))};
3436

@@ -40,7 +42,7 @@ namespace TranslucentFlyouts
4042
return false;
4143
}
4244

43-
static bool ShouldSystemUseDarkMode()
45+
__forceinline bool ShouldSystemUseDarkMode()
4446
{
4547
static const auto s_actualShouldSystemUseDarkMode{ reinterpret_cast<bool(WINAPI*)()>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(138))) };
4648

@@ -52,7 +54,7 @@ namespace TranslucentFlyouts
5254
return false;
5355
}
5456

55-
static bool IsDarkModeAllowedForApp()
57+
__forceinline bool IsDarkModeAllowedForApp()
5658
{
5759
static const auto s_actualIsDarkModeAllowedForApp{ reinterpret_cast<bool(WINAPI*)()>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(139))) };
5860

@@ -64,7 +66,7 @@ namespace TranslucentFlyouts
6466
return false;
6567
}
6668

67-
static bool IsDarkModeAllowedForWindow(HWND hWnd)
69+
__forceinline bool IsDarkModeAllowedForWindow(HWND hWnd)
6870
{
6971
static const auto s_actualIsDarkModeAllowedForWindow{ reinterpret_cast<bool(WINAPI*)(HWND)>(GetProcAddress(GetModuleHandleW(L"UxTheme.dll"), MAKEINTRESOURCEA(137))) };
7072

@@ -76,7 +78,7 @@ namespace TranslucentFlyouts
7678
return false;
7779
}
7880

79-
static HRESULT GetThemeClass(HTHEME hTheme, LPCWSTR pszClassIdList, int cchClass)
81+
__forceinline HRESULT GetThemeClass(HTHEME hTheme, LPCWSTR pszClassIdList, int cchClass)
8082
{
8183
static const auto s_actualGetThemeClass{reinterpret_cast<HRESULT(WINAPI*)(HTHEME, LPCWSTR, int)>(GetProcAddress(GetModuleHandleW(L"UxTheme"), MAKEINTRESOURCEA(74)))};
8284

@@ -88,7 +90,7 @@ namespace TranslucentFlyouts
8890
return E_FAIL;
8991
}
9092

91-
static HRESULT DrawTextWithGlow(
93+
__forceinline HRESULT DrawTextWithGlow(
9294
HDC hdc,
9395
LPCWSTR pszText,
9496
int cchText,
@@ -168,7 +170,7 @@ namespace TranslucentFlyouts
168170
callback(memoryDC, bufferedPaint, buffer, cxRow);
169171
}
170172

171-
updateTarget = TRUE;
173+
updateTarget = static_cast<BOOL>(update);
172174
}
173175

174176
return S_OK;
@@ -245,7 +247,7 @@ namespace TranslucentFlyouts
245247
return S_OK;
246248
}
247249

248-
static bool IsOemBitmap(HBITMAP bitmap)
250+
__forceinline bool IsOemBitmap(HBITMAP bitmap)
249251
{
250252
bool result{false};
251253

@@ -307,4 +309,5 @@ namespace TranslucentFlyouts
307309
return argb;
308310
}
309311
}
310-
}
312+
}
313+
#pragma warning(pop)

Common/Utils.hpp

+26-29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <winrt/base.h>
66
#pragma warning(push)
77
#pragma warning(disable : 6388)
8+
#pragma warning(disable : 4505)
89

910
namespace TranslucentFlyouts::Utils
1011
{
@@ -42,7 +43,7 @@ namespace TranslucentFlyouts::Utils
4243
return rf.fake_ptr;
4344
}
4445

45-
static auto to_error_wstring(HRESULT hr)
46+
__forceinline auto to_error_wstring(HRESULT hr)
4647
{
4748
return winrt::hresult_error{hr}.message();
4849
}
@@ -189,7 +190,7 @@ namespace TranslucentFlyouts::Utils
189190
return std::wstring{};
190191
}
191192

192-
static void CloakWindow(HWND hWnd, BOOL cloak)
193+
__forceinline void CloakWindow(HWND hWnd, BOOL cloak)
193194
{
194195
DwmSetWindowAttribute(hWnd, DWMWA_CLOAK, &cloak, sizeof(cloak));
195196
DwmTransitionOwnedWindow(hWnd, DWMTRANSITION_OWNEDWINDOW_REPOSITION);
@@ -322,7 +323,7 @@ namespace TranslucentFlyouts::Utils
322323
return argb >> 24;
323324
}
324325

325-
static std::array<UCHAR, 4> FromARGB(DWORD argb)
326+
__forceinline std::array<UCHAR, 4> FromARGB(DWORD argb)
326327
{
327328
UCHAR* colorBits{ reinterpret_cast<UCHAR*>(&argb) };
328329
return { colorBits[3], colorBits[2], colorBits[1], colorBits[0] };
@@ -331,42 +332,38 @@ namespace TranslucentFlyouts::Utils
331332
inline bool IsBitmapSupportAlpha(HBITMAP bitmap)
332333
{
333334
bool hasAlpha{ false };
334-
HRESULT hr
335+
[&hasAlpha, bitmap]()
335336
{
336-
[&]()
337-
{
338-
RETURN_HR_IF_NULL_EXPECTED(E_INVALIDARG, bitmap);
337+
RETURN_HR_IF_NULL_EXPECTED(E_INVALIDARG, bitmap);
339338

340-
BITMAPINFO bitmapInfo{ sizeof(bitmapInfo.bmiHeader) };
341-
auto hdc{ wil::GetDC(nullptr) };
342-
RETURN_LAST_ERROR_IF_NULL(hdc);
339+
BITMAPINFO bitmapInfo{ sizeof(bitmapInfo.bmiHeader) };
340+
auto hdc{ wil::GetDC(nullptr) };
341+
RETURN_LAST_ERROR_IF_NULL(hdc);
343342

344-
RETURN_HR_IF_EXPECTED(E_INVALIDARG, GetObjectType(bitmap) != OBJ_BITMAP);
345-
RETURN_LAST_ERROR_IF(GetDIBits(hdc.get(), bitmap, 0, 0, nullptr, &bitmapInfo, DIB_RGB_COLORS) == 0);
343+
RETURN_HR_IF_EXPECTED(E_INVALIDARG, GetObjectType(bitmap) != OBJ_BITMAP);
344+
RETURN_LAST_ERROR_IF(GetDIBits(hdc.get(), bitmap, 0, 0, nullptr, &bitmapInfo, DIB_RGB_COLORS) == 0);
346345

347-
bitmapInfo.bmiHeader.biCompression = BI_RGB;
348-
auto pixelBits{ std::make_unique<UCHAR[]>(bitmapInfo.bmiHeader.biSizeImage) };
346+
bitmapInfo.bmiHeader.biCompression = BI_RGB;
347+
auto pixelBits{ std::make_unique<UCHAR[]>(bitmapInfo.bmiHeader.biSizeImage) };
349348

350-
RETURN_LAST_ERROR_IF(GetDIBits(hdc.get(), bitmap, 0, bitmapInfo.bmiHeader.biHeight, pixelBits.get(), &bitmapInfo, DIB_RGB_COLORS) == 0);
349+
RETURN_LAST_ERROR_IF(GetDIBits(hdc.get(), bitmap, 0, bitmapInfo.bmiHeader.biHeight, pixelBits.get(), &bitmapInfo, DIB_RGB_COLORS) == 0);
351350

352-
if (bitmapInfo.bmiHeader.biBitCount != 32)
353-
{
354-
return S_OK;
355-
}
351+
if (bitmapInfo.bmiHeader.biBitCount != 32)
352+
{
353+
return S_OK;
354+
}
356355

357-
for (size_t i = 0; i < bitmapInfo.bmiHeader.biSizeImage; i += 4)
356+
for (size_t i = 0; i < bitmapInfo.bmiHeader.biSizeImage; i += 4)
357+
{
358+
if (pixelBits[i + 3] != 0)
358359
{
359-
if (pixelBits[i + 3] != 0)
360-
{
361-
hasAlpha = true;
362-
break;
363-
}
360+
hasAlpha = true;
361+
break;
364362
}
365-
366-
return S_OK;
367363
}
368-
()
369-
};
364+
365+
return S_OK;
366+
}();
370367

371368
return hasAlpha;
372369
}

TFMain/ApiEx.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void Api::ApplyEffect(HWND hWnd, bool darkMode, const WindowBackdropEffectContex
1818

1919
void Api::ApplyBorderEffect(HWND hWnd, bool darkMode, const BorderContext& border)
2020
{
21+
EffectHelper::EnableWindowDarkMode(hWnd, darkMode);
2122
if (SystemHelper::g_buildNumber >= 22000)
2223
{
2324
if (border.cornerType != DWM_WINDOW_CORNER_PREFERENCE::DWMWCP_DEFAULT)

0 commit comments

Comments
 (0)