Compare commits

...

40 Commits

Author SHA1 Message Date
Mike Griese
66f8b25ec5 This where i'd minimize the terminal IF I GOT A MINIMIZED FLAG 2023-04-06 10:39:03 -05:00
Mike Griese
46db89cc51 I cannot believe it was that easy 2023-04-06 09:43:40 -05:00
Mike Griese
e7afa5b6f6 Merge branch 'dev/migrie/b/9053-attempt-2' into dev/migrie/b/9053-part-3-the-actual-doing-of-the-thing 2023-04-05 16:41:07 -05:00
Mike Griese
35db280366 VS *shake fist* 2023-04-05 16:28:42 -05:00
Mike Griese
02f5bfa9ce cleanup comment 2023-04-05 16:20:26 -05:00
Mike Griese
e67bfb3380 this is cleaner 2023-04-05 16:08:33 -05:00
Mike Griese
431b26aa58 as it turns out, we don't need the invalidate. that's at least _less_ dumb 2023-04-05 16:02:52 -05:00
Mike Griese
6a99f25d6d as a point of bookmarking - this works 2023-04-05 15:49:12 -05:00
Mike Griese
8b14a22e5c Merge branch 'main' into dev/migrie/b/9053-attempt-2
# Conflicts:
#	src/cascadia/TerminalApp/AppLogic.h
#	src/cascadia/TerminalApp/AppLogic.idl
#	src/cascadia/TerminalApp/TerminalPage.cpp
#	src/cascadia/WindowsTerminal/AppHost.cpp
#	src/cascadia/WindowsTerminal/AppHost.h
2023-04-05 15:05:42 -05:00
Mike Griese
e99af2dc48 Merge branch 'main' into dev/migrie/b/9053-attempt-2 2023-01-24 06:53:06 -06:00
Mike Griese
6a2074156c Merge branch 'dev/migrie/b/9053-attempt-2' of https://github.com/microsoft/terminal into dev/migrie/b/9053-attempt-2 2022-12-01 17:15:05 -06:00
Mike Griese
8c66d9092e Merge remote-tracking branch 'origin/main' into dev/migrie/b/9053-attempt-2 2022-12-01 14:01:16 -06:00
Dustin L. Howett
b37ed82fc6 Migrate spelling-0.0.21 changes from main 2022-08-26 06:16:57 -05:00
Mike Griese
42a5fc9590 Merge remote-tracking branch 'origin/main' into dev/migrie/b/9053-attempt-2 2022-08-26 06:16:57 -05:00
Dustin L. Howett
7fca59f301 Migrate spelling-0.0.21 changes from main 2022-08-22 11:04:15 -05:00
Mike Griese
9bb5fbb65b Revert "until we can be sure, lets take this out"
This reverts commit 1fac403556.
2022-08-22 11:04:15 -05:00
Mike Griese
1fac403556 until we can be sure, lets take this out 2022-08-22 10:55:44 -05:00
Mike Griese
c34495dcfc yea this does it 2022-08-19 13:14:13 -05:00
Mike Griese
a1fd241604 Well this fixes it but I need to sort out the last bits of the launchmode 2022-08-19 13:04:44 -05:00
Mike Griese
4c08b9a1bc Revert "Revert "Hide the window from DWM until we're finished with initialization (#12979)" (#13098)"
This reverts commit 6ffc3dc7a8.
2022-08-19 12:55:17 -05:00
Mike Griese
38de95efa8 Code review notes 2022-08-19 10:04:37 -05:00
Mike Griese
58492798c4 Merge branch 'main' into dev/migrie/f/9458-startupInfoToTerminal 2022-08-19 06:34:28 -05:00
Mike Griese
3ce349e81b big s/o to whoever added the onecore projects to the oss repo, so we caught it 2022-08-12 12:56:07 -05:00
Mike Griese
d2336e3831 Merge remote-tracking branch 'origin/main' into dev/migrie/f/9458-startupInfoToTerminal 2022-08-11 10:21:11 -05:00
Mike Griese
18a62bdae7 I think I'm gonna need to put EVERYTHING in here 2022-07-26 10:43:36 -05:00
Mike Griese
01420b9902 Merge remote-tracking branch 'origin/main' into dev/migrie/f/9458-startupInfoToTerminal 2022-07-26 10:30:17 -05:00
Mike Griese
5bf3c1ee50 had this all before the long weekend 2022-07-26 10:29:48 -05:00
Mike Griese
879a955f3b more comments, cleanup 2022-07-22 13:13:31 -05:00
Mike Griese
e333661a15 cleanup for review 2022-07-22 13:08:27 -05:00
Mike Griese
7268e96ef0 Remove scratch work 2022-07-22 11:00:10 -05:00
Mike Griese
c0b4840dcd Merge remote-tracking branch 'origin/main' into dev/migrie/f/9458-startupInfoToTerminal 2022-07-22 07:13:20 -05:00
Mike Griese
4b717db6f0 Merge remote-tracking branch 'origin/main' into dev/migrie/f/9458-startupInfoToTerminal 2022-07-22 07:13:04 -05:00
Mike Griese
fd75c5e1ea I think this is all the prototyping I need 2022-07-21 15:07:52 -05:00
Mike Griese
9a2ee6a7c2 Cleanup, comments, etc. 2022-07-19 12:30:26 -05:00
Mike Griese
dc78b3267a this does temporarily get the title out of the link, but then it's lose 2022-07-19 12:07:03 -05:00
Mike Griese
874a15b89b Good-news-everyone.gif
This hooks up the defterm interface to pass more info along in the startup. It's notably not the actual link title, but it does work from a plumbing standpoint

  This is for #9458
