Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add property to control dropdown speed of global summon #9977

Merged
merged 112 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
3bef7bb
Get all the projects created and hooked up to the sln
zadjii-msft Dec 16, 2020
1f52d35
Yank all the M/P files, this builds?!
zadjii-msft Dec 16, 2020
5a9cdc8
Shockingly, this works, it works elevated, and it works unpackaged
zadjii-msft Dec 16, 2020
36539cf
This won't work, but I'm committing this becaus I finally got it to c…
zadjii-msft Dec 16, 2020
27ace16
whoop, we pass the commandline from the peasant, to the monarch, and …
zadjii-msft Dec 16, 2020
9a41647
HOLY SHIT I GOT THE COMANDLINE TO EXECUTE IN THE CURRENT WINDOW!!!!!!…
zadjii-msft Dec 17, 2020
5cabcfb
add a note to future me
zadjii-msft Dec 17, 2020
03bfc6e
This works as a unittest, but not a local test. That's batty
zadjii-msft Dec 17, 2020
590b9ff
this macro makes me feel dirty
zadjii-msft Dec 17, 2020
0579b24
LocalTests_Remoting -> UnitTests_Remoting
zadjii-msft Dec 17, 2020
a3faed6
finish renaming this test
zadjii-msft Dec 17, 2020
9c6eac4
Clean up a lot for review
zadjii-msft Dec 17, 2020
0103331
cleanup Peasant for review
zadjii-msft Dec 17, 2020
b4fe1bf
Final cleanup for review
zadjii-msft Dec 17, 2020
d08e65c
_final_ final cleanup for review
zadjii-msft Dec 17, 2020
e101efd
pr nits
zadjii-msft Dec 18, 2020
e1402d8
This seems to work to create a thread listening for the monarch, and …
zadjii-msft Dec 18, 2020
f978a9c
it's hard to believe he's gone / were it so easy
zadjii-msft Dec 18, 2020
5939636
Oh yea actually remove the thing
zadjii-msft Dec 18, 2020
c088895
last commit before the holidays
zadjii-msft Dec 18, 2020
fa2df47
Merge remote-tracking branch 'origin/main' into dev/migrie/f/remoting…
zadjii-msft Jan 5, 2021
0f5c24f
Enable audit mode
zadjii-msft Jan 5, 2021
921d915
nits
zadjii-msft Jan 5, 2021
00184e7
Merge branch 'dev/migrie/f/remoting.dll' into dev/migrie/f/the-first-…
zadjii-msft Jan 5, 2021
658db6b
Ask the TerminalApp to parse the commandline, and tell us what the wi…
zadjii-msft Jan 6, 2021
977db46
Holy bajesus, this works like a charm
zadjii-msft Jan 6, 2021
bcbef34
Add a note about commiting suicide
zadjii-msft Jan 6, 2021
813dbc6
notes, comments, cleanup
zadjii-msft Jan 6, 2021
0f0df5e
activate windows
zadjii-msft Jan 6, 2021
9fc2f0e
add some tracelogging
zadjii-msft Jan 6, 2021
6537686
The peasant will now correctly inform the monarch when it re-connects
zadjii-msft Jan 7, 2021
a75da0a
mostly just notes
zadjii-msft Jan 7, 2021
c02f25a
peasants now switch to the cwd that was requested
zadjii-msft Jan 7, 2021
3e39ab9
more comments
zadjii-msft Jan 7, 2021
52b2cb6
Allow the user to provide ids on the commandline
zadjii-msft Jan 7, 2021
bc492f1
Code cleanup
zadjii-msft Jan 7, 2021
88ffc6f
Merge remote-tracking branch 'origin/main' into dev/migrie/f/remoting…
zadjii-msft Jan 7, 2021
be74b2e
putting var in headers is bad, mkay?
zadjii-msft Jan 7, 2021
2a7bc94
branding
zadjii-msft Jan 7, 2021
81c09d9
Merge branch 'dev/migrie/f/remoting.dll' into dev/migrie/f/the-first-…
zadjii-msft Jan 8, 2021
c34e4ce
Merge remote-tracking branch 'origin/main' into dev/migrie/f/the-firs…
zadjii-msft Jan 8, 2021
5b8ace2
A bunch of tests for Monarch::ProposeCommandline
zadjii-msft Jan 8, 2021
689c385
sure yea that's a doc comment
zadjii-msft Jan 8, 2021
59deca1
Merge branch 'main' into dev/migrie/f/the-first-galactic-empire
zadjii-msft Jan 26, 2021
f02969b
More tests, more redundancy
zadjii-msft Jan 26, 2021
b2db317
man I can't spel
zadjii-msft Jan 26, 2021
d2a3438
Add try/catch's throughout Monarch.cpp
zadjii-msft Jan 27, 2021
a65f341
trycatch the window manager. A lot more going on there.
zadjii-msft Jan 27, 2021
1c2f8e5
This will always summon the monarch window
zadjii-msft Jan 28, 2021
71f6b58
RegisterHotKey will be more robust
zadjii-msft Jan 28, 2021
18d1a20
Add support for the `win` key in keybindings
zadjii-msft Jan 28, 2021
a41bee6
!!! THIS NEEDS TO BE MOVED TO THE PARENT BRANCH !!!
zadjii-msft Jan 28, 2021
6e7ea61
!!! THIS NEEDS TO BE MOVED TO THE PARENT BRANCH !!!
zadjii-msft Jan 28, 2021
18099d2
Summon the most recent window
zadjii-msft Jan 28, 2021
3e5d927
Cleanup, now that this isn't needed
zadjii-msft Jan 28, 2021
91b52d4
!!! THIS NEEDS TO BE MOVED TO THE PARENT BRANCH !!!
zadjii-msft Jan 28, 2021
848682a
Oh hey SetForegroundWindow might be the thing
zadjii-msft Jan 28, 2021
1dcb4cb
man this is crisp
zadjii-msft Jan 28, 2021
fee6473
Still trying to figure this out exactly. For linking: #653
zadjii-msft Jan 28, 2021
342d3f2
This works if the window _isn't_ minimized
zadjii-msft Jan 29, 2021
5052d31
deal with minimized windows too
zadjii-msft Jan 29, 2021
eff18d1
more cleanup
zadjii-msft Jan 29, 2021
5c039ea
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 12, 2021
10779ca
We caan now summon based on window name or just use the MRU one. Note…
zadjii-msft Apr 12, 2021
25b31ff
Allow the user to set multiple globalSummon keys, and quakeMode for s…
zadjii-msft Apr 12, 2021
7c2a514
if there is no window with the name, then make a new window with the …
zadjii-msft Apr 12, 2021
ac8fef0
THATS RIGHT, IT HOT-RELOADS
zadjii-msft Apr 12, 2021
1fdb6b1
Tests and doc comments
zadjii-msft Apr 14, 2021
784ec73
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 14, 2021
b20222f
More comments
zadjii-msft Apr 14, 2021
9d76c62
Some dead code cleanup
zadjii-msft Apr 14, 2021
2a2f5cb
pre emptive spellbot
zadjii-msft Apr 14, 2021
71577fc
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 16, 2021
f892752
Add some tracelogging to find a heisenbug that might not have ever be…
zadjii-msft Apr 16, 2021
4166afa
Okay that was bad pre-emptive spelling
zadjii-msft Apr 16, 2021
717db81
Again, nobody's got disk space to build x86. This is a guess
zadjii-msft Apr 19, 2021
1b2e7a7
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 19, 2021
305e627
oh man, this will magic summon the window to the current desktop. I'm…
zadjii-msft Apr 19, 2021
9f9eacb
!! THIS NEEDS TO GO TO THE PARENT BRANCH !!
zadjii-msft Apr 19, 2021
f71c948
Add support for summoning to the current virtual desktop
zadjii-msft Apr 19, 2021
51617cf
cache these results
zadjii-msft Apr 20, 2021
2eec961
All of carlos's feedback
zadjii-msft Apr 21, 2021
15a8a9c
!! THIS NEEDS TO GO TO THE PARENT BRANCH !!
zadjii-msft Apr 19, 2021
8370789
replace todo with comment
zadjii-msft Apr 21, 2021
4eb1d3a
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 23, 2021
c215a97
Merge branch 'dev/migrie/f/653-QUAKE-MODE' into dev/migrie/f/quake-to…
zadjii-msft Apr 23, 2021
26d5194
this test is _fantastic_
zadjii-msft Apr 23, 2021
91372ea
more tests, because I like being thorough
zadjii-msft Apr 23, 2021
045a8db
fix a build break
zadjii-msft Apr 23, 2021
c95a429
Give Clint the credit they deserce
zadjii-msft Apr 26, 2021
b5e0f2d
When the window is summoned and is already active, minimize it.
zadjii-msft Apr 26, 2021
6c4238b
Toggle the visibility with an optional argument
zadjii-msft Apr 26, 2021
0abd963
update the comment
zadjii-msft Apr 26, 2021
643b860
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 27, 2021
84c1bd9
Merge remote-tracking branch 'origin/main' into dev/migrie/f/quake-to…
zadjii-msft Apr 28, 2021
24bfbe6
BODGY fix for newer builds
zadjii-msft Apr 28, 2021
4c2e6d2
Merge remote-tracking branch 'origin/main' into dev/migrie/f/quake-to…
zadjii-msft Apr 28, 2021
aec2561
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 28, 2021
22036c2
Merge branch 'dev/migrie/f/653-QUAKE-MODE' into dev/migrie/f/quake-to…
zadjii-msft Apr 28, 2021
173720f
Add property to control dropdown speed of global summon
zadjii-msft Apr 28, 2021
b607a55
The OS has first dibs on animation settings
zadjii-msft Apr 28, 2021
63b3658
spel
zadjii-msft Apr 28, 2021
5940f05
Merge remote-tracking branch 'origin/main' into dev/migrie/f/653-QUAK…
zadjii-msft Apr 28, 2021
06cb41b
Address Dustin's PR comments
zadjii-msft Apr 28, 2021
783be75
Merge branch 'dev/migrie/f/653-QUAKE-MODE' into dev/migrie/f/quake-to…
zadjii-msft Apr 28, 2021
6c424f7
pr nits
zadjii-msft Apr 28, 2021
387d675
Merge branch 'dev/migrie/f/quake-toCurrent-desktop' into dev/migrie/f…
zadjii-msft Apr 28, 2021
f190576
Merge branch 'dev/migrie/f/quake-toggleVisibility' into dev/migrie/f/…
zadjii-msft Apr 28, 2021
960e1fa
Merge remote-tracking branch 'origin/main' into dev/migrie/f/quake-dr…
zadjii-msft Apr 29, 2021
caeb17f
Merge remote-tracking branch 'origin/main' into dev/migrie/f/quake-dr…
zadjii-msft May 13, 2021
2d7ed8d
Merge remote-tracking branch 'origin/main' into dev/migrie/f/quake-dr…
zadjii-msft May 17, 2021
f4c9993
Do the windowplacement thing
zadjii-msft May 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/spelling/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ HIGHCONTRASTON
HIGHCONTRASTW
hotkeys
href
hrgn
IActivation
IApp
IAppearance
Expand Down Expand Up @@ -77,6 +78,7 @@ NOASYNC
NOCHANGEDIR
NOPROGRESS
NOREDIRECTIONBITMAP
NOREPEAT
ntprivapi
oaidl
ocidl
Expand Down
30 changes: 30 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,33 @@ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

