diff --git a/src/cascadia/TerminalApp/Pane.cpp b/src/cascadia/TerminalApp/Pane.cpp index 993202315..9948d40b6 100644 --- a/src/cascadia/TerminalApp/Pane.cpp +++ b/src/cascadia/TerminalApp/Pane.cpp @@ -125,7 +125,7 @@ NewTerminalArgs Pane::GetTerminalArgsForPane() const assert(_IsLeaf()); NewTerminalArgs args{}; - auto controlSettings = _control.Settings(); //.as(); + auto controlSettings = _control.Settings(); args.Profile(controlSettings.ProfileName()); // If we know the user's working directory use it instead of the profile. @@ -1463,21 +1463,21 @@ void Pane::UpdateSettings(const TerminalSettingsCreateResult& settings, const Pr assert(_IsLeaf()); _profile = profile; - auto controlSettings = _control.Settings().as(); - // Update the parent of the control's settings object (and not the object itself) so - // that any overrides made by the control don't get affected by the reload - controlSettings.SetParent(settings.DefaultSettings()); - auto unfocusedSettings{ settings.UnfocusedSettings() }; - if (unfocusedSettings) - { - // Note: the unfocused settings needs to be entirely unchanged _except_ we need to - // set its parent to the settings object that lives in the control. This is because - // the overrides made by the control live in that settings object, so we want to make - // sure the unfocused settings inherit from that. - unfocusedSettings.SetParent(controlSettings); - } - // _control.UnfocusedAppearance(unfocusedSettings); - _control.UpdateControlSettings(controlSettings, unfocusedSettings); + // auto controlSettings = _control.Settings().as(); + // // Update the parent of the control's settings object (and not the object itself) so + // // that any overrides made by the control don't get affected by the reload + // controlSettings.SetParent(settings.DefaultSettings()); + // auto unfocusedSettings{ settings.UnfocusedSettings() }; + // if (unfocusedSettings) + // { + // // Note: the unfocused settings needs to be entirely unchanged _except_ we need to + // // set its parent to the settings object that lives in the control. This is because + // // the overrides made by the control live in that settings object, so we want to make + // // sure the unfocused settings inherit from that. + // unfocusedSettings.SetParent(controlSettings); + // } + // // _control.UnfocusedAppearance(unfocusedSettings); + _control.UpdateControlSettings(settings.DefaultSettings(), settings.UnfocusedSettings()); } // Method Description: diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index b2ef82ab1..dfe9fc2b9 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -2161,8 +2161,8 @@ namespace winrt::TerminalApp::implementation { // Give term control a child of the settings so that any overrides go in the child // This way, when we do a settings reload we just update the parent and the overrides remain - const auto child = TerminalSettings::CreateWithParent(settings); - TermControl term{ child.DefaultSettings(), child.UnfocusedSettings(), connection }; + // const auto child = TerminalSettings::CreateWithParent(settings); + TermControl term{ settings.DefaultSettings(), settings.UnfocusedSettings(), connection }; // term.UnfocusedAppearance(child.UnfocusedSettings()); // It is okay for the unfocused settings to be null diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index b22fd5727..8d49c81c5 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -633,26 +633,33 @@ namespace winrt::Microsoft::Terminal::Control::implementation } } + // Method Description: + // - Updates the appearance of the current terminal. + // - INVARIANT: This method can only be called if the caller DOES NOT HAVE writing lock on the terminal. + void ControlCore::ApplyAppearance(const bool& focused) + { + auto lock = _terminal->LockForWriting(); + const auto& newAppearance{ focused ? _settings->FocusedAppearance() : _settings->UnfocusedAppearance() }; + // Update the terminal core with its new Core settings + _terminal->UpdateAppearance(*newAppearance); + + // Update DxEngine settings under the lock + if (_renderEngine) + { + // Update DxEngine settings under the lock + _renderEngine->SetSelectionBackground(til::color{ newAppearance->SelectionBackground() }); + _renderEngine->SetRetroTerminalEffect(newAppearance->RetroTerminalEffect()); + _renderEngine->SetPixelShaderPath(newAppearance->PixelShaderPath()); + _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold()); + _renderer->TriggerRedrawAll(); + } + } + // Method Description: // - Updates the appearance of the current terminal. // - INVARIANT: This method can only be called if the caller DOES NOT HAVE writing lock on the terminal. // void ControlCore::UpdateAppearance(const IControlAppearance& newAppearance) // { - // auto lock = _terminal->LockForWriting(); - - // // Update the terminal core with its new Core settings - // _terminal->UpdateAppearance(newAppearance); - - // // Update DxEngine settings under the lock - // if (_renderEngine) - // { - // // Update DxEngine settings under the lock - // _renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() }); - // _renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect()); - // _renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath()); - // _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold()); - // _renderer->TriggerRedrawAll(); - // } // } void ControlCore::_updateAntiAliasingMode(::Microsoft::Console::Render::DxEngine* const dxEngine) diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index dad1ac4bb..082b24f9a 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -55,6 +55,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation void EnablePainting(); void UpdateSettings(const Control::IControlSettings& settings, const IControlAppearance& newAppearance); + void ApplyAppearance(const bool& focused); // void UpdateAppearance(const Control::IControlAppearance& newAppearance); Control::IControlSettings Settings() const { return *_settings; }; Control::IControlAppearance FocusedAppearance() const { return *_settings->FocusedAppearance(); }; diff --git a/src/cascadia/TerminalControl/ControlCore.idl b/src/cascadia/TerminalControl/ControlCore.idl index 0817b5335..03ff6d9d2 100644 --- a/src/cascadia/TerminalControl/ControlCore.idl +++ b/src/cascadia/TerminalControl/ControlCore.idl @@ -42,6 +42,7 @@ namespace Microsoft.Terminal.Control void UpdateSettings(IControlSettings settings, IControlAppearance appearance); // void UpdateAppearance(IControlAppearance appearance); + void ApplyAppearance(Boolean focused); IControlSettings Settings { get; }; IControlAppearance FocusedAppearance { get; }; IControlAppearance UnfocusedAppearance { get; }; diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index 0ff125713..fa741adc6 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -341,6 +341,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation TSFInputControl().Foreground(foregroundBrush); // TODO! + _core.ApplyAppearance(_focused); // _core.UpdateAppearance(newAppearance.try_as()); }