Skip to content

Commit

Permalink
提高稳定性和修复Notepad++外壳扩展引起的渲染BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTaleX531 committed Aug 11, 2023
1 parent 85408ae commit 49d36ae
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/TFMain/Debug/VC-LTL5.tmp/10.0.10240.0/Win32
/TFMain/x64
/TFMain/x86/Debug
/TFMain/Release/VC-LTL5.tmp/10.0.10240.0/Win32
/TFMain/x86/Release
7 changes: 2 additions & 5 deletions TFMain/MenuAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ namespace TranslucentFlyouts::MenuAnimation
if (uMsg == MenuHandler::MN_SELECTITEM)
{
auto position{static_cast<int>(wParam)};
if (!((position & 0xFFFF'FFFF'FFFF'FFF0) == 0xFFFF'FFFF'FFFF'FFF0))
if (position != -1)
{
if (
RegHelper::GetDword(
Expand Down Expand Up @@ -1110,6 +1110,7 @@ namespace TranslucentFlyouts::MenuAnimation

DWORD WINAPI MenuAnimation::AnimationWorker::ThreadProc(LPVOID lpThreadParameter)
{
auto cleanUp{get_module_reference_for_thread()};
auto& animationWorker{*reinterpret_cast<AnimationWorker*>(lpThreadParameter)};

// We can use it to reuse thread
Expand Down Expand Up @@ -1165,7 +1166,6 @@ DWORD WINAPI MenuAnimation::AnimationWorker::ThreadProc(LPVOID lpThreadParameter
}
}

FreeLibraryAndExitThread(HINST_THISCOMPONENT, 0);
// We will never get here...
return 0;
}
Expand All @@ -1178,9 +1178,6 @@ void MenuAnimation::AnimationWorker::Schedule(shared_ptr<AnimationInfo> animatio
// We have no animation worker thread, create one
if (m_threadId == 0)
{
// Add ref count of current dll, in case it unloads while animation worker thread is still busy...
HMODULE moduleHandle{nullptr};
LOG_IF_WIN32_BOOL_FALSE(GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, reinterpret_cast<LPCWSTR>(HINST_THISCOMPONENT), &moduleHandle));
unique_handle threadHandle{CreateThread(nullptr, 0, ThreadProc, this, 0, &m_threadId)};
}
}
Expand Down
52 changes: 18 additions & 34 deletions TFMain/MenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,26 +146,18 @@ HRESULT MenuHandler::HandleSysBorderColors(std::wstring_view keyName, HWND hWnd,
DWORD borderColor{color};
if (!noBorderColor)
{
try
DWORD enableThemeColorization
{
DWORD enableThemeColorization
{
RegHelper::GetDword(
keyName,
L"EnableThemeColorization",
0
)
};
RegHelper::GetDword(
keyName,
L"EnableThemeColorization",
0
)
};

THROW_HR_IF(E_NOTIMPL, !enableThemeColorization);
THROW_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
}
catch (...)
if (enableThemeColorization)
{
if (ResultFromCaughtException() != E_NOTIMPL)
{
LOG_CAUGHT_EXCEPTION();
}
LOG_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
}

if (useDarkMode)
Expand Down Expand Up @@ -211,26 +203,18 @@ bool MenuHandler::HandlePopupMenuNCBorderColors(HDC hdc, bool useDarkMode, const
// Border color is enabled.
if (!noBorderColor)
{
try
DWORD enableThemeColorization
{
DWORD enableThemeColorization
{
RegHelper::GetDword(
L"Menu",
L"EnableThemeColorization",
0
)
};
RegHelper::GetDword(
L"Menu",
L"EnableThemeColorization",
0
)
};

THROW_HR_IF(E_NOTIMPL, !enableThemeColorization);
THROW_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
}
catch (...)
if (enableThemeColorization)
{
if (ResultFromCaughtException() != E_NOTIMPL)
{
LOG_CAUGHT_EXCEPTION();
}
LOG_IF_FAILED(Utils::GetDwmThemeColor(borderColor));
}

if (useDarkMode)
Expand Down
2 changes: 2 additions & 0 deletions TFMain/TFMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const array g_blockList
L"spoolsv.exe"sv,
L"dllhost.exe"sv,
L"svchost.exe"sv,
L"searchhost.exe"sv,
L"taskhostw.exe"sv,
L"searchhost.exe"sv,
L"RuntimeBroker.exe"sv,
Expand All @@ -26,6 +27,7 @@ const array g_blockList
L"ShellExperienceHost.exe"sv,
L"StartMenuExperienceHost.exe"sv,
L"msedgewebview2.exe"sv,
L"Microsoft.SharePoint.exe"sv,
// For compatibility issues
L"StartAllBackX64.dll"sv
};
Expand Down
10 changes: 9 additions & 1 deletion TFMain/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,19 @@ HRESULT WINAPI Install() try
WCHAR modulePath[MAX_PATH + 1] {};
RETURN_LAST_ERROR_IF(!GetModuleFileName(HINST_THISCOMPONENT, modulePath, MAX_PATH));

#ifdef _WIN64
THROW_IF_FAILED(
execAction->put_Path(
const_cast<BSTR>(L"Rundll32")
const_cast<BSTR>(L"C:\\Windows\\System32\\Rundll32.exe")
)
);
#else
THROW_IF_FAILED(
execAction->put_Path(
const_cast<BSTR>(L"C:\\Windows\\SysWOW64\\Rundll32.exe")
)
);
#endif
THROW_IF_FAILED(
execAction->put_Arguments(
const_cast<BSTR>(
Expand Down

0 comments on commit 49d36ae

Please sign in to comment.