From ddfbe788ad329f2c14da9ff88e403eab11ea6c08 Mon Sep 17 00:00:00 2001 From: khvitaly Date: Mon, 21 Dec 2020 02:23:54 +0200 Subject: [PATCH 1/7] Teach terminal control to hide mouse while typing --- src/cascadia/TerminalControl/TermControl.cpp | 19 +++++++++++++++++++ src/cascadia/TerminalControl/TermControl.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 85f878b2097..7596041220f 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -839,6 +839,13 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _blinkTimer = std::nullopt; } + // Setup mouse vanish attributes + SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false); + + // Store cursor, so we can restore it, e.g., after mouse vanishing + // (we'll need to adapt this logic once we make cursor context aware) + _defaultCursor = CoreWindow::GetForCurrentThread().PointerCursor(); + // import value from WinUser (convert from milli-seconds to micro-seconds) _multiClickTimer = GetDoubleClickTime() * 1000; @@ -869,6 +876,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + if (_shouldMouseVanish && !_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(nullptr); + _isMouseHidden = true; + } + const auto ch = e.Character(); const auto scanCode = gsl::narrow_cast(e.KeyStatus().ScanCode); auto modifiers = _GetPressedModifierKeys(); @@ -1342,6 +1355,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + const auto ptr = args.Pointer(); const auto point = args.GetCurrentPoint(*this); diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index a90bea21cc5..8a0ae6427a2 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -232,6 +232,10 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation std::optional _cursorTimer; std::optional _blinkTimer; + bool _shouldMouseVanish{ false }; + bool _isMouseHidden{ false }; + Windows::UI::Core::CoreCursor _defaultCursor{ nullptr }; + // If this is set, then we assume we are in the middle of panning the // viewport via touch input. std::optional _touchAnchor; From e1d615aa30d357fac68ac3bcafc560ca222994da Mon Sep 17 00:00:00 2001 From: khvitaly Date: Mon, 21 Dec 2020 02:46:43 +0200 Subject: [PATCH 2/7] Teach terminal control to restore cursor upon pointer press and lost focus --- src/cascadia/TerminalControl/TermControl.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 7596041220f..fd8ebd40fea 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -1226,6 +1226,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + _CapturePointer(sender, args); const auto ptr = args.Pointer(); @@ -1568,6 +1574,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + const auto point = args.GetCurrentPoint(*this); const auto props = point.Properties(); const TerminalInput::MouseButtonState state{ props.IsLeftButtonPressed(), props.IsMiddleButtonPressed(), props.IsRightButtonPressed() }; @@ -1999,6 +2011,12 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + _focused = false; if (_uiaEngine.get()) From 5e0e24cc34831b70cd6523357d87d3cb1d467315 Mon Sep 17 00:00:00 2001 From: khvitaly Date: Mon, 21 Dec 2020 02:57:59 +0200 Subject: [PATCH 3/7] Introduce hide and restore cursor methods --- src/cascadia/TerminalControl/TermControl.cpp | 59 +++++++++++--------- src/cascadia/TerminalControl/TermControl.h | 3 + 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index fd8ebd40fea..96d31c8b19c 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -876,11 +876,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - if (_shouldMouseVanish && !_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(nullptr); - _isMouseHidden = true; - } + _HideCursor(); const auto ch = e.Character(); const auto scanCode = gsl::narrow_cast(e.KeyStatus().ScanCode); @@ -1226,12 +1222,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - if (_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); - _isMouseHidden = false; - } - + _RestoreCursor(); _CapturePointer(sender, args); const auto ptr = args.Pointer(); @@ -1361,11 +1352,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - if (_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); - _isMouseHidden = false; - } + _RestoreCursor(); const auto ptr = args.Pointer(); const auto point = args.GetCurrentPoint(*this); @@ -1574,11 +1561,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - if (_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); - _isMouseHidden = false; - } + _RestoreCursor(); const auto point = args.GetCurrentPoint(*this); const auto props = point.Properties(); @@ -1947,6 +1930,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } + _RestoreCursor(); + _focused = true; InputPane::GetForCurrentView().TryShow(); @@ -2011,11 +1996,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - if (_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); - _isMouseHidden = false; - } + _RestoreCursor(); _focused = false; @@ -3265,6 +3246,32 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return _terminal->GetTaskbarProgress(); } + // Method Description: + // - Hides cursor if required + // Return Value: + // - + void TermControl::_HideCursor() + { + if (_shouldMouseVanish && !_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(nullptr); + _isMouseHidden = true; + } + } + + // Method Description: + // - Restores cursor if required + // Return Value: + // - + void TermControl::_RestoreCursor() + { + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + } + // -------------------------------- WinRT Events --------------------------------- // Winrt events need a method for adding a callback to the event and removing the callback. // These macros will define them both for you. diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 8a0ae6427a2..fd28d688243 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -337,6 +337,9 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation void _CurrentCursorPositionHandler(const IInspectable& sender, const CursorPositionEventArgs& eventArgs); void _FontInfoHandler(const IInspectable& sender, const FontInfoEventArgs& eventArgs); + void _HideCursor(); + void _RestoreCursor(); + winrt::fire_and_forget _AsyncCloseConnection(); }; } From 80f648b4fa7ace756cf044feaba30aee390e3bb2 Mon Sep 17 00:00:00 2001 From: khvitaly Date: Mon, 21 Dec 2020 04:06:10 +0200 Subject: [PATCH 4/7] Move the cursor hiding logic to terminal page to ensure consistency --- src/cascadia/TerminalApp/TerminalPage.cpp | 36 +++++++++++++++ src/cascadia/TerminalApp/TerminalPage.h | 6 +++ src/cascadia/TerminalControl/TermControl.cpp | 46 +++----------------- src/cascadia/TerminalControl/TermControl.h | 9 +--- src/cascadia/TerminalControl/TermControl.idl | 2 + 5 files changed, 52 insertions(+), 47 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 3f9b5ee83ff..dc4c29950b5 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -254,6 +254,13 @@ namespace winrt::TerminalApp::implementation _layoutUpdatedRevoker = _tabContent.LayoutUpdated(winrt::auto_revoke, { this, &TerminalPage::_OnFirstLayout }); _isAlwaysOnTop = _settings.GlobalSettings().AlwaysOnTop(); + + // Setup mouse vanish attributes + SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false); + + // Store cursor, so we can restore it, e.g., after mouse vanishing + // (we'll need to adapt this logic once we make cursor context aware) + _defaultCursor = CoreWindow::GetForCurrentThread().PointerCursor(); } // Method Description: @@ -1256,6 +1263,9 @@ namespace winrt::TerminalApp::implementation // Add an event handler for when the terminal wants to set a progress indicator on the taskbar term.SetTaskbarProgress({ this, &TerminalPage::_SetTaskbarProgressHandler }); + term.HideCursor({ this, &TerminalPage::_HideCursorHandler }); + term.RestoreCursor({ this, &TerminalPage::_RestoreCursorHandler }); + // Bind Tab events to the TermControl and the Tab's Pane hostingTab.Initialize(term); @@ -3043,6 +3053,32 @@ namespace winrt::TerminalApp::implementation return text; } + // Method Description: + // - Hides cursor if required + // Return Value: + // - + void TerminalPage::_HideCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) + { + if (_shouldMouseVanish && !_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(nullptr); + _isMouseHidden = true; + } + } + + // Method Description: + // - Restores cursor if required + // Return Value: + // - + void TerminalPage::_RestoreCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) + { + if (_isMouseHidden) + { + CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + _isMouseHidden = false; + } + } + // -------------------------------- WinRT Events --------------------------------- // Winrt events need a method for adding a callback to the event and removing the callback. // These macros will define them both for you. diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index e80549cee5a..e45af5809b7 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -261,6 +261,12 @@ namespace winrt::TerminalApp::implementation void _TryMoveTab(const uint32_t currentTabIndex, const int32_t suggestedNewTabIndex); + bool _shouldMouseVanish{ false }; + bool _isMouseHidden{ false }; + Windows::UI::Core::CoreCursor _defaultCursor{ nullptr }; + void _HideCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); + void _RestoreCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); + #pragma region ActionHandlers // These are all defined in AppActionHandlers.cpp void _HandleOpenNewTabDropdown(const IInspectable& sender, const Microsoft::Terminal::Settings::Model::ActionEventArgs& args); diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 96d31c8b19c..daf3e566efe 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -839,13 +839,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _blinkTimer = std::nullopt; } - // Setup mouse vanish attributes - SystemParametersInfoW(SPI_GETMOUSEVANISH, 0, &_shouldMouseVanish, false); - - // Store cursor, so we can restore it, e.g., after mouse vanishing - // (we'll need to adapt this logic once we make cursor context aware) - _defaultCursor = CoreWindow::GetForCurrentThread().PointerCursor(); - // import value from WinUser (convert from milli-seconds to micro-seconds) _multiClickTimer = GetDoubleClickTime() * 1000; @@ -876,7 +869,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _HideCursor(); + _HideCursorHandlers(*this, nullptr); const auto ch = e.Character(); const auto scanCode = gsl::narrow_cast(e.KeyStatus().ScanCode); @@ -1222,7 +1215,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursor(); + _RestoreCursorHandlers(*this, nullptr); + _CapturePointer(sender, args); const auto ptr = args.Pointer(); @@ -1352,7 +1346,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursor(); + _RestoreCursorHandlers(*this, nullptr); const auto ptr = args.Pointer(); const auto point = args.GetCurrentPoint(*this); @@ -1561,7 +1555,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursor(); + _RestoreCursorHandlers(*this, nullptr); const auto point = args.GetCurrentPoint(*this); const auto props = point.Properties(); @@ -1930,8 +1924,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursor(); - _focused = true; InputPane::GetForCurrentView().TryShow(); @@ -1996,7 +1988,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursor(); + _RestoreCursorHandlers(*this, nullptr); _focused = false; @@ -3246,32 +3238,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return _terminal->GetTaskbarProgress(); } - // Method Description: - // - Hides cursor if required - // Return Value: - // - - void TermControl::_HideCursor() - { - if (_shouldMouseVanish && !_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(nullptr); - _isMouseHidden = true; - } - } - - // Method Description: - // - Restores cursor if required - // Return Value: - // - - void TermControl::_RestoreCursor() - { - if (_isMouseHidden) - { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); - _isMouseHidden = false; - } - } - // -------------------------------- WinRT Events --------------------------------- // Winrt events need a method for adding a callback to the event and removing the callback. // These macros will define them both for you. diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index fd28d688243..994537b7315 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -179,6 +179,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation TYPED_EVENT(ConnectionStateChanged, TerminalControl::TermControl, IInspectable); TYPED_EVENT(Initialized, TerminalControl::TermControl, Windows::UI::Xaml::RoutedEventArgs); TYPED_EVENT(TabColorChanged, IInspectable, IInspectable); + TYPED_EVENT(HideCursor, IInspectable, IInspectable); + TYPED_EVENT(RestoreCursor, IInspectable, IInspectable); // clang-format on private: @@ -232,10 +234,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation std::optional _cursorTimer; std::optional _blinkTimer; - bool _shouldMouseVanish{ false }; - bool _isMouseHidden{ false }; - Windows::UI::Core::CoreCursor _defaultCursor{ nullptr }; - // If this is set, then we assume we are in the middle of panning the // viewport via touch input. std::optional _touchAnchor; @@ -337,9 +335,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation void _CurrentCursorPositionHandler(const IInspectable& sender, const CursorPositionEventArgs& eventArgs); void _FontInfoHandler(const IInspectable& sender, const FontInfoEventArgs& eventArgs); - void _HideCursor(); - void _RestoreCursor(); - winrt::fire_and_forget _AsyncCloseConnection(); }; } diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index bbce2174815..1a66d7b5daa 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -77,6 +77,8 @@ namespace Microsoft.Terminal.TerminalControl event Windows.Foundation.TypedEventHandler SetTaskbarProgress; event Windows.Foundation.TypedEventHandler RaiseNotice; event Windows.Foundation.TypedEventHandler WarningBell; + event Windows.Foundation.TypedEventHandler HideCursor; + event Windows.Foundation.TypedEventHandler RestoreCursor; event Windows.Foundation.TypedEventHandler Initialized; // This is an event handler forwarder for the underlying connection. From eb255708242ec16541d569d0a9713d3319119ca7 Mon Sep 17 00:00:00 2001 From: khvitaly Date: Mon, 21 Dec 2020 04:07:29 +0200 Subject: [PATCH 5/7] Add GETMOUSEVANISH to expected keywords --- .github/actions/spell-check/expect/expect.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spell-check/expect/expect.txt b/.github/actions/spell-check/expect/expect.txt index ad77d910404..f64a2fa4cbb 100644 --- a/.github/actions/spell-check/expect/expect.txt +++ b/.github/actions/spell-check/expect/expect.txt @@ -2868,3 +2868,4 @@ abcd LPMINMAXINFO MINMAXINFO lstrcmpi +GETMOUSEVANISH From 9e90e6ab66ab53347e95cb164ea593692aa496ec Mon Sep 17 00:00:00 2001 From: khvitaly Date: Thu, 24 Dec 2020 11:49:56 +0200 Subject: [PATCH 6/7] Rename event names to *PointerCursor to avoid confusion --- src/cascadia/TerminalApp/TerminalPage.cpp | 12 ++++++------ src/cascadia/TerminalApp/TerminalPage.h | 6 +++--- src/cascadia/TerminalControl/TermControl.cpp | 10 +++++----- src/cascadia/TerminalControl/TermControl.h | 4 ++-- src/cascadia/TerminalControl/TermControl.idl | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index dc4c29950b5..3b625940a91 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -260,7 +260,7 @@ namespace winrt::TerminalApp::implementation // Store cursor, so we can restore it, e.g., after mouse vanishing // (we'll need to adapt this logic once we make cursor context aware) - _defaultCursor = CoreWindow::GetForCurrentThread().PointerCursor(); + _defaultPointerCursor = CoreWindow::GetForCurrentThread().PointerCursor(); } // Method Description: @@ -1263,8 +1263,8 @@ namespace winrt::TerminalApp::implementation // Add an event handler for when the terminal wants to set a progress indicator on the taskbar term.SetTaskbarProgress({ this, &TerminalPage::_SetTaskbarProgressHandler }); - term.HideCursor({ this, &TerminalPage::_HideCursorHandler }); - term.RestoreCursor({ this, &TerminalPage::_RestoreCursorHandler }); + term.HidePointerCursor({ this, &TerminalPage::_HidePointerCursorHandler }); + term.RestorePointerCursor({ this, &TerminalPage::_RestorePointerCursorHandler }); // Bind Tab events to the TermControl and the Tab's Pane hostingTab.Initialize(term); @@ -3057,7 +3057,7 @@ namespace winrt::TerminalApp::implementation // - Hides cursor if required // Return Value: // - - void TerminalPage::_HideCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) + void TerminalPage::_HidePointerCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) { if (_shouldMouseVanish && !_isMouseHidden) { @@ -3070,11 +3070,11 @@ namespace winrt::TerminalApp::implementation // - Restores cursor if required // Return Value: // - - void TerminalPage::_RestoreCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) + void TerminalPage::_RestorePointerCursorHandler(const IInspectable& /*sender*/, const IInspectable& /*eventArgs*/) { if (_isMouseHidden) { - CoreWindow::GetForCurrentThread().PointerCursor(_defaultCursor); + CoreWindow::GetForCurrentThread().PointerCursor(_defaultPointerCursor); _isMouseHidden = false; } } diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index e45af5809b7..d6360b17682 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -263,9 +263,9 @@ namespace winrt::TerminalApp::implementation bool _shouldMouseVanish{ false }; bool _isMouseHidden{ false }; - Windows::UI::Core::CoreCursor _defaultCursor{ nullptr }; - void _HideCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); - void _RestoreCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); + Windows::UI::Core::CoreCursor _defaultPointerCursor{ nullptr }; + void _HidePointerCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); + void _RestorePointerCursorHandler(const IInspectable& sender, const IInspectable& eventArgs); #pragma region ActionHandlers // These are all defined in AppActionHandlers.cpp diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index daf3e566efe..362a9a5171e 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -869,7 +869,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _HideCursorHandlers(*this, nullptr); + _HidePointerCursorHandlers(*this, nullptr); const auto ch = e.Character(); const auto scanCode = gsl::narrow_cast(e.KeyStatus().ScanCode); @@ -1215,7 +1215,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursorHandlers(*this, nullptr); + _RestorePointerCursorHandlers(*this, nullptr); _CapturePointer(sender, args); @@ -1346,7 +1346,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursorHandlers(*this, nullptr); + _RestorePointerCursorHandlers(*this, nullptr); const auto ptr = args.Pointer(); const auto point = args.GetCurrentPoint(*this); @@ -1555,7 +1555,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursorHandlers(*this, nullptr); + _RestorePointerCursorHandlers(*this, nullptr); const auto point = args.GetCurrentPoint(*this); const auto props = point.Properties(); @@ -1988,7 +1988,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return; } - _RestoreCursorHandlers(*this, nullptr); + _RestorePointerCursorHandlers(*this, nullptr); _focused = false; diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 994537b7315..de775ef0298 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -179,8 +179,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation TYPED_EVENT(ConnectionStateChanged, TerminalControl::TermControl, IInspectable); TYPED_EVENT(Initialized, TerminalControl::TermControl, Windows::UI::Xaml::RoutedEventArgs); TYPED_EVENT(TabColorChanged, IInspectable, IInspectable); - TYPED_EVENT(HideCursor, IInspectable, IInspectable); - TYPED_EVENT(RestoreCursor, IInspectable, IInspectable); + TYPED_EVENT(HidePointerCursor, IInspectable, IInspectable); + TYPED_EVENT(RestorePointerCursor, IInspectable, IInspectable); // clang-format on private: diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 1a66d7b5daa..de4ba809075 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -77,8 +77,8 @@ namespace Microsoft.Terminal.TerminalControl event Windows.Foundation.TypedEventHandler SetTaskbarProgress; event Windows.Foundation.TypedEventHandler RaiseNotice; event Windows.Foundation.TypedEventHandler WarningBell; - event Windows.Foundation.TypedEventHandler HideCursor; - event Windows.Foundation.TypedEventHandler RestoreCursor; + event Windows.Foundation.TypedEventHandler HidePointerCursor; + event Windows.Foundation.TypedEventHandler RestorePointerCursor; event Windows.Foundation.TypedEventHandler Initialized; // This is an event handler forwarder for the underlying connection. From d6c27f7f18709142aef5a937d22a16053342c0d3 Mon Sep 17 00:00:00 2001 From: khvitaly Date: Thu, 21 Jan 2021 00:19:06 +0200 Subject: [PATCH 7/7] Fix terminal control to restore cursor when closing --- src/cascadia/TerminalControl/TermControl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 6f5207456c7..0a6b453e8ee 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2582,6 +2582,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation { if (!_closing.exchange(true)) { + _RestorePointerCursorHandlers(*this, nullptr); + // Stop accepting new output and state changes before we disconnect everything. _connection.TerminalOutput(_connectionOutputEventToken); _connectionStateChangedRevoker.revoke();