Skip to content

Commit

Permalink
[FancyZones]Set FancyZones process and main thread priority to Normal (
Browse files Browse the repository at this point in the history
  • Loading branch information
SeraphimaZykova committed Sep 19, 2023
1 parent e09839d commit bdf9a44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/fancyzones/FancyZones/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
return 0;
}

auto process = GetCurrentProcess();
if (!SetPriorityClass(process, NORMAL_PRIORITY_CLASS))
{
std::wstring err = get_last_error_or_default(GetLastError());
Logger::warn(L"Failed to set priority to FancyZones: {}", err);
}

std::wstring pid = std::wstring(lpCmdLine);
if (!pid.empty())
{
Expand Down
5 changes: 5 additions & 0 deletions src/modules/fancyzones/FancyZonesLib/FancyZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ struct FancyZones : public winrt::implements<FancyZones, IFancyZones, IFancyZone
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
})
{
if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL))
{
Logger::warn("Failed to set main thread priority");
}

this->disableModuleCallback = std::move(disableModuleCallbackFunction);

FancyZonesSettings::instance().LoadSettings();
Expand Down

0 comments on commit bdf9a44

Please sign in to comment.