Skip to content

Commit

Permalink
Merge branch 'dev/migrie/fhl/scratchpad-pane' into dev/migrie/f/sui-p…
Browse files Browse the repository at this point in the history
…anes
  • Loading branch information
zadjii-msft committed Mar 20, 2024
2 parents 863840e + 2357653 commit c8d0c0a
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 117 deletions.
18 changes: 9 additions & 9 deletions src/cascadia/TerminalApp/IPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace TerminalApp
Windows.UI.Xaml.FrameworkElement GetRoot();
void UpdateSettings(Microsoft.Terminal.Settings.Model.CascadiaSettings settings);

Windows.Foundation.Size MinSize { get; };
Windows.Foundation.Size MinimumSize { get; };

String Title { get; };
UInt64 TaskbarState { get; };
Expand All @@ -30,15 +30,15 @@ namespace TerminalApp

void Close();

event Windows.Foundation.TypedEventHandler<Object, Object> CloseRequested;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> CloseRequested;

event Windows.Foundation.TypedEventHandler<Object, BellEventArgs> BellRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> TitleChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> TaskbarProgressChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> ConnectionStateChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> ReadOnlyChanged;
event Windows.Foundation.TypedEventHandler<Object, Object> FocusRequested;
event Windows.Foundation.TypedEventHandler<IPaneContent, BellEventArgs> BellRequested;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TitleChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TabColorChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> TaskbarProgressChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> ReadOnlyChanged;
event Windows.Foundation.TypedEventHandler<IPaneContent, Object> FocusRequested;
};


Expand All @@ -51,6 +51,6 @@ namespace TerminalApp
interface ISnappable
{
Single SnapDownToGrid(PaneSnapDirection direction, Single sizeToSnap);
Windows.Foundation.Size GridSize { get; };
Windows.Foundation.Size GridUnitSize { get; };
};
}
33 changes: 9 additions & 24 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "pch.h"
#include "Pane.h"

#include "AppLogic.h"

#include "Utils.h"
Expand Down Expand Up @@ -1080,30 +1081,16 @@ TermControl Pane::GetLastFocusedTerminalControl()
{
if (p->_IsLeaf())
{
if (const auto& terminalPane{ p->_content.try_as<TerminalPaneContent>() })
{
return terminalPane.GetTerminal();
}
else
{
return nullptr;
}
return p->GetTerminalControl();
}
pane = p;
}
// We didn't find our child somehow, they might have closed under us.
}
return _firstChild->GetLastFocusedTerminalControl();
}

if (const auto& terminalPane{ _content.try_as<TerminalPaneContent>() })
{
return terminalPane.GetTerminal();
}
else
{
return nullptr;
}
// we _are_ a leaf.
return GetTerminalControl();
}

