Skip to content

Commit 66f8b25

Browse files
committed
This where i'd minimize the terminal IF I GOT A MINIMIZED FLAG
1 parent 46db89c commit 66f8b25

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

src/cascadia/TerminalApp/AppActionHandlers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ namespace winrt::TerminalApp::implementation
596596
{
597597
if (const auto& realArgs = args.ActionArgs().try_as<SetMaximizedArgs>())
598598
{
599-
RequestSetMaximized(realArgs.IsMaximized());
599+
_RequestSetMaximized(realArgs.IsMaximized());
600600
args.Handled(true);
601601
}
602602
}

src/cascadia/TerminalApp/TerminalPage.cpp

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
ShowWindowChanged
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT license.
44

@@ -24,7 +24,7 @@
2424
#include "TabRowControl.h"
2525
#include "Utils.h"
2626

27-
using namespace winrt;
27+
using namespace winrt;
2828
using namespace winrt::Microsoft::Terminal::Control;
2929
using namespace winrt::Microsoft::Terminal::Settings::Model;
3030
using namespace winrt::Microsoft::Terminal::TerminalConnection;
@@ -3568,7 +3568,7 @@ namespace winrt::TerminalApp::implementation
35683568

35693569
// Method Description:
35703570
// - Asks the window to change its maximized state.
3571-
void TerminalPage::RequestSetMaximized(bool newMaximized)
3571+
void TerminalPage::_RequestSetMaximized(bool newMaximized)
35723572
{
35733573
if (_isMaximized == newMaximized)
35743574
{
@@ -3578,6 +3578,20 @@ namespace winrt::TerminalApp::implementation
35783578
_ChangeMaximizeRequestedHandlers(*this, nullptr);
35793579
}
35803580

3581+
// Set the window to be minimized. This will bubble it up to the window
3582+
// layer, and propogate down to the term controls. This should only be used
3583+
// for an INITIAL defterm connection. We don't really want a `start /min
3584+
// cmd` to glom to an existing wt and minimize it.
3585+
void TerminalPage::_RequestSetMinimized()
3586+
{
3587+
// Two parts here:
3588+
// * We need to tell the window layer to minimize the window
3589+
// * We need to inform the control that we want it to act like it's minimized
3590+
Microsoft::Terminal::Control::ShowWindowArgs args(false /* show */);
3591+
_ShowWindowChangedHandlers(*this, args);
3592+
WindowVisibilityChanged(false);
3593+
}
3594+
35813595
HRESULT TerminalPage::_OnNewConnection(const ConptyConnection& connection)
35823596
{
35833597
_newConnectionRevoker.revoke();
@@ -3634,9 +3648,16 @@ namespace winrt::TerminalApp::implementation
36343648
// Make sure that there were no other tabs already existing (in
36353649
// the case that we are in glomming mode), because we don't want
36363650
// to be maximizing other existing sessions that did not ask for it.
3637-
if (_tabs.Size() == 1 && connection.ShowWindow() == SW_SHOWMAXIMIZED)
3651+
if (_tabs.Size())
36383652
{
3639-
RequestSetMaximized(true);
3653+
if (connection.ShowWindow() == SW_SHOWMAXIMIZED)
3654+
{
3655+
_RequestSetMaximized(true);
3656+
}
3657+
else if (connection.ShowWindow() == SW_SHOWMINIMIZED)
3658+
{
3659+
_RequestSetMinimized();
3660+
}
36403661
}
36413662
return S_OK;
36423663
}

src/cascadia/TerminalApp/TerminalPage.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ namespace winrt::TerminalApp::implementation
130130
void SetFullscreen(bool);
131131
void SetFocusMode(const bool inFocusMode);
132132
void Maximized(bool newMaximized);
133-
void RequestSetMaximized(bool newMaximized);
134133

135134
void SetStartupActions(std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs>& actions);
136135

@@ -524,6 +523,9 @@ namespace winrt::TerminalApp::implementation
524523
void _SelectionMenuOpened(const IInspectable& sender, const IInspectable& args);
525524
void _PopulateContextMenu(const IInspectable& sender, const bool withSelection);
526525

526+
void _RequestSetMaximized(bool newMaximized);
527+
void _RequestSetMinimized();
528+
527529
#pragma region ActionHandlers
528530
// These are all defined in AppActionHandlers.cpp
529531
#define ON_ALL_ACTIONS(action) DECLARE_ACTION_HANDLER(action);

src/cascadia/TerminalControl/EventArgs.h

+5
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
180180
WINRT_PROPERTY(bool, ClearMarkers, false);
181181
};
182182
}
183+
184+
namespace winrt::Microsoft::Terminal::Control::factory_implementation
185+
{
186+
BASIC_FACTORY(ShowWindowArgs);
187+
}

src/cascadia/TerminalControl/EventArgs.idl

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ namespace Microsoft.Terminal.Control
8181

8282
runtimeclass ShowWindowArgs
8383
{
84+
ShowWindowArgs(Boolean showOrHide);
8485
Boolean ShowOrHide { get; };
8586
}
8687

0 commit comments

Comments
 (0)