Prevent read-only warning on mouse move, wheel and release (#9107)

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
This commit is contained in:
Don-Vito 2021-02-11 17:16:36 +02:00 committed by GitHub
parent 8f73145d9d
commit 16d00a68fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
@ -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));
@ -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);
@ -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);
@ -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);