2022-07-19 11:14:17 -05:00
Mike Griese
1dd6e99340 prototype 2022-07-18 16:57:00 -05:00
Mike Griese
11bfc73400 A BLANK SCRATCH COMMIT 2022-07-18 15:05:42 -05:00
Mike Griese
c795793f4c Revert "I just want to run the scratch project, I have no idea how this got so brboken"
This reverts commit 103beb4be1.
2022-07-18 14:59:58 -05:00
Mike Griese
103beb4be1 I just want to run the scratch project, I have no idea how this got so brboken 2022-07-18 14:59:19 -05:00
19 changed files with 179 additions and 47 deletions

View File

@@ -804,6 +804,7 @@ HIBYTE
hicon
HIDEWINDOW
hinst
Hirots
HISTORYBUFS
HISTORYNODUP
HISTORYSIZE
@@ -2283,6 +2284,8 @@ xunit
xutr
XVIRTUALSCREEN
XWalk
xwwyzz
xxyyzz
yact
YCast
YCENTER

View File

@@ -14,9 +14,11 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
}
CommandlineArgs(const winrt::array_view<const winrt::hstring>& args,
winrt::hstring currentDirectory) :
winrt::hstring currentDirectory,
const uint32_t showWindowCommand) :
_args{ args.begin(), args.end() },
_cwd{ currentDirectory }
_cwd{ currentDirectory },
_ShowWindowCommand{ showWindowCommand }
{
}
@@ -25,6 +27,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
void Commandline(const winrt::array_view<const winrt::hstring>& value);
winrt::com_array<winrt::hstring> Commandline();
WINRT_PROPERTY(uint32_t, ShowWindowCommand, SW_NORMAL); // SW_NORMAL is 1, 0 is SW_HIDE
private:
winrt::com_array<winrt::hstring> _args;
winrt::hstring _cwd;

View File

@@ -46,7 +46,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
_Id{ windowInfo.Id() ? windowInfo.Id().Value() : 0 }, // We'll use 0 as a sentinel, since no window will ever get to have that ID
_WindowName{ windowInfo.WindowName() },
_args{ command.Commandline() },
_CurrentDirectory{ command.CurrentDirectory() } {};
_CurrentDirectory{ command.CurrentDirectory() },
_ShowWindowCommand{ command.ShowWindowCommand() } {};
WindowRequestedArgs(const winrt::hstring& window, const winrt::hstring& content, const Windows::Foundation::IReference<Windows::Foundation::Rect>& bounds) :
_Id{ 0u },
@@ -63,6 +64,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
WINRT_PROPERTY(winrt::hstring, WindowName);
WINRT_PROPERTY(winrt::hstring, CurrentDirectory);
WINRT_PROPERTY(winrt::hstring, Content);
WINRT_PROPERTY(uint32_t, ShowWindowCommand, SW_NORMAL);
WINRT_PROPERTY(Windows::Foundation::IReference<Windows::Foundation::Rect>, InitialBounds);
private:

