Skip to content

Commit

Permalink
This where i'd minimize the terminal IF I GOT A MINIMIZED FLAG
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Apr 6, 2023
1 parent 46db89c commit 66f8b25
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
31 changes: 26 additions & 5 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

ShowWindowChanged
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalControl/EventArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/EventArgs.idl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace Microsoft.Terminal.Control

runtimeclass ShowWindowArgs
{
ShowWindowArgs(Boolean showOrHide);
Boolean ShowOrHide { get; };
}

Expand Down

1 comment on commit 66f8b25

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log for details.

Unrecognized words (2)

propogate
stame

Previously acknowledged words that are now absent Hirots NULs xwwyzz xxyyzz :arrow_right:
To accept ✔️ these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/migrie/b/9053-part-4-i-guess-defterm branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.21/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/4630613785/attempts/1'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. If it doesn't work for you, you can manually add (one word per line) / remove items to expect.txt and the excludes.txt files.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.