This where i'd minimize the terminal IF I GOT A MINIMIZED FLAG

This commit is contained in:
Mike Griese
2023-04-06 10:39:03 -05:00
parent 46db89cc51
commit 66f8b25ec5
5 changed files with 36 additions and 7 deletions

View File

@@ -596,7 +596,7 @@ namespace winrt::TerminalApp::implementation
{
if (const auto& realArgs = args.ActionArgs().try_as<SetMaximizedArgs>())
{
RequestSetMaximized(realArgs.IsMaximized());
_RequestSetMaximized(realArgs.IsMaximized());
args.Handled(true);
}
}

View File

@@ -1,4 +1,4 @@
ShowWindowChanged
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
@@ -24,7 +24,7 @@
#include "TabRowControl.h"
#include "Utils.h"
using namespace winrt;
using namespace winrt;
using namespace winrt::Microsoft::Terminal::Control;
using namespace winrt::Microsoft::Terminal::Settings::Model;
using namespace winrt::Microsoft::Terminal::TerminalConnection;
@@ -3568,7 +3568,7 @@ namespace winrt::TerminalApp::implementation
// Method Description:
// - Asks the window to change its maximized state.
void TerminalPage::RequestSetMaximized(bool newMaximized)
void TerminalPage::_RequestSetMaximized(bool newMaximized)
{
if (_isMaximized == newMaximized)
{
@@ -3578,6 +3578,20 @@ namespace winrt::TerminalApp::implementation
_ChangeMaximizeRequestedHandlers(*this, nullptr);
}
// Set the window to be minimized. This will bubble it up to the window
// layer, and propogate down to the term controls. This should only be used
// for an INITIAL defterm connection. We don't really want a `start /min
// cmd` to glom to an existing wt and minimize it.
void TerminalPage::_RequestSetMinimized()
{
// Two parts here:
// * We need to tell the window layer to minimize the window
// * We need to inform the control that we want it to act like it's minimized
Microsoft::Terminal::Control::ShowWindowArgs args(false /* show */);
_ShowWindowChangedHandlers(*this, args);
WindowVisibilityChanged(false);
}
HRESULT TerminalPage::_OnNewConnection(const ConptyConnection& connection)
{
_newConnectionRevoker.revoke();
@@ -3634,9 +3648,16 @@ namespace winrt::TerminalApp::implementation
// Make sure that there were no other tabs already existing (in
// the case that we are in glomming mode), because we don't want
// to be maximizing other existing sessions that did not ask for it.
if (_tabs.Size() == 1 && connection.ShowWindow() == SW_SHOWMAXIMIZED)
if (_tabs.Size())
{
RequestSetMaximized(true);
if (connection.ShowWindow() == SW_SHOWMAXIMIZED)
{
_RequestSetMaximized(true);
}
else if (connection.ShowWindow() == SW_SHOWMINIMIZED)
{
_RequestSetMinimized();
}
}
return S_OK;
}

View File

@@ -130,7 +130,6 @@ namespace winrt::TerminalApp::implementation
void SetFullscreen(bool);
void SetFocusMode(const bool inFocusMode);
void Maximized(bool newMaximized);
void RequestSetMaximized(bool newMaximized);
void SetStartupActions(std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs>& actions);
@@ -524,6 +523,9 @@ namespace winrt::TerminalApp::implementation
void _SelectionMenuOpened(const IInspectable& sender, const IInspectable& args);
void _PopulateContextMenu(const IInspectable& sender, const bool withSelection);
void _RequestSetMaximized(bool newMaximized);
void _RequestSetMinimized();
#pragma region ActionHandlers
// These are all defined in AppActionHandlers.cpp
#define ON_ALL_ACTIONS(action) DECLARE_ACTION_HANDLER(action);

View File

@@ -180,3 +180,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
WINRT_PROPERTY(bool, ClearMarkers, false);
};
}
namespace winrt::Microsoft::Terminal::Control::factory_implementation
{
BASIC_FACTORY(ShowWindowArgs);
}

View File

@@ -81,6 +81,7 @@ namespace Microsoft.Terminal.Control
runtimeclass ShowWindowArgs
{
ShowWindowArgs(Boolean showOrHide);
Boolean ShowOrHide { get; };
}