View File

@@ -26,6 +26,7 @@ namespace Microsoft.Terminal.Remoting
String[] Commandline { get; };
String CurrentDirectory { get; };
UInt32 ShowWindowCommand { get; };
String Content { get; };
Windows.Foundation.IReference<Windows.Foundation.Rect> InitialBounds { get; };

View File

@@ -7,10 +7,11 @@ namespace Microsoft.Terminal.Remoting
runtimeclass CommandlineArgs
{
CommandlineArgs();
CommandlineArgs(String[] args, String cwd);
CommandlineArgs(String[] args, String cwd, UInt32 showWindowCommand);
String[] Commandline { get; set; };
String CurrentDirectory();
UInt32 ShowWindowCommand { get; };
};
runtimeclass RenameRequestArgs

View File

@@ -319,7 +319,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
// If the name wasn't specified, this will be an empty string.
p->WindowName(args.WindowName());
p->ExecuteCommandline(*winrt::make_self<CommandlineArgs>(args.Commandline(), args.CurrentDirectory()));
p->ExecuteCommandline(*winrt::make_self<CommandlineArgs>(args.Commandline(), args.CurrentDirectory(), args.ShowWindowCommand()));
_monarch.AddPeasant(*p);

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;
@@ -623,7 +623,7 @@ namespace winrt::TerminalApp::implementation
// - <none>
// Return Value:
// - <none>
void TerminalPage::_CompleteInitialization()
winrt::fire_and_forget TerminalPage::_CompleteInitialization()
{
_startupState = StartupState::Initialized;
@@ -643,10 +643,39 @@ namespace winrt::TerminalApp::implementation
if (_tabs.Size() == 0 && !(_shouldStartInboundListener || _isEmbeddingInboundListener))
{
_LastTabClosedHandlers(*this, winrt::make<LastTabClosedEventArgs>(false));
co_return;
}
else
{
_InitializedHandlers(*this, nullptr);
// GH#11561: When we start up, our window is initially just a frame
// with a transparent content area. We're gonna do all this startup
// init on the UI thread, so the UI won't actually paint till it's
// all done. This results in a few frames where the frame is
// visible, before the page paints for the first time, before any
// tabs appears, etc.
//
// To mitigate this, we're gonna wait for the UI thread to finish
// everything it's gotta do for the initial init, and _then_ fire
// our Initialized event. By waiting for everything else to finish
// (CoreDispatcherPriority::Low), we let all the tabs and panes
// actually get created. In the window layer, we're gonna cloak the
// window till this event is fired, so we don't actually see this
// frame until we're actually all ready to go.
//
// This will result in the window seemingly not loading as fast, but
// it will actually take exactly the same amount of time before it's
// usable.
//
// We also experimented with drawing a solid BG color before the
// initialization is finished. However, there are still a few frames
// after the frame is displayed before the XAML content first draws,
// so that didn't actually resolve any issues.
Dispatcher().RunAsync(CoreDispatcherPriority::Low, [weak = get_weak()]() {
if (auto self{ weak.get() })
{
self->_InitializedHandlers(*self, nullptr);
}
});
}
}
@@ -3539,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)
{
@@ -3549,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();
@@ -3605,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);
@@ -180,7 +179,7 @@ namespace winrt::TerminalApp::implementation
TYPED_EVENT(AlwaysOnTopChanged, IInspectable, IInspectable);
TYPED_EVENT(RaiseVisualBell, IInspectable, IInspectable);
TYPED_EVENT(SetTaskbarProgress, IInspectable, IInspectable);
TYPED_EVENT(Initialized, IInspectable, winrt::Windows::UI::Xaml::RoutedEventArgs);
TYPED_EVENT(Initialized, IInspectable, IInspectable);
TYPED_EVENT(IdentifyWindowsRequested, IInspectable, IInspectable);
TYPED_EVENT(RenameWindowRequested, Windows::Foundation::IInspectable, winrt::TerminalApp::RenameWindowRequestedArgs);
TYPED_EVENT(SummonWindowRequested, IInspectable, IInspectable);
@@ -447,7 +446,7 @@ namespace winrt::TerminalApp::implementation
void _StartInboundListener();
void _CompleteInitialization();
winrt::fire_and_forget _CompleteInitialization();
void _FocusActiveControl(IInspectable sender, IInspectable eventArgs);
@@ -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

