[Workspaces]Fix snapshotting minimized apps (#37598)

* Fix snapshotting minimized packaged apps

* Fix window arranger to work with the same windows as the snapshot tool.

* spell checker

* optimising code

* Remove filter condition.
This commit is contained in:
Laszlo Nemeth
2025-03-18 12:21:40 +01:00
committed by GitHub
parent 8e90d8e4c5
commit 18a1107ec4
3 changed files with 34 additions and 11 deletions

View File

@@ -52,6 +52,11 @@ namespace SnapshotUtils
for (const auto window : windows) for (const auto window : windows)
{ {
if (WindowFilter::FilterPopup(window))
{
continue;
}
// filter by window rect size // filter by window rect size
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)
@@ -93,7 +98,7 @@ namespace SnapshotUtils
continue; continue;
} }
// fix for the packaged apps that are not caught when minimized, e.g., Settings. // fix for the packaged apps that are not caught when minimized, e.g. Settings, Microsoft ToDo, ...
if (processPath.ends_with(NonLocalizable::ApplicationFrameHost)) if (processPath.ends_with(NonLocalizable::ApplicationFrameHost))
{ {
for (auto otherWindow : windows) for (auto otherWindow : windows)
@@ -110,11 +115,6 @@ namespace SnapshotUtils
} }
} }
if (WindowFilter::FilterPopup(window))
{
continue;
}
auto data = Utils::Apps::GetApp(processPath, pid, installedApps); auto data = Utils::Apps::GetApp(processPath, pid, installedApps);
if (!data.has_value() || data->name.empty()) if (!data.has_value() || data->name.empty())
{ {

View File

@@ -14,6 +14,11 @@
#include <WindowProperties/WorkspacesWindowPropertyUtils.h> #include <WindowProperties/WorkspacesWindowPropertyUtils.h>
#include <WorkspacesLib/PwaHelper.h> #include <WorkspacesLib/PwaHelper.h>
namespace NonLocalizable
{
const std::wstring ApplicationFrameHost = L"ApplicationFrameHost.exe";
}
namespace PlacementHelper namespace PlacementHelper
{ {
// When calculating the coordinates difference (== 'distance') between 2 windows, there are additional values added to the real distance // When calculating the coordinates difference (== 'distance') between 2 windows, there are additional values added to the real distance
@@ -157,6 +162,11 @@ std::optional<WindowWithDistance> WindowArranger::GetNearestWindow(const Workspa
for (HWND window : m_windowsBefore) for (HWND window : m_windowsBefore)
{ {
if (WindowFilter::FilterPopup(window))
{
continue;
}
if (std::find(movedWindows.begin(), movedWindows.end(), window) != movedWindows.end()) if (std::find(movedWindows.begin(), movedWindows.end(), window) != movedWindows.end())
{ {
continue; continue;
@@ -170,6 +180,24 @@ std::optional<WindowWithDistance> WindowArranger::GetNearestWindow(const Workspa
DWORD pid{}; DWORD pid{};
GetWindowThreadProcessId(window, &pid); GetWindowThreadProcessId(window, &pid);
std::wstring title = WindowUtils::GetWindowTitle(window);
// fix for the packaged apps that are not caught when minimized, e.g. Settings, Microsoft ToDo, ...
if (processPath.ends_with(NonLocalizable::ApplicationFrameHost))
{
for (auto otherWindow : m_windowsBefore)
{
DWORD otherPid{};
GetWindowThreadProcessId(otherWindow, &otherPid);
// searching for the window with the same title but different PID
if (pid != otherPid && title == WindowUtils::GetWindowTitle(otherWindow))
{
processPath = get_process_path(otherPid);
break;
}
}
}
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())

View File

@@ -50,11 +50,6 @@ namespace WindowFilter
return false; return false;
} }
if (WindowFilter::FilterPopup(window))
{
return false;
}
if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window)) if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window))
{ {
return false; return false;