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

Code before:
    // - delta: the mouse wheel delta that triggered this event.
    bool ControlInteractivity::MouseWheel(const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
                                          const Core::Point delta,
                                          const Core::Point pixelPosition,
                                          const Control::MouseButtonState buttonState)
    {
        const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition }, false);

        // Short-circuit isReadOnly check to avoid warning dialog.
        //
        // GH#3321: Alternate scroll mode is a special type of mouse input mode
        // where the terminal sends arrow keys when the user mouse wheels, but
        // the client app doesn't care for other mouse input. It's tracked
        // separately from _canSendVTMouseInput.
        if (!_core->IsInReadOnlyMode() &&
            (_canSendVTMouseInput(modifiers) || _shouldSendAlternateScroll(modifiers, delta)))
        {
            // Most mouse event handlers call
            //      _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:

Review comment (refactor):
Oh interesting... I wonder if we should refactor `_sendMouseEventHelper` to allow for both X and Y to be passed? You don't have to do this in this PR of course - I can do that as a follow up (or I push into your PR).

Code after:
    // - delta: the mouse wheel delta that triggered this event.
    bool ControlInteractivity::MouseWheel(const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
                                          const Core::Point delta,
                                          const Core::Point pixelPosition,
                                          const Control::MouseButtonState buttonState)
    {
        const auto terminalPosition = _getTerminalPosition(til::point{ pixelPosition }, false);

        // Short-circuit isReadOnly check to avoid warning dialog.
        //
        // GH#3321: Alternate scroll mode is a special type of mouse input mode
        // where the terminal sends arrow keys when the user mouse wheels, but
        // the client app doesn't care for other mouse input. It's tracked
        // separately from _canSendVTMouseInput.
        if (!_core->IsInReadOnlyMode() &&
            (_canSendVTMouseInput(modifiers) || _shouldSendAlternateScroll(modifiers, delta)))
        {
            // Most mouse event handlers call
            //      _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: