Skip to content

Commit 452fa87

Browse files
authored
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 #3793 (comment) - [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: MicrosoftDocs/terminal#873 - [X] Schema updated (if necessary)
1 parent 3979e82 commit 452fa87

File tree

12 files changed

+25
-2
lines changed

12 files changed

+25
-2
lines changed

doc/cascadia/profiles.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,11 @@
23812381
"description": "When set to true, holding the Ctrl key while scrolling will increase or decrease the terminal font size.",
23822382
"type": "boolean"
23832383
},
2384+
"experimental.scrollToChangeOpacity": {
2385+
"default": true,
2386+
"description": "When set to true, holding the Ctrl and Shift keys while scrolling will change the window opacity.",
2387+
"type": "boolean"
2388+
},
23842389
"compatibility.allowHeadless": {
23852390
"default": false,
23862391
"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.",

src/cascadia/TerminalControl/ControlInteractivity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
515515
const auto ctrlPressed = modifiers.IsCtrlPressed();
516516
const auto shiftPressed = modifiers.IsShiftPressed();
517517

518-
if (ctrlPressed && shiftPressed)
518+
if (ctrlPressed && shiftPressed && _core->Settings().ScrollToChangeOpacity())
519519
{
520520
_mouseTransparencyHandler(delta);
521521
}
522-
else if (ctrlPressed && _core->Settings().ScrollToZoom())
522+
else if (ctrlPressed && !shiftPressed && _core->Settings().ScrollToZoom())
523523
{
524524
_mouseZoomHandler(delta);
525525
}

src/cascadia/TerminalControl/IControlSettings.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace Microsoft.Terminal.Control
6161
Microsoft.Terminal.Control.CopyFormat CopyFormatting { get; };
6262
Boolean FocusFollowMouse { get; };
6363
Boolean ScrollToZoom { get; };
64+
Boolean ScrollToChangeOpacity { get; };
6465

6566
String Commandline { get; };
6667
String StartingDirectory { get; };

src/cascadia/TerminalSettingsEditor/Interaction.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
9090
</local:SettingContainer>
9191

92+
<!-- Enable Window Opacity Changes with Scrolling -->
93+
<local:SettingContainer x:Uid="Globals_ScrollToChangeOpacity">
94+
<ToggleSwitch IsOn="{x:Bind ViewModel.ScrollToChangeOpacity, Mode=TwoWay}"
95+
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
96+
</local:SettingContainer>
97+
9298
<!-- Detect URLs -->
9399
<local:SettingContainer x:Uid="Globals_DetectURLs">
94100
<ToggleSwitch IsOn="{x:Bind ViewModel.DetectURLs, Mode=TwoWay}"

src/cascadia/TerminalSettingsEditor/InteractionViewModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
2626
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SnapToGridOnResize);
2727
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, FocusFollowMouse);
2828
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ScrollToZoom);
29+
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, ScrollToChangeOpacity);
2930
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, DetectURLs);
3031
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, SearchWebDefaultQueryUrl);
3132
PERMANENT_OBSERVABLE_PROJECTED_SETTING(_GlobalSettings, WordDelimiters);

src/cascadia/TerminalSettingsEditor/InteractionViewModel.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace Microsoft.Terminal.Settings.Editor
2323
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, SnapToGridOnResize);
2424
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, FocusFollowMouse);
2525
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ScrollToZoom);
26+
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, ScrollToChangeOpacity);
2627
PERMANENT_OBSERVABLE_PROJECTED_SETTING(Boolean, DetectURLs);
2728
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, SearchWebDefaultQueryUrl);
2829
PERMANENT_OBSERVABLE_PROJECTED_SETTING(String, WordDelimiters);

src/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.resw

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,10 @@
17401740
<value>Adjust terminal font size by scrolling while holding the Ctrl key</value>
17411741
<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>
17421742
</data>
1743+
<data name="Globals_ScrollToChangeOpacity.Header" xml:space="preserve">
1744+
<value>Adjust terminal opacity by scrolling while holding the Ctrl and Shift keys</value>
1745+
<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>
1746+
</data>
17431747
<data name="Globals_DisableAnimationsReversed.Header" xml:space="preserve">
17441748
<value>Pane animations</value>
17451749
<comment>Header for a control to toggle animations on panes. "Enabled" value enables the animations.</comment>

src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ namespace Microsoft.Terminal.Settings.Model
9191
INHERITABLE_SETTING(String, StartupActions);
9292
INHERITABLE_SETTING(Boolean, FocusFollowMouse);
9393
INHERITABLE_SETTING(Boolean, ScrollToZoom);
94+
INHERITABLE_SETTING(Boolean, ScrollToChangeOpacity);
9495
INHERITABLE_SETTING(WindowingMode, WindowingBehavior);
9596
INHERITABLE_SETTING(Boolean, TrimBlockSelection);
9697
INHERITABLE_SETTING(Boolean, DetectURLs);

src/cascadia/TerminalSettingsModel/MTSMSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Author(s):
2525
X(bool, CopyOnSelect, "copyOnSelect", false) \
2626
X(bool, FocusFollowMouse, "focusFollowMouse", false) \
2727
X(bool, ScrollToZoom, "experimental.scrollToZoom", true) \
28+
X(bool, ScrollToChangeOpacity, "experimental.scrollToChangeOpacity", true) \
2829
X(winrt::Microsoft::Terminal::Control::GraphicsAPI, GraphicsAPI, "rendering.graphicsAPI") \
2930
X(bool, DisablePartialInvalidation, "rendering.disablePartialInvalidation", false) \
3031
X(bool, SoftwareRendering, "rendering.software", false) \

src/cascadia/TerminalSettingsModel/TerminalSettings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
368368
_CopyFormatting = globalSettings.CopyFormatting();
369369
_FocusFollowMouse = globalSettings.FocusFollowMouse();
370370
_ScrollToZoom = globalSettings.ScrollToZoom();
371+
_ScrollToChangeOpacity = globalSettings.ScrollToChangeOpacity();
371372
_GraphicsAPI = globalSettings.GraphicsAPI();
372373
_DisablePartialInvalidation = globalSettings.DisablePartialInvalidation();
373374
_SoftwareRendering = globalSettings.SoftwareRendering();

0 commit comments

Comments
 (0)