mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
[Workspaces] Arranger: smart timer (#36096)
* [Workspaces] Add move functionality * spell checker * [Workspaces] Modify Arranger to move apps without launch * moved ipc helper * removed callback * use LauncherStatus in WindowArranger * wait for launching next app * launch in a separate thread and protect by mutexes * update app version in advance * changed canceling launch * increased waiting time * Fix optional parameter load from json * changed arranger waiting time * additional waiting time for Outlook * added app id * ensure ids before launch * set id in editor * minor updates * [Workspaces] Move: Get the nearest window when moving a window * [Workspaces] convert optional boolean to enum to avoid json problems * Handle case when the new Application Property "moveIfExists" does not exist * Re-implementing app-window pairing for moving feature. * spell checker * XAML formatting * Fixing bug: IPC message not arriving * spell checker * Removing app-level-setting for move app. Also fixed compiler errors due styling. * Updating editor window layout * Re-implementing window positioning UI elements * XAML formatting * Code review findings * Code cleanup * Code cleanup * Code cleanup * code cleanup * Code cleanup * Code cleanup * [Workspaces] Arranger: Reset wait timer after each successful arrange action * fix merge error --------- Co-authored-by: Seraphima <zykovas91@gmail.com> Co-authored-by: donlaci <donlaci@yahoo.com>
This commit is contained in:
@@ -313,7 +313,11 @@ WindowArranger::WindowArranger(WorkspacesData::WorkspacesProject project) :
|
|||||||
// process launching windows
|
// process launching windows
|
||||||
while (!m_launchingStatus.AllLaunched() && waitingTime < maxLaunchingWaitingTime)
|
while (!m_launchingStatus.AllLaunched() && waitingTime < maxLaunchingWaitingTime)
|
||||||
{
|
{
|
||||||
processWindows(false);
|
if (processWindows(false))
|
||||||
|
{
|
||||||
|
waitingTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
||||||
waitingTime += ms;
|
waitingTime += ms;
|
||||||
}
|
}
|
||||||
@@ -340,8 +344,9 @@ WindowArranger::WindowArranger(WorkspacesData::WorkspacesProject project) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowArranger::processWindows(bool processAll)
|
bool WindowArranger::processWindows(bool processAll)
|
||||||
{
|
{
|
||||||
|
bool processedAnyWindow = false;
|
||||||
std::vector<HWND> windows = WindowEnumerator::Enumerate(WindowFilter::Filter);
|
std::vector<HWND> windows = WindowEnumerator::Enumerate(WindowFilter::Filter);
|
||||||
|
|
||||||
if (!processAll)
|
if (!processAll)
|
||||||
@@ -353,27 +358,29 @@ void WindowArranger::processWindows(bool processAll)
|
|||||||
|
|
||||||
for (HWND window : windows)
|
for (HWND window : windows)
|
||||||
{
|
{
|
||||||
processWindow(window);
|
processedAnyWindow |= processWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return processedAnyWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowArranger::processWindow(HWND window)
|
bool WindowArranger::processWindow(HWND window)
|
||||||
{
|
{
|
||||||
if (m_launchingStatus.IsWindowProcessed(window))
|
if (m_launchingStatus.IsWindowProcessed(window))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RECT rect = WindowUtils::GetWindowRect(window);
|
RECT rect = WindowUtils::GetWindowRect(window);
|
||||||
if (rect.right - rect.left <= 0 || rect.bottom - rect.top <= 0)
|
if (rect.right - rect.left <= 0 || rect.bottom - rect.top <= 0)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring processPath = get_process_path(window);
|
std::wstring processPath = get_process_path(window);
|
||||||
if (processPath.empty())
|
if (processPath.empty())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD pid{};
|
DWORD pid{};
|
||||||
@@ -382,7 +389,7 @@ void WindowArranger::processWindow(HWND window)
|
|||||||
auto data = Utils::Apps::GetApp(processPath, pid, m_installedApps);
|
auto data = Utils::Apps::GetApp(processPath, pid, m_installedApps);
|
||||||
if (!data.has_value())
|
if (!data.has_value())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& apps = m_launchingStatus.Get();
|
const auto& apps = m_launchingStatus.Get();
|
||||||
@@ -395,7 +402,7 @@ void WindowArranger::processWindow(HWND window)
|
|||||||
if (iter == apps.end())
|
if (iter == apps.end())
|
||||||
{
|
{
|
||||||
Logger::info(L"Skip {}", processPath);
|
Logger::info(L"Skip {}", processPath);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moveWindow(window, iter->first))
|
if (moveWindow(window, iter->first))
|
||||||
@@ -412,6 +419,7 @@ void WindowArranger::processWindow(HWND window)
|
|||||||
{
|
{
|
||||||
sendUpdatedState(state.value());
|
sendUpdatedState(state.value());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowArranger::moveWindow(HWND window, const WorkspacesData::WorkspacesProject::Application& app)
|
bool WindowArranger::moveWindow(HWND window, const WorkspacesData::WorkspacesProject::Application& app)
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ private:
|
|||||||
bool TryMoveWindow(const WorkspacesData::WorkspacesProject::Application& app, HWND windowToMove);
|
bool TryMoveWindow(const WorkspacesData::WorkspacesProject::Application& app, HWND windowToMove);
|
||||||
|
|
||||||
//void onWindowCreated(HWND window);
|
//void onWindowCreated(HWND window);
|
||||||
void processWindows(bool processAll);
|
bool processWindows(bool processAll);
|
||||||
void processWindow(HWND window);
|
bool processWindow(HWND window);
|
||||||
bool moveWindow(HWND window, const WorkspacesData::WorkspacesProject::Application& app);
|
bool moveWindow(HWND window, const WorkspacesData::WorkspacesProject::Application& app);
|
||||||
|
|
||||||
void receiveIpcMessage(const std::wstring& message);
|
void receiveIpcMessage(const std::wstring& message);
|
||||||
|
|||||||
Reference in New Issue
Block a user