Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send focus events even in ReadOnly mode #13483

Merged
3 commits merged into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; });
PankajBhojwani marked this conversation as resolved.
Show resolved Hide resolved
_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