c33a97955f
This PR adds a sample monarch/peasant application. This is a type of application where a single "Monarch" can coordinate the actions of multiple other "Peasant" processes, as described by the specs in #7240 and #8135. This project is intended to be a standalone sample of how the architecture would work, without involving the entirety of the Windows Terminal build. Eventually, this architecture will be incorporated into `wt.exe` itself, to enable scenarios like: * Run `wt` in the current window (#4472) * Single Instance Mode (#2227) For an example of this sample running, see the below GIF: ![monarch-peasant-sample-001](https://user-images.githubusercontent.com/18356694/98262202-f39b1500-1f4a-11eb-9220-4af4d922339f.gif) This sample operates largely by printing to the console, to help the reader understand how it's working through its logic. I'm doing this mostly so we can have a _committed_ sample of this type of application, kinda like how VtPipeTerm is a sample ConPTY application. It's a lot easier to understand (& build on) when there aren't any window shenanigans, settings loading, Island instantiation, or anything else that the whole of `WindowsTerminal.exe` needs * [x] I work here * [x] This is sample code, so I'm not shipping tests for it. * [x] Go see the doc over in #8135
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "Monarch.g.h"
|
|
#include "SamplePeasant.h"
|
|
#include "../cascadia/inc/cppwinrt_utils.h"
|
|
|
|
// {50dba6cd-2222-4b12-8363-5e06f5d0082c}
|
|
constexpr GUID Monarch_clsid{
|
|
0x50dba6cd,
|
|
0x2222,
|
|
0x4b12,
|
|
{ 0x83, 0x63, 0x5e, 0x06, 0xf5, 0xd0, 0x08, 0x2c }
|
|
};
|
|
|
|
enum class WindowingBehavior : uint64_t
|
|
{
|
|
UseNew = 0,
|
|
UseExisting = 1,
|
|
};
|
|
|
|
namespace winrt::MonarchPeasantSample::implementation
|
|
{
|
|
struct Monarch : public MonarchT<Monarch>
|
|
{
|
|
Monarch();
|
|
~Monarch();
|
|
|
|
uint64_t GetPID();
|
|
|
|
uint64_t AddPeasant(winrt::MonarchPeasantSample::IPeasant peasant);
|
|
|
|
void SetSelfID(const uint64_t selfID);
|
|
|
|
bool ProposeCommandline(array_view<const winrt::hstring> args, winrt::hstring cwd);
|
|
void ToggleWindowingBehavior();
|
|
|
|
private:
|
|
uint64_t _nextPeasantID{ 1 };
|
|
uint64_t _thisPeasantID{ 0 };
|
|
uint64_t _mostRecentPeasant{ 0 };
|
|
WindowingBehavior _windowingBehavior{ WindowingBehavior::UseNew };
|
|
std::unordered_map<uint64_t, winrt::MonarchPeasantSample::IPeasant> _peasants;
|
|
|
|
winrt::MonarchPeasantSample::IPeasant _getPeasant(uint64_t peasantID);
|
|
void _setMostRecentPeasant(const uint64_t peasantID);
|
|
|
|
void _peasantWindowActivated(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
};
|
|
}
|
|
|
|
namespace winrt::MonarchPeasantSample::factory_implementation
|
|
{
|
|
struct Monarch : MonarchT<Monarch, implementation::Monarch>
|
|
{
|
|
};
|
|
}
|