mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-27 14:59:16 +08:00
[Workspaces] snapshot: fix coordinates for the minimized apps. (#35455)
This commit is contained in:
parent
f33855aaaa
commit
c3fe541139
@ -168,7 +168,7 @@ namespace SnapshotUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<WorkspacesData::WorkspacesProject::Application> GetApps(const std::function<unsigned int(HWND)> getMonitorNumberFromWindowHandle)
|
||||
std::vector<WorkspacesData::WorkspacesProject::Application> GetApps(const std::function<unsigned int(HWND)> getMonitorNumberFromWindowHandle, const std::function<WorkspacesData::WorkspacesProject::Monitor::MonitorRect(unsigned int)> getMonitorRect)
|
||||
{
|
||||
std::vector<WorkspacesData::WorkspacesProject::Application> apps{};
|
||||
|
||||
@ -249,6 +249,19 @@ namespace SnapshotUtils
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isMinimized = WindowUtils::IsMinimized(window);
|
||||
unsigned int monitorNumber = getMonitorNumberFromWindowHandle(window);
|
||||
|
||||
if (isMinimized)
|
||||
{
|
||||
// set the screen area as position, the values we get for the minimized windows are out of the screens' area
|
||||
WorkspacesData::WorkspacesProject::Monitor::MonitorRect monitorRect = getMonitorRect(monitorNumber);
|
||||
rect.left = monitorRect.left;
|
||||
rect.top = monitorRect.top;
|
||||
rect.right = monitorRect.left + monitorRect.width;
|
||||
rect.bottom = monitorRect.top + monitorRect.height;
|
||||
}
|
||||
|
||||
WorkspacesData::WorkspacesProject::Application app{
|
||||
.name = data.value().name,
|
||||
.title = title,
|
||||
@ -258,7 +271,7 @@ namespace SnapshotUtils
|
||||
.commandLineArgs = L"", // GetCommandLineArgs(pid, wbemHelper),
|
||||
.isElevated = IsProcessElevated(pid),
|
||||
.canLaunchElevated = data.value().canLaunchElevated,
|
||||
.isMinimized = WindowUtils::IsMinimized(window),
|
||||
.isMinimized = isMinimized,
|
||||
.isMaximized = WindowUtils::IsMaximized(window),
|
||||
.position = WorkspacesData::WorkspacesProject::Application::Position{
|
||||
.x = rect.left,
|
||||
@ -266,7 +279,7 @@ namespace SnapshotUtils
|
||||
.width = rect.right - rect.left,
|
||||
.height = rect.bottom - rect.top,
|
||||
},
|
||||
.monitor = getMonitorNumberFromWindowHandle(window),
|
||||
.monitor = monitorNumber,
|
||||
};
|
||||
|
||||
apps.push_back(app);
|
||||
|
@ -4,5 +4,5 @@
|
||||
|
||||
namespace SnapshotUtils
|
||||
{
|
||||
std::vector<WorkspacesData::WorkspacesProject::Application> GetApps(const std::function<unsigned int(HWND)> getMonitorNumberFromWindowHandle);
|
||||
std::vector<WorkspacesData::WorkspacesProject::Application> GetApps(const std::function<unsigned int(HWND)> getMonitorNumberFromWindowHandle, const std::function<WorkspacesData::WorkspacesProject::Monitor::MonitorRect(unsigned int)> getMonitorRect);
|
||||
};
|
||||
|
@ -65,7 +65,15 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdLine, int cm
|
||||
}
|
||||
|
||||
return monitorNumber;
|
||||
});
|
||||
}, [&](unsigned int monitorId) -> WorkspacesData::WorkspacesProject::Monitor::MonitorRect {
|
||||
for (const auto& monitor : project.monitors)
|
||||
{
|
||||
if (monitor.number == monitorId)
|
||||
{
|
||||
return monitor.monitorRectDpiUnaware;
|
||||
}
|
||||
}
|
||||
return project.monitors[0].monitorRectDpiUnaware; });
|
||||
|
||||
JsonUtils::Write(WorkspacesData::TempWorkspacesFile(), project);
|
||||
Logger::trace(L"WorkspacesProject {}:{} created", project.name, project.id);
|
||||
|
Loading…
Reference in New Issue
Block a user