Repository: microsoft/terminal
File: src/cascadia/TerminalControl/TermControl.cpp (C++)

Code before:
            uiButton = WM_MBUTTONUP;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::RightButtonPressed:
            uiButton = WM_RBUTTONDOWN;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::RightButtonReleased:
            uiButton = WM_RBUTTONUP;
            break;
        default:
            uiButton = WM_MOUSEMOVE;
        }

        return uiButton;
    }

    void TermControl::_coreWarningBell(const IInspectable& /*sender*/, const IInspectable& /*args*/)
    {
        _playWarningBell->Run();
    }

    Windows::UI::Xaml::DependencyProperty VisualBellLight::m_isTargetProperty =
        Windows::UI::Xaml::DependencyProperty::RegisterAttached(
            L"IsTarget",
            winrt::xaml_typename<bool>(),
            winrt::xaml_typename<winrt::Microsoft::Terminal::Control::VisualBellLight>(),
            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<float>(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()
    {

Review comment (performance):
Check out...
- https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalSettingsEditor/SettingContainer.h
   - there's a `DEPENDENCY_PROPERTY` macro I created there. You may be able to move this into `cppwinrt_utils` and use it yourself.
- https://github.com/microsoft/terminal/blob/0e8d5f24c4cf80e104cf6d16ae004c54015c13ce/src/cascadia/TerminalSettingsEditor/SettingContainer.cpp#L13-L64
   - We lazy load the dependency properties in `_InitializeProperties`. I'd take a look there and apply the same code pattern here.

Code after:
        switch (props.PointerUpdateKind())
        {
        case winrt::Windows::UI::Input::PointerUpdateKind::LeftButtonPressed:
            uiButton = WM_LBUTTONDOWN;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::LeftButtonReleased:
            uiButton = WM_LBUTTONUP;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::MiddleButtonPressed:
            uiButton = WM_MBUTTONDOWN;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::MiddleButtonReleased:
            uiButton = WM_MBUTTONUP;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::RightButtonPressed:
            uiButton = WM_RBUTTONDOWN;
            break;
        case winrt::Windows::UI::Input::PointerUpdateKind::RightButtonReleased:
            uiButton = WM_RBUTTONUP;
            break;
        default:
            uiButton = WM_MOUSEMOVE;
        }

        return uiButton;
    }

    void TermControl::_coreWarningBell(const IInspectable& /*sender*/, const IInspectable& /*args*/)
    {
        _playWarningBell->Run();
    }
}