Skip to content

Commit

Permalink
some last changes for making events relative to the control origin
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Mar 27, 2020
1 parent f3483c2 commit c7a1e77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,15 +1239,13 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// scrolling on devices where the touchpad doesn't correctly handle
// scrolling inactive windows.
// Arguments:
// - location: the location of the mouse during this event
// - location: the location of the mouse during this event. This location is
// relative to the origin of the control
// - delta: the mouse wheel delta that triggered this event.
bool TermControl::OnMouseWheel(const Windows::Foundation::Point location,
const int32_t delta)
{
// TODO: Right now, the location is window-relative. I believe this needs to get converted to control-relative

const auto modifiers = _GetPressedModifierKeys();

return _DoMouseWheel(location, modifiers, delta, false);
}

Expand Down
8 changes: 7 additions & 1 deletion src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,13 @@ void AppHost::_WindowMouseWheeled(const til::point coord, const int32_t delta)
// If that element has implemented IMouseWheelListener, call OnMouseWheel on that element.
if (auto control{ e.try_as<winrt::Microsoft::Terminal::TerminalControl::IMouseWheelListener>() })
{
if (control.OnMouseWheel(coord, delta))
// Translate the event to the coordinate space of the control
// we're attempting to dispatch it to
const auto transform = e.TransformToVisual(nullptr);
const auto controlOrigin = transform.TransformPoint(til::point{ 0, 0 });
const til::point offsetPoint{ ::base::ClampSub(coord.x(), controlOrigin.X), ::base::ClampSub(coord.y(), controlOrigin.Y) };

if (control.OnMouseWheel(offsetPoint, delta))
{
// If the element handled the mouse wheel event, don't
// continue to iterate over the remaining controls.
Expand Down

1 comment on commit c7a1e77

@github-actions

This comment was marked as resolved.

Please sign in to comment.