feat: add option to adjust opacity with Ctrl+Shift+scroll (#19151)

## Summary of the Pull Request
This PR introduces an experimental setting that allows to toggle opacity
changes with scrolling.

## References and Relevant Issues
#3793

## Detailed Description of the Pull Request / Additional comments
By default, holding Ctrl + Shift while scrolling changes the terminal's
opacity. This PR adds an option to disable that behavior.

## Validation Steps Performed
I built the project locally and verified that the new feature works as
intended.

## PR Checklist
- [x] Resolves
https://github.com/microsoft/terminal/issues/3793#issuecomment-3085684640
- [x] Tests ~~added/~~ passed
- [x] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it here:
https://github.com/MicrosoftDocs/terminal/pull/873
- [X] Schema updated (if necessary)
This commit is contained in:
Paulina Kalicka 2025-07-22 00:24:46 +02:00 committed by GitHub
parent 3979e82c2b
commit 452fa87937
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 25 additions and 2 deletions

View File

@ -2381,6 +2381,11 @@
"description": "When set to true, holding the Ctrl key while scrolling will increase or decrease the terminal font size.",
"type": "boolean"
},
"experimental.scrollToChangeOpacity": {
"default": true,
"description": "When set to true, holding the Ctrl and Shift keys while scrolling will change the window opacity.",
"type": "boolean"
},
"compatibility.allowHeadless": {
"default": false,
"description": "When set to true, Windows Terminal will run in the background. This allows globalSummon and quakeMode actions to work even when no windows are open.",

View File

@ -515,11 +515,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto ctrlPressed = modifiers.IsCtrlPressed();
const auto shiftPressed = modifiers.IsShiftPressed();
if (ctrlPressed && shiftPressed)
if (ctrlPressed && shiftPressed && _core->Settings().ScrollToChangeOpacity())
{
_mouseTransparencyHandler(delta);
}
else if (ctrlPressed && _core->Settings().ScrollToZoom())
else if (ctrlPressed && !shiftPressed && _core->Settings().ScrollToZoom())
{
_mouseZoomHandler(delta);
}

View File

@ -61,6 +61,7 @@ namespace Microsoft.Terminal.Control
Microsoft.Terminal.Control.CopyFormat CopyFormatting { get; };
Boolean FocusFollowMouse { get; };
Boolean ScrollToZoom { get; };
Boolean ScrollToChangeOpacity { get; };
String Commandline { get; };
String StartingDirectory { get; };

View File

@ -89,6 +89,12 @@
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
<!-- Enable Window Opacity Changes with Scrolling -->
<local:SettingContainer x:Uid="Globals_ScrollToChangeOpacity">
<ToggleSwitch IsOn="{x:Bind ViewModel.ScrollToChangeOpacity, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
<!-- Detect URLs -->
<local:SettingContainer x:Uid="Globals_DetectURLs">
<ToggleSwitch IsOn="{x:Bind ViewModel.DetectURLs, Mode=TwoWay}"

View File

@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SnapToGridOnResize);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, FocusFollowMouse);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ScrollToZoom);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ScrollToChangeOpacity);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DetectURLs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);

View File

@ -23,6 +23,7 @@ namespace Microsoft.Terminal.Settings.Editor
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SnapToGridOnResize);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, FocusFollowMouse);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ScrollToZoom);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ScrollToChangeOpacity);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, SearchWebDefaultQueryUrl);
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters);

View File

@ -1740,6 +1740,10 @@
<value>Adjust terminal font size by scrolling while holding the Ctrl key</value>
<comment>Header for a control to toggle font size changes with scrolling. When enabled, holding the Ctrl key while scrolling will increase or decrease the terminal font size.</comment>
</data>
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
<value>Adjust terminal opacity by scrolling while holding the Ctrl and Shift keys</value>
<comment>Header for a control to toggle opacity changes with scrolling. When enabled, holding the Ctrl and Shift keys while scrolling will increase or decrease the window opacity.</comment>
</data>
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
<value>Pane animations</value>
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

View File

@ -91,6 +91,7 @@ namespace Microsoft.Terminal.Settings.Model
INHERITABLE_SETTING(String, StartupActions);
INHERITABLE_SETTING(Boolean, FocusFollowMouse);
INHERITABLE_SETTING(Boolean, ScrollToZoom);
INHERITABLE_SETTING(Boolean, ScrollToChangeOpacity);
INHERITABLE_SETTING(WindowingMode, WindowingBehavior);
INHERITABLE_SETTING(Boolean, TrimBlockSelection);
INHERITABLE_SETTING(Boolean, DetectURLs);

View File

@ -25,6 +25,7 @@ Author(s):
X(bool, CopyOnSelect, "copyOnSelect", false) \
X(bool, FocusFollowMouse, "focusFollowMouse", false) \
X(bool, ScrollToZoom, "experimental.scrollToZoom", true) \
X(bool, ScrollToChangeOpacity, "experimental.scrollToChangeOpacity", true) \
X(winrt::Microsoft::Terminal::Control::GraphicsAPI, GraphicsAPI, "rendering.graphicsAPI") \
X(bool, DisablePartialInvalidation, "rendering.disablePartialInvalidation", false) \
X(bool, SoftwareRendering, "rendering.software", false) \

View File

@ -368,6 +368,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
_CopyFormatting = globalSettings.CopyFormatting();
_FocusFollowMouse = globalSettings.FocusFollowMouse();
_ScrollToZoom = globalSettings.ScrollToZoom();
_ScrollToChangeOpacity = globalSettings.ScrollToChangeOpacity();
_GraphicsAPI = globalSettings.GraphicsAPI();
_DisablePartialInvalidation = globalSettings.DisablePartialInvalidation();
_SoftwareRendering = globalSettings.SoftwareRendering();

View File

@ -95,6 +95,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
INHERITABLE_SETTING(Model::TerminalSettings, Microsoft::Terminal::Control::CopyFormat, CopyFormatting, 0);
INHERITABLE_SETTING(Model::TerminalSettings, bool, FocusFollowMouse, false);
INHERITABLE_SETTING(Model::TerminalSettings, bool, ScrollToZoom, true);
INHERITABLE_SETTING(Model::TerminalSettings, bool, ScrollToChangeOpacity, true);
INHERITABLE_SETTING(Model::TerminalSettings, bool, AllowVtChecksumReport, false);
INHERITABLE_SETTING(Model::TerminalSettings, bool, TrimBlockSelection, true);
INHERITABLE_SETTING(Model::TerminalSettings, bool, DetectURLs, true);

View File

@ -43,6 +43,7 @@
X(bool, CopyOnSelect, false) \
X(bool, FocusFollowMouse, false) \
X(bool, ScrollToZoom, true) \
X(bool, ScrollToChangeOpacity, true) \
X(winrt::Windows::Foundation::IReference<winrt::Microsoft::Terminal::Core::Color>, TabColor, nullptr) \
X(winrt::Windows::Foundation::IReference<winrt::Microsoft::Terminal::Core::Color>, StartingTabColor, nullptr) \
X(bool, TrimBlockSelection, true) \