-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a setting to flash the pane when BEL is emitted (#9270)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Adds a new bellStyle called `window`. When `window` is set and a BEL is emitted, we flash the pane that emitted it. Additionally, changes bellStyle in the SUI to a list of checkboxes instead of radio buttons, to match bellStyle being a flag-enum. Deprecates 'BellStyle::Visual' in the schema, but still allows it to be set in the json (it maps to `Window | Taskbar`) <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #6700 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [x] I work here <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed GIF in Teams
- Loading branch information
1 parent
27582a9
commit 227ec37
Showing
21 changed files
with
305 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
#include "TermControl.h" | ||
#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 | ||
{ | ||
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 = | ||
DependencyProperty::RegisterAttached( | ||
L"IsTarget", | ||
winrt::xaml_typename<bool>(), | ||
winrt::xaml_typename<Control::VisualBellLight>(), | ||
PropertyMetadata{ winrt::box_value(false), 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(UIElement const& /* newElement */) | ||
{ | ||
if (!CompositionLight()) | ||
{ | ||
auto spotLight{ Window::Current().Compositor().CreateAmbientLight() }; | ||
spotLight.Color(Windows::UI::Colors::White()); | ||
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(UIElement const& /* oldElement */) | ||
{ | ||
if (CompositionLight()) | ||
{ | ||
CompositionLight(nullptr); | ||
} | ||
} | ||
|
||
winrt::hstring VisualBellLight::GetId() | ||
{ | ||
return VisualBellLight::GetIdStatic(); | ||
} | ||
|
||
void VisualBellLight::OnIsTargetChanged(DependencyObject const& d, DependencyPropertyChangedEventArgs const& e) | ||
{ | ||
const auto uielem{ d.try_as<UIElement>() }; | ||
const auto brush{ d.try_as<Brush>() }; | ||
|
||
if (!uielem && !brush) | ||
{ | ||
// terminate early | ||
return; | ||
} | ||
|
||
const auto isAdding = winrt::unbox_value<bool>(e.NewValue()); | ||
const auto id = GetIdStatic(); | ||
|
||
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "cppwinrt_utils.h" | ||
#include "VisualBellLight.g.h" | ||
|
||
namespace winrt::Microsoft::Terminal::Control::implementation | ||
{ | ||
struct VisualBellLight : VisualBellLightT<VisualBellLight> | ||
{ | ||
VisualBellLight(); | ||
|
||
winrt::hstring GetId(); | ||
|
||
static Windows::UI::Xaml::DependencyProperty IsTargetProperty() { return _IsTargetProperty; } | ||
|
||
static bool GetIsTarget(Windows::UI::Xaml::DependencyObject const& target) | ||
{ | ||
return winrt::unbox_value<bool>(target.GetValue(_IsTargetProperty)); | ||
} | ||
|
||
static void SetIsTarget(Windows::UI::Xaml::DependencyObject const& target, bool value) | ||
{ | ||
target.SetValue(_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<winrt::Microsoft::Terminal::Control::VisualBellLight>().Name; | ||
} | ||
|
||
private: | ||
static void _InitializeProperties(); | ||
static Windows::UI::Xaml::DependencyProperty _IsTargetProperty; | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::Terminal::Control::factory_implementation | ||
{ | ||
BASIC_FACTORY(VisualBellLight); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.