```

## `VirtualDesktopUtils`

**Source**: [https://github.com/microsoft/PowerToys](https://github.com/microsoft/PowerToys)

### License

```
The MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
12 changes: 12 additions & 0 deletions src/cascadia/Remoting/Microsoft.Terminal.RemotingLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<ClInclude Include="ProposeCommandlineResult.h">
<DependentUpon>Monarch.idl</DependentUpon>
</ClInclude>
<ClInclude Include="SummonWindowSelectionArgs.h">
<DependentUpon>Monarch.idl</DependentUpon>
</ClInclude>
<ClInclude Include="SummonWindowBehavior.h">
<DependentUpon>Peasant.idl</DependentUpon>
</ClInclude>
<ClInclude Include="RenameRequestArgs.h">
<DependentUpon>Peasant.idl</DependentUpon>
</ClInclude>
Expand Down Expand Up @@ -54,6 +60,12 @@
<ClCompile Include="ProposeCommandlineResult.cpp">
<DependentUpon>Monarch.idl</DependentUpon>
</ClCompile>
<ClCompile Include="SummonWindowSelectionArgs.cpp">
<DependentUpon>Monarch.idl</DependentUpon>
</ClCompile>
<ClCompile Include="SummonWindowBehavior.cpp">
<DependentUpon>Peasant.idl</DependentUpon>
</ClCompile>
<ClCompile Include="RenameRequestArgs.cpp">
<DependentUpon>Peasant.idl</DependentUpon>
</ClCompile>
Expand Down
52 changes: 51 additions & 1 deletion src/cascadia/Remoting/Monarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
continue;
}

