Skip to content

Commit

Permalink
Prevent read-only warning on mouse move, wheel and release (#9107)
Browse files Browse the repository at this point in the history
Avoid sending mouse move / wheel / release to Terminal in the first place.
This kind of short-circuiting will prevent us reaching the
attempt to send input to connection
(that could result in the warning dialog in the read-only mode)

Closes #9074
  • Loading branch information
Don-Vito authored Feb 11, 2021
1 parent 8f73145 commit 16d00a6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// - Whether the key was handled.
bool TermControl::OnDirectKeyEvent(const uint32_t vkey, const uint8_t scanCode, const bool down)
{
// Short-circuit isReadOnly check to avoid warning dialog
if (_isReadOnly)
{
return false;
Expand Down Expand Up @@ -970,6 +971,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const auto vkey = gsl::narrow_cast<WORD>(e.OriginalKey());
const auto scanCode = gsl::narrow_cast<WORD>(e.KeyStatus().ScanCode);

// Short-circuit isReadOnly check to avoid warning dialog
if (_isReadOnly)
{
e.Handled(!keyDown || _TryHandleKeyBinding(vkey, scanCode, modifiers));
Expand Down Expand Up @@ -1369,7 +1371,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
{
if (_focused && _CanSendVTMouseInput())
// Short-circuit isReadOnly check to avoid warning dialog
if (_focused && !_isReadOnly && _CanSendVTMouseInput())
{
_TrySendMouseEvent(point);
args.Handled(true);
Expand Down Expand Up @@ -1521,7 +1524,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation

if (ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Mouse || ptr.PointerDeviceType() == Windows::Devices::Input::PointerDeviceType::Pen)
{
if (_CanSendVTMouseInput())
// Short-circuit isReadOnly check to avoid warning dialog
if (!_isReadOnly && _CanSendVTMouseInput())
{
_TrySendMouseEvent(point);
args.Handled(true);
Expand Down Expand Up @@ -1596,7 +1600,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
const int32_t delta,
const TerminalInput::MouseButtonState state)
{
if (_CanSendVTMouseInput())
// Short-circuit isReadOnly check to avoid warning dialog
if (!_isReadOnly && _CanSendVTMouseInput())
{
// Most mouse event handlers call
// _TrySendMouseEvent(point);
Expand Down

0 comments on commit 16d00a6

Please sign in to comment.