IPaneContent Pane::GetLastFocusedContent()
Expand Down Expand Up @@ -1140,7 +1127,7 @@ TermControl Pane::GetTerminalControl() const
{
if (const auto& terminalPane{ _getTerminalContent() })
{
return terminalPane.GetTerminal();
return terminalPane.GetTermControl();
}
else
{
Expand Down Expand Up @@ -2667,7 +2654,7 @@ Pane::SnapSizeResult Pane::_CalcSnappedDimension(const bool widthOrHeight, const
}
else
{
const auto cellSize = snappable.GridSize();
const auto cellSize = snappable.GridUnitSize();
const auto higher = lower + (direction == PaneSnapDirection::Width ?
cellSize.Width :
cellSize.Height);
Expand Down Expand Up @@ -2728,13 +2715,11 @@ void Pane::_AdvanceSnappedDimension(const bool widthOrHeight, LayoutSizeNode& si
// be, say, half a character, or fixed 10 pixels), so snap it upward. It might
// however be already snapped, so add 1 to make sure it really increases
// (not strictly necessary but to avoid surprises).
sizeNode.size = _CalcSnappedDimension(widthOrHeight,
sizeNode.size + 1)
.higher;
sizeNode.size = _CalcSnappedDimension(widthOrHeight, sizeNode.size + 1).higher;
}
else
{
const auto cellSize = snappable.GridSize();
const auto cellSize = snappable.GridUnitSize();
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
}
}
Expand Down Expand Up @@ -2850,7 +2835,7 @@ Size Pane::_GetMinSize() const
{
if (_IsLeaf())
{
auto controlSize = _content.MinSize();
auto controlSize = _content.MinimumSize();
auto newWidth = controlSize.Width;
auto newHeight = controlSize.Height;

Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/Pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class Pane : public std::enable_shared_from_this<Pane>

WINRT_CALLBACK(GotFocus, gotFocusArgs);
WINRT_CALLBACK(LostFocus, winrt::delegate<std::shared_ptr<Pane>>);
WINRT_CALLBACK(PaneRaiseBell, winrt::Windows::Foundation::EventHandler<bool>);
WINRT_CALLBACK(Detached, winrt::delegate<std::shared_ptr<Pane>>);

private:
Expand Down
6 changes: 0 additions & 6 deletions src/cascadia/TerminalApp/PaneArgs.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions src/cascadia/TerminalApp/PaneArgs.h

This file was deleted.

6 changes: 0 additions & 6 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@
</ClInclude>
<ClInclude Include="FilteredCommand.h" />
<ClInclude Include="Pane.h" />
<ClInclude Include="PaneArgs.h">
<DependentUpon>IPaneContent.idl</DependentUpon>
</ClInclude>
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="ShortcutActionDispatch.h">
Expand Down Expand Up @@ -239,9 +236,6 @@
</ClCompile>
<ClCompile Include="FilteredCommand.cpp" />
<ClCompile Include="Pane.cpp" />
<ClCompile Include="PaneArgs.cpp">
<DependentUpon>IPaneContent.idl</DependentUpon>
</ClCompile>
<ClCompile Include="Pane.LayoutSizeNode.cpp" />
<ClCompile Include="ColorHelper.cpp">
<PrecompiledHeader>NotUsing</PrecompiledHeader>
Expand Down
33 changes: 9 additions & 24 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ namespace winrt::TerminalApp::implementation
return nullptr;
}

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

void TerminalPage::_RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent)
{
paneContent.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
hostingTab.RestartTerminalRequested({ get_weak(), &TerminalPage::_restartPaneConnection });
}

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

// When we split the pane, the Pane itself will create a _new_ Pane
// instance for the original content. We need to make sure we also
// re-add our event handler to that newly created pane.
//
// _MakePane will already call this for the newly created pane.
if (const auto& paneContent{ original->GetContent().try_as<TerminalPaneContent>() })
{
_RegisterPaneEvents(*paneContent);
}

// After GH#6586, the control will no longer focus itself
// automatically when it's finished being laid out. Manually focus
// the control here instead.
Expand Down Expand Up @@ -3131,8 +3118,8 @@ namespace winrt::TerminalApp::implementation
// serialize the actual profile's GUID along with the content guid.
const auto& profile = _settings.GetProfileForArgs(newTerminalArgs);
const auto control = _AttachControlToContent(newTerminalArgs.ContentId());
auto terminalPane{ winrt::make<TerminalPaneContent>(profile, control) };
return std::make_shared<Pane>(terminalPane);
auto paneContent{ winrt::make<TerminalPaneContent>(profile, control) };
return std::make_shared<Pane>(paneContent);
}

TerminalSettingsCreateResult controlSettings{ nullptr };
Expand Down Expand Up @@ -3188,15 +3175,15 @@ namespace winrt::TerminalApp::implementation

const auto control = _CreateNewControlAndContent(controlSettings, connection);

auto terminalPane{ winrt::make<TerminalPaneContent>(profile, control) };
auto resultPane = std::make_shared<Pane>(terminalPane);
auto paneContent{ winrt::make<TerminalPaneContent>(profile, control) };
auto resultPane = std::make_shared<Pane>(paneContent);

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

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

_RegisterPaneEvents(terminalPane);

return resultPane;
}

Expand All @@ -3225,7 +3210,7 @@ namespace winrt::TerminalApp::implementation
// for nulls
if (const auto& connection{ _duplicateConnectionForRestart(paneContent) })
{
paneContent.GetTerminal().Connection(connection);
paneContent.GetTermControl().Connection(connection);
connection.Start();
}
}
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ namespace winrt::TerminalApp::implementation
void _InitializeTab(winrt::com_ptr<TerminalTab> newTabImpl, uint32_t insertPosition = -1);
void _RegisterTerminalEvents(Microsoft::Terminal::Control::TermControl term);
void _RegisterTabEvents(TerminalTab& hostingTab);
void _RegisterPaneEvents(const TerminalApp::TerminalPaneContent& paneContent);

void _DismissTabContextMenus();
void _FocusCurrentTab(const bool focusAlways);
Expand Down
9 changes: 5 additions & 4 deletions src/cascadia/TerminalApp/TerminalPaneContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include "pch.h"
#include "TerminalPaneContent.h"
#include "PaneArgs.h"
#include "TerminalPaneContent.g.cpp"

