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

Code before:
    // - point: the location of the mouse during this event
    // - modifiers: The modifiers pressed during this event, in the form of a VirtualKeyModifiers
    // - 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

Review comment (suggestion):
This isn't a big deal, but shouldn't this be `delta.Y != 0 ? WM_MOUSEWHEEL : WM_MOUSEHWEEL`? Because if there's movement along both axes, I would expect the vertical movement to take precedence, because that's more likely the direction the user is trying to move.

Code after:
    // - point: the location of the mouse during this event
    // - modifiers: The modifiers pressed during this event, in the form of a VirtualKeyModifiers
    // - 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