Files
PowerToys/src/modules/Workspaces/WorkspacesLib/WorkspacesData.h
Laszlo Nemeth 6b3bbf7e8f [Workspaces] Implement PWA recognition, launch. (#35913)
* [Workspaces] PWA: first steps: implement PWA app searcher, add basic controls to the editor

* spell checker

* Snapshot tool: adding command line args for edge

* PWA: add icon handling, add launch of PWA

* Impllement Aumid getters and comparison to connect PWA windows and processes. Update LauncherUI, Launcher

* Minor fixes, simplifications

* Spell checker

* Removing manual PWA selection, spell checker

* Fix merge conflict

* Trying to convince spell checker, that "PEB" is a correct word.

* XAML format fix

* Extending snapshot tool by logs for better testablility

* spell checker fix

* extending logs

* extending logs

* Removing some logs, modifying search criteria for pwa helper process search

* extending PWA detection for the case the directory with the app-id is missing

* Fix issue when pwaAppId is null

* fix missing pwa-app-id handling in the editor. Removed unused property (code cleaning) and updating json parser in Launcher

* Code cleaning: Moving duplicate code to a common project

* Fix issue: adding new Guid as app id if it is empty

* Code cleanup: moving Pwa related code from snapshotUtils to PwaHelper

* Code cleaning

* Code cleanup: Move common Application model to Csharp Library

* code cleanup

* modifying package name

* Ading project reference to Common.UI

* Code cleaning, fixing references

---------

Co-authored-by: donlaci <donlaci@yahoo.com>
2024-11-20 20:15:18 +01:00

155 lines
4.5 KiB
C++

#pragma once
#include <common/utils/json.h>
#include <WorkspacesLib/LaunchingStateEnum.h>
namespace WorkspacesData
{
std::wstring WorkspacesFile();
std::wstring TempWorkspacesFile();
struct WorkspacesProject
{
struct Application
{
struct Position
{
int x;
int y;
int width;
int height;
RECT toRect() const noexcept;
auto operator<=>(const Position&) const = default;
};
std::wstring id;
std::wstring name;
std::wstring title;
std::wstring path;
std::wstring packageFullName;
std::wstring appUserModelId;
std::wstring pwaAppId;
std::wstring commandLineArgs;
bool isElevated{};
bool canLaunchElevated{};
bool isMinimized{};
bool isMaximized{};
Position position{};
unsigned int monitor{};
auto operator<=>(const Application&) const = default;
};
struct Monitor
{
struct MonitorRect
{
int top;
int left;
int width;
int height;
inline bool operator==(const MonitorRect& other) const noexcept
{
return top == other.top && left == other.left && width == other.width && height == other.height;
}
};
HMONITOR monitor{};
std::wstring id;
std::wstring instanceId;
unsigned int number{};
unsigned int dpi{};
MonitorRect monitorRectDpiAware{};
MonitorRect monitorRectDpiUnaware{};
};
std::wstring id;
std::wstring name;
time_t creationTime;
std::optional<time_t> lastLaunchedTime;
bool isShortcutNeeded;
bool moveExistingWindows;
std::vector<Monitor> monitors;
std::vector<Application> apps;
};
struct WorkspacesList
{
std::vector<WorkspacesProject> projects;
};
struct LaunchingAppState
{
WorkspacesData::WorkspacesProject::Application application;
HWND window{};
LaunchingState state { LaunchingState::Waiting };
};
using LaunchingAppStateMap = std::map<WorkspacesData::WorkspacesProject::Application, LaunchingAppState>;
using LaunchingAppStateList = std::vector<std::pair<WorkspacesData::WorkspacesProject::Application, LaunchingState>>;
struct AppLaunchData
{
LaunchingAppStateMap appsStateList;
int launcherProcessID = 0;
};
namespace WorkspacesProjectJSON
{
namespace ApplicationJSON
{
namespace PositionJSON
{
json::JsonObject ToJson(const WorkspacesProject::Application::Position& position);
std::optional<WorkspacesProject::Application::Position> FromJson(const json::JsonObject& json);
}
json::JsonObject ToJson(const WorkspacesProject::Application& data);
std::optional<WorkspacesProject::Application> FromJson(const json::JsonObject& json);
}
namespace MonitorJSON
{
namespace MonitorRectJSON
{
json::JsonObject ToJson(const WorkspacesProject::Monitor::MonitorRect& data);
std::optional<WorkspacesProject::Monitor::MonitorRect> FromJson(const json::JsonObject& json);
}
json::JsonObject ToJson(const WorkspacesProject::Monitor& data);
std::optional<WorkspacesProject::Monitor> FromJson(const json::JsonObject& json);
}
json::JsonObject ToJson(const WorkspacesProject& data);
std::optional<WorkspacesProject> FromJson(const json::JsonObject& json);
}
namespace WorkspacesListJSON
{
json::JsonObject ToJson(const std::vector<WorkspacesProject>& data);
std::optional<std::vector<WorkspacesProject>> FromJson(const json::JsonObject& json);
}
namespace AppLaunchInfoJSON
{
json::JsonObject ToJson(const LaunchingAppState& data);
std::optional<LaunchingAppState> FromJson(const json::JsonObject& json);
}
namespace AppLaunchInfoListJSON
{
json::JsonObject ToJson(const LaunchingAppStateMap& data);
std::optional<LaunchingAppStateMap> FromJson(const json::JsonObject& json);
}
namespace AppLaunchDataJSON
{
json::JsonObject ToJson(const AppLaunchData& data);
}
};