@@ -89,7 +89,7 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<Object, Object> FocusModeChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> FullscreenChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> AlwaysOnTopChanged;
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.RoutedEventArgs> Initialized;
event Windows.Foundation.TypedEventHandler<Object, Object> Initialized;
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;

View File

@@ -203,6 +203,8 @@ namespace winrt::TerminalApp::implementation
// 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(Initialized, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, Initialized);
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);

View File

@@ -114,6 +114,8 @@ namespace TerminalApp
// information.
void DismissDialog();
event Windows.Foundation.TypedEventHandler<Object, Object> Initialized;
event Windows.Foundation.TypedEventHandler<Object, Windows.UI.Xaml.UIElement> SetTitleBarContent;
event Windows.Foundation.TypedEventHandler<Object, String> TitleChanged;
event Windows.Foundation.TypedEventHandler<Object, LastTabClosedEventArgs> LastTabClosed;

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; };
}

View File

@@ -60,8 +60,7 @@ AppHost::AppHost(const winrt::TerminalApp::AppLogic& logic,
auto pfn = std::bind(&AppHost::_HandleCreateWindow,
this,
std::placeholders::_1,
std::placeholders::_2,
std::placeholders::_3);
std::placeholders::_2);
_window->SetCreateCallback(pfn);
// Event handlers:
@@ -196,6 +195,8 @@ void AppHost::_HandleCommandlineArgs(const Remoting::WindowRequestedArgs& window
}
}
_launchShowWindowCommand = windowArgs.ShowWindowCommand();
// This is a fix for GH#12190 and hopefully GH#12169.
//
// If the commandline we were provided is going to result in us only
@@ -339,6 +340,7 @@ void AppHost::Initialize()
_window->UpdateSettingsRequested({ this, &AppHost::_requestUpdateSettings });
_revokers.Initialized = _windowLogic.Initialized(winrt::auto_revoke, { this, &AppHost::_WindowInitializedHandler });
_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 });
@@ -510,12 +512,31 @@ LaunchPosition AppHost::_GetWindowLaunchPosition()
return pos;
}
// Method Description:
// - Callback for when the window is first being created (during WM_CREATE).
// Stash the proposed size for later. We'll need that once we're totally
// initialized, so that we can show the window in the right position *when we
// want to show it*. If we did the _initialResizeAndRepositionWindow work now,
// it would have no effect, because the window is not yet visible.
// Arguments:
// - hwnd: The HWND of the window we're about to create.
// - proposedRect: The location and size of the window that we're about to
// create. We'll use this rect to determine which monitor the window is about
// to appear on.
void AppHost::_HandleCreateWindow(const HWND /* hwnd */, const til::rect& proposedRect)
{
// GH#11561: Hide the window until we're totally done being initialized.
// More commentary in TerminalPage::_CompleteInitialization
_initialResizeAndRepositionWindow(_window->GetHandle(), proposedRect, _launchMode);
}
// Method Description:
// - Resize the window we're about to create to the appropriate dimensions, as
// specified in the settings. This will be called during the handling of
// WM_CREATE. We'll load the settings for the app, then get the proposed size
// of the terminal from the app. Using that proposed size, we'll resize the
// window we're creating, so that it'll match the values in the settings.
// specified in the settings. This is called once the app has finished it's
// initial setup, once we have created all the tabs, panes, etc. We'll load
// the settings for the app, then get the proposed size of the terminal from
// the app. Using that proposed size, we'll resize the window we're creating,
// so that it'll match the values in the settings.
// Arguments:
// - hwnd: The HWND of the window we're about to create.
// - proposedRect: The location and size of the window that we're about to
@@ -524,7 +545,7 @@ LaunchPosition AppHost::_GetWindowLaunchPosition()
// - launchMode: A LaunchMode enum reference that indicates the launch mode
// Return Value:
// - None
void AppHost::_HandleCreateWindow(const HWND hwnd, til::rect proposedRect, LaunchMode& launchMode)
void AppHost::_initialResizeAndRepositionWindow(const HWND hwnd, til::rect proposedRect, LaunchMode& launchMode)
{
launchMode = _windowLogic.GetLaunchMode();
@@ -1211,6 +1232,32 @@ void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspect
}
}
winrt::fire_and_forget AppHost::_WindowInitializedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*arg*/)
{
// GH#11561: We're totally done being initialized. Resize the window to
// match the initial settings, and then call ShowWindow to finally make us
// visible.
// Use the visibility that we were originally requested with as a base. We
// can't just use SW_SHOWDEFAULT, because that is set on a per-process
// basis. That means that a second window needs to have its STARTUPINFO's
// wShowCmd passed into the original process.
auto nCmdShow = _launchShowWindowCommand;
if (WI_IsFlagSet(_launchMode, LaunchMode::MaximizedMode))
{
nCmdShow = SW_MAXIMIZE;
}
// For inexplicable reasons, again, hop to the BG thread, then back to the
// UI thread. This is shockingly load bearing - without this, then
// sometimes, we'll _still_ show the HWND before the XAML island actually
// paints.
co_await winrt::resume_background();
co_await wil::resume_foreground(_windowLogic.GetRoot().Dispatcher(), winrt::Windows::UI::Core::CoreDispatcherPriority::Low);
ShowWindow(_window->GetHandle(), nCmdShow);
}
winrt::TerminalApp::TerminalWindow AppHost::Logic()
{
return _windowLogic;

View File

@@ -39,15 +39,19 @@ private:
winrt::com_ptr<IVirtualDesktopManager> _desktopManager{ nullptr };
bool _useNonClientArea{ false };
winrt::Microsoft::Terminal::Settings::Model::LaunchMode _launchMode{};
std::shared_ptr<ThrottledFuncTrailing<bool>> _showHideWindowThrottler;
uint32_t _launchShowWindowCommand{ SW_NORMAL };
void _preInit();
void _HandleCommandlineArgs(const winrt::Microsoft::Terminal::Remoting::WindowRequestedArgs& args);
winrt::Microsoft::Terminal::Settings::Model::LaunchPosition _GetWindowLaunchPosition();
void _HandleCreateWindow(const HWND hwnd, til::rect proposedRect, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode);
void _HandleCreateWindow(const HWND hwnd, const til::rect& proposedRect);
void _UpdateTitleBarContent(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::UIElement& arg);
void _UpdateTheme(const winrt::Windows::Foundation::IInspectable&,
@@ -60,6 +64,9 @@ private:
const winrt::Windows::Foundation::IInspectable& arg);
void _AlwaysOnTopChanged(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& arg);
winrt::fire_and_forget _WindowInitializedHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& arg);
void _RaiseVisualBell(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& arg);
void _WindowMouseWheeled(const til::point coord, const int32_t delta);
@@ -116,7 +123,7 @@ private:
void _PropertyChangedHandler(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);
void _initialResizeAndRepositionWindow(const HWND hwnd, RECT proposedRect, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode);
void _initialResizeAndRepositionWindow(const HWND hwnd, til::rect proposedRect, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode);
void _handleMoveContent(const winrt::Windows::Foundation::IInspectable& sender,
winrt::TerminalApp::RequestMoveContentArgs args);
@@ -146,8 +153,10 @@ 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::Microsoft::Terminal::Remoting::Peasant::AttachRequested_revoker AttachRequested;
winrt::TerminalApp::TerminalWindow::Initialized_revoker Initialized;
winrt::TerminalApp::TerminalWindow::CloseRequested_revoker CloseRequested;
winrt::TerminalApp::TerminalWindow::RequestedThemeChanged_revoker RequestedThemeChanged;
winrt::TerminalApp::TerminalWindow::FullscreenChanged_revoker FullscreenChanged;

View File

@@ -111,7 +111,7 @@ void IslandWindow::Close()
// window.
// Return Value:
// - <none>
void IslandWindow::SetCreateCallback(std::function<void(const HWND, const til::rect&, LaunchMode& launchMode)> pfn) noexcept
void IslandWindow::SetCreateCallback(std::function<void(const HWND, const til::rect&)> pfn) noexcept
{
_pfnCreateCallback = pfn;
}
@@ -153,19 +153,13 @@ void IslandWindow::_HandleCreateWindow(const WPARAM, const LPARAM lParam) noexce
rc.right = rc.left + pcs->cx;
rc.bottom = rc.top + pcs->cy;
auto launchMode = LaunchMode::DefaultMode;
if (_pfnCreateCallback)
{
_pfnCreateCallback(_window.get(), rc, launchMode);
_pfnCreateCallback(_window.get(), rc);
}
auto nCmdShow = SW_SHOW;
if (WI_IsFlagSet(launchMode, LaunchMode::MaximizedMode))
{
nCmdShow = SW_MAXIMIZE;
}
ShowWindow(_window.get(), nCmdShow);
// GH#11561: DO NOT call ShowWindow here. The AppHost will call ShowWindow
// once the app has completed its initialization.
UpdateWindow(_window.get());

View File

