This commit introduces a new recursive pane shutdown that will give all controls under a tab a chance to clean up their state before beign detached from the UI. It also reorders the call to LastTabClosed() so that the application does not exit before the final connections are terminated. It also teaches TSFInputControl how to shut down to avoid a dramatic platform bug. Fixes #4159. Fixes #4336. ## PR Checklist * [x] CLA signed * [x] I've discussed this with core contributors already. ## Validation Steps Performed Validated through manual terminal teardown within and without the debugger, given a crazy number of panes and tabs.
60 lines
2.4 KiB
C++
60 lines
2.4 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
#include "Pane.h"
|
|
|
|
class Tab : public std::enable_shared_from_this<Tab>
|
|
{
|
|
public:
|
|
Tab(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
|
|
// Called after construction to setup events with weak_ptr
|
|
void BindEventHandlers(const winrt::Microsoft::Terminal::TerminalControl::TermControl& control) noexcept;
|
|
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem GetTabViewItem();
|
|
winrt::Windows::UI::Xaml::UIElement GetRootElement();
|
|
winrt::Microsoft::Terminal::TerminalControl::TermControl GetActiveTerminalControl() const;
|
|
std::optional<GUID> GetFocusedProfile() const noexcept;
|
|
|
|
bool IsFocused() const noexcept;
|
|
void SetFocused(const bool focused);
|
|
|
|
winrt::fire_and_forget Scroll(const int delta);
|
|
|
|
bool CanSplitPane(winrt::TerminalApp::SplitState splitType);
|
|
void SplitPane(winrt::TerminalApp::SplitState splitType, const GUID& profile, winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
|
|
winrt::fire_and_forget UpdateIcon(const winrt::hstring iconPath);
|
|
|
|
float CalcSnappedDimension(const bool widthOrHeight, const float dimension) const;
|
|
|
|
void ResizeContent(const winrt::Windows::Foundation::Size& newSize);
|
|
void ResizePane(const winrt::TerminalApp::Direction& direction);
|
|
void NavigateFocus(const winrt::TerminalApp::Direction& direction);
|
|
|
|
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::TerminalSettings& settings, const GUID& profile);
|
|
winrt::hstring GetActiveTitle() const;
|
|
winrt::fire_and_forget SetTabText(const winrt::hstring text);
|
|
|
|
void Shutdown();
|
|
void ClosePane();
|
|
|
|
WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
|
|
DECLARE_EVENT(ActivePaneChanged, _ActivePaneChangedHandlers, winrt::delegate<>);
|
|
|
|
private:
|
|
std::shared_ptr<Pane> _rootPane{ nullptr };
|
|
std::shared_ptr<Pane> _activePane{ nullptr };
|
|
winrt::hstring _lastIconPath{};
|
|
|
|
bool _focused{ false };
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem _tabViewItem{ nullptr };
|
|
|
|
void _MakeTabViewItem();
|
|
void _Focus();
|
|
|
|
void _AttachEventHandlersToControl(const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
void _AttachEventHandlersToPane(std::shared_ptr<Pane> pane);
|
|
};
|