-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shockingly, this works, it works elevated, and it works unpackaged
- Loading branch information
1 parent
1f52d35
commit 5a9cdc8
Showing
9 changed files
with
263 additions
and
108 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "pch.h" | ||
#include "WindowManager.h" | ||
#include "MonarchFactory.h" | ||
|
||
#include "WindowManager.g.cpp" | ||
#include "../../types/inc/utils.hpp" | ||
|
||
using namespace winrt; | ||
using namespace winrt::Windows::Foundation; | ||
using namespace ::Microsoft::Console; | ||
|
||
namespace winrt::Microsoft::Terminal::Remoting::implementation | ||
{ | ||
WindowManager::WindowManager() | ||
{ | ||
_RegisterAsMonarch(); | ||
_CreateMonarch(); | ||
} | ||
WindowManager::~WindowManager() | ||
{ | ||
// IMPORTANT! Tear down the registration as soon as we exit. If we're not a | ||
// real peasant window (the monarch passed our commandline to someone else), | ||
// then the monarch dies, we don't want our registration becoming the active | ||
// monarch! | ||
CoRevokeClassObject(_registrationHostClass); | ||
_registrationHostClass = 0; | ||
} | ||
|
||
void WindowManager::ProposeCommandline() | ||
{ | ||
_shouldCreateWindow = true; | ||
} | ||
|
||
bool WindowManager::ShouldCreateWindow() | ||
{ | ||
return _shouldCreateWindow; | ||
} | ||
|
||
void WindowManager::_RegisterAsMonarch() | ||
{ | ||
winrt::check_hresult(CoRegisterClassObject(Monarch_clsid, | ||
winrt::make<::MonarchFactory>().get(), | ||
CLSCTX_LOCAL_SERVER, | ||
REGCLS_MULTIPLEUSE, | ||
&_registrationHostClass)); | ||
} | ||
|
||
void WindowManager::_CreateMonarch() | ||
{ | ||
// Heads up! This only works because we're using | ||
// "metadata-based-marshalling" for our WinRT types. THat means the OS is | ||
// using the .winmd file we generate to figure out the proxy/stub | ||
// definitions for our types automatically. This only works in the following | ||
// cases: | ||
// | ||
// * If we're running unpackaged: the .winmd but be a sibling of the .exe | ||
// * If we're running packaged: the .winmd must be in the package root | ||
_monarch = create_instance<winrt::Microsoft::Terminal::Remoting::Monarch>(Monarch_clsid, | ||
CLSCTX_LOCAL_SERVER); | ||
} | ||
|
||
// bool AppHost::_ProposeCommandlineToMonarch() | ||
// { | ||
// // returns true if we should create a new window | ||
// return true; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "WindowManager.g.h" | ||
#include "Peasant.h" | ||
#include "Monarch.h" | ||
#include "../cascadia/inc/cppwinrt_utils.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Remoting::implementation | ||
{ | ||
struct WindowManager : public WindowManagerT<WindowManager> | ||
{ | ||
WindowManager(); | ||
~WindowManager(); | ||
|
||
void ProposeCommandline(); | ||
bool ShouldCreateWindow(); | ||
|
||
private: | ||
bool _shouldCreateWindow{ false }; | ||
DWORD _registrationHostClass{ 0 }; | ||
winrt::Microsoft::Terminal::Remoting::Monarch _monarch{ nullptr }; | ||
|
||
void _RegisterAsMonarch(); | ||
void _CreateMonarch(); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::Terminal::Remoting::factory_implementation | ||
{ | ||
BASIC_FACTORY(WindowManager); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
namespace Microsoft.Terminal.Remoting | ||
{ | ||
|
||
[default_interface] runtimeclass WindowManager | ||
{ | ||
WindowManager(); | ||
void ProposeCommandline(); | ||
Boolean ShouldCreateWindow { get; }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters