Skip to content

Commit c8d0c0a

Browse files
committed
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-panes
2 parents 863840e + 2357653 commit c8d0c0a

14 files changed

+102
-117
lines changed

src/cascadia/TerminalApp/IPaneContent.idl

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace TerminalApp
1414
Windows.UI.Xaml.FrameworkElement GetRoot();
1515
void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);
1616

17-
Windows.Foundation.Size MinSize { get; };
17+
Windows.Foundation.Size MinimumSize { get; };
1818

1919
String Title { get; };
2020
UInt64 TaskbarState { get; };
@@ -30,15 +30,15 @@ namespace TerminalApp
3030

3131
void Close();
3232

33-
event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
33+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> CloseRequested;
3434

35-
event Windows.Foundation.TypedEventHandler<Object, BellEventArgs> BellRequested;
36-
event Windows.Foundation.TypedEventHandler<Object, Object> TitleChanged;
37-
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
38-
event Windows.Foundation.TypedEventHandler<Object, Object> TaskbarProgressChanged;
3935
event Windows.Foundation.TypedEventHandler<Object, Object> ConnectionStateChanged;
40-
event Windows.Foundation.TypedEventHandler<Object, Object> ReadOnlyChanged;
41-
event Windows.Foundation.TypedEventHandler<Object, Object> FocusRequested;
36+
event Windows.Foundation.TypedEventHandler<IPaneContent, BellEventArgs> BellRequested;
37+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TitleChanged;
38+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TabColorChanged;
39+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TaskbarProgressChanged;
40+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> ReadOnlyChanged;
41+
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> FocusRequested;
4242
};
4343

4444

@@ -51,6 +51,6 @@ namespace TerminalApp
5151
interface ISnappable
5252
{
5353
Single SnapDownToGrid(PaneSnapDirection direction, Single sizeToSnap);
54-
Windows.Foundation.Size GridSize { get; };
54+
Windows.Foundation.Size GridUnitSize { get; };
5555
};
5656
}

src/cascadia/TerminalApp/Pane.cpp

+9-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "pch.h"
55
#include "Pane.h"
6+
67
#include "AppLogic.h"
78

89
#include "Utils.h"
@@ -1080,30 +1081,16 @@ TermControl Pane::GetLastFocusedTerminalControl()
10801081
{
10811082
if (p->_IsLeaf())
10821083
{
1083-
if (const auto& terminalPane{ p->_content.try_as<TerminalPaneContent>() })
1084-
{
1085-
return terminalPane.GetTerminal();
1086-
}
1087-
else
1088-
{
1089-
return nullptr;
1090-
}
1084+
return p->GetTerminalControl();
10911085
}
10921086
pane = p;
10931087
}
10941088
// We didn't find our child somehow, they might have closed under us.
10951089
}
10961090
return _firstChild->GetLastFocusedTerminalControl();
10971091
}
1098-
1099-
if (const auto& terminalPane{ _content.try_as<TerminalPaneContent>() })
1100-
{
1101-
return terminalPane.GetTerminal();
1102-
}
1103-
else
1104-
{
1105-
return nullptr;
1106-
}
1092+
// we _are_ a leaf.
1093+
return GetTerminalControl();
11071094
}
11081095

11091096
IPaneContent Pane::GetLastFocusedContent()
@@ -1140,7 +1127,7 @@ TermControl Pane::GetTerminalControl() const
11401127
{
11411128
if (const auto& terminalPane{ _getTerminalContent() })
11421129
{
1143-
return terminalPane.GetTerminal();
1130+
return terminalPane.GetTermControl();
11441131
}
11451132
else
11461133
{
@@ -2667,7 +2654,7 @@ Pane::SnapSizeResult Pane::_CalcSnappedDimension(const bool widthOrHeight, const
26672654
}
26682655
else
26692656
{
2670-
const auto cellSize = snappable.GridSize();
2657+
const auto cellSize = snappable.GridUnitSize();
26712658
const auto higher = lower + (direction == PaneSnapDirection::Width ?
26722659
cellSize.Width :
26732660
cellSize.Height);
@@ -2728,13 +2715,11 @@ void Pane::_AdvanceSnappedDimension(const bool widthOrHeight, LayoutSizeNode& si
27282715
// be, say, half a character, or fixed 10 pixels), so snap it upward. It might
27292716
// however be already snapped, so add 1 to make sure it really increases
27302717
// (not strictly necessary but to avoid surprises).
2731-
sizeNode.size = _CalcSnappedDimension(widthOrHeight,
2732-
sizeNode.size + 1)
2733-
.higher;
2718+
sizeNode.size = _CalcSnappedDimension(widthOrHeight, sizeNode.size + 1).higher;
27342719
}
27352720
else
27362721
{
2737-
const auto cellSize = snappable.GridSize();
2722+
const auto cellSize = snappable.GridUnitSize();
27382723
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
27392724
}
27402725
}
@@ -2850,7 +2835,7 @@ Size Pane::_GetMinSize() const
28502835
{
28512836
if (_IsLeaf())
28522837
{
2853-
auto controlSize = _content.MinSize();
2838+
auto controlSize = _content.MinimumSize();
28542839
auto newWidth = controlSize.Width;
28552840
auto newHeight = controlSize.Height;
28562841

src/cascadia/TerminalApp/Pane.h

-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ class Pane : public std::enable_shared_from_this<Pane>
222222

223223
WINRT_CALLBACK(GotFocus, gotFocusArgs);
224224
WINRT_CALLBACK(LostFocus, winrt::delegate<std::shared_ptr<Pane>>);
225-
WINRT_CALLBACK(PaneRaiseBell, winrt::Windows::Foundation::EventHandler<bool>);
226225
WINRT_CALLBACK(Detached, winrt::delegate<std::shared_ptr<Pane>>);
227226

228227
private:

src/cascadia/TerminalApp/PaneArgs.cpp

-6
This file was deleted.

src/cascadia/TerminalApp/PaneArgs.h

-18
This file was deleted.

src/cascadia/TerminalApp/TerminalAppLib.vcxproj

-6
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@
128128
</ClInclude>
129129
<ClInclude Include="FilteredCommand.h" />
130130
<ClInclude Include="Pane.h" />
131-
<ClInclude Include="PaneArgs.h">
132-
<DependentUpon>IPaneContent.idl</DependentUpon>
133-
</ClInclude>
134131
<ClInclude Include="ColorHelper.h" />
135132
<ClInclude Include="pch.h" />
136133
<ClInclude Include="ShortcutActionDispatch.h">
@@ -239,9 +236,6 @@
239236
</ClCompile>
240237
<ClCompile Include="FilteredCommand.cpp" />
241238
<ClCompile Include="Pane.cpp" />
242-
<ClCompile Include="PaneArgs.cpp">
243-
<DependentUpon>IPaneContent.idl</DependentUpon>
244-
</ClCompile>
245239
<ClCompile Include="Pane.LayoutSizeNode.cpp" />
246240
<ClCompile Include="ColorHelper.cpp">
247241
<PrecompiledHeader>NotUsing</PrecompiledHeader>

src/cascadia/TerminalApp/TerminalPage.cpp

+9-24
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ namespace winrt::TerminalApp::implementation
13061306
return nullptr;
13071307
}
13081308

1309-
const auto& control{ paneContent.GetTerminal() };
1309+
const auto& control{ paneContent.GetTermControl() };
13101310
if (control == nullptr)
13111311
{
13121312
return nullptr;
@@ -1731,11 +1731,8 @@ namespace winrt::TerminalApp::implementation
17311731
// Add an event handler for when the terminal or tab wants to set a
17321732
// progress indicator on the taskbar
17331733
hostingTab.TaskbarProgressChanged({ get_weak(), &TerminalPage::_SetTaskbarProgressHandler });
1734-
}
17351734

1736-
void TerminalPage::_RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent)
1737-
{
1738-
paneContent.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
1735+
hostingTab.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
17391736
}
17401737

17411738
// Method Description:
@@ -2390,16 +2387,6 @@ namespace winrt::TerminalApp::implementation
23902387
_UnZoomIfNeeded();
23912388
auto [original, _] = activeTab->SplitPane(*realSplitType, splitSize, newPane);
23922389

2393-
// When we split the pane, the Pane itself will create a _new_ Pane
2394-
// instance for the original content. We need to make sure we also
2395-
// re-add our event handler to that newly created pane.
2396-
//
2397-
// _MakePane will already call this for the newly created pane.
2398-
if (const auto& paneContent{ original->GetContent().try_as<TerminalPaneContent>() })
2399-
{
2400-
_RegisterPaneEvents(*paneContent);
2401-
}
2402-
24032390
// After GH#6586, the control will no longer focus itself
24042391
// automatically when it's finished being laid out. Manually focus
24052392
// the control here instead.
@@ -3131,8 +3118,8 @@ namespace winrt::TerminalApp::implementation
31313118
// serialize the actual profile's GUID along with the content guid.
31323119
const auto& profile = _settings.GetProfileForArgs(newTerminalArgs);
31333120
const auto control = _AttachControlToContent(newTerminalArgs.ContentId());
3134-
auto terminalPane{ winrt::make<TerminalPaneContent>(profile, control) };
3135-
return std::make_shared<Pane>(terminalPane);
3121+
auto paneContent{ winrt::make<TerminalPaneContent>(profile, control) };
3122+
return std::make_shared<Pane>(paneContent);
31363123
}
31373124

31383125
TerminalSettingsCreateResult controlSettings{ nullptr };
@@ -3188,15 +3175,15 @@ namespace winrt::TerminalApp::implementation
31883175

31893176
const auto control = _CreateNewControlAndContent(controlSettings, connection);
31903177

3191-
auto terminalPane{ winrt::make<TerminalPaneContent>(profile, control) };
3192-
auto resultPane = std::make_shared<Pane>(terminalPane);
3178+
auto paneContent{ winrt::make<TerminalPaneContent>(profile, control) };
3179+
auto resultPane = std::make_shared<Pane>(paneContent);
31933180

31943181
if (debugConnection) // this will only be set if global debugging is on and tap is active
31953182
{
31963183
auto newControl = _CreateNewControlAndContent(controlSettings, debugConnection);
31973184
// Split (auto) with the debug tap.
3198-
auto debugTerminalPane{ winrt::make<TerminalPaneContent>(profile, newControl) };
3199-
auto debugPane = std::make_shared<Pane>(debugTerminalPane);
3185+
auto debugContent{ winrt::make<TerminalPaneContent>(profile, newControl) };
3186+
auto debugPane = std::make_shared<Pane>(debugContent);
32003187

32013188
// Since we're doing this split directly on the pane (instead of going through TerminalTab,
32023189
// we need to handle the panes 'active' states
@@ -3210,8 +3197,6 @@ namespace winrt::TerminalApp::implementation
32103197
original->SetActive();
32113198
}
32123199

3213-
_RegisterPaneEvents(terminalPane);
3214-
32153200
return resultPane;
32163201
}
32173202

@@ -3225,7 +3210,7 @@ namespace winrt::TerminalApp::implementation
32253210
// for nulls
32263211
if (const auto& connection{ _duplicateConnectionForRestart(paneContent) })
32273212
{
3228-
paneContent.GetTerminal().Connection(connection);
3213+
paneContent.GetTermControl().Connection(connection);
32293214
connection.Start();
32303215
}
32313216
}

src/cascadia/TerminalApp/TerminalPage.h

-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ namespace winrt::TerminalApp::implementation
347347
void _InitializeTab(winrt::com_ptr<TerminalTab> newTabImpl, uint32_t insertPosition = -1);
348348
void _RegisterTerminalEvents(Microsoft::Terminal::Control::TermControl term);
349349
void _RegisterTabEvents(TerminalTab& hostingTab);
350-
void _RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent);
351350

352351
void _DismissTabContextMenus();
353352
void _FocusCurrentTab(const bool focusAlways);

src/cascadia/TerminalApp/TerminalPaneContent.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
#include "pch.h"
55
#include "TerminalPaneContent.h"
6-
#include "PaneArgs.h"
76
#include "TerminalPaneContent.g.cpp"
87

8+
#include "BellEventArgs.g.cpp"
9+
910
#include <Mmsystem.h>
1011
using namespace winrt::Windows::Foundation;
1112
using namespace winrt::Windows::UI::Xaml;
@@ -45,11 +46,11 @@ namespace winrt::TerminalApp::implementation
4546
{
4647
return _control;
4748
}
48-
winrt::Microsoft::Terminal::Control::TermControl TerminalPaneContent::GetTerminal()
49+
winrt::Microsoft::Terminal::Control::TermControl TerminalPaneContent::GetTermControl()
4950
{
5051
return _control;
5152
}
52-
winrt::Windows::Foundation::Size TerminalPaneContent::MinSize()
53+
winrt::Windows::Foundation::Size TerminalPaneContent::MinimumSize()
5354
{
5455
return _control.MinimumSize();
5556
}
@@ -348,7 +349,7 @@ namespace winrt::TerminalApp::implementation
348349
{
349350
return _control.SnapDimensionToGrid(direction == PaneSnapDirection::Width, sizeToSnap);
350351
}
351-
Windows::Foundation::Size TerminalPaneContent::GridSize()
352+
Windows::Foundation::Size TerminalPaneContent::GridUnitSize()
352353
{
353354
return _control.CharacterDimensions();
354355
}

