diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index a0e56a650de..f34d7013c02 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -39,6 +39,9 @@ constexpr const auto TsfRedrawInterval = std::chrono::milliseconds(100); // The minimum delay between updating the locations of regex patterns constexpr const auto UpdatePatternLocationsInterval = std::chrono::milliseconds(500); +// The minimum delay between emitting warning bells +constexpr const auto TerminalWarningBellInterval = std::chrono::milliseconds(1000); + DEFINE_ENUM_FLAG_OPERATORS(winrt::Microsoft::Terminal::Control::CopyFormat); namespace winrt::Microsoft::Terminal::Control::implementation @@ -91,7 +94,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation // GH#8969: pre-seed working directory to prevent potential races _terminal->SetWorkingDirectory(_settings.StartingDirectory()); - auto pfnWarningBell = std::bind(&TermControl::_TerminalWarningBell, this); + auto pfnWarningBell = [this]() { + _playWarningBell->Run(); + }; _terminal->SetWarningBellCallback(pfnWarningBell); auto pfnTitleChanged = std::bind(&TermControl::_TerminalTitleChanged, this, std::placeholders::_1); @@ -167,6 +172,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation UpdatePatternLocationsInterval, Dispatcher()); + _playWarningBell = std::make_shared>( + [weakThis = get_weak()]() { + if (auto control{ weakThis.get() }) + { + control->_TerminalWarningBell(); + } + }, + TerminalWarningBellInterval, + Dispatcher()); + _updateScrollBar = std::make_shared>( [weakThis = get_weak()](const auto& update) { if (auto control{ weakThis.get() }) diff --git a/src/cascadia/TerminalControl/TermControl.h b/src/cascadia/TerminalControl/TermControl.h index f38d8592eeb..0ebbc9186e2 100644 --- a/src/cascadia/TerminalControl/TermControl.h +++ b/src/cascadia/TerminalControl/TermControl.h @@ -145,6 +145,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation std::shared_ptr> _updatePatternLocations; + std::shared_ptr> _playWarningBell; + struct ScrollBarUpdate { std::optional newValue;