#include "BellEventArgs.g.cpp"

#include <Mmsystem.h>
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::UI::Xaml;
Expand Down Expand Up @@ -45,11 +46,11 @@ namespace winrt::TerminalApp::implementation
{
return _control;
}
winrt::Microsoft::Terminal::Control::TermControl TerminalPaneContent::GetTerminal()
winrt::Microsoft::Terminal::Control::TermControl TerminalPaneContent::GetTermControl()
{
return _control;
}
winrt::Windows::Foundation::Size TerminalPaneContent::MinSize()
winrt::Windows::Foundation::Size TerminalPaneContent::MinimumSize()
{
return _control.MinimumSize();
}
Expand Down Expand Up @@ -348,7 +349,7 @@ namespace winrt::TerminalApp::implementation
{
return _control.SnapDimensionToGrid(direction == PaneSnapDirection::Width, sizeToSnap);
}
Windows::Foundation::Size TerminalPaneContent::GridSize()
Windows::Foundation::Size TerminalPaneContent::GridUnitSize()
{
return _control.CharacterDimensions();
}
Expand Down
34 changes: 21 additions & 13 deletions src/cascadia/TerminalApp/TerminalPaneContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@

#pragma once
#include "TerminalPaneContent.g.h"
#include "../../cascadia/inc/cppwinrt_utils.h"
#include <til/winrt.h>
#include "BellEventArgs.g.h"

namespace winrt::TerminalApp::implementation
{
struct BellEventArgs : public BellEventArgsT<BellEventArgs>
{
public:
BellEventArgs(bool flashTaskbar) :
FlashTaskbar(flashTaskbar) {}

til::property<bool> FlashTaskbar;
};

struct TerminalPaneContent : TerminalPaneContentT<TerminalPaneContent>
{
TerminalPaneContent(const winrt::Microsoft::Terminal::Settings::Model::Profile& profile,
const winrt::Microsoft::Terminal::Control::TermControl& control);

winrt::Windows::UI::Xaml::FrameworkElement GetRoot();
winrt::Microsoft::Terminal::Control::TermControl GetTerminal();
winrt::Windows::Foundation::Size MinSize();
winrt::Microsoft::Terminal::Control::TermControl GetTermControl();
winrt::Windows::Foundation::Size MinimumSize();
void Focus(winrt::Windows::UI::Xaml::FocusState reason = winrt::Windows::UI::Xaml::FocusState::Programmatic);
void Close();

Expand All @@ -29,7 +37,7 @@ namespace winrt::TerminalApp::implementation
winrt::Microsoft::Terminal::Settings::Model::Profile GetProfile() const
{
return _profile;
};
}

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

float SnapDownToGrid(const TerminalApp::PaneSnapDirection direction, const float sizeToSnap);
Windows::Foundation::Size GridSize();
Windows::Foundation::Size GridUnitSize();

til::typed_event<TerminalApp::TerminalPaneContent, winrt::Windows::Foundation::IInspectable> RestartTerminalRequested;
til::typed_event<> CloseRequested;
til::typed_event<winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::BellEventArgs> BellRequested;
til::typed_event<> TitleChanged;
til::typed_event<> TabColorChanged;
til::typed_event<> TaskbarProgressChanged;
til::typed_event<> ConnectionStateChanged;
til::typed_event<> ReadOnlyChanged;
til::typed_event<> FocusRequested;
til::typed_event<IPaneContent> CloseRequested;
til::typed_event<IPaneContent, winrt::TerminalApp::BellEventArgs> BellRequested;
til::typed_event<IPaneContent> TitleChanged;
til::typed_event<IPaneContent> TabColorChanged;
til::typed_event<IPaneContent> TaskbarProgressChanged;
til::typed_event<IPaneContent> ReadOnlyChanged;
til::typed_event<IPaneContent> FocusRequested;

private:
winrt::Microsoft::Terminal::Control::TermControl _control{ nullptr };
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPaneContent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace TerminalApp
{
[default_interface] runtimeclass TerminalPaneContent : IPaneContent, ISnappable
{
Microsoft.Terminal.Control.TermControl GetTerminal();
Microsoft.Terminal.Control.TermControl GetTermControl();

void UpdateTerminalSettings(TerminalSettingsCache cache);

Expand Down
Loading

0 comments on commit c8d0c0a

Please sign in to comment.