mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
[Workspaces] Handle admin windows repositioning. (#34965)
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <WorkspacesLib/WorkspacesData.h>
|
||||
|
||||
#include <common/logger/logger.h>
|
||||
|
||||
namespace WorkspacesJsonUtils
|
||||
{
|
||||
inline std::vector<WorkspacesData::WorkspacesProject> Read(const std::wstring& fileName)
|
||||
{
|
||||
std::vector<WorkspacesData::WorkspacesProject> projects{};
|
||||
try
|
||||
{
|
||||
auto savedProjectsJson = json::from_file(fileName);
|
||||
if (savedProjectsJson.has_value())
|
||||
{
|
||||
auto savedProjects = WorkspacesData::WorkspacesListJSON::FromJson(savedProjectsJson.value());
|
||||
if (savedProjects.has_value())
|
||||
{
|
||||
projects = savedProjects.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception ex)
|
||||
{
|
||||
Logger::error("Error reading workspaces file. {}", ex.what());
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
inline void Write(const std::wstring& fileName, const std::vector<WorkspacesData::WorkspacesProject>& projects)
|
||||
{
|
||||
try
|
||||
{
|
||||
json::to_file(fileName, WorkspacesData::WorkspacesListJSON::ToJson(projects));
|
||||
}
|
||||
catch (std::exception ex)
|
||||
{
|
||||
Logger::error("Error writing workspaces file. {}", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
inline void Write(const std::wstring& fileName, const WorkspacesData::WorkspacesProject& project)
|
||||
{
|
||||
try
|
||||
{
|
||||
json::to_file(fileName, WorkspacesData::WorkspacesProjectJSON::ToJson(project));
|
||||
}
|
||||
catch (std::exception ex)
|
||||
{
|
||||
Logger::error("Error writing workspaces file. {}", ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,6 @@
|
||||
<ClCompile Include="SnapshotUtils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="JsonUtils.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="resource.base.h" />
|
||||
<ClInclude Include="SnapshotUtils.h" />
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="JsonUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SnapshotUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
#include <workspaces-common/GuidUtils.h>
|
||||
#include <workspaces-common/MonitorUtils.h>
|
||||
|
||||
#include <WorkspacesLib/JsonUtils.h>
|
||||
#include <WorkspacesLib/WorkspacesData.h>
|
||||
|
||||
#include <JsonUtils.h>
|
||||
#include <SnapshotUtils.h>
|
||||
|
||||
#include <common/utils/gpo.h>
|
||||
#include <common/utils/logger_helper.h>
|
||||
#include <common/utils/UnhandledExceptionHandler.h>
|
||||
|
||||
const std::wstring moduleName = L"Workspaces\\ProjectsSnapshotTool";
|
||||
const std::wstring moduleName = L"Workspaces\\WorkspacesSnapshotTool";
|
||||
const std::wstring internalPath = L"";
|
||||
|
||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdLine, int cmdShow)
|
||||
{
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::workspacesLauncherLoggerName);
|
||||
LoggerHelpers::init_logger(moduleName, internalPath, LogSettings::workspacesSnapshotToolLoggerName);
|
||||
InitUnhandledExceptionHandler();
|
||||
|
||||
if (powertoys_gpo::getConfiguredWorkspacesEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
|
||||
@@ -46,14 +46,6 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdLine, int cm
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::wstring fileName = WorkspacesData::WorkspacesFile();
|
||||
std::string cmdLineStr(cmdLine);
|
||||
if (!cmdLineStr.empty())
|
||||
{
|
||||
std::wstring fileNameParam(cmdLineStr.begin(), cmdLineStr.end());
|
||||
fileName = fileNameParam;
|
||||
}
|
||||
|
||||
// create new project
|
||||
time_t creationTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||
WorkspacesData::WorkspacesProject project{ .id = CreateGuidString(), .creationTime = creationTime };
|
||||
@@ -75,7 +67,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR cmdLine, int cm
|
||||
return monitorNumber;
|
||||
});
|
||||
|
||||
WorkspacesJsonUtils::Write(WorkspacesData::TempWorkspacesFile(), project);
|
||||
JsonUtils::Write(WorkspacesData::TempWorkspacesFile(), project);
|
||||
Logger::trace(L"WorkspacesProject {}:{} created", project.name, project.id);
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
Reference in New Issue
Block a user