Skip to content

Commit

Permalink
More things we might need for Non-Terminal content, #997
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Sep 2, 2021
1 parent 736a351 commit 7f29e1e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,11 +2144,14 @@ std::pair<std::shared_ptr<Pane>, std::shared_ptr<Pane>> Pane::_Split(SplitState
std::unique_lock lock{ _createCloseLock };

const auto& termControl{ _control.try_as<TermControl>() };
// revoke our handler - the child will take care of the control now.
termControl.ConnectionStateChanged(_connectionStateChangedToken);
_connectionStateChangedToken.value = 0;
termControl.WarningBell(_warningBellToken);
_warningBellToken.value = 0;
if (termControl)
{
// revoke our handler - the child will take care of the control now.
termControl.ConnectionStateChanged(_connectionStateChangedToken);
termControl.WarningBell(_warningBellToken);
_connectionStateChangedToken.value = 0;
_warningBellToken.value = 0;
}

// Remove our old GotFocus handler from the control. We don't what the
// control telling us that it's now focused, we want it telling its new
Expand Down Expand Up @@ -2584,6 +2587,15 @@ void Pane::_AdvanceSnappedDimension(const bool widthOrHeight, LayoutSizeNode& si
sizeNode.size += widthOrHeight ? cellSize.Width : cellSize.Height;
}
}
else if (_IsLeaf())
{
// If we're a leaf that didn't have a TermControl, then just increment
// by one. We have to increment by _some_ value, because this is used in
// a while() loop to find the next bigger size we can snap to. But since
// a non-terminal control doesn't really care what size it's snapped to,
// we can just say "one pixel larger is the next snap point"
sizeNode.size += 1;
}
else if (!_IsLeaf())
{
// We're a parent pane, so we have to advance dimension of our children panes. In
Expand Down Expand Up @@ -2877,7 +2889,9 @@ std::optional<SplitState> Pane::PreCalculateAutoSplit(const std::shared_ptr<Pane
bool Pane::ContainsReadOnly() const
{
const auto& termControl{ GetTerminalControl() };
return termControl ? termControl.ReadOnly() : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly());
return termControl ?
termControl.ReadOnly() :
(_IsLeaf() ? false : (_firstChild->ContainsReadOnly() || _secondChild->ContainsReadOnly()));
}

// Method Description:
Expand Down
5 changes: 4 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,10 @@ namespace winrt::TerminalApp::implementation
// the control here instead.
if (_startupState == StartupState::Initialized)
{
_GetActiveControl().Focus(FocusState::Programmatic);
if (const auto& activeControl{ _GetActiveControl() })
{
activeControl.Focus(FocusState::Programmatic);
}
}
}
CATCH_LOG();
Expand Down

0 comments on commit 7f29e1e

Please sign in to comment.