if (peasant.WindowName() == L"_quake")
if (peasant.WindowName() == QuakeWindowName)
{
// The _quake window should never be treated as the MRU window.
// Skip it if we see it. Users can still target it with `wt -w
Expand Down Expand Up @@ -686,4 +686,54 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
}

// Method Description:
// - Attempt to summon a window. `args` contains information about which
// window we should try to summon:
// * if a WindowName is provided, we'll try to find a window with exactly
// that name, and fail if there isn't one.
// - Calls Peasant::Summon on the matching peasant (which might be an RPC call)
// - This should only ever be called by the WindowManager in the monarch
// process itself. The monarch is the one registering for global hotkeys,
// so it's the one calling this method.
// Arguments:
// - args: contains information about the window that should be summoned.
// Return Value:
// - <none>
// - Sets args.FoundMatch when a window matching args is found successfully.
void Monarch::SummonWindow(const Remoting::SummonWindowSelectionArgs& args)
{
const auto searchedForName{ args.WindowName() };
try
{
args.FoundMatch(false);
uint64_t windowId = 0;
// If no name was provided, then just summon the MRU window.
if (searchedForName.empty())
{
// Use the value of the `desktop` arg to determine if we should
// limit to the current desktop (desktop:onCurrent) or not
// (desktop:any or desktop:toCurrent)
windowId = _getMostRecentPeasantID(args.OnCurrentDesktop());
}
else
{
// Try to find a peasant that currently has this name
windowId = _lookupPeasantIdForName(searchedForName);
}
if (auto targetPeasant{ _getPeasant(windowId) })
{
targetPeasant.Summon(args.SummonBehavior());
args.FoundMatch(true);
}
}
catch (...)
{
LOG_CAUGHT_EXCEPTION();
TraceLoggingWrite(g_hRemotingProvider,
"Monarch_SummonWindow_Failed",
TraceLoggingWideString(searchedForName.c_str(), "searchedForName", "The name of the window we tried to summon"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));
}
}
}
1 change: 1 addition & 0 deletions src/cascadia/Remoting/Monarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation

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);

