diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 1e41fdb5c..53f8b99a8 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -435,14 +435,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation return; } - auto newOpacity = std::clamp(_settings.Opacity() + adjustment, + auto newOpacity = std::clamp(Opacity() + adjustment, 0.0, 1.0); // GH#5098: Inform the engine of the new opacity of the default text background. SetBackgroundOpacity(::base::saturated_cast(newOpacity)); - _settings.Opacity(newOpacity); + Opacity(newOpacity); auto eventArgs = winrt::make_self(newOpacity); _TransparencyChangedHandlers(*this, *eventArgs); @@ -569,6 +569,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation _settings = settings; + _runtimeOpacity = std::nullopt; + // Initialize our font information. const auto fontFace = _settings.FontFace(); const short fontHeight = ::base::saturated_cast(_settings.FontSize()); diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index a04032ef7..7d3d406d3 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -30,6 +30,14 @@ namespace ControlUnitTests class ControlInteractivityTests; }; +#define RUNTIME_SETTING(type, name, setting) \ +private: \ + std::optional _runtime##name{ std::nullopt }; \ + void name(const type newValue) { _runtime##name = newValue; } \ + \ +public: \ + type name() const { return _runtime##name ? *_runtime##name : setting; } + namespace winrt::Microsoft::Terminal::Control::implementation { struct ControlCore : ControlCoreT @@ -149,6 +157,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation hstring ReadEntireBuffer() const; + RUNTIME_SETTING(double, Opacity, _settings.Opacity()); + // -------------------------------- WinRT Events --------------------------------- // clang-format off WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs); diff --git a/src/cascadia/TerminalControl/ControlCore.idl b/src/cascadia/TerminalControl/ControlCore.idl index 84cb83e80..23f85abc9 100644 --- a/src/cascadia/TerminalControl/ControlCore.idl +++ b/src/cascadia/TerminalControl/ControlCore.idl @@ -47,6 +47,7 @@ namespace Microsoft.Terminal.Control Windows.Foundation.Size FontSize { get; }; String FontFaceName { get; }; UInt16 FontWeight { get; }; + Double Opacity { get; }; Boolean TrySendKeyEvent(Int16 vkey, Int16 scanCode, diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index f90190a5d..fc6f882b8 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -450,7 +450,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation acrylic.TintColor(bgColor); // Apply brush settings - acrylic.TintOpacity(appearance.Opacity()); + acrylic.TintOpacity(_core.Opacity()); // Apply brush to control if it's not already there if (RootGrid().Background() != acrylic) @@ -459,16 +459,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation } // GH#5098: Inform the engine of the new opacity of the default text background. - _core.SetBackgroundOpacity(::base::saturated_cast(appearance.Opacity())); + _core.SetBackgroundOpacity(::base::saturated_cast(_core.Opacity())); } else { Media::SolidColorBrush solidColor{}; - solidColor.Opacity(_settings.Opacity()); + solidColor.Opacity(_core.Opacity()); RootGrid().Background(solidColor); // GH#5098: Inform the engine of the new opacity of the default text background. - _core.SetBackgroundOpacity(appearance.Opacity()); + _core.SetBackgroundOpacity(_core.Opacity()); } } diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettings.idl b/src/cascadia/TerminalSettingsModel/TerminalSettings.idl index 80231906e..480f897ed 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettings.idl +++ b/src/cascadia/TerminalSettingsModel/TerminalSettings.idl @@ -35,5 +35,9 @@ namespace Microsoft.Terminal.Settings.Model void ApplyColorScheme(ColorScheme scheme); ColorScheme AppliedColorScheme; + + String Commandline { set; }; + String StartingDirectory { set; }; + String EnvironmentVariables { set; }; }; }