Skip to content

Commit

Permalink
Send focus events even in ReadOnly mode (#13483)
Browse files Browse the repository at this point in the history
Does what it says on the tin. When we get focused, temporarily turn off readonly mode, as to not pop the dialog when the focus sequence is eventually sent to the connection.

* closes #13461

(cherry picked from commit b4a52c8)
Service-Card-Id: 84111371
Service-Version: 1.15
  • Loading branch information
zadjii-msft authored and DHowett committed Jul 19, 2022
1 parent 91a60ca commit a4a12ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1912,13 +1912,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - This is related to work done for GH#2988.
void ControlCore::GotFocus()
{
_terminal->FocusChanged(true);
_focusChanged(true);
}

// See GotFocus.
void ControlCore::LostFocus()
{
_terminal->FocusChanged(false);
_focusChanged(false);
}

void ControlCore::_focusChanged(bool focused)
{
// GH#13461 - temporarily turn off read-only mode, send the focus event,
// then turn it back on. Even in focus mode, focus events are fine to
// send. We don't want to pop a warning every time the control is
// focused.
const auto previous = std::exchange(_isReadOnly, false);
const auto restore = wil::scope_exit([&]() { _isReadOnly = previous; });
_terminal->FocusChanged(focused);
}

bool ControlCore::_isBackgroundTransparent()
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void _setOpacity(const double opacity);

bool _isBackgroundTransparent();
void _focusChanged(bool focused);

inline bool _IsClosing() const noexcept
{
Expand Down

0 comments on commit a4a12ef

Please sign in to comment.