Expand Down
14 changes: 14 additions & 0 deletions src/cascadia/Remoting/Monarch.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,27 @@ namespace Microsoft.Terminal.Remoting
Boolean ShouldCreateWindow { get; }; // If you name this `CreateWindow`, the compiler will explode
}

[default_interface] runtimeclass SummonWindowSelectionArgs {
SummonWindowSelectionArgs();
SummonWindowSelectionArgs(String windowName);
String WindowName;
Boolean OnCurrentDesktop;
// TODO GH#8888 Other options:
// * CurrentMonitor

Boolean FoundMatch;
SummonWindowBehavior SummonBehavior;
}


[default_interface] runtimeclass Monarch {
Monarch();

UInt64 GetPID();
UInt64 AddPeasant(IPeasant peasant);
ProposeCommandlineResult ProposeCommandline(CommandlineArgs args);
void HandleActivatePeasant(WindowActivatedArgs args);
void SummonWindow(SummonWindowSelectionArgs args);

event Windows.Foundation.TypedEventHandler<Object, FindTargetWindowArgs> FindTargetWindowRequested;
};
Expand Down
23 changes: 23 additions & 0 deletions src/cascadia/Remoting/Peasant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "pch.h"
#include "Peasant.h"
#include "CommandlineArgs.h"
#include "SummonWindowBehavior.h"
#include "Peasant.g.cpp"
#include "../../types/inc/utils.hpp"

