Adds support for two new actions: * `globalSummon`, which can be used to activate a window using a _global_ (READ: OS-level) hotkey. - accepts an optional `name` argument. When provided, this will attempt to summon with the given name. When omitted, we'll try to summon the most recent window. * `quakeMode` which is `globalSummon` for the `_quake` window. These actions are stored in the actions array, but are read by the `WindowsTerminal` level and bound to the OS in `IslandWindow`. The monarch registers for these keybindings with the OS. When one is pressed, the monarch will recieve a `WM_HOTKEY` message. It'll use that to look up the corresponding action args. It'll use those to try and summon the right window. ## References * #8888: Quake mode megathread * #9274: Spec (**guys seriously i just need one more ✔️**) * #9785: The start of granting "\_quake" super powers ## PR Checklist * [x] Closes #653 - I'm gonna say this closes it for now, though we have _many_ follow-ups in #8888 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed * Validated that it works with `win` keys * Validated that it works without `win` keys * Validated that it hot-reloads * Validated that it moves to the new monarch * Validated that you can bind both `globalSummon` and `quakeMode` at the same time and do different things * Validated that you can bind `globalSummon` with a name and it creates that name if it doesn't already exist
95 lines
3.5 KiB
C++
95 lines
3.5 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
#include "Monarch.g.h"
|
|
#include "Peasant.h"
|
|
#include "../cascadia/inc/cppwinrt_utils.h"
|
|
#include "WindowActivatedArgs.h"
|
|
|
|
// We sure different GUIDs here depending on whether we're running a Release,
|
|
// Preview, or Dev build. This ensures that different installs don't
|
|
// accidentally talk to one another.
|
|
//
|
|
// * Release: {06171993-7eb1-4f3e-85f5-8bdd7386cce3}
|
|
// * Preview: {04221993-7eb1-4f3e-85f5-8bdd7386cce3}
|
|
// * Dev: {08302020-7eb1-4f3e-85f5-8bdd7386cce3}
|
|
constexpr GUID Monarch_clsid
|
|
{
|
|
#if defined(WT_BRANDING_RELEASE)
|
|
0x06171993,
|
|
#elif defined(WT_BRANDING_PREVIEW)
|
|
0x04221993,
|
|
#else
|
|
0x08302020,
|
|
#endif
|
|
0x7eb1,
|
|
0x4f3e,
|
|
{
|
|
0x85, 0xf5, 0x8b, 0xdd, 0x73, 0x86, 0xcc, 0xe3
|
|
}
|
|
};
|
|
|
|
namespace RemotingUnitTests
|
|
{
|
|
class RemotingTests;
|
|
};
|
|
|
|
namespace winrt::Microsoft::Terminal::Remoting::implementation
|
|
{
|
|
struct Monarch : public MonarchT<Monarch>
|
|
{
|
|
Monarch();
|
|
~Monarch();
|
|
|
|
uint64_t GetPID();
|
|
|
|
uint64_t AddPeasant(winrt::Microsoft::Terminal::Remoting::IPeasant peasant);
|
|
|
|
winrt::Microsoft::Terminal::Remoting::ProposeCommandlineResult ProposeCommandline(const winrt::Microsoft::Terminal::Remoting::CommandlineArgs& args);
|
|
void HandleActivatePeasant(const winrt::Microsoft::Terminal::Remoting::WindowActivatedArgs& args);
|
|
void SummonWindow(const Remoting::SummonWindowSelectionArgs& args);
|
|
|
|
TYPED_EVENT(FindTargetWindowRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs);
|
|
|
|
private:
|
|
Monarch(const uint64_t testPID);
|
|
uint64_t _ourPID;
|
|
|
|
uint64_t _nextPeasantID{ 1 };
|
|
uint64_t _thisPeasantID{ 0 };
|
|
|
|
winrt::com_ptr<IVirtualDesktopManager> _desktopManager{ nullptr };
|
|
|
|
std::unordered_map<uint64_t, winrt::Microsoft::Terminal::Remoting::IPeasant> _peasants;
|
|
|
|
std::vector<Remoting::WindowActivatedArgs> _mruPeasants;
|
|
|
|
winrt::Microsoft::Terminal::Remoting::IPeasant _getPeasant(uint64_t peasantID);
|
|
uint64_t _getMostRecentPeasantID(bool limitToCurrentDesktop);
|
|
uint64_t _lookupPeasantIdForName(std::wstring_view name);
|
|
|
|
void _peasantWindowActivated(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Microsoft::Terminal::Remoting::WindowActivatedArgs& args);
|
|
void _doHandleActivatePeasant(const winrt::com_ptr<winrt::Microsoft::Terminal::Remoting::implementation::WindowActivatedArgs>& args);
|
|
void _clearOldMruEntries(const uint64_t peasantID);
|
|
|
|
void _forAllPeasantsIgnoringTheDead(std::function<void(const winrt::Microsoft::Terminal::Remoting::IPeasant&, const uint64_t)> callback,
|
|
std::function<void(const uint64_t)> errorCallback);
|
|
|
|
void _identifyWindows(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Windows::Foundation::IInspectable& args);
|
|
|
|
void _renameRequested(const winrt::Windows::Foundation::IInspectable& sender,
|
|
const winrt::Microsoft::Terminal::Remoting::RenameRequestArgs& args);
|
|
|
|
friend class RemotingUnitTests::RemotingTests;
|
|
};
|
|
}
|
|
|
|
namespace winrt::Microsoft::Terminal::Remoting::factory_implementation
|
|
{
|
|
BASIC_FACTORY(Monarch);
|
|
}
|