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

Commit 49d36ae

Browse files
committed
提高稳定性和修复Notepad++外壳扩展引起的渲染BUG
1 parent 85408ae commit 49d36ae

File tree

5 files changed

+33
-40
lines changed

5 files changed

+33
-40
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
/TFMain/Debug/VC-LTL5.tmp/10.0.10240.0/Win32
99
/TFMain/x64
1010
/TFMain/x86/Debug
11+
/TFMain/Release/VC-LTL5.tmp/10.0.10240.0/Win32
12+
/TFMain/x86/Release

TFMain/MenuAnimation.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ namespace TranslucentFlyouts::MenuAnimation
812812
if (uMsg == MenuHandler::MN_SELECTITEM)
813813
{
814814
auto position{static_cast<int>(wParam)};
815-
if (!((position & 0xFFFF'FFFF'FFFF'FFF0) == 0xFFFF'FFFF'FFFF'FFF0))
815+
if (position != -1)
816816
{
817817
if (
818818
RegHelper::GetDword(
@@ -1110,6 +1110,7 @@ namespace TranslucentFlyouts::MenuAnimation
11101110

11111111
DWORD WINAPI MenuAnimation::AnimationWorker::ThreadProc(LPVOID lpThreadParameter)
11121112
{
1113+
auto cleanUp{get_module_reference_for_thread()};
11131114
auto& animationWorker{*reinterpret_cast<AnimationWorker*>(lpThreadParameter)};
11141115

11151116
// We can use it to reuse thread
@@ -1165,7 +1166,6 @@ DWORD WINAPI MenuAnimation::AnimationWorker::ThreadProc(LPVOID lpThreadParameter
11651166
}
11661167
}
11671168

1168-
FreeLibraryAndExitThread(HINST_THISCOMPONENT, 0);
11691169
// We will never get here...
11701170
return 0;
11711171
}
@@ -1178,9 +1178,6 @@ void MenuAnimation::AnimationWorker::Schedule(shared_ptr<AnimationInfo> animatio
11781178
// We have no animation worker thread, create one
11791179
if (m_threadId == 0)
11801180
{
1181-
// Add ref count of current dll, in case it unloads while animation worker thread is still busy...
1182-
HMODULE moduleHandle{nullptr};
1183-
LOG_IF_WIN32_BOOL_FALSE(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<LPCWSTR>(HINST_THISCOMPONENT), &moduleHandle));
11841181
unique_handle threadHandle{CreateThread(nullptr, 0, ThreadProc, this, 0, &m_threadId)};
11851182
}
11861183
}

TFMain/MenuHandler.cpp

+18-34
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,18 @@ HRESULT MenuHandler::HandleSysBorderColors(std::wstring_view keyName, HWND hWnd,
146146
DWORD borderColor{color};
147147
if (!noBorderColor)
148148
{
149-
try
149+
DWORD enableThemeColorization
150150
{
151-
DWORD enableThemeColorization
152-
{
153-
RegHelper::GetDword(
154-
keyName,
155-
L"EnableThemeColorization",
156-
0
157-
)
158-
};
151+
RegHelper::GetDword(
152+
keyName,
153+
L"EnableThemeColorization",
154+
0
155+
)
156+
};
159157

160-
THROW_HR_IF(E_NOTIMPL, !enableThemeColorization);
161-
THROW_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
162-
}
163-
catch (...)
158+
if (enableThemeColorization)
164159
{
165-
if (ResultFromCaughtException() != E_NOTIMPL)
166-
{
167-
LOG_CAUGHT_EXCEPTION();
168-
}
160+
LOG_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
169161
}
170162

171163
if (useDarkMode)
@@ -211,26 +203,18 @@ bool MenuHandler::HandlePopupMenuNCBorderColors(HDC hdc, bool useDarkMode, const
211203
// Border color is enabled.
212204
if (!noBorderColor)
213205
{
214-
try
206+
DWORD enableThemeColorization
215207
{
216-
DWORD enableThemeColorization
217-
{
218-
RegHelper::GetDword(
219-
L"Menu",
220-
L"EnableThemeColorization",
221-
0
222-
)
223-
};
208+
RegHelper::GetDword(
209+
L"Menu",
210+
L"EnableThemeColorization",
211+
0
212+
)
213+
};
224214

225-
THROW_HR_IF(E_NOTIMPL, !enableThemeColorization);
226-
THROW_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
227-
}
228-
catch (...)
215+
if (enableThemeColorization)
229216
{
230-
if (ResultFromCaughtException() != E_NOTIMPL)
231-
{
232-
LOG_CAUGHT_EXCEPTION();
233-
}
217+
LOG_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
234218
}
235219

236220
if (useDarkMode)

TFMain/TFMain.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const array g_blockList
1515
L"spoolsv.exe"sv,
1616
L"dllhost.exe"sv,
1717
L"svchost.exe"sv,
18+
L"searchhost.exe"sv,
1819
L"taskhostw.exe"sv,
1920
L"searchhost.exe"sv,
2021
L"RuntimeBroker.exe"sv,
@@ -26,6 +27,7 @@ const array g_blockList
2627
L"ShellExperienceHost.exe"sv,
2728
L"StartMenuExperienceHost.exe"sv,
2829
L"msedgewebview2.exe"sv,
30+
L"Microsoft.SharePoint.exe"sv,
2931
// For compatibility issues
3032
L"StartAllBackX64.dll"sv
3133
};

TFMain/dllmain.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ HRESULT WINAPI Install() try
9494
WCHAR modulePath[MAX_PATH + 1] {};
9595
RETURN_LAST_ERROR_IF(!GetModuleFileName(HINST_THISCOMPONENT, modulePath, MAX_PATH));
9696

97+
#ifdef _WIN64
9798
THROW_IF_FAILED(
9899
execAction->put_Path(
99-
const_cast<BSTR>(L"Rundll32")
100+
const_cast<BSTR>(L"C:\\Windows\\System32\\Rundll32.exe")
100101
)
101102
);
103+
#else
104+
THROW_IF_FAILED(
105+
execAction->put_Path(
106+
const_cast<BSTR>(L"C:\\Windows\\SysWOW64\\Rundll32.exe")
107+
)
108+
);
109+
#endif
102110
THROW_IF_FAILED(
103111
execAction->put_Arguments(
104112
const_cast<BSTR>(

0 commit comments

Comments
 (0)