Expand Down Expand Up @@ -117,6 +118,28 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
return _lastActivatedArgs;
}

// Method Description:
// - Summon this peasant to become the active window. Currently, it just
// causes the peasant to become the active window wherever the window
// already was.
// - Will raise a SummonRequested event to ask the hosting window to handle for us.
// Arguments:
// - <none>
// Return Value:
// - <none>
void Peasant::Summon(const Remoting::SummonWindowBehavior& summonBehavior)
{
auto localCopy = winrt::make<implementation::SummonWindowBehavior>(summonBehavior);

TraceLoggingWrite(g_hRemotingProvider,
"Peasant_Summon",
TraceLoggingUInt64(GetID(), "peasantID", "Our ID"),
TraceLoggingUInt64(localCopy->MoveToCurrentDesktop(), "MoveToCurrentDesktop", "true if we should move to the current desktop"),
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE));

_SummonRequestedHandlers(*this, localCopy);
}

// Method Description:
// - Tell this window to display it's window ID. We'll raise a
// DisplayWindowIdRequested event, which will get handled in the AppHost,
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/Remoting/Peasant.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation

bool ExecuteCommandline(const winrt::Microsoft::Terminal::Remoting::CommandlineArgs& args);
void ActivateWindow(const winrt::Microsoft::Terminal::Remoting::WindowActivatedArgs& args);

