minimized settings snap fix

This commit is contained in:
seraphima
2024-07-09 20:19:06 +02:00
parent cbedf45796
commit f93aa42b19
2 changed files with 25 additions and 14 deletions

View File

@@ -12,6 +12,11 @@
namespace SnapshotUtils
{
namespace NonLocalizable
{
const std::wstring ApplicationFrameHost = L"ApplicationFrameHost.exe";
}
class WbemHelper
{
public:
@@ -169,18 +174,37 @@ namespace SnapshotUtils
}
// filter by app path
std::wstring processPath = get_process_path_waiting_uwp(window);
std::wstring processPath = get_process_path(window);
if (processPath.empty() || WindowUtils::IsExcludedByDefault(window, processPath, title))
{
Logger::debug(L"Excluded by default: {}, {}", title, processPath);
continue;
}
DWORD pid{};
GetWindowThreadProcessId(window, &pid);
// fix for the packaged apps that are not caught when minimized, e.g., Settings.
if (processPath.ends_with(NonLocalizable::ApplicationFrameHost))
{
for (auto otherWindow : windows)
{
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, installedApps);
if (!data.has_value() || data->name.empty())
{
Logger::debug(L"Installed app not found: {}, {}", title, processPath);
continue;
}

View File

@@ -31,19 +31,6 @@ namespace WindowFilter
return false;
}
bool isPopup = WindowUtils::HasStyle(style, WS_POPUP);
bool hasThickFrame = WindowUtils::HasStyle(style, WS_THICKFRAME);
bool hasCaption = WindowUtils::HasStyle(style, WS_CAPTION);
bool hasMinimizeMaximizeButtons = WindowUtils::HasStyle(style, WS_MINIMIZEBOX) || WindowUtils::HasStyle(style, WS_MAXIMIZEBOX);
if (isPopup && !(hasThickFrame && (hasCaption || hasMinimizeMaximizeButtons)))
{
// popup windows we want to snap: e.g. Calculator, Telegram
// popup windows we don't want to snap: start menu, notification popup, tray window, etc.
// WS_CAPTION, WS_MINIMIZEBOX, WS_MAXIMIZEBOX are used for filtering out menus,
// e.g., in Edge "Running as admin" menu when creating a new PowerToys issue.
return false;
}
if (!VirtualDesktop::instance().IsWindowOnCurrentDesktop(window))
{
return false;