From 370e0c0d4415122ccd5c505860e45654af885e27 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 18 Feb 2021 10:27:36 -0800 Subject: [PATCH 01/28] initial --- src/cascadia/TerminalApp/Pane.cpp | 1 + src/cascadia/TerminalControl/TermControl.cpp | 21 ++++++++++++++++++++ src/cascadia/TerminalControl/TermControl.h | 4 ++++ src/cascadia/TerminalControl/TermControl.idl | 2 ++ 4 files changed, 28 insertions(+) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index f7d681564a5..b957ef945a0 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -380,6 +380,7 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect // raise the event with the bool value corresponding to the visual flag _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual)); + _control.InvertScreenColors(); } } } diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 0fd5273ce1b..589ddf3c6b0 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -77,6 +77,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _touchAnchor{ std::nullopt }, _cursorTimer{}, _blinkTimer{}, + _invertTimer{}, _lastMouseClickTimestamp{}, _lastMouseClickPos{}, _selectionNeedsToBeCopied{ false }, @@ -835,6 +836,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _blinkTimer = std::nullopt; } + DispatcherTimer invertTimer; + invertTimer.Interval(UpdatePatternLocationsInterval); + invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); + _invertTimer.emplace(std::move(invertTimer)); + // import value from WinUser (convert from milli-seconds to micro-seconds) _multiClickTimer = GetDoubleClickTime() * 1000; @@ -3233,6 +3239,21 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation return _terminal->GetTaskbarProgress(); } + winrt::fire_and_forget TermControl::InvertScreenColors() + { + co_await winrt::resume_foreground(Dispatcher()); + + _invertTimer.value().Start(); + _terminal->SetScreenMode(true); + } + + void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */, + Windows::Foundation::IInspectable const& /* e */) + { + _terminal->SetScreenMode(false); + _invertTimer.value().Stop(); + } + // Method Description: // - Checks whether the control is in a read-only mode (in this mode node input is sent to connection). // Return Value: diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 171c28de8a5..ea577647577 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -164,6 +164,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation const size_t TaskbarState() const noexcept; const size_t TaskbarProgress() const noexcept; + winrt::fire_and_forget InvertScreenColors(); + bool ReadOnly() const noexcept; void ToggleReadOnly(); @@ -239,6 +241,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation std::optional _cursorTimer; std::optional _blinkTimer; + std::optional _invertTimer; // If this is set, then we assume we are in the middle of panning the // viewport via touch input. @@ -295,6 +298,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation void _CursorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _BlinkTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); + void _InvertTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _SetEndSelectionPointAtCursor(Windows::Foundation::Point const& cursorPosition); void _SendInputToConnection(const winrt::hstring& wstr); void _SendInputToConnection(std::wstring_view wstr); diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 0bad381493b..997f87c6aac 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -112,6 +112,8 @@ namespace Microsoft.Terminal.TerminalControl UInt64 TaskbarState { get; }; UInt64 TaskbarProgress { get; }; + void InvertScreenColors(); + String WorkingDirectory { get; }; Windows.Foundation.IReference TabColor { get; }; From 3d7c9dbb65e1ff7d169087e9dee777ce3dcd6beb Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 18 Feb 2021 15:41:36 -0800 Subject: [PATCH 02/28] optional timer --- src/cascadia/TerminalControl/TermControl.cpp | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 589ddf3c6b0..549474d2b44 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -836,11 +836,6 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation _blinkTimer = std::nullopt; } - DispatcherTimer invertTimer; - invertTimer.Interval(UpdatePatternLocationsInterval); - invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); - _invertTimer.emplace(std::move(invertTimer)); - // import value from WinUser (convert from milli-seconds to micro-seconds) _multiClickTimer = GetDoubleClickTime() * 1000; @@ -3241,17 +3236,28 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation winrt::fire_and_forget TermControl::InvertScreenColors() { - co_await winrt::resume_foreground(Dispatcher()); + if (!_invertTimer) + { + co_await winrt::resume_foreground(Dispatcher()); - _invertTimer.value().Start(); - _terminal->SetScreenMode(true); + DispatcherTimer invertTimer; + invertTimer.Interval(UpdatePatternLocationsInterval); + invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); + invertTimer.Start(); + _invertTimer.emplace(std::move(invertTimer)); + _terminal->SetScreenMode(true); + } } void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */, Windows::Foundation::IInspectable const& /* e */) { - _terminal->SetScreenMode(false); - _invertTimer.value().Stop(); + if (_invertTimer) + { + _terminal->SetScreenMode(false); + _invertTimer.value().Stop(); + _invertTimer = std::nullopt; + } } // Method Description: From 54a683dd86555b04b3385681bed4e122473cedbd Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 19 Feb 2021 10:09:53 -0800 Subject: [PATCH 03/28] add setting --- src/cascadia/TerminalApp/Pane.cpp | 14 +++++++++++--- src/cascadia/TerminalSettingsModel/Profile.idl | 2 ++ .../TerminalSettingsSerializationHelpers.h | 4 +++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index b957ef945a0..cc3998511d3 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -378,9 +378,17 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY); } - // raise the event with the bool value corresponding to the visual flag - _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual)); - _control.InvertScreenColors(); + if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || + WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) + { + _control.InvertScreenColors(); + } + + const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || + WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar); + + // raise the event with the bool value corresponding to the taskbar or visual flag + _PaneRaiseBellHandlers(nullptr, flashTaskbar); } } } diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index f65b34e5c5a..05e59984970 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -15,6 +15,8 @@ namespace Microsoft.Terminal.Settings.Model { Audible = 0x1, Visual = 0x2, + Window = 0x4, + Taskbar = 0x8, All = 0xffffffff }; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 82b16cdefb0..7de418f4203 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -50,10 +50,12 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::TerminalControl::ScrollbarState) JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, pair_type{ "visual", ValueType::Visual }, + pair_type{ "window", ValueType::Window }, + pair_type{ "taskbar", ValueType::Taskbar }, pair_type{ "all", AllSet }, }; From d59a4324a98eca7160cdc7017636c170b33574c4 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 24 Feb 2021 10:28:13 -0800 Subject: [PATCH 04/28] change timer --- src/cascadia/TerminalControl/TermControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index d8b362931c0..4d4559b57a7 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3262,7 +3262,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation co_await winrt::resume_foreground(Dispatcher()); DispatcherTimer invertTimer; - invertTimer.Interval(UpdatePatternLocationsInterval); + invertTimer.Interval(std::chrono::milliseconds(2000)); invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); invertTimer.Start(); _invertTimer.emplace(std::move(invertTimer)); From c1172cd782ffb687e949ad125238791c0bf40d97 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 1 Mar 2021 15:12:53 -0800 Subject: [PATCH 05/28] format --- src/cascadia/TerminalControl/TermControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 4d4559b57a7..1f2738b1c3d 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3271,7 +3271,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation } void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */, - Windows::Foundation::IInspectable const& /* e */) + Windows::Foundation::IInspectable const& /* e */) { if (_invertTimer) { From e0c9f899eac2f046f6dff9cf1fea7b3732877a7e Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 19 Mar 2021 15:59:25 -0700 Subject: [PATCH 06/28] stash, lock --- src/cascadia/TerminalControl/TermControl.cpp | 13 ++++++++++--- src/cascadia/TerminalControl/TermControl.h | 1 + src/cascadia/TerminalCore/Terminal.cpp | 5 +++++ src/cascadia/TerminalCore/Terminal.hpp | 2 ++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 1f2738b1c3d..4b507bf9296 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3261,21 +3261,28 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation { co_await winrt::resume_foreground(Dispatcher()); + auto lock = _terminal->LockForWriting(); DispatcherTimer invertTimer; invertTimer.Interval(std::chrono::milliseconds(2000)); invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); invertTimer.Start(); _invertTimer.emplace(std::move(invertTimer)); - _terminal->SetScreenMode(true); + + // stash away the value of the terminal's current screen mode, + // we want to return to this once the timer fires + _termScreenReversed = _terminal->ScreenMode(); + _terminal->SetScreenMode(!_termScreenReversed); } } void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */, Windows::Foundation::IInspectable const& /* e */) { - if (_invertTimer) + if (_invertTimer && !_closing) { - _terminal->SetScreenMode(false); + auto lock = _terminal->LockForWriting(); + // revert the terminal's screen mode to the stashed value + _terminal->SetScreenMode(_termScreenReversed); _invertTimer.value().Stop(); _invertTimer = std::nullopt; } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index c9f33a59ee7..c82368177e8 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -197,6 +197,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation friend struct TermControlT; // friend our parent so it can bind private event handlers TerminalConnection::ITerminalConnection _connection; bool _initializedTerminal; + bool _termScreenReversed; winrt::com_ptr _searchBox; diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 942def662ca..18381b8595b 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -870,6 +870,11 @@ int Terminal::ViewEndIndex() const noexcept return _mutableViewport.BottomInclusive(); } +bool Terminal::ScreenMode() const noexcept +{ + return _screenReversed; +} + // _VisibleStartIndex is the first visible line of the buffer int Terminal::_VisibleStartIndex() const noexcept { diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index fac17b22979..202b9a81a21 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -78,6 +78,8 @@ class Microsoft::Terminal::Core::Terminal final : int ViewStartIndex() const noexcept; int ViewEndIndex() const noexcept; + bool ScreenMode() const noexcept; + #pragma region ITerminalApi // These methods are defined in TerminalApi.cpp bool PrintString(std::wstring_view stringView) noexcept override; From e89f273e6c8ee5e8ec24c3a920023597cfabedfc Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 19 Mar 2021 16:05:22 -0700 Subject: [PATCH 07/28] weak this --- src/cascadia/TerminalControl/TermControl.cpp | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 4b507bf9296..873a79aac84 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -3259,19 +3259,23 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation { if (!_invertTimer) { + auto weakThis{ get_weak() }; co_await winrt::resume_foreground(Dispatcher()); - auto lock = _terminal->LockForWriting(); - DispatcherTimer invertTimer; - invertTimer.Interval(std::chrono::milliseconds(2000)); - invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); - invertTimer.Start(); - _invertTimer.emplace(std::move(invertTimer)); - - // stash away the value of the terminal's current screen mode, - // we want to return to this once the timer fires - _termScreenReversed = _terminal->ScreenMode(); - _terminal->SetScreenMode(!_termScreenReversed); + if (auto control{ weakThis.get() }) + { + auto lock = control->_terminal->LockForWriting(); + DispatcherTimer invertTimer; + invertTimer.Interval(std::chrono::milliseconds(2000)); + invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); + invertTimer.Start(); + control->_invertTimer.emplace(std::move(invertTimer)); + + // stash away the value of the terminal's current screen mode, + // we want to return to this once the timer fires + control->_termScreenReversed = control->_terminal->ScreenMode(); + control->_terminal->SetScreenMode(!control->_termScreenReversed); + } } } From 4c125c32477c5aeafc4e7cc7b9cdec481583c5c8 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 24 Mar 2021 10:28:35 -0700 Subject: [PATCH 08/28] resw, schema --- doc/cascadia/profiles.schema.json | 8 ++++++-- .../Resources/en-US/Resources.resw | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 681a0b6bebe..f3db122c4f0 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -37,7 +37,9 @@ "type": "string", "enum": [ "audible", - "visual" + "visual", + "taskbar", + "window" ] } }, @@ -46,6 +48,8 @@ "enum": [ "audible", "visual", + "taskbar", + "window", "all", "none" ] @@ -1008,7 +1012,7 @@ }, "bellStyle": { "default": "audible", - "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound and flash the taskbar icon. An array of specific behaviors can also be used. Supported array values include `audible` and `visual`. When set to \"none\", nothing will happen.", + "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound, flash the taskbar icon and flash the window. An array of specific behaviors can also be used. Supported array values include `audible`, `visual`, `taskbar` and `window`. When set to \"none\", nothing will happen.", "$ref": "#/definitions/BellStyle" }, "closeOnExit": { diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index c5b305d9495..6c48f2a4238 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -870,9 +870,17 @@ An option to choose from for the "bell style" setting. When selected, a combination of the other bell styles is used to notify the user. - Visual (flash taskbar) + Visual (flash window and taskbar) + An option to choose from for the "bell style" setting. When selected, both the window and taskbar are flashed to notify the user. + + + Flash taskbar An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed. + + Flash window + An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the window is flashed. + Add new Button label that creates a new color scheme. From 76c182aebdc9c818ce5a22dd10558c7fe4eb63c6 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 7 May 2021 06:12:26 -0700 Subject: [PATCH 09/28] use xaml light --- src/cascadia/TerminalApp/Pane.cpp | 2 +- src/cascadia/TerminalControl/TermControl.cpp | 110 +++++++++++++----- src/cascadia/TerminalControl/TermControl.h | 41 ++++++- src/cascadia/TerminalControl/TermControl.idl | 10 +- src/cascadia/TerminalControl/TermControl.xaml | 3 + 5 files changed, 134 insertions(+), 32 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index eda2f54adb3..a6294afe915 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -381,7 +381,7 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) { - _control.InvertScreenColors(); + _control.BellLightOn(); } const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index a7b9e4cac12..858c360c0ec 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -14,6 +14,7 @@ #include "../../types/inc/Utils.hpp" #include "TermControl.g.cpp" +#include "VisualBellLight.g.cpp" #include "TermControlAutomationPeer.h" using namespace ::Microsoft::Console::Types; @@ -58,7 +59,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _lastAutoScrollUpdateTime{ std::nullopt }, _cursorTimer{}, _blinkTimer{}, - _invertTimer{}, + _bellLightTimer{}, _searchBox{ nullptr } { InitializeComponent(); @@ -2359,40 +2360,31 @@ namespace winrt::Microsoft::Terminal::Control::implementation return _core->TaskbarProgress(); } - winrt::fire_and_forget TermControl::InvertScreenColors() + void TermControl::BellLightOn() { - if (!_invertTimer) + if (!_bellLightTimer) { - auto weakThis{ get_weak() }; - co_await winrt::resume_foreground(Dispatcher()); + // Start the timer, when the timer ticks we switch off the light + DispatcherTimer invertTimer; + invertTimer.Interval(std::chrono::milliseconds(2000)); + invertTimer.Tick({ get_weak(), &TermControl::_BellLightOff }); + invertTimer.Start(); + _bellLightTimer.emplace(std::move(invertTimer)); - if (auto control{ weakThis.get() }) - { - //auto lock = control->_terminal->LockForWriting(); - //DispatcherTimer invertTimer; - //invertTimer.Interval(std::chrono::milliseconds(2000)); - //invertTimer.Tick({ get_weak(), &TermControl::_InvertTimerTick }); - //invertTimer.Start(); - //control->_invertTimer.emplace(std::move(invertTimer)); - - //// stash away the value of the terminal's current screen mode, - //// we want to return to this once the timer fires - //control->_termScreenReversed = control->_terminal->ScreenMode(); - //control->_terminal->SetScreenMode(!control->_termScreenReversed); - } + // Switch on the light + VisualBellLight::SetIsTarget(RootGrid(), true); } } - void TermControl::_InvertTimerTick(Windows::Foundation::IInspectable const& /* sender */, - Windows::Foundation::IInspectable const& /* e */) + void TermControl::_BellLightOff(Windows::Foundation::IInspectable const& /* sender */, + Windows::Foundation::IInspectable const& /* e */) { - if (_invertTimer && !_closing) + if (_bellLightTimer && !_closing) { - //auto lock = _terminal->LockForWriting(); - //// revert the terminal's screen mode to the stashed value - //_terminal->SetScreenMode(_termScreenReversed); - //_invertTimer.value().Stop(); - //_invertTimer = std::nullopt; + // Stop the timer and switch off the light + _bellLightTimer.value().Stop(); + _bellLightTimer = std::nullopt; + VisualBellLight::SetIsTarget(RootGrid(), false); } } @@ -2530,4 +2522,68 @@ namespace winrt::Microsoft::Terminal::Control::implementation { _playWarningBell->Run(); } + + Windows::UI::Xaml::DependencyProperty VisualBellLight::m_isTargetProperty = + Windows::UI::Xaml::DependencyProperty::RegisterAttached( + L"IsTarget", + winrt::xaml_typename(), + winrt::xaml_typename(), + Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + + void VisualBellLight::OnConnected(Windows::UI::Xaml::UIElement const& /* newElement */) + { + if (!CompositionLight()) + { + // OnConnected is called when the first target UIElement is shown on the screen. This enables delaying composition object creation until it's actually necessary. + auto spotLight2{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; + spotLight2.Color(Windows::UI::Colors::WhiteSmoke()); + spotLight2.Intensity(static_cast(1.5)); + CompositionLight(spotLight2); + } + } + + void VisualBellLight::OnDisconnected(Windows::UI::Xaml::UIElement const& /* oldElement */) + { + // OnDisconnected is called when there are no more target UIElements on the screen. + // Dispose of composition resources when no longer in use. + if (CompositionLight()) + { + CompositionLight(nullptr); + } + } + + winrt::hstring VisualBellLight::GetId() + { + return VisualBellLight::GetIdStatic(); + } + + void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) + { + auto uie{ d.try_as() }; + auto brush{ d.try_as() }; + + auto isAdding = winrt::unbox_value(e.NewValue()); + if (isAdding) + { + if (uie) + { + Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uie); + } + else if (brush) + { + Windows::UI::Xaml::Media::XamlLight::AddTargetBrush(VisualBellLight::GetIdStatic(), brush); + } + } + else + { + if (uie) + { + Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uie); + } + else if (brush) + { + Windows::UI::Xaml::Media::XamlLight::RemoveTargetBrush(VisualBellLight::GetIdStatic(), brush); + } + } + } } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index cd6845be4d2..1a2d11881c7 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -4,6 +4,7 @@ #pragma once #include "TermControl.g.h" +#include "VisualBellLight.g.h" #include "EventArgs.h" #include "../../renderer/base/Renderer.hpp" #include "../../renderer/dx/DxRenderer.hpp" @@ -98,7 +99,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation const winrt::hstring& padding, const uint32_t dpi); - winrt::fire_and_forget InvertScreenColors(); + void BellLightOn(); bool ReadOnly() const noexcept; void ToggleReadOnly(); @@ -169,7 +170,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation std::optional _cursorTimer; std::optional _blinkTimer; - std::optional _invertTimer; + std::optional _bellLightTimer; event_token _coreOutputEventToken; @@ -206,7 +207,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void _CursorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _BlinkTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); - void _InvertTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); + void _BellLightOff(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e); void _SetEndSelectionPointAtCursor(Windows::Foundation::Point const& cursorPosition); @@ -254,9 +255,43 @@ namespace winrt::Microsoft::Terminal::Control::implementation void _coreRaisedNotice(const IInspectable& s, const Control::NoticeEventArgs& args); void _coreWarningBell(const IInspectable& sender, const IInspectable& args); }; + + struct VisualBellLight : VisualBellLightT + { + VisualBellLight() = default; + + winrt::hstring GetId(); + + static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return m_isTargetProperty; } + + static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) + { + return winrt::unbox_value(target.GetValue(m_isTargetProperty)); + } + + static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) + { + target.SetValue(m_isTargetProperty, winrt::box_value(value)); + } + + void OnConnected(Windows::UI::Xaml::UIElement const& newElement); + void OnDisconnected(Windows::UI::Xaml::UIElement const& oldElement); + + static void OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e); + + inline static winrt::hstring GetIdStatic() + { + // This specifies the unique name of the light. In most cases you should use the type's full name. + return winrt::xaml_typename().Name; + } + + private: + static Windows::UI::Xaml::DependencyProperty m_isTargetProperty; + }; } namespace winrt::Microsoft::Terminal::Control::factory_implementation { BASIC_FACTORY(TermControl); + BASIC_FACTORY(VisualBellLight); } diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 2216bdf2471..8fa9d434b08 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -63,9 +63,17 @@ namespace Microsoft.Terminal.Control void ToggleShaderEffects(); void SendInput(String input); - void InvertScreenColors(); + void BellLightOn(); Boolean ReadOnly { get; }; void ToggleReadOnly(); } + + [default_interface] runtimeclass VisualBellLight : Windows.UI.Xaml.Media.XamlLight + { + VisualBellLight(); + static Windows.UI.Xaml.DependencyProperty IsTargetProperty { get; }; + static Boolean GetIsTarget(Windows.UI.Xaml.DependencyObject target); + static void SetIsTarget(Windows.UI.Xaml.DependencyObject target, Boolean value); + } } diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index 70330614bdc..1e71eacaeea 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -33,6 +33,9 @@ --> + + + From 5ed7e93c807f0bbaa348c06951e57b036cdee519 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 7 May 2021 06:30:37 -0700 Subject: [PATCH 10/28] spell --- src/cascadia/TerminalControl/TermControl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 858c360c0ec..a0716645e51 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2559,15 +2559,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) { - auto uie{ d.try_as() }; + auto uielem{ d.try_as() }; auto brush{ d.try_as() }; auto isAdding = winrt::unbox_value(e.NewValue()); if (isAdding) { - if (uie) + if (uielem) { - Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uie); + Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uielem); } else if (brush) { @@ -2576,9 +2576,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation } else { - if (uie) + if (uielem) { - Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uie); + Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uielem); } else if (brush) { From 678cfb583ff4f6c2fb1a00d9ae162c3f60b31813 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 7 May 2021 08:30:30 -0700 Subject: [PATCH 11/28] er what --- doc/cascadia/profiles.schema.json | 7 +++---- src/cascadia/TerminalApp/Pane.cpp | 10 +++------- src/cascadia/TerminalControl/TermControl.xaml | 2 +- src/cascadia/TerminalCore/Terminal.cpp | 5 ----- src/cascadia/TerminalCore/Terminal.hpp | 2 -- .../Resources/en-US/Resources.resw | 6 +----- src/cascadia/TerminalSettingsModel/Profile.idl | 5 ++--- .../TerminalSettingsSerializationHelpers.h | 3 +-- 8 files changed, 11 insertions(+), 29 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 7a0eb7b1114..ec1812187f0 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -37,9 +37,8 @@ "type": "string", "enum": [ "audible", - "visual", - "taskbar", - "window" + "window", + "taskbar" ] } }, @@ -1175,7 +1174,7 @@ }, "bellStyle": { "default": "audible", - "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound, flash the taskbar icon and flash the window. An array of specific behaviors can also be used. Supported array values include `audible`, `visual`, `taskbar` and `window`. When set to \"none\", nothing will happen.", + "description": "Controls what happens when the application emits a BEL character. When set to \"all\", the Terminal will play a sound, flash the taskbar icon (if the terminal window is not in focus) and flash the window. An array of specific behaviors can also be used. Supported array values include `audible`, `window` and `taskbar`. When set to \"none\", nothing will happen.", "$ref": "#/definitions/BellStyle" }, "closeOnExit": { diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index a6294afe915..a4939e0d3ed 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -378,17 +378,13 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY); } - if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || - WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) + if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) { _control.BellLightOn(); } - const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual) || - WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar); - - // raise the event with the bool value corresponding to the taskbar or visual flag - _PaneRaiseBellHandlers(nullptr, flashTaskbar); + // raise the event with the bool value corresponding to the taskbar flag + _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar)); } } } diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index 1e71eacaeea..cb3bc261834 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -34,7 +34,7 @@ - + diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index bdcec5e8200..ac3c4820dad 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -891,11 +891,6 @@ int Terminal::ViewEndIndex() const noexcept return _mutableViewport.BottomInclusive(); } -bool Terminal::ScreenMode() const noexcept -{ - return _screenReversed; -} - // _VisibleStartIndex is the first visible line of the buffer int Terminal::_VisibleStartIndex() const noexcept { diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index c8888d6d894..502bfd1b160 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -82,8 +82,6 @@ class Microsoft::Terminal::Core::Terminal final : int ViewStartIndex() const noexcept; int ViewEndIndex() const noexcept; - bool ScreenMode() const noexcept; - #pragma region ITerminalApi // These methods are defined in TerminalApi.cpp bool PrintString(std::wstring_view stringView) noexcept override; diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 5d455e0bf99..0c88b3715fa 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -899,13 +899,9 @@ All An option to choose from for the "bell style" setting. When selected, a combination of the other bell styles is used to notify the user. - - Visual (flash window and taskbar) - An option to choose from for the "bell style" setting. When selected, both the window and taskbar are flashed to notify the user. - Flash taskbar - An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed. + An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed (only if the terminal window is not in focus). Flash window diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index d66294a256e..12d47e59f75 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -31,9 +31,8 @@ namespace Microsoft.Terminal.Settings.Model enum BellStyle { Audible = 0x1, - Visual = 0x2, - Window = 0x4, - Taskbar = 0x8, + Window = 0x2, + Taskbar = 0x4, All = 0xffffffff }; diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index fdc20e5e4d9..ff412912444 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -50,10 +50,9 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::ScrollbarState) JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, - pair_type{ "visual", ValueType::Visual }, pair_type{ "window", ValueType::Window }, pair_type{ "taskbar", ValueType::Taskbar }, pair_type{ "all", AllSet }, From 23dc1fd49f03b73f672e45dfadd2a9e5b216b217 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Sun, 9 May 2021 20:09:19 -0700 Subject: [PATCH 12/28] move light to own file --- src/cascadia/TerminalControl/TermControl.cpp | 65 ---------------- src/cascadia/TerminalControl/TermControl.h | 37 +--------- src/cascadia/TerminalControl/TermControl.idl | 8 -- .../TerminalControlLib.vcxproj | 7 ++ src/cascadia/TerminalControl/XamlLights.cpp | 74 +++++++++++++++++++ src/cascadia/TerminalControl/XamlLights.h | 60 +++++++++++++++ src/cascadia/TerminalControl/XamlLights.idl | 13 ++++ .../Resources/en-US/Resources.resw | 6 +- 8 files changed, 160 insertions(+), 110 deletions(-) create mode 100644 src/cascadia/TerminalControl/XamlLights.cpp create mode 100644 src/cascadia/TerminalControl/XamlLights.h create mode 100644 src/cascadia/TerminalControl/XamlLights.idl diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index a0716645e51..9de0249a3cd 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -14,7 +14,6 @@ #include "../../types/inc/Utils.hpp" #include "TermControl.g.cpp" -#include "VisualBellLight.g.cpp" #include "TermControlAutomationPeer.h" using namespace ::Microsoft::Console::Types; @@ -2522,68 +2521,4 @@ namespace winrt::Microsoft::Terminal::Control::implementation { _playWarningBell->Run(); } - - Windows::UI::Xaml::DependencyProperty VisualBellLight::m_isTargetProperty = - Windows::UI::Xaml::DependencyProperty::RegisterAttached( - L"IsTarget", - winrt::xaml_typename(), - winrt::xaml_typename(), - Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); - - void VisualBellLight::OnConnected(Windows::UI::Xaml::UIElement const& /* newElement */) - { - if (!CompositionLight()) - { - // OnConnected is called when the first target UIElement is shown on the screen. This enables delaying composition object creation until it's actually necessary. - auto spotLight2{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; - spotLight2.Color(Windows::UI::Colors::WhiteSmoke()); - spotLight2.Intensity(static_cast(1.5)); - CompositionLight(spotLight2); - } - } - - void VisualBellLight::OnDisconnected(Windows::UI::Xaml::UIElement const& /* oldElement */) - { - // OnDisconnected is called when there are no more target UIElements on the screen. - // Dispose of composition resources when no longer in use. - if (CompositionLight()) - { - CompositionLight(nullptr); - } - } - - winrt::hstring VisualBellLight::GetId() - { - return VisualBellLight::GetIdStatic(); - } - - void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) - { - auto uielem{ d.try_as() }; - auto brush{ d.try_as() }; - - auto isAdding = winrt::unbox_value(e.NewValue()); - if (isAdding) - { - if (uielem) - { - Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uielem); - } - else if (brush) - { - Windows::UI::Xaml::Media::XamlLight::AddTargetBrush(VisualBellLight::GetIdStatic(), brush); - } - } - else - { - if (uielem) - { - Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uielem); - } - else if (brush) - { - Windows::UI::Xaml::Media::XamlLight::RemoveTargetBrush(VisualBellLight::GetIdStatic(), brush); - } - } - } } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 1a2d11881c7..97f67382f2a 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -4,7 +4,7 @@ #pragma once #include "TermControl.g.h" -#include "VisualBellLight.g.h" +#include "XamlLights.h" #include "EventArgs.h" #include "../../renderer/base/Renderer.hpp" #include "../../renderer/dx/DxRenderer.hpp" @@ -132,7 +132,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation private: friend struct TermControlT; // friend our parent so it can bind private event handlers - bool _termScreenReversed; winrt::com_ptr _core; winrt::com_ptr _interactivity; @@ -255,43 +254,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation void _coreRaisedNotice(const IInspectable& s, const Control::NoticeEventArgs& args); void _coreWarningBell(const IInspectable& sender, const IInspectable& args); }; - - struct VisualBellLight : VisualBellLightT - { - VisualBellLight() = default; - - winrt::hstring GetId(); - - static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return m_isTargetProperty; } - - static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) - { - return winrt::unbox_value(target.GetValue(m_isTargetProperty)); - } - - static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) - { - target.SetValue(m_isTargetProperty, winrt::box_value(value)); - } - - void OnConnected(Windows::UI::Xaml::UIElement const& newElement); - void OnDisconnected(Windows::UI::Xaml::UIElement const& oldElement); - - static void OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e); - - inline static winrt::hstring GetIdStatic() - { - // This specifies the unique name of the light. In most cases you should use the type's full name. - return winrt::xaml_typename().Name; - } - - private: - static Windows::UI::Xaml::DependencyProperty m_isTargetProperty; - }; } namespace winrt::Microsoft::Terminal::Control::factory_implementation { BASIC_FACTORY(TermControl); - BASIC_FACTORY(VisualBellLight); } diff --git a/src/cascadia/TerminalControl/TermControl.idl b/src/cascadia/TerminalControl/TermControl.idl index 8fa9d434b08..0be44ccd95c 100644 --- a/src/cascadia/TerminalControl/TermControl.idl +++ b/src/cascadia/TerminalControl/TermControl.idl @@ -68,12 +68,4 @@ namespace Microsoft.Terminal.Control Boolean ReadOnly { get; }; void ToggleReadOnly(); } - - [default_interface] runtimeclass VisualBellLight : Windows.UI.Xaml.Media.XamlLight - { - VisualBellLight(); - static Windows.UI.Xaml.DependencyProperty IsTargetProperty { get; }; - static Boolean GetIsTarget(Windows.UI.Xaml.DependencyObject target); - static void SetIsTarget(Windows.UI.Xaml.DependencyObject target, Boolean value); - } } diff --git a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj index 5220de3e4d2..e52161fb937 100644 --- a/src/cascadia/TerminalControl/TerminalControlLib.vcxproj +++ b/src/cascadia/TerminalControl/TerminalControlLib.vcxproj @@ -43,6 +43,9 @@ SearchBoxControl.xaml + + XamlLights.idl + TermControl.xaml @@ -76,6 +79,9 @@ SearchBoxControl.xaml + + XamlLights.idl + TermControl.xaml @@ -102,6 +108,7 @@ SearchBoxControl.xaml + TermControl.xaml diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp new file mode 100644 index 00000000000..018184c96f5 --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "pch.h" +#include "XamlLights.h" +#include "VisualBellLight.g.cpp" +#include "TermControlAutomationPeer.h" + +namespace winrt::Microsoft::Terminal::Control::implementation +{ + Windows::UI::Xaml::DependencyProperty VisualBellLight::m_isTargetProperty = + Windows::UI::Xaml::DependencyProperty::RegisterAttached( + L"IsTarget", + winrt::xaml_typename(), + winrt::xaml_typename(), + Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + + void VisualBellLight::OnConnected(Windows::UI::Xaml::UIElement const& /* newElement */) + { + if (!CompositionLight()) + { + // OnConnected is called when the first target UIElement is shown on the screen. This enables delaying composition object creation until it's actually necessary. + auto spotLight2{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; + spotLight2.Color(Windows::UI::Colors::WhiteSmoke()); + spotLight2.Intensity(static_cast(1.5)); + CompositionLight(spotLight2); + } + } + + void VisualBellLight::OnDisconnected(Windows::UI::Xaml::UIElement const& /* oldElement */) + { + // OnDisconnected is called when there are no more target UIElements on the screen. + // Dispose of composition resources when no longer in use. + if (CompositionLight()) + { + CompositionLight(nullptr); + } + } + + winrt::hstring VisualBellLight::GetId() + { + return VisualBellLight::GetIdStatic(); + } + + void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) + { + auto uielem{ d.try_as() }; + auto brush{ d.try_as() }; + + auto isAdding = winrt::unbox_value(e.NewValue()); + if (isAdding) + { + if (uielem) + { + Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uielem); + } + else if (brush) + { + Windows::UI::Xaml::Media::XamlLight::AddTargetBrush(VisualBellLight::GetIdStatic(), brush); + } + } + else + { + if (uielem) + { + Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uielem); + } + else if (brush) + { + Windows::UI::Xaml::Media::XamlLight::RemoveTargetBrush(VisualBellLight::GetIdStatic(), brush); + } + } + } +} diff --git a/src/cascadia/TerminalControl/XamlLights.h b/src/cascadia/TerminalControl/XamlLights.h new file mode 100644 index 00000000000..9735ea5a5ab --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.h @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// +// Module Name: +// - ControlCore.h +// +// Abstract: +// - This encapsulates a `Terminal` instance, a `DxEngine` and `Renderer`, and +// an `ITerminalConnection`. This is intended to be everything that someone +// might need to stand up a terminal instance in a control, but without any +// regard for how the UX works. +// +// Author: +// - Mike Griese (zadjii-msft) 01-Apr-2021 + +#pragma once + +#include "cppwinrt_utils.h" +#include "VisualBellLight.g.h" + +namespace winrt::Microsoft::Terminal::Control::implementation +{ + struct VisualBellLight : VisualBellLightT + { + VisualBellLight() = default; + + winrt::hstring GetId(); + + static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return m_isTargetProperty; } + + static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) + { + return winrt::unbox_value(target.GetValue(m_isTargetProperty)); + } + + static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) + { + target.SetValue(m_isTargetProperty, winrt::box_value(value)); + } + + void OnConnected(Windows::UI::Xaml::UIElement const& newElement); + void OnDisconnected(Windows::UI::Xaml::UIElement const& oldElement); + + static void OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e); + + inline static winrt::hstring GetIdStatic() + { + // This specifies the unique name of the light. In most cases you should use the type's full name. + return winrt::xaml_typename().Name; + } + + private: + static Windows::UI::Xaml::DependencyProperty m_isTargetProperty; + }; +} + +namespace winrt::Microsoft::Terminal::Control::factory_implementation +{ + BASIC_FACTORY(VisualBellLight); +} diff --git a/src/cascadia/TerminalControl/XamlLights.idl b/src/cascadia/TerminalControl/XamlLights.idl new file mode 100644 index 00000000000..78a536c4a8a --- /dev/null +++ b/src/cascadia/TerminalControl/XamlLights.idl @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.Terminal.Control +{ + [default_interface] runtimeclass VisualBellLight : Windows.UI.Xaml.Media.XamlLight + { + VisualBellLight(); + static Windows.UI.Xaml.DependencyProperty IsTargetProperty { get; }; + static Boolean GetIsTarget(Windows.UI.Xaml.DependencyObject target); + static void SetIsTarget(Windows.UI.Xaml.DependencyObject target, Boolean value); + } +} diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 0c88b3715fa..3f302520375 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -899,9 +899,13 @@ All An option to choose from for the "bell style" setting. When selected, a combination of the other bell styles is used to notify the user. + + Visual (flash taskbar and window) + An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar and window are both flashed. + Flash taskbar - An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed (only if the terminal window is not in focus). + An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar is flashed. Flash window From 9282a161f7da9cf50485728c59a09754b8d5bc2b Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Sun, 9 May 2021 20:13:27 -0700 Subject: [PATCH 13/28] nits --- src/cascadia/TerminalControl/XamlLights.cpp | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index 018184c96f5..c8de8ef60bb 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -15,22 +15,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::xaml_typename(), Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + // Method Description: + // - This function is called when the first target UIElement is shown on the screen, + // this enables delaying composition object creation until it's actually necessary. + // Arguments: + // - newElement: unused void VisualBellLight::OnConnected(Windows::UI::Xaml::UIElement const& /* newElement */) { if (!CompositionLight()) { - // OnConnected is called when the first target UIElement is shown on the screen. This enables delaying composition object creation until it's actually necessary. - auto spotLight2{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; - spotLight2.Color(Windows::UI::Colors::WhiteSmoke()); - spotLight2.Intensity(static_cast(1.5)); - CompositionLight(spotLight2); + auto spotLight{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; + spotLight.Color(Windows::UI::Colors::WhiteSmoke()); + spotLight.Intensity(static_cast(1.5)); + CompositionLight(spotLight); } } + // Method Description: + // - This function is called when there are no more target UIElements on the screen + // - Disposes of composition resources when no longer in use + // Arguments: + // - oldElement: unused void VisualBellLight::OnDisconnected(Windows::UI::Xaml::UIElement const& /* oldElement */) { - // OnDisconnected is called when there are no more target UIElements on the screen. - // Dispose of composition resources when no longer in use. if (CompositionLight()) { CompositionLight(nullptr); @@ -44,10 +51,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) { - auto uielem{ d.try_as() }; - auto brush{ d.try_as() }; + const auto& uielem{ d.try_as() }; + const auto& brush{ d.try_as() }; - auto isAdding = winrt::unbox_value(e.NewValue()); + const auto isAdding = winrt::unbox_value(e.NewValue()); if (isAdding) { if (uielem) From eedb317d1ccf8ce3cde62d0f70494ff242e1b896 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Sun, 9 May 2021 21:19:05 -0700 Subject: [PATCH 14/28] lazy load --- src/cascadia/TerminalControl/XamlLights.cpp | 32 +++++++++++++++------ src/cascadia/TerminalControl/XamlLights.h | 23 ++++----------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index c8de8ef60bb..14bf62eb8e0 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -2,18 +2,34 @@ // Licensed under the MIT license. #include "pch.h" +#include "TermControl.h" #include "XamlLights.h" #include "VisualBellLight.g.cpp" -#include "TermControlAutomationPeer.h" namespace winrt::Microsoft::Terminal::Control::implementation { - Windows::UI::Xaml::DependencyProperty VisualBellLight::m_isTargetProperty = - Windows::UI::Xaml::DependencyProperty::RegisterAttached( - L"IsTarget", - winrt::xaml_typename(), - winrt::xaml_typename(), - Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + Windows::UI::Xaml::DependencyProperty VisualBellLight::_IsTargetProperty{ nullptr }; + + VisualBellLight::VisualBellLight() + { + _InitializeProperties(); + } + + void VisualBellLight::_InitializeProperties() + { + // Initialize any dependency properties here. + // This performs a lazy load on these properties, instead of + // initializing them when the DLL loads. + if (!_IsTargetProperty) + { + _IsTargetProperty = + Windows::UI::Xaml::DependencyProperty::RegisterAttached( + L"IsTarget", + winrt::xaml_typename(), + winrt::xaml_typename(), + Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + } + } // Method Description: // - This function is called when the first target UIElement is shown on the screen, @@ -25,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (!CompositionLight()) { auto spotLight{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; - spotLight.Color(Windows::UI::Colors::WhiteSmoke()); + spotLight.Color(Windows::UI::Colors::White()); spotLight.Intensity(static_cast(1.5)); CompositionLight(spotLight); } diff --git a/src/cascadia/TerminalControl/XamlLights.h b/src/cascadia/TerminalControl/XamlLights.h index 9735ea5a5ab..c0542f71685 100644 --- a/src/cascadia/TerminalControl/XamlLights.h +++ b/src/cascadia/TerminalControl/XamlLights.h @@ -1,17 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -// -// Module Name: -// - ControlCore.h -// -// Abstract: -// - This encapsulates a `Terminal` instance, a `DxEngine` and `Renderer`, and -// an `ITerminalConnection`. This is intended to be everything that someone -// might need to stand up a terminal instance in a control, but without any -// regard for how the UX works. -// -// Author: -// - Mike Griese (zadjii-msft) 01-Apr-2021 #pragma once @@ -22,20 +10,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation { struct VisualBellLight : VisualBellLightT { - VisualBellLight() = default; + VisualBellLight(); winrt::hstring GetId(); - static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return m_isTargetProperty; } + static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return _IsTargetProperty; } static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) { - return winrt::unbox_value(target.GetValue(m_isTargetProperty)); + return winrt::unbox_value(target.GetValue(_IsTargetProperty)); } static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) { - target.SetValue(m_isTargetProperty, winrt::box_value(value)); + target.SetValue(_IsTargetProperty, winrt::box_value(value)); } void OnConnected(Windows::UI::Xaml::UIElement const& newElement); @@ -50,7 +38,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation } private: - static Windows::UI::Xaml::DependencyProperty m_isTargetProperty; + static void _InitializeProperties(); + static Windows::UI::Xaml::DependencyProperty _IsTargetProperty; }; } From 5b72726897fd5a959ee91ce2efec1e4b147db2f0 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Sun, 9 May 2021 21:50:49 -0700 Subject: [PATCH 15/28] some cleanup --- src/cascadia/TerminalControl/XamlLights.cpp | 53 +++++++++------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index 14bf62eb8e0..4e01a56211f 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -6,9 +6,12 @@ #include "XamlLights.h" #include "VisualBellLight.g.cpp" +using namespace winrt::Windows::UI::Xaml; +using namespace winrt::Windows::UI::Xaml::Media; + namespace winrt::Microsoft::Terminal::Control::implementation { - Windows::UI::Xaml::DependencyProperty VisualBellLight::_IsTargetProperty{ nullptr }; + DependencyProperty VisualBellLight::_IsTargetProperty{ nullptr }; VisualBellLight::VisualBellLight() { @@ -23,11 +26,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation if (!_IsTargetProperty) { _IsTargetProperty = - Windows::UI::Xaml::DependencyProperty::RegisterAttached( + DependencyProperty::RegisterAttached( L"IsTarget", winrt::xaml_typename(), - winrt::xaml_typename(), - Windows::UI::Xaml::PropertyMetadata{ winrt::box_value(false), Windows::UI::Xaml::PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); + winrt::xaml_typename(), + PropertyMetadata{ winrt::box_value(false), PropertyChangedCallback{ &VisualBellLight::OnIsTargetChanged } }); } } @@ -36,11 +39,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // this enables delaying composition object creation until it's actually necessary. // Arguments: // - newElement: unused - void VisualBellLight::OnConnected(Windows::UI::Xaml::UIElement const& /* newElement */) + void VisualBellLight::OnConnected(UIElement const& /* newElement */) { if (!CompositionLight()) { - auto spotLight{ Windows::UI::Xaml::Window::Current().Compositor().CreateAmbientLight() }; + auto spotLight{ Window::Current().Compositor().CreateAmbientLight() }; spotLight.Color(Windows::UI::Colors::White()); spotLight.Intensity(static_cast(1.5)); CompositionLight(spotLight); @@ -52,7 +55,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // - Disposes of composition resources when no longer in use // Arguments: // - oldElement: unused - void VisualBellLight::OnDisconnected(Windows::UI::Xaml::UIElement const& /* oldElement */) + void VisualBellLight::OnDisconnected(UIElement const& /* oldElement */) { if (CompositionLight()) { @@ -65,33 +68,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation return VisualBellLight::GetIdStatic(); } - void VisualBellLight::OnIsTargetChanged(Windows::UI::Xaml::DependencyObject const& d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs const& e) + void VisualBellLight::OnIsTargetChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& e) { - const auto& uielem{ d.try_as() }; - const auto& brush{ d.try_as() }; + const auto& uielem{ d.try_as() }; + const auto& brush{ d.try_as() }; - const auto isAdding = winrt::unbox_value(e.NewValue()); - if (isAdding) - { - if (uielem) - { - Windows::UI::Xaml::Media::XamlLight::AddTargetElement(VisualBellLight::GetIdStatic(), uielem); - } - else if (brush) - { - Windows::UI::Xaml::Media::XamlLight::AddTargetBrush(VisualBellLight::GetIdStatic(), brush); - } - } - else + if (!uielem && !brush) { - if (uielem) - { - Windows::UI::Xaml::Media::XamlLight::RemoveTargetElement(VisualBellLight::GetIdStatic(), uielem); - } - else if (brush) - { - Windows::UI::Xaml::Media::XamlLight::RemoveTargetBrush(VisualBellLight::GetIdStatic(), brush); - } + // terminate early + return; } + + const auto isAdding = winrt::unbox_value(e.NewValue()); + const auto id = GetIdStatic(); + + isAdding ? (uielem ? XamlLight::AddTargetElement(id, uielem) : XamlLight::AddTargetBrush(id, brush)) : + (uielem ? XamlLight::RemoveTargetElement(id, uielem) : XamlLight::RemoveTargetBrush(id, brush)); } } From 692ad1414f8d27972bd45d718eadadc8027e419a Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 12 May 2021 01:59:08 -0700 Subject: [PATCH 16/28] animation --- src/cascadia/TerminalControl/TermControl.cpp | 13 ++++++++++--- src/cascadia/TerminalControl/TermControl.h | 2 ++ src/cascadia/TerminalControl/TermControl.xaml | 2 +- src/cascadia/TerminalControl/XamlLights.cpp | 1 - 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 9de0249a3cd..1a1f1c8dd62 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -59,7 +59,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation _cursorTimer{}, _blinkTimer{}, _bellLightTimer{}, - _searchBox{ nullptr } + _searchBox{ nullptr }, + _bellLightAnimation{ Window::Current().Compositor().CreateScalarKeyFrameAnimation() } { InitializeComponent(); @@ -168,6 +169,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation _autoScrollTimer.Interval(AutoScrollUpdateInterval); _autoScrollTimer.Tick({ this, &TermControl::_UpdateAutoScroll }); + // Add key frames and a duration to our bell light animation + _bellLightAnimation.InsertKeyFrame(0.0, 2.0); + _bellLightAnimation.InsertKeyFrame(1.0, 1.0); + _bellLightAnimation.Duration(winrt::Windows::Foundation::TimeSpan(std::chrono::milliseconds(TerminalWarningBellInterval))); + _ApplyUISettings(_settings); } @@ -2365,13 +2371,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation { // Start the timer, when the timer ticks we switch off the light DispatcherTimer invertTimer; - invertTimer.Interval(std::chrono::milliseconds(2000)); + invertTimer.Interval(std::chrono::milliseconds(TerminalWarningBellInterval)); invertTimer.Tick({ get_weak(), &TermControl::_BellLightOff }); invertTimer.Start(); _bellLightTimer.emplace(std::move(invertTimer)); - // Switch on the light + // Switch on the light and animate the intensity to fade out VisualBellLight::SetIsTarget(RootGrid(), true); + BellLight().CompositionLight().StartAnimation(L"Intensity", _bellLightAnimation); } } diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index 97f67382f2a..bf39a411c06 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -167,6 +167,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation Windows::UI::Xaml::DispatcherTimer _autoScrollTimer; std::optional _lastAutoScrollUpdateTime; + winrt::Windows::UI::Composition::ScalarKeyFrameAnimation _bellLightAnimation; + std::optional _cursorTimer; std::optional _blinkTimer; std::optional _bellLightTimer; diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index cb3bc261834..084c9939e3c 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -34,7 +34,7 @@ - + diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index 4e01a56211f..b2cd00d6003 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -45,7 +45,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation { auto spotLight{ Window::Current().Compositor().CreateAmbientLight() }; spotLight.Color(Windows::UI::Colors::White()); - spotLight.Intensity(static_cast(1.5)); CompositionLight(spotLight); } } From 8a428048bc1fa7d80c500608c8ce9e184ae892c4 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 12 May 2021 02:12:47 -0700 Subject: [PATCH 17/28] Format --- src/cascadia/TerminalControl/TermControl.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalControl/TermControl.xaml b/src/cascadia/TerminalControl/TermControl.xaml index 084c9939e3c..94aa92c5fa0 100644 --- a/src/cascadia/TerminalControl/TermControl.xaml +++ b/src/cascadia/TerminalControl/TermControl.xaml @@ -34,7 +34,7 @@ - + From b3c50f8d5ce468f1191c728a0a9b47ff4b98ae23 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 12 May 2021 19:18:51 -0700 Subject: [PATCH 18/28] small changes --- src/cascadia/TerminalControl/TermControl.cpp | 13 ++++++++----- src/cascadia/TerminalControl/XamlLights.cpp | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 1a1f1c8dd62..55391a20db4 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -58,7 +58,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation _lastAutoScrollUpdateTime{ std::nullopt }, _cursorTimer{}, _blinkTimer{}, - _bellLightTimer{}, _searchBox{ nullptr }, _bellLightAnimation{ Window::Current().Compositor().CreateScalarKeyFrameAnimation() } { @@ -2385,12 +2384,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::_BellLightOff(Windows::Foundation::IInspectable const& /* sender */, Windows::Foundation::IInspectable const& /* e */) { - if (_bellLightTimer && !_closing) + if (_bellLightTimer) { // Stop the timer and switch off the light - _bellLightTimer.value().Stop(); - _bellLightTimer = std::nullopt; - VisualBellLight::SetIsTarget(RootGrid(), false); + _bellLightTimer->Stop(); + _bellLightTimer.reset(); + + if (!_closing) + { + VisualBellLight::SetIsTarget(RootGrid(), false); + } } } diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index b2cd00d6003..39cd13f7f07 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -69,8 +69,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation void VisualBellLight::OnIsTargetChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& e) { - const auto& uielem{ d.try_as() }; - const auto& brush{ d.try_as() }; + const auto uielem{ d.try_as() }; + const auto brush{ d.try_as() }; if (!uielem && !brush) { From ab0ce5fe63fccfc8f618f7877ab481a6c2fe517b Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Sun, 16 May 2021 20:32:08 -0700 Subject: [PATCH 19/28] ahhh --- src/cascadia/TerminalApp/Pane.cpp | 8 ++++++-- .../TerminalSettingsModel/EnumMappings.cpp | 18 +++++++++++++++++- src/cascadia/TerminalSettingsModel/Profile.idl | 1 + .../TerminalSettingsSerializationHelpers.h | 9 +++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index a4939e0d3ed..3f45edc8032 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -378,13 +378,17 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY); } - if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) + if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window))// || + //WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual)) { _control.BellLightOn(); } + const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar); // || + //WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual); + // raise the event with the bool value corresponding to the taskbar flag - _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar)); + _PaneRaiseBellHandlers(nullptr, flashTaskbar); } } } diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 14dd008cf66..d8697446e9b 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -43,7 +43,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); - DEFINE_ENUM_MAP(Model::BellStyle, BellStyle); + //DEFINE_ENUM_MAP(Model::BellStyle, BellStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. @@ -59,4 +59,20 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation }(); return enumMap; } + + // Bellstyle is special because we deprecated 'visual' for the settings UI but + // want to allow it for legacy users + winrt::Windows::Foundation::Collections::IMap EnumMappings::BellStyle() + { + static IMap enumMap = []() { + auto map = single_threaded_map(); + for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) + { + map.Insert(winrt::to_hstring(enumStr), enumVal); + } + map.Insert(winrt::to_hstring(L"visual"), Model::BellStyle::Window | Model::BellStyle::Taskbar); + return map; + }(); + return enumMap; + } } diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index 12d47e59f75..63854daa8d2 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -31,6 +31,7 @@ namespace Microsoft.Terminal.Settings.Model enum BellStyle { Audible = 0x1, + //Visual = 0x2, Window = 0x2, Taskbar = 0x4, All = 0xffffffff diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index ff412912444..b4b9ec46a11 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -53,6 +53,7 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, + //pair_type{ "visual", ValueType::Visual }, pair_type{ "window", ValueType::Window }, pair_type{ "taskbar", ValueType::Taskbar }, pair_type{ "all", AllSet }, @@ -64,6 +65,14 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { return json.asBool() ? AllSet : AllClear; } + else if (json.isString()) + { + const auto name = Detail::GetStringView(json); + if (name == "visual") + { + return (ValueType::Taskbar | ValueType::Window); + } + } return BaseFlagMapper::FromJson(json); } From 80266989baa2f33e28932d1f3776dba7baf813d9 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 18 May 2021 21:14:20 -0700 Subject: [PATCH 20/28] deprecate visual --- src/cascadia/TerminalApp/Pane.cpp | 8 ++--- .../TerminalSettingsEditor/Profiles.cpp | 29 +++++++++++++++++-- .../TerminalSettingsEditor/Profiles.h | 7 ++++- .../TerminalSettingsEditor/Profiles.idl | 7 +++-- .../TerminalSettingsEditor/Profiles.xaml | 17 +++++++++-- .../TerminalSettingsModel/EnumMappings.cpp | 8 +++-- .../TerminalSettingsModel/JsonUtils.h | 3 +- .../TerminalSettingsModel/Profile.idl | 1 - .../TerminalSettingsSerializationHelpers.h | 12 ++------ 9 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 3f45edc8032..a4939e0d3ed 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -378,17 +378,13 @@ void Pane::_ControlWarningBellHandler(const winrt::Windows::Foundation::IInspect PlaySound(soundAlias, NULL, SND_ALIAS_ID | SND_ASYNC | SND_SENTRY); } - if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window))// || - //WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual)) + if (WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Window)) { _control.BellLightOn(); } - const auto flashTaskbar = WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar); // || - //WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Visual); - // raise the event with the bool value corresponding to the taskbar flag - _PaneRaiseBellHandlers(nullptr, flashTaskbar); + _PaneRaiseBellHandlers(nullptr, WI_IsFlagSet(paneProfile.BellStyle(), winrt::Microsoft::Terminal::Settings::Model::BellStyle::Taskbar)); } } } diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index c1c83e3dc60..e1d0276424a 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -436,7 +436,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(BackgroundImageStretchMode, BackgroundImageStretchMode, winrt::Windows::UI::Xaml::Media::Stretch, L"Profile_BackgroundImageStretchMode", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(AntiAliasingMode, TextAntialiasingMode, winrt::Microsoft::Terminal::Control::TextAntialiasingMode, L"Profile_AntialiasingMode", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(CloseOnExitMode, CloseOnExitMode, winrt::Microsoft::Terminal::Settings::Model::CloseOnExitMode, L"Profile_CloseOnExit", L"Content"); - INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER(BellStyle, BellStyle, winrt::Microsoft::Terminal::Settings::Model::BellStyle, L"Profile_BellStyle", L"Content"); INITIALIZE_BINDABLE_ENUM_SETTING(ScrollState, ScrollbarState, winrt::Microsoft::Terminal::Control::ScrollbarState, L"Profile_ScrollbarVisibility", L"Content"); // manually add Custom FontWeight option. Don't add it to the Map @@ -506,6 +505,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation State().Profile().FontFace(newFontFace.LocalizedName()); } + void Profiles::BellStyle_SelectionChanged(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) + { + Model::BellStyle bellStyle{}; + WI_SetFlagIf(bellStyle, Model::BellStyle::Audible, AudibleCheckBox().IsChecked().GetBoolean()); + WI_SetFlagIf(bellStyle, Model::BellStyle::Window, WindowCheckBox().IsChecked().GetBoolean()); + WI_SetFlagIf(bellStyle, Model::BellStyle::Taskbar, TaskbarCheckBox().IsChecked().GetBoolean()); + State().Profile().BellStyle(bellStyle); + } + void Profiles::OnNavigatedTo(const NavigationEventArgs& e) { _State = e.Parameter().as(); @@ -573,7 +581,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } else if (settingName == L"BellStyle") { - _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentBellStyle" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleAudible" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleWindow" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleTaskbar" }); } else if (settingName == L"ScrollState") { @@ -627,6 +637,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _State.Profile().ColorSchemeName(val.Name()); } + bool Profiles::BellStyleAudible() + { + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Audible); + } + + bool Profiles::BellStyleWindow() + { + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Window); + } + + bool Profiles::BellStyleTaskbar() + { + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Taskbar); + } + void Profiles::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) { auto state{ winrt::get_self(_State) }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 96f62d250ca..7ddf6777fd6 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -171,6 +171,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Model::ColorScheme CurrentColorScheme(); void CurrentColorScheme(const Model::ColorScheme& val); + // bell style bits + bool BellStyleAudible(); + bool BellStyleWindow(); + bool BellStyleTaskbar(); + fire_and_forget BackgroundImage_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); fire_and_forget Commandline_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); fire_and_forget StartingDirectory_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); @@ -179,6 +184,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void DeleteConfirmation_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); void Pivot_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); void FontFace_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& e); + void BellStyle_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); // CursorShape visibility logic bool IsVintageCursor() const; @@ -197,7 +203,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation GETSET_BINDABLE_ENUM_SETTING(BackgroundImageStretchMode, Windows::UI::Xaml::Media::Stretch, State().Profile, BackgroundImageStretchMode); GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, State().Profile, AntialiasingMode); GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, State().Profile, CloseOnExit); - GETSET_BINDABLE_ENUM_SETTING(BellStyle, Microsoft::Terminal::Settings::Model::BellStyle, State().Profile, BellStyle); GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, State().Profile, ScrollState); private: diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index f8354692dfb..6488be5f5d7 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -100,6 +100,10 @@ namespace Microsoft.Terminal.Settings.Editor Profiles(); ProfilePageNavigationState State { get; }; + Boolean BellStyleAudible { get; }; + Boolean BellStyleWindow { get; }; + Boolean BellStyleTaskbar { get; }; + IInspectable CurrentCursorShape; Boolean IsVintageCursor { get; }; Windows.Foundation.Collections.IObservableVector CursorShapeList { get; }; @@ -113,9 +117,6 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentCloseOnExitMode; Windows.Foundation.Collections.IObservableVector CloseOnExitModeList { get; }; - IInspectable CurrentBellStyle; - Windows.Foundation.Collections.IObservableVector BellStyleList { get; }; - IInspectable CurrentScrollState; Windows.Foundation.Collections.IObservableVector ScrollStateList { get; }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 16b539617fc..5166ff22aac 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -769,9 +769,20 @@ ClearSettingValue="{x:Bind State.Profile.ClearBellStyle}" HasSettingValue="{x:Bind State.Profile.HasBellStyle, Mode=OneWay}" SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"> - + + + + + diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index d8697446e9b..ce5dedb5335 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -68,9 +68,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation auto map = single_threaded_map(); for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) { - map.Insert(winrt::to_hstring(enumStr), enumVal); + const auto enumHStr = winrt::to_hstring(enumStr); + // skip visual + if (enumHStr != L"visual") + { + map.Insert(enumHStr, enumVal); + } } - map.Insert(winrt::to_hstring(L"visual"), Model::BellStyle::Window | Model::BellStyle::Taskbar); return map; }(); return enumMap; diff --git a/src/cascadia/TerminalSettingsModel/JsonUtils.h b/src/cascadia/TerminalSettingsModel/JsonUtils.h index 1e2f5193bb2..2b8493b6247 100644 --- a/src/cascadia/TerminalSettingsModel/JsonUtils.h +++ b/src/cascadia/TerminalSettingsModel/JsonUtils.h @@ -630,7 +630,8 @@ namespace Microsoft::Terminal::Settings::Model::JsonUtils for (const auto& pair : TBase::mappings) { if (pair.second != AllClear && - (val & pair.second) == pair.second) + (val & pair.second) == pair.second && + WI_IsSingleFlagSet(pair.second)) { json.append(BaseEnumMapper::ToJson(pair.second)); } diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index 63854daa8d2..12d47e59f75 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -31,7 +31,6 @@ namespace Microsoft.Terminal.Settings.Model enum BellStyle { Audible = 0x1, - //Visual = 0x2, Window = 0x2, Taskbar = 0x4, All = 0xffffffff diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index b4b9ec46a11..74b5aee35ce 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -50,10 +50,10 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::ScrollbarState) JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { - static constexpr std::array mappings = { + static constexpr std::array mappings = { pair_type{ "none", AllClear }, pair_type{ "audible", ValueType::Audible }, - //pair_type{ "visual", ValueType::Visual }, + pair_type{ "visual", ValueType::Window | ValueType::Taskbar }, pair_type{ "window", ValueType::Window }, pair_type{ "taskbar", ValueType::Taskbar }, pair_type{ "all", AllSet }, @@ -65,14 +65,6 @@ JSON_FLAG_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::BellStyle) { return json.asBool() ? AllSet : AllClear; } - else if (json.isString()) - { - const auto name = Detail::GetStringView(json); - if (name == "visual") - { - return (ValueType::Taskbar | ValueType::Window); - } - } return BaseFlagMapper::FromJson(json); } From fb2778788ad58b3ed0b594ccc680ade6d905d706 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 18 May 2021 21:20:01 -0700 Subject: [PATCH 21/28] here and there --- doc/cascadia/profiles.schema.json | 1 - src/cascadia/TerminalSettingsModel/EnumMappings.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index ec1812187f0..efac39663bc 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -46,7 +46,6 @@ "type": "string", "enum": [ "audible", - "visual", "taskbar", "window", "all", diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index ce5dedb5335..cc3d4ae0f41 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -43,7 +43,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); - //DEFINE_ENUM_MAP(Model::BellStyle, BellStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. From 2f9bc61a062c29e34a27703efed4bf9c5f7a5df1 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Tue, 18 May 2021 21:24:38 -0700 Subject: [PATCH 22/28] spell --- src/cascadia/TerminalSettingsModel/EnumMappings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index cc3d4ae0f41..43ee33a6bad 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -59,7 +59,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation return enumMap; } - // Bellstyle is special because we deprecated 'visual' for the settings UI but + // BellStyle is special because we deprecated 'visual' for the settings UI but // want to allow it for legacy users winrt::Windows::Foundation::Collections::IMap EnumMappings::BellStyle() { From 084ff79ca60bd56bc178e35116138345347bf603 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 19 May 2021 21:17:48 -0700 Subject: [PATCH 23/28] fix crash, two-way binding --- src/cascadia/TerminalControl/TermControl.cpp | 5 ++- .../TerminalSettingsEditor/Profiles.cpp | 44 ++++++++++++------- .../TerminalSettingsEditor/Profiles.h | 8 ++-- .../TerminalSettingsEditor/Profiles.idl | 7 +-- .../TerminalSettingsEditor/Profiles.xaml | 18 +++----- .../TerminalSettingsModel/EnumMappings.cpp | 38 ++++++++-------- 6 files changed, 65 insertions(+), 55 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 55391a20db4..4154eb9a1dc 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2366,7 +2366,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation void TermControl::BellLightOn() { - if (!_bellLightTimer) + Windows::Foundation::Numerics::float2 zeroSize{ 0, 0 }; + // If the grid has 0 size or if the bell timer is + // already active, do nothing + if (RootGrid().ActualSize() != zeroSize && !_bellLightTimer) { // Start the timer, when the timer ticks we switch off the light DispatcherTimer invertTimer; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index e1d0276424a..cae8ecb89c6 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -505,15 +505,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation State().Profile().FontFace(newFontFace.LocalizedName()); } - void Profiles::BellStyle_SelectionChanged(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) - { - Model::BellStyle bellStyle{}; - WI_SetFlagIf(bellStyle, Model::BellStyle::Audible, AudibleCheckBox().IsChecked().GetBoolean()); - WI_SetFlagIf(bellStyle, Model::BellStyle::Window, WindowCheckBox().IsChecked().GetBoolean()); - WI_SetFlagIf(bellStyle, Model::BellStyle::Taskbar, TaskbarCheckBox().IsChecked().GetBoolean()); - State().Profile().BellStyle(bellStyle); - } - void Profiles::OnNavigatedTo(const NavigationEventArgs& e) { _State = e.Parameter().as(); @@ -637,19 +628,42 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _State.Profile().ColorSchemeName(val.Name()); } - bool Profiles::BellStyleAudible() + bool Profiles::IsBellStyleFlagSet(const uint32_t flag) + { + // 'flag' is not a compile time constant, so we cannot + // use it directly with WI_IsFlagSet and we have to use this + // seemingly redundant switch statement instead + switch (static_cast(flag)) + { + case Model::BellStyle::Audible: + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Audible); + case Model::BellStyle::Window: + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Window); + case Model::BellStyle::Taskbar: + return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Taskbar); + } + return false; + } + + void Profiles::SetBellStyleAudible(winrt::Windows::Foundation::IReference on) { - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Audible); + auto currentStyle = State().Profile().BellStyle(); + on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Audible) : WI_ClearFlag(currentStyle, Model::BellStyle::Audible); + State().Profile().BellStyle(currentStyle); } - bool Profiles::BellStyleWindow() + void Profiles::SetBellStyleWindow(winrt::Windows::Foundation::IReference on) { - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Window); + auto currentStyle = State().Profile().BellStyle(); + on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Window) : WI_ClearFlag(currentStyle, Model::BellStyle::Window); + State().Profile().BellStyle(currentStyle); } - bool Profiles::BellStyleTaskbar() + void Profiles::SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on) { - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Taskbar); + auto currentStyle = State().Profile().BellStyle(); + on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Taskbar) : WI_ClearFlag(currentStyle, Model::BellStyle::Taskbar); + State().Profile().BellStyle(currentStyle); } void Profiles::DeleteConfirmation_Click(IInspectable const& /*sender*/, RoutedEventArgs const& /*e*/) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.h b/src/cascadia/TerminalSettingsEditor/Profiles.h index 7ddf6777fd6..3a5f894c234 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.h +++ b/src/cascadia/TerminalSettingsEditor/Profiles.h @@ -172,9 +172,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void CurrentColorScheme(const Model::ColorScheme& val); // bell style bits - bool BellStyleAudible(); - bool BellStyleWindow(); - bool BellStyleTaskbar(); + bool IsBellStyleFlagSet(const uint32_t flag); + void SetBellStyleAudible(winrt::Windows::Foundation::IReference on); + void SetBellStyleWindow(winrt::Windows::Foundation::IReference on); + void SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on); fire_and_forget BackgroundImage_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); fire_and_forget Commandline_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); @@ -184,7 +185,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void DeleteConfirmation_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); void Pivot_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); void FontFace_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& e); - void BellStyle_SelectionChanged(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); // CursorShape visibility logic bool IsVintageCursor() const; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.idl b/src/cascadia/TerminalSettingsEditor/Profiles.idl index 6488be5f5d7..96def0eedd4 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.idl +++ b/src/cascadia/TerminalSettingsEditor/Profiles.idl @@ -100,9 +100,10 @@ namespace Microsoft.Terminal.Settings.Editor Profiles(); ProfilePageNavigationState State { get; }; - Boolean BellStyleAudible { get; }; - Boolean BellStyleWindow { get; }; - Boolean BellStyleTaskbar { get; }; + Boolean IsBellStyleFlagSet(UInt32 flag); + void SetBellStyleAudible(Windows.Foundation.IReference on); + void SetBellStyleWindow(Windows.Foundation.IReference on); + void SetBellStyleTaskbar(Windows.Foundation.IReference on); IInspectable CurrentCursorShape; Boolean IsVintageCursor { get; }; diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.xaml b/src/cascadia/TerminalSettingsEditor/Profiles.xaml index 5166ff22aac..15d0d8ae22c 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.xaml +++ b/src/cascadia/TerminalSettingsEditor/Profiles.xaml @@ -770,18 +770,12 @@ HasSettingValue="{x:Bind State.Profile.HasBellStyle, Mode=OneWay}" SettingOverrideSource="{x:Bind State.Profile.BellStyleOverrideSource, Mode=OneWay}"> - - - + + + diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 43ee33a6bad..23e3131bca1 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -27,6 +27,23 @@ using namespace ::Microsoft::Terminal::Settings::Model; return enumMap; \ } +#define DEFINE_FLAG_MAP(type, name) \ + winrt::Windows::Foundation::Collections::IMap EnumMappings::name() \ + { \ + static IMap enumMap = []() { \ + auto map = single_threaded_map(); \ + for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) \ + { \ + if (WI_IsSingleFlagSet(enumVal)) \ + { \ + map.Insert(winrt::to_hstring(enumStr), enumVal); \ + } \ + } \ + return map; \ + }(); \ + return enumMap; \ + } + namespace winrt::Microsoft::Terminal::Settings::Model::implementation { // Global Settings @@ -43,6 +60,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); + DEFINE_FLAG_MAP(Model::BellStyle, BellStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. @@ -58,24 +76,4 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation }(); return enumMap; } - - // BellStyle is special because we deprecated 'visual' for the settings UI but - // want to allow it for legacy users - winrt::Windows::Foundation::Collections::IMap EnumMappings::BellStyle() - { - static IMap enumMap = []() { - auto map = single_threaded_map(); - for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) - { - const auto enumHStr = winrt::to_hstring(enumStr); - // skip visual - if (enumHStr != L"visual") - { - map.Insert(enumHStr, enumVal); - } - } - return map; - }(); - return enumMap; - } } From f1237d91a5e6ac25d8bd8a1c812bb01a395fed83 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Wed, 19 May 2021 21:33:29 -0700 Subject: [PATCH 24/28] remove flag map --- .../TerminalSettingsModel/EnumMappings.cpp | 18 ------------------ .../TerminalSettingsModel/EnumMappings.h | 1 - .../TerminalSettingsModel/EnumMappings.idl | 1 - 3 files changed, 20 deletions(-) diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 23e3131bca1..b8a2e5f5200 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -27,23 +27,6 @@ using namespace ::Microsoft::Terminal::Settings::Model; return enumMap; \ } -#define DEFINE_FLAG_MAP(type, name) \ - winrt::Windows::Foundation::Collections::IMap EnumMappings::name() \ - { \ - static IMap enumMap = []() { \ - auto map = single_threaded_map(); \ - for (auto [enumStr, enumVal] : JsonUtils::ConversionTrait::mappings) \ - { \ - if (WI_IsSingleFlagSet(enumVal)) \ - { \ - map.Insert(winrt::to_hstring(enumStr), enumVal); \ - } \ - } \ - return map; \ - }(); \ - return enumMap; \ - } - namespace winrt::Microsoft::Terminal::Settings::Model::implementation { // Global Settings @@ -60,7 +43,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Windows::UI::Xaml::Media::Stretch, BackgroundImageStretchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextAntialiasingMode, TextAntialiasingMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Core::CursorStyle, CursorStyle); - DEFINE_FLAG_MAP(Model::BellStyle, BellStyle); // FontWeight is special because the JsonUtils::ConversionTrait for it // creates a FontWeight object, but we need to use the uint16_t value. diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.h b/src/cascadia/TerminalSettingsModel/EnumMappings.h index de54adf3925..b9ca05ae1df 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -39,7 +39,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::Windows::Foundation::Collections::IMap BackgroundImageStretchMode(); static winrt::Windows::Foundation::Collections::IMap TextAntialiasingMode(); static winrt::Windows::Foundation::Collections::IMap CursorStyle(); - static winrt::Windows::Foundation::Collections::IMap BellStyle(); static winrt::Windows::Foundation::Collections::IMap FontWeight(); }; } diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.idl b/src/cascadia/TerminalSettingsModel/EnumMappings.idl index 257962c59c4..7b9e6609e78 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.idl +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.idl @@ -21,7 +21,6 @@ namespace Microsoft.Terminal.Settings.Model static Windows.Foundation.Collections.IMap BackgroundImageStretchMode { get; }; static Windows.Foundation.Collections.IMap TextAntialiasingMode { get; }; static Windows.Foundation.Collections.IMap CursorStyle { get; }; - static Windows.Foundation.Collections.IMap BellStyle { get; }; static Windows.Foundation.Collections.IMap FontWeight { get; }; } } From b675b2a95138b6e6eb322afcfb571854cb7a7620 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 20 May 2021 20:15:43 -0700 Subject: [PATCH 25/28] Cleanup --- .../TerminalSettingsEditor/Profiles.cpp | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index cae8ecb89c6..106f817d735 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -572,9 +572,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } else if (settingName == L"BellStyle") { - _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleAudible" }); - _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleWindow" }); - _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"BellStyleTaskbar" }); + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"IsBellStyleFlagSet" }); } else if (settingName == L"ScrollState") { @@ -630,39 +628,27 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation bool Profiles::IsBellStyleFlagSet(const uint32_t flag) { - // 'flag' is not a compile time constant, so we cannot - // use it directly with WI_IsFlagSet and we have to use this - // seemingly redundant switch statement instead - switch (static_cast(flag)) - { - case Model::BellStyle::Audible: - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Audible); - case Model::BellStyle::Window: - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Window); - case Model::BellStyle::Taskbar: - return WI_IsFlagSet(_State.Profile().BellStyle(), Model::BellStyle::Taskbar); - } - return false; + return WI_EnumValue(_State.Profile().BellStyle()) & flag; } void Profiles::SetBellStyleAudible(winrt::Windows::Foundation::IReference on) { auto currentStyle = State().Profile().BellStyle(); - on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Audible) : WI_ClearFlag(currentStyle, Model::BellStyle::Audible); + WI_UpdateFlag(currentStyle, Model::BellStyle::Audible, winrt::unbox_value(on)); State().Profile().BellStyle(currentStyle); } void Profiles::SetBellStyleWindow(winrt::Windows::Foundation::IReference on) { auto currentStyle = State().Profile().BellStyle(); - on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Window) : WI_ClearFlag(currentStyle, Model::BellStyle::Window); + WI_UpdateFlag(currentStyle, Model::BellStyle::Window, winrt::unbox_value(on)); State().Profile().BellStyle(currentStyle); } void Profiles::SetBellStyleTaskbar(winrt::Windows::Foundation::IReference on) { auto currentStyle = State().Profile().BellStyle(); - on.GetBoolean() ? WI_SetFlag(currentStyle, Model::BellStyle::Taskbar) : WI_ClearFlag(currentStyle, Model::BellStyle::Taskbar); + WI_UpdateFlag(currentStyle, Model::BellStyle::Taskbar, winrt::unbox_value(on)); State().Profile().BellStyle(currentStyle); } From 6c9d8ef4f1f6b0e4e9cd7530e49704e600d63e34 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Thu, 20 May 2021 21:35:16 -0700 Subject: [PATCH 26/28] == flag --- src/cascadia/TerminalSettingsEditor/Profiles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/TerminalSettingsEditor/Profiles.cpp b/src/cascadia/TerminalSettingsEditor/Profiles.cpp index 106f817d735..03e36688af0 100644 --- a/src/cascadia/TerminalSettingsEditor/Profiles.cpp +++ b/src/cascadia/TerminalSettingsEditor/Profiles.cpp @@ -628,7 +628,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation bool Profiles::IsBellStyleFlagSet(const uint32_t flag) { - return WI_EnumValue(_State.Profile().BellStyle()) & flag; + return (WI_EnumValue(_State.Profile().BellStyle()) & flag) == flag; } void Profiles::SetBellStyleAudible(winrt::Windows::Foundation::IReference on) From 730cf09b45063ff1eb9f983d9dc812bacb643c1a Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Mon, 24 May 2021 01:18:11 -0700 Subject: [PATCH 27/28] Ternary --- src/cascadia/TerminalControl/XamlLights.cpp | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/XamlLights.cpp b/src/cascadia/TerminalControl/XamlLights.cpp index 39cd13f7f07..2bf8b1e831d 100644 --- a/src/cascadia/TerminalControl/XamlLights.cpp +++ b/src/cascadia/TerminalControl/XamlLights.cpp @@ -81,7 +81,27 @@ namespace winrt::Microsoft::Terminal::Control::implementation const auto isAdding = winrt::unbox_value(e.NewValue()); const auto id = GetIdStatic(); - isAdding ? (uielem ? XamlLight::AddTargetElement(id, uielem) : XamlLight::AddTargetBrush(id, brush)) : - (uielem ? XamlLight::RemoveTargetElement(id, uielem) : XamlLight::RemoveTargetBrush(id, brush)); + if (isAdding) + { + if (uielem) + { + XamlLight::AddTargetElement(id, uielem); + } + else + { + XamlLight::AddTargetBrush(id, brush); + } + } + else + { + if (uielem) + { + XamlLight::RemoveTargetElement(id, uielem); + } + else + { + XamlLight::RemoveTargetBrush(id, brush); + } + } } } From f5bb54e1554a9f77eedddc98e6983932c3b01301 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Mon, 24 May 2021 12:14:30 -0500 Subject: [PATCH 28/28] Apply suggestions from code review --- .../TerminalSettingsEditor/Resources/en-US/Resources.resw | 3 +-- src/cascadia/TerminalSettingsModel/Profile.idl | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw index 3f302520375..ed6081a6f50 100644 --- a/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw @@ -900,8 +900,7 @@ An option to choose from for the "bell style" setting. When selected, a combination of the other bell styles is used to notify the user. - Visual (flash taskbar and window) - An option to choose from for the "bell style" setting. When selected, a visual notification is used to notify the user. In this case, the taskbar and window are both flashed. + Visual (flash taskbar) Flash taskbar diff --git a/src/cascadia/TerminalSettingsModel/Profile.idl b/src/cascadia/TerminalSettingsModel/Profile.idl index 12d47e59f75..ceee66d5a44 100644 --- a/src/cascadia/TerminalSettingsModel/Profile.idl +++ b/src/cascadia/TerminalSettingsModel/Profile.idl @@ -30,6 +30,7 @@ namespace Microsoft.Terminal.Settings.Model [flags] enum BellStyle { + // !! If you update this, you must update the values in TerminalSettingsEditor/Profiles.xaml Audible = 0x1, Window = 0x2, Taskbar = 0x4,