void Summon(const Remoting::SummonWindowBehavior& summonBehavior);
void RequestIdentifyWindows();
void DisplayWindowId();
void RequestRename(const winrt::Microsoft::Terminal::Remoting::RenameRequestArgs& args);
Expand All @@ -37,6 +39,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
TYPED_EVENT(IdentifyWindowsRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(DisplayWindowIdRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
TYPED_EVENT(RenameRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::RenameRequestArgs);
TYPED_EVENT(SummonRequested, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Remoting::SummonWindowBehavior);

private:
Peasant(const uint64_t testPID);
Expand Down
16 changes: 14 additions & 2 deletions src/cascadia/Remoting/Peasant.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ namespace Microsoft.Terminal.Remoting
Windows.Foundation.DateTime ActivatedTime { get; };
};

[default_interface] runtimeclass SummonWindowBehavior {
SummonWindowBehavior();
Boolean MoveToCurrentDesktop;
Boolean ToggleVisibility;
UInt32 DropdownDuration;
// Other options:
// * CurrentMonitor
}

interface IPeasant
{
CommandlineArgs InitialArgs { get; };
Expand All @@ -40,17 +49,20 @@ namespace Microsoft.Terminal.Remoting
Boolean ExecuteCommandline(CommandlineArgs args);
void ActivateWindow(WindowActivatedArgs args);
WindowActivatedArgs GetLastActivatedArgs();
String WindowName { get; };
void RequestIdentifyWindows(); // Tells us to raise a IdentifyWindowsRequested

void DisplayWindowId(); // Tells us to display its own ID (which causes a DisplayWindowIdRequested to be raised)

String WindowName { get; };
void RequestIdentifyWindows(); // Tells us to raise a IdentifyWindowsRequested
void RequestRename(RenameRequestArgs args); // Tells us to raise a RenameRequested
void Summon(SummonWindowBehavior behavior);

event Windows.Foundation.TypedEventHandler<Object, WindowActivatedArgs> WindowActivated;
event Windows.Foundation.TypedEventHandler<Object, CommandlineArgs> ExecuteCommandlineRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> DisplayWindowIdRequested;
event Windows.Foundation.TypedEventHandler<Object, RenameRequestArgs> RenameRequested;
event Windows.Foundation.TypedEventHandler<Object, SummonWindowBehavior> SummonRequested;
};

[default_interface] runtimeclass Peasant : IPeasant
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/Remoting/SummonWindowBehavior.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "SummonWindowBehavior.h"
#include "SummonWindowBehavior.g.cpp"
39 changes: 39 additions & 0 deletions src/cascadia/Remoting/SummonWindowBehavior.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.

Class Name:
- SummonWindowBehavior.h

Abstract:
- TODO!

--*/

#pragma once

#include "SummonWindowBehavior.g.h"
#include "../cascadia/inc/cppwinrt_utils.h"

namespace winrt::Microsoft::Terminal::Remoting::implementation
{
struct SummonWindowBehavior : public SummonWindowBehaviorT<SummonWindowBehavior>
{
public:
SummonWindowBehavior() = default;
WINRT_PROPERTY(bool, MoveToCurrentDesktop, true);
WINRT_PROPERTY(bool, ToggleVisibility, true);
WINRT_PROPERTY(uint32_t, DropdownDuration, 0);

public:
SummonWindowBehavior(const Remoting::SummonWindowBehavior& other) :
_MoveToCurrentDesktop{ other.MoveToCurrentDesktop() },
_DropdownDuration{ other.DropdownDuration() },
_ToggleVisibility{ other.ToggleVisibility() } {};
};
}

namespace winrt::Microsoft::Terminal::Remoting::factory_implementation
{
BASIC_FACTORY(SummonWindowBehavior);
}
5 changes: 5 additions & 0 deletions src/cascadia/Remoting/SummonWindowSelectionArgs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "pch.h"
#include "SummonWindowSelectionArgs.h"
#include "SummonWindowSelectionArgs.g.cpp"
43 changes: 43 additions & 0 deletions src/cascadia/Remoting/SummonWindowSelectionArgs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.

Class Name:
- SummonWindowSelectionArgs.h

Abstract:
- This is a helper class for determining which window a should be summoned when
a global hotkey is pressed. Parameters from a GlobalSummon action will be
filled in here. The Monarch will use these to find the window that matches
these args, and Summon() that Peasant.
- When the monarch finds a match, it will set FoundMatch to true. If it doesn't,
then the Monarch window might need to create a new window matching these args
instead.
--*/

#pragma once

#include "SummonWindowSelectionArgs.g.h"
#include "../cascadia/inc/cppwinrt_utils.h"

namespace winrt::Microsoft::Terminal::Remoting::implementation
{
struct SummonWindowSelectionArgs : public SummonWindowSelectionArgsT<SummonWindowSelectionArgs>
{
public:
SummonWindowSelectionArgs() = default;
SummonWindowSelectionArgs(winrt::hstring name) :
_WindowName{ name } {};

WINRT_PROPERTY(winrt::hstring, WindowName);

WINRT_PROPERTY(bool, FoundMatch, false);
WINRT_PROPERTY(bool, OnCurrentDesktop, false);
WINRT_PROPERTY(SummonWindowBehavior, SummonBehavior);
};
}

namespace winrt::Microsoft::Terminal::Remoting::factory_implementation
{
BASIC_FACTORY(SummonWindowSelectionArgs);
}
16 changes: 16 additions & 0 deletions src/cascadia/Remoting/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// window, and when the current monarch dies.

_monarch.FindTargetWindowRequested({ this, &WindowManager::_raiseFindTargetWindowRequested });

_BecameMonarchHandlers(*this, nullptr);
}

bool WindowManager::_areWeTheKing()
Expand Down Expand Up @@ -478,4 +480,18 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
{
_FindTargetWindowRequestedHandlers(sender, args);
}

bool WindowManager::IsMonarch()
{
return _isKing;
}

void WindowManager::SummonWindow(const Remoting::SummonWindowSelectionArgs& args)
{
// We should only ever get called when we are the monarch, because only
// the monarch ever registers for the global hotkey. So the monarch is
// the only window that will be calling this.
_monarch.SummonWindow(args);
}

}
Loading