Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ TerminalInput::OutputType Terminal::SendCharEvent(const wchar_t ch, const WORD s
// - none
TerminalInput::OutputType Terminal::FocusChanged(const bool focused)
{
_isFocused = focused;
return _getTerminalInput().HandleFocus(focused);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a if (_isFocused != focused) here, if we're at it? This would prevent accidental, redundant HandleFocus calls.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I’ve added the optimization and pushed it to the PR.

}

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ class Microsoft::Terminal::Core::Terminal final :
til::CoordType _scrollbackLines = 0;
bool _detectURLs = false;
bool _clipboardOperationsAllowed = true;
bool _isFocused = false;

til::size _altBufferSize;
std::optional<til::size> _deferredResize;
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ unsigned int Terminal::GetInputCodePage() const noexcept

void Terminal::CopyToClipboard(wil::zwstring_view content)
{
if (_clipboardOperationsAllowed)
// Only allow VT clipboard writes when the terminal has focus
if (_clipboardOperationsAllowed && _isFocused)
{
_pfnCopyToClipboard(content);
}
Expand Down