src/cascadia/TerminalApp/TerminalPaneContent.h

+21-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@
33

44
#pragma once
55
#include "TerminalPaneContent.g.h"
6-
#include "../../cascadia/inc/cppwinrt_utils.h"
7-
#include <til/winrt.h>
6+
#include "BellEventArgs.g.h"
87

98
namespace winrt::TerminalApp::implementation
109
{
10+
struct BellEventArgs : public BellEventArgsT<BellEventArgs>
11+
{
12+
public:
13+
BellEventArgs(bool flashTaskbar) :
14+
FlashTaskbar(flashTaskbar) {}
15+
16+
til::property<bool> FlashTaskbar;
17+
};
18+
1119
struct TerminalPaneContent : TerminalPaneContentT<TerminalPaneContent>
1220
{
1321
TerminalPaneContent(const winrt::Microsoft::Terminal::Settings::Model::Profile& profile,
1422
const winrt::Microsoft::Terminal::Control::TermControl& control);
1523

1624
winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
17-
winrt::Microsoft::Terminal::Control::TermControl GetTerminal();
18-
winrt::Windows::Foundation::Size MinSize();
25+
winrt::Microsoft::Terminal::Control::TermControl GetTermControl();
26+
winrt::Windows::Foundation::Size MinimumSize();
1927
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
2028
void Close();
2129

@@ -29,7 +37,7 @@ namespace winrt::TerminalApp::implementation
2937
winrt::Microsoft::Terminal::Settings::Model::Profile GetProfile() const
3038
{
3139
return _profile;
32-
};
40+
}
3341

3442
winrt::hstring Title() { return _control.Title(); }
3543
uint64_t TaskbarState() { return _control.TaskbarState(); }
@@ -40,17 +48,17 @@ namespace winrt::TerminalApp::implementation
4048
winrt::Windows::UI::Xaml::Media::Brush BackgroundBrush();
4149

4250
float SnapDownToGrid(const TerminalApp::PaneSnapDirection direction, const float sizeToSnap);
43-
Windows::Foundation::Size GridSize();
51+
Windows::Foundation::Size GridUnitSize();
4452

4553
til::typed_event<TerminalApp::TerminalPaneContent, winrt::Windows::Foundation::IInspectable> RestartTerminalRequested;
46-
til::typed_event<> CloseRequested;
47-
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::BellEventArgs> BellRequested;
48-
til::typed_event<> TitleChanged;
49-
til::typed_event<> TabColorChanged;
50-
til::typed_event<> TaskbarProgressChanged;
5154
til::typed_event<> ConnectionStateChanged;
52-
til::typed_event<> ReadOnlyChanged;
53-
til::typed_event<> FocusRequested;
55+
til::typed_event<IPaneContent> CloseRequested;
56+
til::typed_event<IPaneContent, winrt::TerminalApp::BellEventArgs> BellRequested;
57+
til::typed_event<IPaneContent> TitleChanged;
58+
til::typed_event<IPaneContent> TabColorChanged;
59+
til::typed_event<IPaneContent> TaskbarProgressChanged;
60+
til::typed_event<IPaneContent> ReadOnlyChanged;
61+
til::typed_event<IPaneContent> FocusRequested;
5462

5563
private:
5664
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr };

src/cascadia/TerminalApp/TerminalPaneContent.idl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace TerminalApp
88
{
99
[default_interface] runtimeclass TerminalPaneContent : IPaneContent, ISnappable
1010
{
11-
Microsoft.Terminal.Control.TermControl GetTerminal();
11+
Microsoft.Terminal.Control.TermControl GetTermControl();
1212

1313
void UpdateTerminalSettings(TerminalSettingsCache cache);
1414

0 commit comments

Comments
 (0)