one shot one opportunity

This commit is contained in:
Mike Griese
2022-07-15 06:20:19 -05:00
parent 35c82d37f0
commit 4b4e057a75
2 changed files with 54 additions and 1 deletions

View File

@@ -249,6 +249,10 @@ namespace winrt::TerminalApp::implementation
_tabView.TabCloseRequested({ this, &TerminalPage::_OnTabCloseRequested });
_tabView.TabItemsChanged({ this, &TerminalPage::_OnTabItemsChanged });
_tabView.TabDragStarting({ this, &TerminalPage::_onTabDragStarting });
_tabView.TabStripDragOver({ this, &TerminalPage::_onTabStripDragOver });
_tabView.TabStripDrop({ this, &TerminalPage::_onTabStripDrop });
_CreateNewTabFlyout();
_UpdateTabWidthMode();
@@ -1978,7 +1982,7 @@ namespace winrt::TerminalApp::implementation
// TODO! if the first action is a split pane and tabIndex > tabs.size,
// then remove it and insert an equivalent newTab
co_await wil::resume_foreground(Dispatcher(), CoreDispatcherPriority::High); // may need to go to the top of _createNewTabFromContent
co_await wil::resume_foreground(Dispatcher(), CoreDispatcherPriority::Normal); // may need to go to the top of _createNewTabFromContent
for (const auto& action : args)
{
_actionDispatch->DoAction(action);
@@ -4599,4 +4603,49 @@ namespace winrt::TerminalApp::implementation
_activated = activated;
_updateThemeColors();
}
void TerminalPage::_onTabDragStarting(winrt::Microsoft::UI::Xaml::Controls::TabView sender,
winrt::Microsoft::UI::Xaml::Controls::TabViewTabDragStartingEventArgs e)
{
if (const auto terminalTab{ _GetFocusedTabImpl() })
{
auto startupActions = terminalTab->BuildStartupActions(true);
auto winRtActions{ winrt::single_threaded_vector<ActionAndArgs>(std::move(startupActions)) };
auto str = ActionAndArgs::Serialize(winRtActions);
e.Data().Properties().Insert(L"content", winrt::box_value(str));
e.Data().RequestedOperation(DataPackageOperation::Move);
}
}
void TerminalPage::_onTabStripDragOver(winrt::Windows::Foundation::IInspectable sender,
winrt::Windows::UI::Xaml::DragEventArgs e)
{
if (e.DataView().Properties().HasKey(L"content"))
{
e.AcceptedOperation(DataPackageOperation::Move);
}
}
winrt::fire_and_forget TerminalPage::_onTabStripDrop(winrt::Windows::Foundation::IInspectable sender,
winrt::Windows::UI::Xaml::DragEventArgs e)
{
auto contentObj { e.DataView().Properties().TryLookup(L"content") };
if (contentObj == nullptr)
{
co_return;
}
auto contentString{ winrt::unbox_value<winrt::hstring>(contentObj) };
if (!contentString.empty())
{
auto args = ActionAndArgs::Deserialize(contentString);
// TODO! if the first action is a split pane and tabIndex > tabs.size,
// then remove it and insert an equivalent newTab
co_await wil::resume_foreground(Dispatcher(), CoreDispatcherPriority::Normal); // may need to go to the top of _createNewTabFromContent
for (const auto& action : args)
{
_actionDispatch->DoAction(action);
}
}
}
}

View File

@@ -511,6 +511,10 @@ namespace winrt::TerminalApp::implementation
winrt::Microsoft::Terminal::TerminalConnection::ConnectionInformation _CreateConnectionInfoFromSettings(const winrt::Microsoft::Terminal::Settings::Model::Profile& profile,
const winrt::Microsoft::Terminal::Settings::Model::TerminalSettings& settings);
void _onTabDragStarting(winrt::Microsoft::UI::Xaml::Controls::TabView sender, winrt::Microsoft::UI::Xaml::Controls::TabViewTabDragStartingEventArgs e);
void _onTabStripDragOver(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::DragEventArgs e);
winrt::fire_and_forget _onTabStripDrop(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::DragEventArgs e);
#pragma region ActionHandlers
// These are all defined in AppActionHandlers.cpp
#define ON_ALL_ACTIONS(action) DECLARE_ACTION_HANDLER(action);