mirror of
https://github.com/microsoft/terminal.git
synced 2026-11-17 18:01:11 +00:00
Merge branch 'dev/migrie/oop/3/foreword' into dev/migrie/oop/3/ainulindale
# Conflicts: # src/cascadia/WindowsTerminal/AppHost.h
This commit is contained in:
@@ -77,22 +77,24 @@ namespace winrt::TerminalApp::implementation
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
void App::OnLaunched(const LaunchActivatedEventArgs& /*e*/)
|
||||
{
|
||||
// TODO! UWP mode is straight up not supported anymore, yea?
|
||||
//
|
||||
// if this is a UWP... it means its our problem to hook up the content to the window here.
|
||||
if (_isUwp)
|
||||
{
|
||||
auto content = Window::Current().Content();
|
||||
if (content == nullptr)
|
||||
{
|
||||
auto logic = Logic();
|
||||
logic.RunAsUwp(); // Must set UWP status first, settings might change based on it.
|
||||
logic.ReloadSettings();
|
||||
logic.Create();
|
||||
//if (_isUwp)
|
||||
//{
|
||||
// auto content = Window::Current().Content();
|
||||
// if (content == nullptr)
|
||||
// {
|
||||
// auto logic = Logic();
|
||||
// logic.RunAsUwp(); // Must set UWP status first, settings might change based on it.
|
||||
// logic.ReloadSettings();
|
||||
// logic.Create();
|
||||
|
||||
auto page = logic.GetRoot().as<TerminalPage>();
|
||||
// auto page = logic.GetRoot().as<TerminalPage>();
|
||||
|
||||
Window::Current().Content(page);
|
||||
Window::Current().Activate();
|
||||
}
|
||||
}
|
||||
// Window::Current().Content(page);
|
||||
// Window::Current().Activate();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,10 +5,11 @@
|
||||
|
||||
#include "AppLogic.g.h"
|
||||
#include "FindTargetWindowResult.g.h"
|
||||
#include "SystemMenuChangeArgs.g.h"
|
||||
|
||||
#include "Jumplist.h"
|
||||
#include "LanguageProfileNotifier.h"
|
||||
#include "TerminalPage.h"
|
||||
#include "AppCommandlineArgs.h"
|
||||
#include "TerminalWindow.h"
|
||||
|
||||
#include <inc/cppwinrt_utils.h>
|
||||
#include <ThrottledFunc.h>
|
||||
@@ -36,18 +37,7 @@ namespace winrt::TerminalApp::implementation
|
||||
FindTargetWindowResult(id, L""){};
|
||||
};
|
||||
|
||||
struct SystemMenuChangeArgs : SystemMenuChangeArgsT<SystemMenuChangeArgs>
|
||||
{
|
||||
WINRT_PROPERTY(winrt::hstring, Name, L"");
|
||||
WINRT_PROPERTY(SystemMenuChangeAction, Action, SystemMenuChangeAction::Add);
|
||||
WINRT_PROPERTY(SystemMenuItemHandler, Handler, nullptr);
|
||||
|
||||
public:
|
||||
SystemMenuChangeArgs(const winrt::hstring& name, SystemMenuChangeAction action, SystemMenuItemHandler handler = nullptr) :
|
||||
_Name{ name }, _Action{ action }, _Handler{ handler } {};
|
||||
};
|
||||
|
||||
struct AppLogic : AppLogicT<AppLogic, IInitializeWithWindow>
|
||||
struct AppLogic : AppLogicT<AppLogic>
|
||||
{
|
||||
public:
|
||||
static AppLogic* Current() noexcept;
|
||||
@@ -56,124 +46,48 @@ namespace winrt::TerminalApp::implementation
|
||||
AppLogic();
|
||||
~AppLogic() = default;
|
||||
|
||||
STDMETHODIMP Initialize(HWND hwnd);
|
||||
|
||||
void Create();
|
||||
bool IsUwp() const noexcept;
|
||||
void RunAsUwp();
|
||||
bool IsElevated() const noexcept;
|
||||
void ReloadSettings();
|
||||
|
||||
bool HasSettingsStartupActions() const noexcept;
|
||||
|
||||
[[nodiscard]] Microsoft::Terminal::Settings::Model::CascadiaSettings GetSettings() const noexcept;
|
||||
|
||||
void Quit();
|
||||
|
||||
bool HasCommandlineArguments() const noexcept;
|
||||
bool HasSettingsStartupActions() const noexcept;
|
||||
int32_t SetStartupCommandline(array_view<const winrt::hstring> actions);
|
||||
int32_t ExecuteCommandline(array_view<const winrt::hstring> actions, const winrt::hstring& cwd);
|
||||
TerminalApp::FindTargetWindowResult FindTargetWindow(array_view<const winrt::hstring> actions);
|
||||
winrt::hstring ParseCommandlineMessage();
|
||||
bool ShouldExitEarly();
|
||||
|
||||
bool FocusMode() const;
|
||||
bool Fullscreen() const;
|
||||
void Maximized(bool newMaximized);
|
||||
bool AlwaysOnTop() const;
|
||||
bool AutoHideWindow();
|
||||
|
||||
bool ShouldUsePersistedLayout();
|
||||
bool ShouldImmediatelyHandoffToElevated();
|
||||
void HandoffToElevated();
|
||||
hstring GetWindowLayoutJson(Microsoft::Terminal::Settings::Model::LaunchPosition position);
|
||||
void SaveWindowLayoutJsons(const Windows::Foundation::Collections::IVector<hstring>& layouts);
|
||||
void IdentifyWindow();
|
||||
void RenameFailed();
|
||||
winrt::hstring WindowName();
|
||||
void WindowName(const winrt::hstring& name);
|
||||
uint64_t WindowId();
|
||||
void WindowId(const uint64_t& id);
|
||||
void SetPersistedLayoutIdx(const uint32_t idx);
|
||||
void SetNumberOfOpenWindows(const uint64_t num);
|
||||
bool IsQuakeWindow() const noexcept;
|
||||
void RequestExitFullscreen();
|
||||
|
||||
Windows::Foundation::Size GetLaunchDimensions(uint32_t dpi);
|
||||
bool CenterOnLaunch();
|
||||
TerminalApp::InitialPosition GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY);
|
||||
winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme();
|
||||
Microsoft::Terminal::Settings::Model::LaunchMode GetLaunchMode();
|
||||
bool GetShowTabsInTitlebar();
|
||||
bool GetInitialAlwaysOnTop();
|
||||
float CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;
|
||||
|
||||
Windows::UI::Xaml::UIElement GetRoot() noexcept;
|
||||
|
||||
void SetInboundListener();
|
||||
|
||||
hstring Title();
|
||||
void TitlebarClicked();
|
||||
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
|
||||
|
||||
void CloseWindow(Microsoft::Terminal::Settings::Model::LaunchPosition position);
|
||||
void WindowVisibilityChanged(const bool showOrHide);
|
||||
|
||||
winrt::TerminalApp::TaskbarState TaskbarState();
|
||||
winrt::Windows::UI::Xaml::Media::Brush TitlebarBrush();
|
||||
void WindowActivated(const bool activated);
|
||||
|
||||
bool GetMinimizeToNotificationArea();
|
||||
bool GetAlwaysShowNotificationIcon();
|
||||
bool GetShowTitleInTitlebar();
|
||||
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog);
|
||||
void DismissDialog();
|
||||
|
||||
Windows::Foundation::Collections::IMapView<Microsoft::Terminal::Control::KeyChord, Microsoft::Terminal::Settings::Model::Command> GlobalHotkeys();
|
||||
|
||||
Microsoft::Terminal::Settings::Model::Theme Theme();
|
||||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
// PropertyChanged is surprisingly not a typed event, so we'll define that one manually.
|
||||
// Usually we'd just do
|
||||
// WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
//
|
||||
// But what we're doing here is exposing the Page's PropertyChanged _as
|
||||
// our own event_. It's a FORWARDED_CALLBACK, essentially.
|
||||
winrt::event_token PropertyChanged(Windows::UI::Xaml::Data::PropertyChangedEventHandler const& handler) { return _root->PropertyChanged(handler); }
|
||||
void PropertyChanged(winrt::event_token const& token) { _root->PropertyChanged(token); }
|
||||
TerminalApp::TerminalWindow CreateNewWindow();
|
||||
|
||||
TYPED_EVENT(RequestedThemeChanged, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Settings::Model::Theme);
|
||||
TYPED_EVENT(SettingsChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);
|
||||
TYPED_EVENT(SystemMenuChangeRequested, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SystemMenuChangeArgs);
|
||||
|
||||
private:
|
||||
bool _isUwp{ false };
|
||||
bool _isElevated{ false };
|
||||
|
||||
// If you add controls here, but forget to null them either here or in
|
||||
// the ctor, you're going to have a bad time. It'll mysteriously fail to
|
||||
// activate the AppLogic.
|
||||
// ALSO: If you add any UIElements as roots here, make sure they're
|
||||
// updated in _ApplyTheme. The root currently is _root.
|
||||
winrt::com_ptr<TerminalPage> _root{ nullptr };
|
||||
Microsoft::Terminal::Settings::Model::CascadiaSettings _settings{ nullptr };
|
||||
|
||||
winrt::hstring _settingsLoadExceptionText;
|
||||
HRESULT _settingsLoadedResult = S_OK;
|
||||
bool _loadedInitialSettings = false;
|
||||
|
||||
uint64_t _numOpenWindows{ 0 };
|
||||
|
||||
std::shared_mutex _dialogLock;
|
||||
winrt::Windows::UI::Xaml::Controls::ContentDialog _dialog;
|
||||
|
||||
::TerminalApp::AppCommandlineArgs _appArgs;
|
||||
bool _hasSettingsStartupActions{ false };
|
||||
::TerminalApp::AppCommandlineArgs _settingsAppArgs;
|
||||
|
||||
std::shared_ptr<ThrottledFuncTrailing<>> _reloadSettings;
|
||||
til::throttled_func_trailing<> _reloadState;
|
||||
|
||||
std::vector<Microsoft::Terminal::Settings::Model::SettingsLoadWarnings> _warnings;
|
||||
|
||||
// These fields invoke _reloadSettings and must be destroyed before _reloadSettings.
|
||||
// (C++ destroys members in reverse-declaration-order.)
|
||||
winrt::com_ptr<LanguageProfileNotifier> _languageProfileNotifier;
|
||||
@@ -182,46 +96,13 @@ namespace winrt::TerminalApp::implementation
|
||||
static TerminalApp::FindTargetWindowResult _doFindTargetWindow(winrt::array_view<const hstring> args,
|
||||
const Microsoft::Terminal::Settings::Model::WindowingMode& windowingBehavior);
|
||||
|
||||
void _ShowLoadErrorsDialog(const winrt::hstring& titleKey, const winrt::hstring& contentKey, HRESULT settingsLoadedResult);
|
||||
void _ShowLoadWarningsDialog();
|
||||
bool _IsKeyboardServiceEnabled();
|
||||
|
||||
void _ApplyLanguageSettingChange() noexcept;
|
||||
void _RefreshThemeRoutine();
|
||||
fire_and_forget _ApplyStartupTaskStateChange();
|
||||
|
||||
void _OnLoaded(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
||||
|
||||
[[nodiscard]] HRESULT _TryLoadSettings() noexcept;
|
||||
void _ProcessLazySettingsChanges();
|
||||
void _RegisterSettingsChange();
|
||||
fire_and_forget _DispatchReloadSettings();
|
||||
void _OpenSettingsUI();
|
||||
|
||||
bool _hasCommandLineArguments{ false };
|
||||
bool _hasSettingsStartupActions{ false };
|
||||
std::vector<Microsoft::Terminal::Settings::Model::SettingsLoadWarnings> _warnings;
|
||||
|
||||
// These are events that are handled by the TerminalPage, but are
|
||||
// exposed through the AppLogic. This macro is used to forward the event
|
||||
// directly to them.
|
||||
FORWARDED_TYPED_EVENT(SetTitleBarContent, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement, _root, SetTitleBarContent);
|
||||
FORWARDED_TYPED_EVENT(TitleChanged, winrt::Windows::Foundation::IInspectable, winrt::hstring, _root, TitleChanged);
|
||||
FORWARDED_TYPED_EVENT(LastTabClosed, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs, _root, LastTabClosed);
|
||||
FORWARDED_TYPED_EVENT(FocusModeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FocusModeChanged);
|
||||
FORWARDED_TYPED_EVENT(FullscreenChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FullscreenChanged);
|
||||
FORWARDED_TYPED_EVENT(ChangeMaximizeRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, ChangeMaximizeRequested);
|
||||
FORWARDED_TYPED_EVENT(AlwaysOnTopChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, AlwaysOnTopChanged);
|
||||
FORWARDED_TYPED_EVENT(RaiseVisualBell, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, RaiseVisualBell);
|
||||
FORWARDED_TYPED_EVENT(SetTaskbarProgress, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, SetTaskbarProgress);
|
||||
FORWARDED_TYPED_EVENT(IdentifyWindowsRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IdentifyWindowsRequested);
|
||||
FORWARDED_TYPED_EVENT(RenameWindowRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs, _root, RenameWindowRequested);
|
||||
FORWARDED_TYPED_EVENT(IsQuakeWindowChanged, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IsQuakeWindowChanged);
|
||||
FORWARDED_TYPED_EVENT(SummonWindowRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, SummonWindowRequested);
|
||||
FORWARDED_TYPED_EVENT(CloseRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, CloseRequested);
|
||||
FORWARDED_TYPED_EVENT(OpenSystemMenu, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, OpenSystemMenu);
|
||||
FORWARDED_TYPED_EVENT(QuitRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, QuitRequested);
|
||||
FORWARDED_TYPED_EVENT(ShowWindowChanged, Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs, _root, ShowWindowChanged);
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend class TerminalAppLocalTests::CommandlineTest;
|
||||
|
||||
@@ -1,41 +1,18 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import "TerminalPage.idl";
|
||||
import "ShortcutActionDispatch.idl";
|
||||
import "IDirectKeyListener.idl";
|
||||
import "TerminalWindow.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
struct InitialPosition
|
||||
{
|
||||
Int64 X;
|
||||
Int64 Y;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass FindTargetWindowResult
|
||||
{
|
||||
Int32 WindowId { get; };
|
||||
String WindowName { get; };
|
||||
};
|
||||
|
||||
delegate void SystemMenuItemHandler();
|
||||
|
||||
enum SystemMenuChangeAction
|
||||
{
|
||||
Add = 0,
|
||||
Remove = 1
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass SystemMenuChangeArgs {
|
||||
String Name { get; };
|
||||
SystemMenuChangeAction Action { get; };
|
||||
SystemMenuItemHandler Handler { get; };
|
||||
};
|
||||
|
||||
// See IDialogPresenter and TerminalPage's DialogPresenter for more
|
||||
// information.
|
||||
[default_interface] runtimeclass AppLogic : IDirectKeyListener, IDialogPresenter, Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
[default_interface] runtimeclass AppLogic
|
||||
{
|
||||
AppLogic();
|
||||
|
||||
@@ -50,94 +27,24 @@ namespace TerminalApp
|
||||
void RunAsUwp();
|
||||
Boolean IsElevated();
|
||||
|
||||
Boolean HasCommandlineArguments();
|
||||
Boolean HasSettingsStartupActions();
|
||||
Int32 SetStartupCommandline(String[] commands);
|
||||
Int32 ExecuteCommandline(String[] commands, String cwd);
|
||||
String ParseCommandlineMessage { get; };
|
||||
Boolean ShouldExitEarly { get; };
|
||||
|
||||
void Quit();
|
||||
|
||||
void ReloadSettings();
|
||||
Windows.UI.Xaml.UIElement GetRoot();
|
||||
|
||||
void SetInboundListener();
|
||||
|
||||
String Title { get; };
|
||||
|
||||
Boolean FocusMode { get; };
|
||||
Boolean Fullscreen { get; };
|
||||
void Maximized(Boolean newMaximized);
|
||||
Boolean AlwaysOnTop { get; };
|
||||
Boolean AutoHideWindow { get; };
|
||||
|
||||
void IdentifyWindow();
|
||||
String WindowName;
|
||||
UInt64 WindowId;
|
||||
void SetPersistedLayoutIdx(UInt32 idx);
|
||||
void SetNumberOfOpenWindows(UInt64 num);
|
||||
void RenameFailed();
|
||||
void RequestExitFullscreen();
|
||||
Boolean IsQuakeWindow();
|
||||
|
||||
Windows.Foundation.Size GetLaunchDimensions(UInt32 dpi);
|
||||
Boolean CenterOnLaunch { get; };
|
||||
|
||||
InitialPosition GetInitialPosition(Int64 defaultInitialX, Int64 defaultInitialY);
|
||||
Windows.UI.Xaml.ElementTheme GetRequestedTheme();
|
||||
Microsoft.Terminal.Settings.Model.LaunchMode GetLaunchMode();
|
||||
Boolean GetShowTabsInTitlebar();
|
||||
Boolean GetInitialAlwaysOnTop();
|
||||
Single CalcSnappedDimension(Boolean widthOrHeight, Single dimension);
|
||||
void TitlebarClicked();
|
||||
void CloseWindow(Microsoft.Terminal.Settings.Model.LaunchPosition position);
|
||||
void WindowVisibilityChanged(Boolean showOrHide);
|
||||
|
||||
TaskbarState TaskbarState{ get; };
|
||||
Windows.UI.Xaml.Media.Brush TitlebarBrush { get; };
|
||||
void WindowActivated(Boolean activated);
|
||||
|
||||
Boolean ShouldUsePersistedLayout();
|
||||
Boolean ShouldImmediatelyHandoffToElevated();
|
||||
void HandoffToElevated();
|
||||
String GetWindowLayoutJson(Microsoft.Terminal.Settings.Model.LaunchPosition position);
|
||||
void SaveWindowLayoutJsons(Windows.Foundation.Collections.IVector<String> layouts);
|
||||
|
||||
Boolean GetMinimizeToNotificationArea();
|
||||
Boolean GetAlwaysShowNotificationIcon();
|
||||
Boolean GetShowTitleInTitlebar();
|
||||
|
||||
Microsoft.Terminal.Settings.Model.Theme Theme { get; };
|
||||
|
||||
FindTargetWindowResult FindTargetWindow(String[] args);
|
||||
|
||||
TerminalWindow CreateNewWindow();
|
||||
|
||||
Boolean ShouldImmediatelyHandoffToElevated();
|
||||
void HandoffToElevated();
|
||||
|
||||
Windows.Foundation.Collections.IMapView<Microsoft.Terminal.Control.KeyChord, Microsoft.Terminal.Settings.Model.Command> GlobalHotkeys();
|
||||
|
||||
// See IDialogPresenter and TerminalPage's DialogPresenter for more
|
||||
// information.
|
||||
Windows.Foundation.IAsyncOperation<Windows.UI.Xaml.Controls.ContentDialogResult> ShowDialog(Windows.UI.Xaml.Controls.ContentDialog dialog);
|
||||
void DismissDialog();
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.UIElement> SetTitleBarContent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, String> TitleChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, LastTabClosedEventArgs> LastTabClosed;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Settings.Model.Theme> RequestedThemeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> FocusModeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> FullscreenChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> ChangeMaximizeRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> AlwaysOnTopChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RaiseVisualBell;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SettingsChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IsQuakeWindowChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> QuitRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, TerminalApp.SystemMenuChangeArgs> SystemMenuChangeRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Control.ShowWindowArgs> ShowWindowChanged;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,9 @@
|
||||
<ClInclude Include="AppLogic.h">
|
||||
<DependentUpon>AppLogic.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TerminalWindow.h">
|
||||
<DependentUpon>TerminalWindow.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Toast.h" />
|
||||
</ItemGroup>
|
||||
<!-- ========================= Cpp Files ======================== -->
|
||||
@@ -231,6 +234,9 @@
|
||||
<ClCompile Include="AppLogic.cpp">
|
||||
<DependentUpon>AppLogic.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TerminalWindow.cpp">
|
||||
<DependentUpon>TerminalWindow.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="Toast.cpp" />
|
||||
</ItemGroup>
|
||||
@@ -252,6 +258,7 @@
|
||||
<Midl Include="ShortcutActionDispatch.idl" />
|
||||
<Midl Include="AppKeyBindings.idl" />
|
||||
<Midl Include="AppLogic.idl" />
|
||||
<Midl Include="TerminalWindow.idl" />
|
||||
<Midl Include="MinMaxCloseControl.idl">
|
||||
<DependentUpon>MinMaxCloseControl.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
|
||||
@@ -621,6 +621,8 @@ namespace winrt::TerminalApp::implementation
|
||||
const bool initial,
|
||||
const winrt::hstring cwd)
|
||||
{
|
||||
const auto paramFistSize = actions.Size();
|
||||
|
||||
auto weakThis{ get_weak() };
|
||||
|
||||
// Handle it on a subsequent pass of the UI thread.
|
||||
@@ -651,6 +653,11 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
const auto memberSize = page->_startupActions.Size();
|
||||
const auto paramSecondSize = actions.Size();
|
||||
memberSize;
|
||||
paramFistSize;
|
||||
paramSecondSize;
|
||||
for (const auto& action : actions)
|
||||
{
|
||||
if (auto page{ weakThis.get() })
|
||||
@@ -3045,11 +3052,15 @@ namespace winrt::TerminalApp::implementation
|
||||
// - <none>
|
||||
void TerminalPage::SetStartupActions(std::vector<ActionAndArgs>& actions)
|
||||
{
|
||||
const auto initSize = actions.size();
|
||||
initSize;
|
||||
// The fastest way to copy all the actions out of the std::vector and
|
||||
// put them into a winrt::IVector is by making a copy, then moving the
|
||||
// copy into the winrt vector ctor.
|
||||
auto listCopy = actions;
|
||||
_startupActions = winrt::single_threaded_vector<ActionAndArgs>(std::move(listCopy));
|
||||
const auto afterSize = _startupActions.Size();
|
||||
assert(initSize == afterSize);// you donkey
|
||||
}
|
||||
|
||||
// Routine Description:
|
||||
|
||||
1155
src/cascadia/TerminalApp/TerminalWindow.cpp
Normal file
1155
src/cascadia/TerminalApp/TerminalWindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
185
src/cascadia/TerminalApp/TerminalWindow.h
Normal file
185
src/cascadia/TerminalApp/TerminalWindow.h
Normal file
@@ -0,0 +1,185 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "TerminalWindow.g.h"
|
||||
#include "SystemMenuChangeArgs.g.h"
|
||||
|
||||
#include "TerminalPage.h"
|
||||
|
||||
#include <inc/cppwinrt_utils.h>
|
||||
#include <ThrottledFunc.h>
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
// fwdecl unittest classes
|
||||
namespace TerminalAppLocalTests
|
||||
{
|
||||
class CommandlineTest;
|
||||
};
|
||||
#endif
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct SystemMenuChangeArgs : SystemMenuChangeArgsT<SystemMenuChangeArgs>
|
||||
{
|
||||
WINRT_PROPERTY(winrt::hstring, Name, L"");
|
||||
WINRT_PROPERTY(SystemMenuChangeAction, Action, SystemMenuChangeAction::Add);
|
||||
WINRT_PROPERTY(SystemMenuItemHandler, Handler, nullptr);
|
||||
|
||||
public:
|
||||
SystemMenuChangeArgs(const winrt::hstring& name, SystemMenuChangeAction action, SystemMenuItemHandler handler = nullptr) :
|
||||
_Name{ name }, _Action{ action }, _Handler{ handler } {};
|
||||
};
|
||||
|
||||
struct TerminalWindow : TerminalWindowT<TerminalWindow, IInitializeWithWindow>
|
||||
{
|
||||
public:
|
||||
TerminalWindow(const Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
|
||||
~TerminalWindow() = default;
|
||||
|
||||
STDMETHODIMP Initialize(HWND hwnd);
|
||||
|
||||
void Create();
|
||||
bool IsUwp() const noexcept;
|
||||
void RunAsUwp();
|
||||
bool IsElevated() const noexcept;
|
||||
|
||||
void Quit();
|
||||
|
||||
void UpdateSettings(const HRESULT settingsLoadedResult, const Microsoft::Terminal::Settings::Model::CascadiaSettings& settings);
|
||||
|
||||
bool HasCommandlineArguments() const noexcept;
|
||||
// bool HasSettingsStartupActions() const noexcept;
|
||||
int32_t SetStartupCommandline(array_view<const winrt::hstring> actions);
|
||||
int32_t ExecuteCommandline(array_view<const winrt::hstring> actions, const winrt::hstring& cwd);
|
||||
void SetSettingsStartupArgs(const std::vector<winrt::Microsoft::Terminal::Settings::Model::ActionAndArgs>& actions);
|
||||
winrt::hstring ParseCommandlineMessage();
|
||||
bool ShouldExitEarly();
|
||||
|
||||
bool FocusMode() const;
|
||||
bool Fullscreen() const;
|
||||
void Maximized(bool newMaximized);
|
||||
bool AlwaysOnTop() const;
|
||||
bool AutoHideWindow();
|
||||
|
||||
bool ShouldUsePersistedLayout();
|
||||
|
||||
hstring GetWindowLayoutJson(Microsoft::Terminal::Settings::Model::LaunchPosition position);
|
||||
void SaveWindowLayoutJsons(const Windows::Foundation::Collections::IVector<hstring>& layouts);
|
||||
void IdentifyWindow();
|
||||
void RenameFailed();
|
||||
winrt::hstring WindowName();
|
||||
void WindowName(const winrt::hstring& name);
|
||||
uint64_t WindowId();
|
||||
void WindowId(const uint64_t& id);
|
||||
void SetPersistedLayoutIdx(const uint32_t idx);
|
||||
void SetNumberOfOpenWindows(const uint64_t num);
|
||||
bool IsQuakeWindow() const noexcept;
|
||||
void RequestExitFullscreen();
|
||||
|
||||
Windows::Foundation::Size GetLaunchDimensions(uint32_t dpi);
|
||||
bool CenterOnLaunch();
|
||||
TerminalApp::InitialPosition GetInitialPosition(int64_t defaultInitialX, int64_t defaultInitialY);
|
||||
winrt::Windows::UI::Xaml::ElementTheme GetRequestedTheme();
|
||||
Microsoft::Terminal::Settings::Model::LaunchMode GetLaunchMode();
|
||||
bool GetShowTabsInTitlebar();
|
||||
bool GetInitialAlwaysOnTop();
|
||||
float CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;
|
||||
|
||||
Windows::UI::Xaml::UIElement GetRoot() noexcept;
|
||||
|
||||
hstring Title();
|
||||
void TitlebarClicked();
|
||||
bool OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down);
|
||||
|
||||
void CloseWindow(Microsoft::Terminal::Settings::Model::LaunchPosition position);
|
||||
void WindowVisibilityChanged(const bool showOrHide);
|
||||
|
||||
winrt::TerminalApp::TaskbarState TaskbarState();
|
||||
winrt::Windows::UI::Xaml::Media::Brush TitlebarBrush();
|
||||
void WindowActivated(const bool activated);
|
||||
|
||||
bool GetMinimizeToNotificationArea();
|
||||
bool GetAlwaysShowNotificationIcon();
|
||||
bool GetShowTitleInTitlebar();
|
||||
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::UI::Xaml::Controls::ContentDialogResult> ShowDialog(winrt::Windows::UI::Xaml::Controls::ContentDialog dialog);
|
||||
void DismissDialog();
|
||||
|
||||
Microsoft::Terminal::Settings::Model::Theme Theme();
|
||||
void UpdateSettingsHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& arg);
|
||||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
// PropertyChanged is surprisingly not a typed event, so we'll define that one manually.
|
||||
// Usually we'd just do
|
||||
// WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
//
|
||||
// But what we're doing here is exposing the Page's PropertyChanged _as
|
||||
// our own event_. It's a FORWARDED_CALLBACK, essentially.
|
||||
winrt::event_token PropertyChanged(Windows::UI::Xaml::Data::PropertyChangedEventHandler const& handler) { return _root->PropertyChanged(handler); }
|
||||
void PropertyChanged(winrt::event_token const& token) { _root->PropertyChanged(token); }
|
||||
|
||||
TYPED_EVENT(RequestedThemeChanged, winrt::Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Settings::Model::Theme);
|
||||
|
||||
private:
|
||||
bool _isUwp{ false };
|
||||
bool _isElevated{ false };
|
||||
// If you add controls here, but forget to null them either here or in
|
||||
// the ctor, you're going to have a bad time. It'll mysteriously fail to
|
||||
// activate the AppLogic.
|
||||
// ALSO: If you add any UIElements as roots here, make sure they're
|
||||
// updated in _ApplyTheme. The root currently is _root.
|
||||
winrt::com_ptr<TerminalPage> _root{ nullptr };
|
||||
winrt::Windows::UI::Xaml::Controls::ContentDialog _dialog{ nullptr };
|
||||
std::shared_mutex _dialogLock;
|
||||
|
||||
bool _hasCommandLineArguments{ false };
|
||||
::TerminalApp::AppCommandlineArgs _appArgs;
|
||||
bool _gotSettingsStartupActions{ false };
|
||||
std::vector<winrt::Microsoft::Terminal::Settings::Model::ActionAndArgs> _settingsStartupArgs{};
|
||||
|
||||
uint64_t _numOpenWindows{ 0 };
|
||||
|
||||
Microsoft::Terminal::Settings::Model::CascadiaSettings _settings{ nullptr };
|
||||
|
||||
void _ShowLoadErrorsDialog(const winrt::hstring& titleKey, const winrt::hstring& contentKey, HRESULT settingsLoadedResult);
|
||||
void _ShowLoadWarningsDialog();
|
||||
bool _IsKeyboardServiceEnabled();
|
||||
|
||||
void _RefreshThemeRoutine();
|
||||
void _OnLoaded(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
||||
void _OpenSettingsUI();
|
||||
// These are events that are handled by the TerminalPage, but are
|
||||
// exposed through the AppLogic. This macro is used to forward the event
|
||||
// directly to them.
|
||||
FORWARDED_TYPED_EVENT(SetTitleBarContent, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement, _root, SetTitleBarContent);
|
||||
FORWARDED_TYPED_EVENT(TitleChanged, winrt::Windows::Foundation::IInspectable, winrt::hstring, _root, TitleChanged);
|
||||
FORWARDED_TYPED_EVENT(LastTabClosed, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs, _root, LastTabClosed);
|
||||
FORWARDED_TYPED_EVENT(FocusModeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FocusModeChanged);
|
||||
FORWARDED_TYPED_EVENT(FullscreenChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FullscreenChanged);
|
||||
FORWARDED_TYPED_EVENT(ChangeMaximizeRequested, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, ChangeMaximizeRequested);
|
||||
FORWARDED_TYPED_EVENT(AlwaysOnTopChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, AlwaysOnTopChanged);
|
||||
FORWARDED_TYPED_EVENT(RaiseVisualBell, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, RaiseVisualBell);
|
||||
FORWARDED_TYPED_EVENT(SetTaskbarProgress, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, SetTaskbarProgress);
|
||||
FORWARDED_TYPED_EVENT(IdentifyWindowsRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IdentifyWindowsRequested);
|
||||
FORWARDED_TYPED_EVENT(RenameWindowRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs, _root, RenameWindowRequested);
|
||||
FORWARDED_TYPED_EVENT(IsQuakeWindowChanged, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, IsQuakeWindowChanged);
|
||||
FORWARDED_TYPED_EVENT(SummonWindowRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, SummonWindowRequested);
|
||||
FORWARDED_TYPED_EVENT(CloseRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, CloseRequested);
|
||||
FORWARDED_TYPED_EVENT(OpenSystemMenu, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, OpenSystemMenu);
|
||||
FORWARDED_TYPED_EVENT(QuitRequested, Windows::Foundation::IInspectable, Windows::Foundation::IInspectable, _root, QuitRequested);
|
||||
FORWARDED_TYPED_EVENT(ShowWindowChanged, Windows::Foundation::IInspectable, winrt::Microsoft::Terminal::Control::ShowWindowArgs, _root, ShowWindowChanged);
|
||||
|
||||
TYPED_EVENT(SystemMenuChangeRequested, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::SystemMenuChangeArgs);
|
||||
|
||||
#ifdef UNIT_TESTING
|
||||
friend class TerminalAppLocalTests::CommandlineTest;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
namespace winrt::TerminalApp::factory_implementation
|
||||
{
|
||||
BASIC_FACTORY(TerminalWindow);
|
||||
}
|
||||
130
src/cascadia/TerminalApp/TerminalWindow.idl
Normal file
130
src/cascadia/TerminalApp/TerminalWindow.idl
Normal file
@@ -0,0 +1,130 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import "TerminalPage.idl";
|
||||
import "ShortcutActionDispatch.idl";
|
||||
import "IDirectKeyListener.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
struct InitialPosition
|
||||
{
|
||||
Int64 X;
|
||||
Int64 Y;
|
||||
};
|
||||
|
||||
delegate void SystemMenuItemHandler();
|
||||
|
||||
enum SystemMenuChangeAction
|
||||
{
|
||||
Add = 0,
|
||||
Remove = 1
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass SystemMenuChangeArgs {
|
||||
String Name { get; };
|
||||
SystemMenuChangeAction Action { get; };
|
||||
SystemMenuItemHandler Handler { get; };
|
||||
};
|
||||
|
||||
// See IDialogPresenter and TerminalPage's DialogPresenter for more
|
||||
// information.
|
||||
[default_interface] runtimeclass TerminalWindow : IDirectKeyListener, IDialogPresenter, Windows.UI.Xaml.Data.INotifyPropertyChanged
|
||||
{
|
||||
TerminalWindow(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
|
||||
|
||||
|
||||
// For your own sanity, it's better to do setup outside the ctor.
|
||||
// If you do any setup in the ctor that ends up throwing an exception,
|
||||
// then it might look like TermApp just failed to activate, which will
|
||||
// cause you to chase down the rabbit hole of "why is TermApp not
|
||||
// registered?" when it definitely is.
|
||||
void Create();
|
||||
|
||||
Boolean IsUwp();
|
||||
void RunAsUwp();
|
||||
Boolean IsElevated();
|
||||
|
||||
Boolean HasCommandlineArguments();
|
||||
// Boolean HasSettingsStartupActions();
|
||||
|
||||
Int32 SetStartupCommandline(String[] commands);
|
||||
|
||||
Int32 ExecuteCommandline(String[] commands, String cwd);
|
||||
String ParseCommandlineMessage { get; };
|
||||
Boolean ShouldExitEarly { get; };
|
||||
|
||||
void Quit();
|
||||
|
||||
Windows.UI.Xaml.UIElement GetRoot();
|
||||
|
||||
String Title { get; };
|
||||
Boolean FocusMode { get; };
|
||||
Boolean Fullscreen { get; };
|
||||
void Maximized(Boolean newMaximized);
|
||||
Boolean AlwaysOnTop { get; };
|
||||
Boolean AutoHideWindow { get; };
|
||||
|
||||
void IdentifyWindow();
|
||||
String WindowName;
|
||||
UInt64 WindowId;
|
||||
void SetPersistedLayoutIdx(UInt32 idx);
|
||||
void SetNumberOfOpenWindows(UInt64 num);
|
||||
void RenameFailed();
|
||||
void RequestExitFullscreen();
|
||||
Boolean IsQuakeWindow();
|
||||
|
||||
Windows.Foundation.Size GetLaunchDimensions(UInt32 dpi);
|
||||
Boolean CenterOnLaunch { get; };
|
||||
|
||||
InitialPosition GetInitialPosition(Int64 defaultInitialX, Int64 defaultInitialY);
|
||||
Windows.UI.Xaml.ElementTheme GetRequestedTheme();
|
||||
Microsoft.Terminal.Settings.Model.LaunchMode GetLaunchMode();
|
||||
Boolean GetShowTabsInTitlebar();
|
||||
Boolean GetInitialAlwaysOnTop();
|
||||
Single CalcSnappedDimension(Boolean widthOrHeight, Single dimension);
|
||||
void TitlebarClicked();
|
||||
void CloseWindow(Microsoft.Terminal.Settings.Model.LaunchPosition position);
|
||||
void WindowVisibilityChanged(Boolean showOrHide);
|
||||
|
||||
TaskbarState TaskbarState{ get; };
|
||||
Windows.UI.Xaml.Media.Brush TitlebarBrush { get; };
|
||||
void WindowActivated(Boolean activated);
|
||||
|
||||
Boolean ShouldUsePersistedLayout();
|
||||
// Boolean ShouldImmediatelyHandoffToElevated();
|
||||
// void HandoffToElevated();
|
||||
String GetWindowLayoutJson(Microsoft.Terminal.Settings.Model.LaunchPosition position);
|
||||
void SaveWindowLayoutJsons(Windows.Foundation.Collections.IVector<String> layouts);
|
||||
|
||||
Boolean GetMinimizeToNotificationArea();
|
||||
Boolean GetAlwaysShowNotificationIcon();
|
||||
Boolean GetShowTitleInTitlebar();
|
||||
|
||||
// See IDialogPresenter and TerminalPage's DialogPresenter for more
|
||||
// information.
|
||||
Windows.Foundation.IAsyncOperation<Windows.UI.Xaml.Controls.ContentDialogResult> ShowDialog(Windows.UI.Xaml.Controls.ContentDialog dialog);
|
||||
void DismissDialog();
|
||||
|
||||
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.UIElement> SetTitleBarContent;
|
||||
event Windows.Foundation.TypedEventHandler<Object, String> TitleChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, LastTabClosedEventArgs> LastTabClosed;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Settings.Model.Theme> RequestedThemeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> FocusModeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> FullscreenChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> ChangeMaximizeRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> AlwaysOnTopChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> RaiseVisualBell;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> IsQuakeWindowChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> SummonWindowRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> OpenSystemMenu;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Object> QuitRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, TerminalApp.SystemMenuChangeArgs> SystemMenuChangeRequested;
|
||||
event Windows.Foundation.TypedEventHandler<Object, Microsoft.Terminal.Control.ShowWindowArgs> ShowWindowChanged;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,12 @@ static constexpr short KeyPressed{ gsl::narrow_cast<short>(0x8000) };
|
||||
AppHost::AppHost() noexcept :
|
||||
_app{},
|
||||
_windowManager{},
|
||||
_logic{ nullptr }, // don't make one, we're going to take a ref on app's
|
||||
_appLogic{ nullptr }, // don't make one, we're going to take a ref on app's
|
||||
_windowLogic{ nullptr },
|
||||
_window{ nullptr },
|
||||
_getWindowLayoutThrottler{} // this will get set if we become the monarch
|
||||
{
|
||||
_logic = _app.Logic(); // get a ref to app's logic
|
||||
_appLogic = _app.Logic(); // get a ref to app's logic
|
||||
|
||||
// Inform the WindowManager that it can use us to find the target window for
|
||||
// a set of commandline args. This needs to be done before
|
||||
@@ -54,10 +55,11 @@ AppHost::AppHost() noexcept :
|
||||
return;
|
||||
}
|
||||
|
||||
_useNonClientArea = _logic.GetShowTabsInTitlebar();
|
||||
// _HandleCommandlineArgs will create a _windowLogic
|
||||
_useNonClientArea = _windowLogic.GetShowTabsInTitlebar();
|
||||
if (_useNonClientArea)
|
||||
{
|
||||
_window = std::make_unique<NonClientIslandWindow>(_logic.GetRequestedTheme());
|
||||
_window = std::make_unique<NonClientIslandWindow>(_windowLogic.GetRequestedTheme());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -67,7 +69,7 @@ AppHost::AppHost() noexcept :
|
||||
// Update our own internal state tracking if we're in quake mode or not.
|
||||
_IsQuakeWindowChanged(nullptr, nullptr);
|
||||
|
||||
_window->SetMinimizeToNotificationAreaBehavior(_logic.GetMinimizeToNotificationArea());
|
||||
_window->SetMinimizeToNotificationAreaBehavior(_windowLogic.GetMinimizeToNotificationArea());
|
||||
|
||||
// Tell the window to callback to us when it's about to handle a WM_CREATE
|
||||
auto pfn = std::bind(&AppHost::_HandleCreateWindow,
|
||||
@@ -77,8 +79,8 @@ AppHost::AppHost() noexcept :
|
||||
std::placeholders::_3);
|
||||
_window->SetCreateCallback(pfn);
|
||||
|
||||
_window->SetSnapDimensionCallback(std::bind(&winrt::TerminalApp::AppLogic::CalcSnappedDimension,
|
||||
_logic,
|
||||
_window->SetSnapDimensionCallback(std::bind(&winrt::TerminalApp::TerminalWindow::CalcSnappedDimension,
|
||||
_windowLogic,
|
||||
std::placeholders::_1,
|
||||
std::placeholders::_2));
|
||||
|
||||
@@ -100,10 +102,10 @@ AppHost::AppHost() noexcept :
|
||||
_window->WindowActivated({ this, &AppHost::_WindowActivated });
|
||||
_window->WindowMoved({ this, &AppHost::_WindowMoved });
|
||||
_window->HotkeyPressed({ this, &AppHost::_GlobalHotkeyPressed });
|
||||
_window->ShouldExitFullscreen({ &_logic, &winrt::TerminalApp::AppLogic::RequestExitFullscreen });
|
||||
_window->ShouldExitFullscreen({ &_windowLogic, &winrt::TerminalApp::TerminalWindow::RequestExitFullscreen });
|
||||
|
||||
_window->SetAlwaysOnTop(_logic.GetInitialAlwaysOnTop());
|
||||
_window->SetAutoHideWindow(_logic.AutoHideWindow());
|
||||
_window->SetAlwaysOnTop(_windowLogic.GetInitialAlwaysOnTop());
|
||||
_window->SetAutoHideWindow(_windowLogic.AutoHideWindow());
|
||||
|
||||
_window->MakeWindow();
|
||||
|
||||
@@ -152,9 +154,9 @@ AppHost::~AppHost()
|
||||
|
||||
bool AppHost::OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down)
|
||||
{
|
||||
if (_logic)
|
||||
if (_windowLogic)
|
||||
{
|
||||
return _logic.OnDirectKeyEvent(vkey, scanCode, down);
|
||||
return _windowLogic.OnDirectKeyEvent(vkey, scanCode, down);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -169,9 +171,9 @@ bool AppHost::OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, cons
|
||||
void AppHost::SetTaskbarProgress(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const winrt::Windows::Foundation::IInspectable& /*args*/)
|
||||
{
|
||||
if (_logic)
|
||||
if (_windowLogic)
|
||||
{
|
||||
const auto state = _logic.TaskbarState();
|
||||
const auto state = _windowLogic.TaskbarState();
|
||||
_window->SetTaskbarProgress(gsl::narrow_cast<size_t>(state.State()),
|
||||
gsl::narrow_cast<size_t>(state.Progress()));
|
||||
}
|
||||
@@ -231,12 +233,16 @@ void AppHost::_HandleCommandlineArgs()
|
||||
return;
|
||||
}
|
||||
|
||||
// We did want to make a window, so let's instantiate it here.
|
||||
// We don't have XAML yet, but we do have other stuff.
|
||||
_windowLogic = _appLogic.CreateNewWindow();
|
||||
|
||||
if (auto peasant{ _windowManager.CurrentWindow() })
|
||||
{
|
||||
if (auto args{ peasant.InitialArgs() })
|
||||
{
|
||||
const auto result = _logic.SetStartupCommandline(args.Commandline());
|
||||
const auto message = _logic.ParseCommandlineMessage();
|
||||
const auto result = _windowLogic.SetStartupCommandline(args.Commandline());
|
||||
const auto message = _windowLogic.ParseCommandlineMessage();
|
||||
if (!message.empty())
|
||||
{
|
||||
const auto displayHelp = result == 0;
|
||||
@@ -249,7 +255,7 @@ void AppHost::_HandleCommandlineArgs()
|
||||
GetStringResource(messageTitle).data(),
|
||||
MB_OK | messageIcon);
|
||||
|
||||
if (_logic.ShouldExitEarly())
|
||||
if (_windowLogic.ShouldExitEarly())
|
||||
{
|
||||
ExitProcess(result);
|
||||
}
|
||||
@@ -263,10 +269,10 @@ void AppHost::_HandleCommandlineArgs()
|
||||
// the window at all here. In that case, we're going through this
|
||||
// special escape hatch to dispatch all the calls to elevate-shim, and
|
||||
// then we're going to exit immediately.
|
||||
if (_logic.ShouldImmediatelyHandoffToElevated())
|
||||
if (_appLogic.ShouldImmediatelyHandoffToElevated())
|
||||
{
|
||||
_shouldCreateWindow = false;
|
||||
_logic.HandoffToElevated();
|
||||
_appLogic.HandoffToElevated();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -288,7 +294,7 @@ void AppHost::_HandleCommandlineArgs()
|
||||
{
|
||||
const auto numPeasants = _windowManager.GetNumberOfPeasants();
|
||||
const auto layouts = ApplicationState::SharedInstance().PersistedWindowLayouts();
|
||||
if (_logic.ShouldUsePersistedLayout() &&
|
||||
if (_windowLogic.ShouldUsePersistedLayout() &&
|
||||
layouts &&
|
||||
layouts.Size() > 0)
|
||||
{
|
||||
@@ -299,9 +305,9 @@ void AppHost::_HandleCommandlineArgs()
|
||||
// Otherwise create this window normally with its commandline, and create
|
||||
// a new window using the first saved layout information.
|
||||
// The 2nd+ layout will always get a new window.
|
||||
if (numPeasants == 1 && !_logic.HasCommandlineArguments() && !_logic.HasSettingsStartupActions())
|
||||
if (numPeasants == 1 && !_windowLogic.HasCommandlineArguments() && !_appLogic.HasSettingsStartupActions())
|
||||
{
|
||||
_logic.SetPersistedLayoutIdx(startIdx);
|
||||
_windowLogic.SetPersistedLayoutIdx(startIdx);
|
||||
startIdx += 1;
|
||||
}
|
||||
|
||||
@@ -328,10 +334,10 @@ void AppHost::_HandleCommandlineArgs()
|
||||
));
|
||||
}
|
||||
}
|
||||
_logic.SetNumberOfOpenWindows(numPeasants);
|
||||
_windowLogic.SetNumberOfOpenWindows(numPeasants);
|
||||
}
|
||||
_logic.WindowName(peasant.WindowName());
|
||||
_logic.WindowId(peasant.GetID());
|
||||
_windowLogic.WindowName(peasant.WindowName());
|
||||
_windowLogic.WindowId(peasant.GetID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +356,7 @@ void AppHost::Initialize()
|
||||
{
|
||||
_window->Initialize();
|
||||
|
||||
if (auto withWindow{ _logic.try_as<IInitializeWithWindow>() })
|
||||
if (auto withWindow{ _windowLogic.try_as<IInitializeWithWindow>() })
|
||||
{
|
||||
withWindow->Initialize(_window->GetHandle());
|
||||
}
|
||||
@@ -360,7 +366,7 @@ void AppHost::Initialize()
|
||||
// Register our callback for when the app's non-client content changes.
|
||||
// This has to be done _before_ App::Create, as the app might set the
|
||||
// content in Create.
|
||||
_logic.SetTitleBarContent({ this, &AppHost::_UpdateTitleBarContent });
|
||||
_windowLogic.SetTitleBarContent({ this, &AppHost::_UpdateTitleBarContent });
|
||||
}
|
||||
|
||||
// MORE EVENT HANDLERS HERE!
|
||||
@@ -383,27 +389,27 @@ void AppHost::Initialize()
|
||||
});
|
||||
// If the user requests a close in another way handle the same as if the 'X'
|
||||
// was clicked.
|
||||
_revokers.CloseRequested = _logic.CloseRequested(winrt::auto_revoke, { this, &AppHost::_CloseRequested });
|
||||
_revokers.CloseRequested = _windowLogic.CloseRequested(winrt::auto_revoke, { this, &AppHost::_CloseRequested });
|
||||
|
||||
// Add an event handler to plumb clicks in the titlebar area down to the
|
||||
// application layer.
|
||||
_window->DragRegionClicked([this]() { _logic.TitlebarClicked(); });
|
||||
_window->DragRegionClicked([this]() { _windowLogic.TitlebarClicked(); });
|
||||
|
||||
_window->WindowVisibilityChanged([this](bool showOrHide) { _logic.WindowVisibilityChanged(showOrHide); });
|
||||
_window->UpdateSettingsRequested([this]() { _logic.ReloadSettings(); });
|
||||
_window->WindowVisibilityChanged([this](bool showOrHide) { _windowLogic.WindowVisibilityChanged(showOrHide); });
|
||||
_window->UpdateSettingsRequested([this]() { _appLogic.ReloadSettings(); });
|
||||
|
||||
_revokers.RequestedThemeChanged = _logic.RequestedThemeChanged(winrt::auto_revoke, { this, &AppHost::_UpdateTheme });
|
||||
_revokers.FullscreenChanged = _logic.FullscreenChanged(winrt::auto_revoke, { this, &AppHost::_FullscreenChanged });
|
||||
_revokers.FocusModeChanged = _logic.FocusModeChanged(winrt::auto_revoke, { this, &AppHost::_FocusModeChanged });
|
||||
_revokers.AlwaysOnTopChanged = _logic.AlwaysOnTopChanged(winrt::auto_revoke, { this, &AppHost::_AlwaysOnTopChanged });
|
||||
_revokers.RaiseVisualBell = _logic.RaiseVisualBell(winrt::auto_revoke, { this, &AppHost::_RaiseVisualBell });
|
||||
_revokers.SystemMenuChangeRequested = _logic.SystemMenuChangeRequested(winrt::auto_revoke, { this, &AppHost::_SystemMenuChangeRequested });
|
||||
_revokers.ChangeMaximizeRequested = _logic.ChangeMaximizeRequested(winrt::auto_revoke, { this, &AppHost::_ChangeMaximizeRequested });
|
||||
_revokers.RequestedThemeChanged = _windowLogic.RequestedThemeChanged(winrt::auto_revoke, { this, &AppHost::_UpdateTheme });
|
||||
_revokers.FullscreenChanged = _windowLogic.FullscreenChanged(winrt::auto_revoke, { this, &AppHost::_FullscreenChanged });
|
||||
_revokers.FocusModeChanged = _windowLogic.FocusModeChanged(winrt::auto_revoke, { this, &AppHost::_FocusModeChanged });
|
||||
_revokers.AlwaysOnTopChanged = _windowLogic.AlwaysOnTopChanged(winrt::auto_revoke, { this, &AppHost::_AlwaysOnTopChanged });
|
||||
_revokers.RaiseVisualBell = _windowLogic.RaiseVisualBell(winrt::auto_revoke, { this, &AppHost::_RaiseVisualBell });
|
||||
_revokers.SystemMenuChangeRequested = _windowLogic.SystemMenuChangeRequested(winrt::auto_revoke, { this, &AppHost::_SystemMenuChangeRequested });
|
||||
_revokers.ChangeMaximizeRequested = _windowLogic.ChangeMaximizeRequested(winrt::auto_revoke, { this, &AppHost::_ChangeMaximizeRequested });
|
||||
|
||||
_window->MaximizeChanged([this](bool newMaximize) {
|
||||
if (_logic)
|
||||
if (_appLogic)
|
||||
{
|
||||
_logic.Maximized(newMaximize);
|
||||
_windowLogic.Maximized(newMaximize);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -416,21 +422,22 @@ void AppHost::Initialize()
|
||||
// Load bearing: make sure the PropertyChanged handler is added before we
|
||||
// call Create, so that when the app sets up the titlebar brush, we're
|
||||
// already prepared to listen for the change notification
|
||||
_revokers.PropertyChanged = _logic.PropertyChanged(winrt::auto_revoke, { this, &AppHost::_PropertyChangedHandler });
|
||||
_revokers.PropertyChanged = _windowLogic.PropertyChanged(winrt::auto_revoke, { this, &AppHost::_PropertyChangedHandler });
|
||||
|
||||
_logic.Create();
|
||||
_appLogic.Create();
|
||||
_windowLogic.Create();
|
||||
|
||||
_revokers.TitleChanged = _logic.TitleChanged(winrt::auto_revoke, { this, &AppHost::AppTitleChanged });
|
||||
_revokers.LastTabClosed = _logic.LastTabClosed(winrt::auto_revoke, { this, &AppHost::LastTabClosed });
|
||||
_revokers.SetTaskbarProgress = _logic.SetTaskbarProgress(winrt::auto_revoke, { this, &AppHost::SetTaskbarProgress });
|
||||
_revokers.IdentifyWindowsRequested = _logic.IdentifyWindowsRequested(winrt::auto_revoke, { this, &AppHost::_IdentifyWindowsRequested });
|
||||
_revokers.RenameWindowRequested = _logic.RenameWindowRequested(winrt::auto_revoke, { this, &AppHost::_RenameWindowRequested });
|
||||
_revokers.SettingsChanged = _logic.SettingsChanged(winrt::auto_revoke, { this, &AppHost::_HandleSettingsChanged });
|
||||
_revokers.IsQuakeWindowChanged = _logic.IsQuakeWindowChanged(winrt::auto_revoke, { this, &AppHost::_IsQuakeWindowChanged });
|
||||
_revokers.SummonWindowRequested = _logic.SummonWindowRequested(winrt::auto_revoke, { this, &AppHost::_SummonWindowRequested });
|
||||
_revokers.OpenSystemMenu = _logic.OpenSystemMenu(winrt::auto_revoke, { this, &AppHost::_OpenSystemMenu });
|
||||
_revokers.QuitRequested = _logic.QuitRequested(winrt::auto_revoke, { this, &AppHost::_RequestQuitAll });
|
||||
_revokers.ShowWindowChanged = _logic.ShowWindowChanged(winrt::auto_revoke, { this, &AppHost::_ShowWindowChanged });
|
||||
_revokers.TitleChanged = _windowLogic.TitleChanged(winrt::auto_revoke, { this, &AppHost::AppTitleChanged });
|
||||
_revokers.LastTabClosed = _windowLogic.LastTabClosed(winrt::auto_revoke, { this, &AppHost::LastTabClosed });
|
||||
_revokers.SetTaskbarProgress = _windowLogic.SetTaskbarProgress(winrt::auto_revoke, { this, &AppHost::SetTaskbarProgress });
|
||||
_revokers.IdentifyWindowsRequested = _windowLogic.IdentifyWindowsRequested(winrt::auto_revoke, { this, &AppHost::_IdentifyWindowsRequested });
|
||||
_revokers.RenameWindowRequested = _windowLogic.RenameWindowRequested(winrt::auto_revoke, { this, &AppHost::_RenameWindowRequested });
|
||||
_revokers.SettingsChanged = _appLogic.SettingsChanged(winrt::auto_revoke, { this, &AppHost::_HandleSettingsChanged });
|
||||
_revokers.IsQuakeWindowChanged = _windowLogic.IsQuakeWindowChanged(winrt::auto_revoke, { this, &AppHost::_IsQuakeWindowChanged });
|
||||
_revokers.SummonWindowRequested = _windowLogic.SummonWindowRequested(winrt::auto_revoke, { this, &AppHost::_SummonWindowRequested });
|
||||
_revokers.OpenSystemMenu = _windowLogic.OpenSystemMenu(winrt::auto_revoke, { this, &AppHost::_OpenSystemMenu });
|
||||
_revokers.QuitRequested = _windowLogic.QuitRequested(winrt::auto_revoke, { this, &AppHost::_RequestQuitAll });
|
||||
_revokers.ShowWindowChanged = _windowLogic.ShowWindowChanged(winrt::auto_revoke, { this, &AppHost::_ShowWindowChanged });
|
||||
|
||||
// BODGY
|
||||
// On certain builds of Windows, when Terminal is set as the default
|
||||
@@ -439,13 +446,13 @@ void AppHost::Initialize()
|
||||
// applications. This call into TerminalThemeHelpers will tell our
|
||||
// compositor to automatically complete animations that are scheduled
|
||||
// while the screen is off.
|
||||
TerminalTrySetAutoCompleteAnimationsWhenOccluded(static_cast<::IUnknown*>(winrt::get_abi(_logic.GetRoot())), true);
|
||||
TerminalTrySetAutoCompleteAnimationsWhenOccluded(static_cast<::IUnknown*>(winrt::get_abi(_windowLogic.GetRoot())), true);
|
||||
|
||||
_window->UpdateTitle(_logic.Title());
|
||||
_window->UpdateTitle(_windowLogic.Title());
|
||||
|
||||
// Set up the content of the application. If the app has a custom titlebar,
|
||||
// set that content as well.
|
||||
_window->SetContent(_logic.GetRoot());
|
||||
_window->SetContent(_windowLogic.GetRoot());
|
||||
_window->OnAppInitialized();
|
||||
|
||||
// BODGY
|
||||
@@ -478,7 +485,7 @@ void AppHost::Initialize()
|
||||
// - <none>
|
||||
void AppHost::AppTitleChanged(const winrt::Windows::Foundation::IInspectable& /*sender*/, winrt::hstring newTitle)
|
||||
{
|
||||
if (_logic.GetShowTitleInTitlebar())
|
||||
if (_windowLogic.GetShowTitleInTitlebar())
|
||||
{
|
||||
_window->UpdateTitle(newTitle);
|
||||
}
|
||||
@@ -564,11 +571,11 @@ LaunchPosition AppHost::_GetWindowLaunchPosition()
|
||||
// - None
|
||||
void AppHost::_HandleCreateWindow(const HWND hwnd, til::rect proposedRect, LaunchMode& launchMode)
|
||||
{
|
||||
launchMode = _logic.GetLaunchMode();
|
||||
launchMode = _windowLogic.GetLaunchMode();
|
||||
|
||||
// Acquire the actual initial position
|
||||
auto initialPos = _logic.GetInitialPosition(proposedRect.left, proposedRect.top);
|
||||
const auto centerOnLaunch = _logic.CenterOnLaunch();
|
||||
auto initialPos = _windowLogic.GetInitialPosition(proposedRect.left, proposedRect.top);
|
||||
const auto centerOnLaunch = _windowLogic.CenterOnLaunch();
|
||||
proposedRect.left = gsl::narrow<til::CoordType>(initialPos.X);
|
||||
proposedRect.top = gsl::narrow<til::CoordType>(initialPos.Y);
|
||||
|
||||
@@ -615,7 +622,7 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, til::rect proposedRect, Launc
|
||||
proposedRect.top = monitorInfo.rcWork.top;
|
||||
}
|
||||
|
||||
auto initialSize = _logic.GetLaunchDimensions(dpix);
|
||||
auto initialSize = _windowLogic.GetLaunchDimensions(dpix);
|
||||
|
||||
const auto islandWidth = Utils::ClampToShortMax(
|
||||
static_cast<long>(ceil(initialSize.Width)), 1);
|
||||
@@ -649,7 +656,7 @@ void AppHost::_HandleCreateWindow(const HWND hwnd, til::rect proposedRect, Launc
|
||||
til::point origin{ (proposedRect.left + nonClientFrame.left),
|
||||
(proposedRect.top) };
|
||||
|
||||
if (_logic.IsQuakeWindow())
|
||||
if (_windowLogic.IsQuakeWindow())
|
||||
{
|
||||
// If we just use rcWork by itself, we'll fail to account for the invisible
|
||||
// space reserved for the resize handles. So retrieve that size here.
|
||||
@@ -706,7 +713,7 @@ void AppHost::_UpdateTitleBarContent(const winrt::Windows::Foundation::IInspecta
|
||||
{
|
||||
auto nonClientWindow{ static_cast<NonClientIslandWindow*>(_window.get()) };
|
||||
nonClientWindow->SetTitlebarContent(arg);
|
||||
nonClientWindow->SetTitlebarBackground(_logic.TitlebarBrush());
|
||||
nonClientWindow->SetTitlebarBackground(_windowLogic.TitlebarBrush());
|
||||
}
|
||||
|
||||
_updateTheme();
|
||||
@@ -729,13 +736,13 @@ void AppHost::_UpdateTheme(const winrt::Windows::Foundation::IInspectable&,
|
||||
void AppHost::_FocusModeChanged(const winrt::Windows::Foundation::IInspectable&,
|
||||
const winrt::Windows::Foundation::IInspectable&)
|
||||
{
|
||||
_window->FocusModeChanged(_logic.FocusMode());
|
||||
_window->FocusModeChanged(_windowLogic.FocusMode());
|
||||
}
|
||||
|
||||
void AppHost::_FullscreenChanged(const winrt::Windows::Foundation::IInspectable&,
|
||||
const winrt::Windows::Foundation::IInspectable&)
|
||||
{
|
||||
_window->FullscreenChanged(_logic.Fullscreen());
|
||||
_window->FullscreenChanged(_windowLogic.Fullscreen());
|
||||
}
|
||||
|
||||
void AppHost::_ChangeMaximizeRequested(const winrt::Windows::Foundation::IInspectable&,
|
||||
@@ -773,7 +780,7 @@ void AppHost::_AlwaysOnTopChanged(const winrt::Windows::Foundation::IInspectable
|
||||
return;
|
||||
}
|
||||
|
||||
_window->SetAlwaysOnTop(_logic.AlwaysOnTop());
|
||||
_window->SetAlwaysOnTop(_windowLogic.AlwaysOnTop());
|
||||
}
|
||||
|
||||
// Method Description
|
||||
@@ -801,10 +808,10 @@ void AppHost::_RaiseVisualBell(const winrt::Windows::Foundation::IInspectable&,
|
||||
// - <none>
|
||||
void AppHost::_WindowMouseWheeled(const til::point coord, const int32_t delta)
|
||||
{
|
||||
if (_logic)
|
||||
if (_appLogic)
|
||||
{
|
||||
// Find all the elements that are underneath the mouse
|
||||
auto elems = winrt::Windows::UI::Xaml::Media::VisualTreeHelper::FindElementsInHostCoordinates(coord.to_winrt_point(), _logic.GetRoot());
|
||||
auto elems = winrt::Windows::UI::Xaml::Media::VisualTreeHelper::FindElementsInHostCoordinates(coord.to_winrt_point(), _windowLogic.GetRoot());
|
||||
for (const auto& e : elems)
|
||||
{
|
||||
// If that element has implemented IMouseWheelListener, call OnMouseWheel on that element.
|
||||
@@ -862,7 +869,7 @@ void AppHost::_DispatchCommandline(winrt::Windows::Foundation::IInspectable send
|
||||
// Summon the window whenever we dispatch a commandline to it. This will
|
||||
// make it obvious when a new tab/pane is created in a window.
|
||||
_HandleSummon(sender, summonArgs);
|
||||
_logic.ExecuteCommandline(args.Commandline(), args.CurrentDirectory());
|
||||
_windowLogic.ExecuteCommandline(args.Commandline(), args.CurrentDirectory());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
@@ -881,11 +888,11 @@ winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> AppHost::_GetWindowL
|
||||
|
||||
winrt::hstring layoutJson = L"";
|
||||
// Use the main thread since we are accessing controls.
|
||||
co_await wil::resume_foreground(_logic.GetRoot().Dispatcher());
|
||||
co_await wil::resume_foreground(_windowLogic.GetRoot().Dispatcher());
|
||||
try
|
||||
{
|
||||
const auto pos = _GetWindowLaunchPosition();
|
||||
layoutJson = _logic.GetWindowLayoutJson(pos);
|
||||
layoutJson = _windowLogic.GetWindowLayoutJson(pos);
|
||||
}
|
||||
CATCH_LOG()
|
||||
|
||||
@@ -908,14 +915,14 @@ winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> AppHost::_GetWindowL
|
||||
void AppHost::_FindTargetWindow(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const Remoting::FindTargetWindowArgs& args)
|
||||
{
|
||||
const auto targetWindow = _logic.FindTargetWindow(args.Args().Commandline());
|
||||
const auto targetWindow = _appLogic.FindTargetWindow(args.Args().Commandline());
|
||||
args.ResultTargetWindow(targetWindow.WindowId());
|
||||
args.ResultTargetWindowName(targetWindow.WindowName());
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_WindowActivated(bool activated)
|
||||
{
|
||||
_logic.WindowActivated(activated);
|
||||
_windowLogic.WindowActivated(activated);
|
||||
|
||||
if (!activated)
|
||||
{
|
||||
@@ -955,27 +962,27 @@ void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*s
|
||||
|
||||
if (_windowManager.DoesQuakeWindowExist() ||
|
||||
_window->IsQuakeWindow() ||
|
||||
(_logic.GetAlwaysShowNotificationIcon() || _logic.GetMinimizeToNotificationArea()))
|
||||
(_windowLogic.GetAlwaysShowNotificationIcon() || _windowLogic.GetMinimizeToNotificationArea()))
|
||||
{
|
||||
_CreateNotificationIcon();
|
||||
}
|
||||
|
||||
// Set the number of open windows (so we know if we are the last window)
|
||||
// and subscribe for updates if there are any changes to that number.
|
||||
_logic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants());
|
||||
_windowLogic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants());
|
||||
|
||||
_WindowCreatedToken = _windowManager.WindowCreated([this](auto&&, auto&&) {
|
||||
if (_getWindowLayoutThrottler) {
|
||||
_getWindowLayoutThrottler.value()();
|
||||
}
|
||||
_logic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants()); });
|
||||
_windowLogic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants()); });
|
||||
|
||||
_WindowClosedToken = _windowManager.WindowClosed([this](auto&&, auto&&) {
|
||||
if (_getWindowLayoutThrottler)
|
||||
{
|
||||
_getWindowLayoutThrottler.value()();
|
||||
}
|
||||
_logic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants());
|
||||
_windowLogic.SetNumberOfOpenWindows(_windowManager.GetNumberOfPeasants());
|
||||
});
|
||||
|
||||
// These events are coming from peasants that become or un-become quake windows.
|
||||
@@ -1000,7 +1007,7 @@ winrt::Windows::Foundation::IAsyncAction AppHost::_SaveWindowLayouts()
|
||||
// Make sure we run on a background thread to not block anything.
|
||||
co_await winrt::resume_background();
|
||||
|
||||
if (_logic.ShouldUsePersistedLayout())
|
||||
if (_windowLogic.ShouldUsePersistedLayout())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1015,7 +1022,7 @@ winrt::Windows::Foundation::IAsyncAction AppHost::_SaveWindowLayouts()
|
||||
TraceLoggingDescription("Logged when writing window state"),
|
||||
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
|
||||
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
|
||||
_logic.SaveWindowLayoutJsons(layoutJsons);
|
||||
_windowLogic.SaveWindowLayoutJsons(layoutJsons);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -1058,13 +1065,13 @@ winrt::fire_and_forget AppHost::_SaveWindowLayoutsRepeat()
|
||||
|
||||
void AppHost::_listenForInboundConnections()
|
||||
{
|
||||
_logic.SetInboundListener();
|
||||
_appLogic.SetInboundListener();
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_setupGlobalHotkeys()
|
||||
{
|
||||
// The hotkey MUST be registered on the main thread. It will fail otherwise!
|
||||
co_await wil::resume_foreground(_logic.GetRoot().Dispatcher());
|
||||
co_await wil::resume_foreground(_windowLogic.GetRoot().Dispatcher());
|
||||
|
||||
if (!_window)
|
||||
{
|
||||
@@ -1089,7 +1096,7 @@ winrt::fire_and_forget AppHost::_setupGlobalHotkeys()
|
||||
_hotkeys.clear();
|
||||
|
||||
// Re-register all current hotkeys.
|
||||
for (const auto& [keyChord, cmd] : _logic.GlobalHotkeys())
|
||||
for (const auto& [keyChord, cmd] : _appLogic.GlobalHotkeys())
|
||||
{
|
||||
if (auto summonArgs = cmd.ActionAndArgs().Args().try_as<Settings::Model::GlobalSummonArgs>())
|
||||
{
|
||||
@@ -1311,7 +1318,7 @@ winrt::fire_and_forget AppHost::_IdentifyWindowsRequested(const winrt::Windows::
|
||||
void AppHost::_DisplayWindowId(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
const winrt::Windows::Foundation::IInspectable& /*args*/)
|
||||
{
|
||||
_logic.IdentifyWindow();
|
||||
_windowLogic.IdentifyWindow();
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Foundation::IInspectable /*sender*/,
|
||||
@@ -1335,11 +1342,11 @@ winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Fou
|
||||
|
||||
if (requestArgs.Succeeded())
|
||||
{
|
||||
_logic.WindowName(args.ProposedName());
|
||||
_windowLogic.WindowName(args.ProposedName());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.RenameFailed();
|
||||
_windowLogic.RenameFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1373,11 +1380,11 @@ static bool _isActuallyDarkTheme(const auto requestedTheme)
|
||||
|
||||
void AppHost::_updateTheme()
|
||||
{
|
||||
auto theme = _logic.Theme();
|
||||
auto theme = _appLogic.Theme();
|
||||
|
||||
_window->OnApplicationThemeChanged(theme.RequestedTheme());
|
||||
|
||||
const auto b = _logic.TitlebarBrush();
|
||||
const auto b = _windowLogic.TitlebarBrush();
|
||||
const auto color = ThemeColor::ColorFromBrush(b);
|
||||
const auto colorOpacity = b ? color.A / 255.0 : 0.0;
|
||||
const auto brushOpacity = _opacityFromBrush(b);
|
||||
@@ -1409,11 +1416,11 @@ void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspecta
|
||||
{
|
||||
if (!_windowManager.DoesQuakeWindowExist())
|
||||
{
|
||||
if (!_notificationIcon && (_logic.GetMinimizeToNotificationArea() || _logic.GetAlwaysShowNotificationIcon()))
|
||||
if (!_notificationIcon && (_windowLogic.GetMinimizeToNotificationArea() || _windowLogic.GetAlwaysShowNotificationIcon()))
|
||||
{
|
||||
_CreateNotificationIcon();
|
||||
}
|
||||
else if (_notificationIcon && !_logic.GetMinimizeToNotificationArea() && !_logic.GetAlwaysShowNotificationIcon())
|
||||
else if (_notificationIcon && !_windowLogic.GetMinimizeToNotificationArea() && !_windowLogic.GetAlwaysShowNotificationIcon())
|
||||
{
|
||||
_windowManager.SummonAllWindows();
|
||||
_DestroyNotificationIcon();
|
||||
@@ -1421,8 +1428,8 @@ void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspecta
|
||||
}
|
||||
}
|
||||
|
||||
_window->SetMinimizeToNotificationAreaBehavior(_logic.GetMinimizeToNotificationArea());
|
||||
_window->SetAutoHideWindow(_logic.AutoHideWindow());
|
||||
_window->SetMinimizeToNotificationAreaBehavior(_windowLogic.GetMinimizeToNotificationArea());
|
||||
_window->SetAutoHideWindow(_windowLogic.AutoHideWindow());
|
||||
_updateTheme();
|
||||
}
|
||||
|
||||
@@ -1434,25 +1441,25 @@ void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectab
|
||||
// to show regardless of the notification icon settings.
|
||||
// This also means we'll need to destroy the notification icon if it was created
|
||||
// specifically for the quake window. If not, it should not be destroyed.
|
||||
if (!_window->IsQuakeWindow() && _logic.IsQuakeWindow())
|
||||
if (!_window->IsQuakeWindow() && _windowLogic.IsQuakeWindow())
|
||||
{
|
||||
_ShowNotificationIconRequested(nullptr, nullptr);
|
||||
}
|
||||
else if (_window->IsQuakeWindow() && !_logic.IsQuakeWindow())
|
||||
else if (_window->IsQuakeWindow() && !_windowLogic.IsQuakeWindow())
|
||||
{
|
||||
_HideNotificationIconRequested(nullptr, nullptr);
|
||||
}
|
||||
|
||||
_window->IsQuakeWindow(_logic.IsQuakeWindow());
|
||||
_window->IsQuakeWindow(_windowLogic.IsQuakeWindow());
|
||||
}
|
||||
|
||||
winrt::fire_and_forget AppHost::_QuitRequested(const winrt::Windows::Foundation::IInspectable&,
|
||||
const winrt::Windows::Foundation::IInspectable&)
|
||||
{
|
||||
// Need to be on the main thread to close out all of the tabs.
|
||||
co_await wil::resume_foreground(_logic.GetRoot().Dispatcher());
|
||||
co_await wil::resume_foreground(_windowLogic.GetRoot().Dispatcher());
|
||||
|
||||
_logic.Quit();
|
||||
_windowLogic.Quit();
|
||||
}
|
||||
|
||||
void AppHost::_RequestQuitAll(const winrt::Windows::Foundation::IInspectable&,
|
||||
@@ -1585,8 +1592,8 @@ void AppHost::_HideNotificationIconRequested(const winrt::Windows::Foundation::I
|
||||
{
|
||||
// Destroy it only if our settings allow it
|
||||
if (_notificationIcon &&
|
||||
!_logic.GetAlwaysShowNotificationIcon() &&
|
||||
!_logic.GetMinimizeToNotificationArea())
|
||||
!_windowLogic.GetAlwaysShowNotificationIcon() &&
|
||||
!_windowLogic.GetMinimizeToNotificationArea())
|
||||
{
|
||||
_DestroyNotificationIcon();
|
||||
}
|
||||
@@ -1607,14 +1614,14 @@ void AppHost::_HideNotificationIconRequested(const winrt::Windows::Foundation::I
|
||||
// - <none>
|
||||
void AppHost::_WindowMoved()
|
||||
{
|
||||
if (_logic)
|
||||
if (_windowLogic)
|
||||
{
|
||||
// Ensure any open ContentDialog is dismissed.
|
||||
// Closing the popup in the UI tree as done below is not sufficient because
|
||||
// it does not terminate the dialog's async operation.
|
||||
_logic.DismissDialog();
|
||||
_windowLogic.DismissDialog();
|
||||
|
||||
const auto root{ _logic.GetRoot() };
|
||||
const auto root{ _windowLogic.GetRoot() };
|
||||
if (root && root.XamlRoot())
|
||||
{
|
||||
try
|
||||
@@ -1643,7 +1650,7 @@ void AppHost::_CloseRequested(const winrt::Windows::Foundation::IInspectable& /*
|
||||
const winrt::Windows::Foundation::IInspectable& /*args*/)
|
||||
{
|
||||
const auto pos = _GetWindowLaunchPosition();
|
||||
_logic.CloseWindow(pos);
|
||||
_windowLogic.CloseWindow(pos);
|
||||
}
|
||||
|
||||
void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
|
||||
@@ -1654,7 +1661,7 @@ void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspect
|
||||
if (_useNonClientArea)
|
||||
{
|
||||
auto nonClientWindow{ static_cast<NonClientIslandWindow*>(_window.get()) };
|
||||
nonClientWindow->SetTitlebarBackground(_logic.TitlebarBrush());
|
||||
nonClientWindow->SetTitlebarBackground(_windowLogic.TitlebarBrush());
|
||||
_updateTheme();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,11 @@ public:
|
||||
|
||||
private:
|
||||
std::unique_ptr<IslandWindow> _window;
|
||||
|
||||
// winrt::TerminalApp::App _app;
|
||||
winrt::TerminalApp::AppLogic _logic;
|
||||
winrt::TerminalApp::AppLogic _appLogic;
|
||||
winrt::TerminalApp::TerminalWindow _windowLogic;
|
||||
|
||||
winrt::Microsoft::Terminal::Remoting::WindowManager _windowManager{ nullptr };
|
||||
|
||||
std::vector<winrt::Microsoft::Terminal::Settings::Model::GlobalSummonArgs> _hotkeys;
|
||||
@@ -153,28 +156,28 @@ private:
|
||||
winrt::Microsoft::Terminal::Remoting::Peasant::SummonRequested_revoker peasantSummonRequested;
|
||||
winrt::Microsoft::Terminal::Remoting::Peasant::DisplayWindowIdRequested_revoker peasantDisplayWindowIdRequested;
|
||||
winrt::Microsoft::Terminal::Remoting::Peasant::QuitRequested_revoker peasantQuitRequested;
|
||||
winrt::TerminalApp::AppLogic::CloseRequested_revoker CloseRequested;
|
||||
winrt::TerminalApp::AppLogic::RequestedThemeChanged_revoker RequestedThemeChanged;
|
||||
winrt::TerminalApp::AppLogic::FullscreenChanged_revoker FullscreenChanged;
|
||||
winrt::TerminalApp::AppLogic::FocusModeChanged_revoker FocusModeChanged;
|
||||
winrt::TerminalApp::AppLogic::AlwaysOnTopChanged_revoker AlwaysOnTopChanged;
|
||||
winrt::TerminalApp::AppLogic::RaiseVisualBell_revoker RaiseVisualBell;
|
||||
winrt::TerminalApp::AppLogic::SystemMenuChangeRequested_revoker SystemMenuChangeRequested;
|
||||
winrt::TerminalApp::AppLogic::ChangeMaximizeRequested_revoker ChangeMaximizeRequested;
|
||||
winrt::TerminalApp::AppLogic::TitleChanged_revoker TitleChanged;
|
||||
winrt::TerminalApp::AppLogic::LastTabClosed_revoker LastTabClosed;
|
||||
winrt::TerminalApp::AppLogic::SetTaskbarProgress_revoker SetTaskbarProgress;
|
||||
winrt::TerminalApp::AppLogic::IdentifyWindowsRequested_revoker IdentifyWindowsRequested;
|
||||
winrt::TerminalApp::AppLogic::RenameWindowRequested_revoker RenameWindowRequested;
|
||||
winrt::TerminalApp::TerminalWindow::CloseRequested_revoker CloseRequested;
|
||||
winrt::TerminalApp::TerminalWindow::RequestedThemeChanged_revoker RequestedThemeChanged;
|
||||
winrt::TerminalApp::TerminalWindow::FullscreenChanged_revoker FullscreenChanged;
|
||||
winrt::TerminalApp::TerminalWindow::FocusModeChanged_revoker FocusModeChanged;
|
||||
winrt::TerminalApp::TerminalWindow::AlwaysOnTopChanged_revoker AlwaysOnTopChanged;
|
||||
winrt::TerminalApp::TerminalWindow::RaiseVisualBell_revoker RaiseVisualBell;
|
||||
winrt::TerminalApp::TerminalWindow::SystemMenuChangeRequested_revoker SystemMenuChangeRequested;
|
||||
winrt::TerminalApp::TerminalWindow::ChangeMaximizeRequested_revoker ChangeMaximizeRequested;
|
||||
winrt::TerminalApp::TerminalWindow::TitleChanged_revoker TitleChanged;
|
||||
winrt::TerminalApp::TerminalWindow::LastTabClosed_revoker LastTabClosed;
|
||||
winrt::TerminalApp::TerminalWindow::SetTaskbarProgress_revoker SetTaskbarProgress;
|
||||
winrt::TerminalApp::TerminalWindow::IdentifyWindowsRequested_revoker IdentifyWindowsRequested;
|
||||
winrt::TerminalApp::TerminalWindow::RenameWindowRequested_revoker RenameWindowRequested;
|
||||
winrt::TerminalApp::TerminalWindow::IsQuakeWindowChanged_revoker IsQuakeWindowChanged;
|
||||
winrt::TerminalApp::TerminalWindow::SummonWindowRequested_revoker SummonWindowRequested;
|
||||
winrt::TerminalApp::TerminalWindow::OpenSystemMenu_revoker OpenSystemMenu;
|
||||
winrt::TerminalApp::TerminalWindow::QuitRequested_revoker QuitRequested;
|
||||
winrt::TerminalApp::TerminalWindow::ShowWindowChanged_revoker ShowWindowChanged;
|
||||
winrt::TerminalApp::TerminalWindow::PropertyChanged_revoker PropertyChanged;
|
||||
winrt::TerminalApp::AppLogic::SettingsChanged_revoker SettingsChanged;
|
||||
winrt::TerminalApp::AppLogic::IsQuakeWindowChanged_revoker IsQuakeWindowChanged;
|
||||
winrt::TerminalApp::AppLogic::SummonWindowRequested_revoker SummonWindowRequested;
|
||||
winrt::TerminalApp::AppLogic::OpenSystemMenu_revoker OpenSystemMenu;
|
||||
winrt::TerminalApp::AppLogic::QuitRequested_revoker QuitRequested;
|
||||
winrt::TerminalApp::AppLogic::ShowWindowChanged_revoker ShowWindowChanged;
|
||||
winrt::Microsoft::Terminal::Remoting::WindowManager::ShowNotificationIconRequested_revoker ShowNotificationIconRequested;
|
||||
winrt::Microsoft::Terminal::Remoting::WindowManager::HideNotificationIconRequested_revoker HideNotificationIconRequested;
|
||||
winrt::Microsoft::Terminal::Remoting::WindowManager::QuitAllRequested_revoker QuitAllRequested;
|
||||
winrt::TerminalApp::AppLogic::PropertyChanged_revoker PropertyChanged;
|
||||
} _revokers{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user