Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workspaces] Fix snapshotting minimized apps #37598

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/modules/Workspaces/WorkspacesSnapshotTool/SnapshotUtils.cpp
Original file line number Diff line number Diff line change
@@ -52,6 +52,11 @@ namespace SnapshotUtils

for (const auto window : windows)
{
if (WindowFilter::FilterPopup(window))
{
continue;
}

// filter by window rect size
RECT rect = WindowUtils::GetWindowRect(window);
if (rect.right - rect.left <= 0 || rect.bottom - rect.top <= 0)
@@ -93,7 +98,7 @@ namespace SnapshotUtils
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))
{
for (auto otherWindow : windows)
@@ -110,11 +115,6 @@ namespace SnapshotUtils
}
}

if (WindowFilter::FilterPopup(window))
{
continue;
}

auto data = Utils::Apps::GetApp(processPath, pid, installedApps);
if (!data.has_value() || data->name.empty())
{
28 changes: 28 additions & 0 deletions src/modules/Workspaces/WorkspacesWindowArranger/WindowArranger.cpp
Original file line number Diff line number Diff line change
@@ -14,6 +14,11 @@
#include <WindowProperties/WorkspacesWindowPropertyUtils.h>
#include <WorkspacesLib/PwaHelper.h>

namespace NonLocalizable
{
const std::wstring ApplicationFrameHost = L"ApplicationFrameHost.exe";
}

namespace PlacementHelper
{
// 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)
{
if (WindowFilter::FilterPopup(window))
{
continue;
}

if (std::find(movedWindows.begin(), movedWindows.end(), window) != movedWindows.end())
{
continue;
@@ -170,6 +180,24 @@ std::optional<WindowWithDistance> WindowArranger::GetNearestWindow(const Workspa

DWORD 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);
if (!data.has_value())
5 changes: 0 additions & 5 deletions src/modules/Workspaces/workspaces-common/WindowFilter.h
Original file line number Diff line number Diff line change
@@ -50,11 +50,6 @@ namespace WindowFilter
return false;
}

if (WindowFilter::FilterPopup(window))
{
return false;
}

if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window))
{
return false;
Loading
Oops, something went wrong.