@@ -182,12 +182,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
182182 }
183183 else if (_canSendVTMouseInput (modifiers))
184184 {
185- const auto adjustment = _core->ScrollOffset () > 0 ? _core->BufferHeight () - _core->ScrollOffset () - _core->ViewHeight () : 0 ;
186- // If the click happened outside the active region, just don't send any mouse event
187- if (const auto adjustedY = terminalPosition.y () - adjustment; adjustedY >= 0 )
188- {
189- _core->SendMouseEvent ({ terminalPosition.x (), adjustedY }, pointerUpdateKind, modifiers, 0 , buttonState);
190- }
185+ _sendMouseEventHelper (terminalPosition, pointerUpdateKind, modifiers, 0 , buttonState);
191186 }
192187 else if (buttonState.isLeftButtonDown )
193188 {
@@ -254,7 +249,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
254249 // Short-circuit isReadOnly check to avoid warning dialog
255250 if (focused && !_core->IsInReadOnlyMode () && _canSendVTMouseInput (modifiers))
256251 {
257- _core-> SendMouseEvent (terminalPosition, pointerUpdateKind, modifiers, 0 , buttonState);
252+ _sendMouseEventHelper (terminalPosition, pointerUpdateKind, modifiers, 0 , buttonState);
258253 }
259254 else if (focused && buttonState.isLeftButtonDown )
260255 {
@@ -333,7 +328,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
333328 // Short-circuit isReadOnly check to avoid warning dialog
334329 if (!_core->IsInReadOnlyMode () && _canSendVTMouseInput (modifiers))
335330 {
336- _core-> SendMouseEvent (terminalPosition, pointerUpdateKind, modifiers, 0 , buttonState);
331+ _sendMouseEventHelper (terminalPosition, pointerUpdateKind, modifiers, 0 , buttonState);
337332 return ;
338333 }
339334
@@ -383,11 +378,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
383378 // here with a PointerPoint. However, as of #979, we don't have a
384379 // PointerPoint to work with. So, we're just going to do a
385380 // mousewheel event manually
386- return _core-> SendMouseEvent (terminalPosition,
381+ return _sendMouseEventHelper (terminalPosition,
387382 WM_MOUSEWHEEL,
388383 modifiers,
389384 ::base::saturated_cast<short >(delta),
390- state );
385+ buttonState );
391386 }
392387
393388 const auto ctrlPressed = modifiers.IsCtrlPressed ();
@@ -562,4 +557,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation
562557 // Convert the location in pixels to characters within the current viewport.
563558 return til::point{ pixelPosition / fontSize };
564559 }
560+
561+ bool ControlInteractivity::_sendMouseEventHelper (const til::point terminalPosition,
562+ const unsigned int pointerUpdateKind,
563+ const ::Microsoft::Terminal::Core::ControlKeyStates modifiers,
564+ const SHORT wheelDelta,
565+ Control::MouseButtonState buttonState)
566+ {
567+ const auto adjustment = _core->ScrollOffset () > 0 ? _core->BufferHeight () - _core->ScrollOffset () - _core->ViewHeight () : 0 ;
568+ // If the click happened outside the active region, just don't send any mouse event
569+ if (const auto adjustedY = terminalPosition.y () - adjustment; adjustedY >= 0 )
570+ {
571+ return _core->SendMouseEvent ({ terminalPosition.x (), adjustedY }, pointerUpdateKind, modifiers, wheelDelta, toInternalMouseState (buttonState));
572+ }
573+ return false ;
574+ }
575+
565576}
0 commit comments