@@ -39,7 +39,8 @@ public:
virtual void Initialize();
void SetCreateCallback(std::function<void(const HWND, const til::rect&, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> pfn) noexcept;
void SetCreateCallback(std::function<void(const HWND, const til::rect&)> pfn) noexcept;
void SetSnapDimensionCallback(std::function<float(bool widthOrHeight, float dimension)> pfn) noexcept;
void FocusModeChanged(const bool focusMode);
@@ -97,7 +98,7 @@ protected:
winrt::Windows::UI::Xaml::Controls::Grid _rootGrid;
wil::com_ptr<ITaskbarList3> _taskbar;
std::function<void(const HWND, const til::rect&, winrt::Microsoft::Terminal::Settings::Model::LaunchMode& launchMode)> _pfnCreateCallback;
std::function<void(const HWND, const til::rect&)> _pfnCreateCallback;
std::function<float(bool, float)> _pfnSnapDimensionCallback;
void _HandleCreateWindow(const WPARAM wParam, const LPARAM lParam) noexcept;

View File

@@ -73,7 +73,15 @@ bool WindowEmperor::HandleCommandlineArgs()
_buildArgsFromCommandline(args);
auto cwd{ wil::GetCurrentDirectoryW<std::wstring>() };
Remoting::CommandlineArgs eventArgs{ { args }, { cwd } };
// Get the requested initial state of the window from our startup info. For
// something like `start /min`, this will set the wShowWindow member to
// SW_SHOWMINIMIZED. We'll need to make sure is bubbled all the way through,
// so we can open a new window with the stame state.
STARTUPINFOW si;
GetStartupInfoW(&si);
const auto showWindow = si.wShowWindow;
Remoting::CommandlineArgs eventArgs{ { args }, { cwd }, showWindow };
const auto isolatedMode{ _app.Logic().IsolatedMode() };
@@ -173,14 +181,14 @@ void WindowEmperor::_windowStartedHandlerPostXAML(const std::shared_ptr<WindowTh
// the foreground, but we should act like the new window is.
//
// TODO: GH#14957 - use AllowSetForeground from the original wt.exe instead
Remoting::SummonWindowSelectionArgs args{};
args.OnCurrentDesktop(false);
args.WindowID(sender->Peasant().GetID());
args.SummonBehavior().MoveToCurrentDesktop(false);
args.SummonBehavior().ToggleVisibility(false);
args.SummonBehavior().DropdownDuration(0);
args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::InPlace);
_manager.SummonWindow(args);
// Remoting::SummonWindowSelectionArgs args{};
// args.OnCurrentDesktop(false);
// args.WindowID(sender->Peasant().GetID());
// args.SummonBehavior().MoveToCurrentDesktop(false);
// args.SummonBehavior().ToggleVisibility(false);
// args.SummonBehavior().DropdownDuration(0);
// args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::InPlace);
// _manager.SummonWindow(args);
// Now that the window is ready to go, we can add it to our list of windows,
// because we know it will be well behaved.