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

Code before:
            //      _trySendMouseEvent(point);
            // here with a PointerPoint. However, as of #979, we don't have a
            // PointerPoint to work with. So, we're just going to do a
            // mousewheel event manually
            return _sendMouseEventHelper(terminalPosition,
                                         delta.X != 0 ? WM_MOUSEHWHEEL : WM_MOUSEWHEEL,
                                         modifiers,
                                         ::base::saturated_cast<short>(delta.X != 0 ? delta.X : delta.Y),
                                         buttonState);
        }

        const auto ctrlPressed = modifiers.IsCtrlPressed();
        const auto shiftPressed = modifiers.IsShiftPressed();

        if (ctrlPressed && shiftPressed && _core->Settings().ScrollToChangeOpacity())
        {
            _mouseTransparencyHandler(delta.X != 0 ? delta.X : delta.Y);
        }
        else if (ctrlPressed && !shiftPressed && _core->Settings().ScrollToZoom())
        {
            _mouseZoomHandler(delta.X != 0 ? delta.X : delta.Y);
        }
        else
        {
            _mouseScrollHandler(delta.X != 0 ? delta.X : delta.Y, pixelPosition, WI_IsFlagSet(buttonState, MouseButtonState::IsLeftButtonDown));
        }
        return false;
    }

    // Method Description:
    // - Adjust the opacity of the acrylic background in response to a mouse
    //   scrolling event.
    // Arguments:
    // - mouseDelta: the mouse wheel delta that triggered this event.
    void ControlInteractivity::_mouseTransparencyHandler(const int32_t mouseDelta) const
    {
        // Transparency is on a scale of [0.0,1.0], so only increment by .01.
        const auto effectiveDelta = mouseDelta < 0 ? -.01f : .01f;
        _core->AdjustOpacity(effectiveDelta);
    }

    // Method Description:
    // - Adjust the font size of the terminal in response to a mouse scrolling
    //   event.
    // Arguments:
    // - mouseDelta: the mouse wheel delta that triggered this event.
    void ControlInteractivity::_mouseZoomHandler(const int32_t mouseDelta) const
    {
        const auto fontDelta = mouseDelta < 0 ? -1.0f : 1.0f;
        _core->AdjustFontSize(fontDelta);
    }

Review comment (suggestion):
And for these cases, should we even be checking the X delta at all? Surely these settings are only intended to be affected by the vertical mouse wheel? At some point we may want to support horizontal scrolling of the viewport, but not like this - we don't want to scroll vertically when a mouse wheel is moved horizontally.

Code after:
            //      _trySendMouseEvent(point);
            // here with a PointerPoint. However, as of #979, we don't have a
            // PointerPoint to work with. So, we're just going to do a
            // mousewheel event manually
            return _sendMouseEventHelper(terminalPosition,
                                         delta.Y != 0 ? WM_MOUSEWHEEL : WM_MOUSEHWHEEL,
                                         modifiers,
                                         ::base::saturated_cast<short>(delta.Y != 0 ? delta.Y : delta.X),
                                         buttonState);
        }

        const auto ctrlPressed = modifiers.IsCtrlPressed();
        const auto shiftPressed = modifiers.IsShiftPressed();

        if (ctrlPressed && shiftPressed && _core->Settings().ScrollToChangeOpacity())
        {
            _mouseTransparencyHandler(delta.Y);
        }
        else if (ctrlPressed && !shiftPressed && _core->Settings().ScrollToZoom())
        {
            _mouseZoomHandler(delta.Y);
        }
        else
        {
            _mouseScrollHandler(delta.Y, pixelPosition, WI_IsFlagSet(buttonState, MouseButtonState::IsLeftButtonDown));
        }
        return false;
    }

    // Method Description:
    // - Adjust the opacity of the acrylic background in response to a mouse
    //   scrolling event.
    // Arguments:
    // - mouseDelta: the mouse wheel delta that triggered this event.
    void ControlInteractivity::_mouseTransparencyHandler(const int32_t mouseDelta) const
    {
        // Transparency is on a scale of [0.0,1.0], so only increment by .01.
        const auto effectiveDelta = mouseDelta < 0 ? -.01f : .01f;
        _core->AdjustOpacity(effectiveDelta);
    }

    // Method Description:
    // - Adjust the font size of the terminal in response to a mouse scrolling
    //   event.
    // Arguments:
    // - mouseDelta: the mouse wheel delta that triggered this event.
    void ControlInteractivity::_mouseZoomHandler(const int32_t mouseDelta) const
    {
        const auto fontDelta = mouseDelta < 0 ? -1.0f : 1.0f;
        _core->AdjustFontSize(fontDelta);
    }