Skip to content

Commit

Permalink
Fixed horizontal scroll using trackpad gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
EdnY1 authored and tishion committed Sep 21, 2024
1 parent c1b00ec commit 4326aef
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/details/QCefViewPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,18 +1036,22 @@ QCefViewPrivate::onViewWheelEvent(QWheelEvent* event)
e.modifiers |= m & Qt::ControlModifier ? EVENTFLAG_CONTROL_DOWN : 0;
e.modifiers |= m & Qt::ShiftModifier ? EVENTFLAG_SHIFT_DOWN : 0;
e.modifiers |= m & Qt::AltModifier ? EVENTFLAG_ALT_DOWN : 0;
e.modifiers |= b & Qt::LeftButton ? EVENTFLAG_LEFT_MOUSE_BUTTON : 0;
e.modifiers |= b & Qt::RightButton ? EVENTFLAG_RIGHT_MOUSE_BUTTON : 0;
e.modifiers |= b & Qt::MiddleButton ? EVENTFLAG_MIDDLE_MOUSE_BUTTON : 0;

e.x = p.x();
e.y = p.y();

// angleDelta().y() provides the angle through which the common vertical mouse wheel was rotated since the previous
// event. angleDelta().x() provides the angle through which the horizontal mouse wheel was rotated, if the mouse has
// a horizontal wheel; otherwise it stays at zero.
pCefBrowser_->GetHost()->SendMouseWheelEvent(
e, m & Qt::ShiftModifier ? d.x() : 0, m & Qt::ShiftModifier ? d.y() : d.y());
// Prevent diagonal scrolling: only allow scrolling in one direction at a time
if (d.x() != 0 && d.y() != 0) {
if (std::abs(d.x()) > std::abs(d.y())) {
d.setY(0);
} else {
d.setX(0);
}
}

pCefBrowser_->GetHost()->SendMouseWheelEvent(e, d.x(), d.y());
}
}

Expand Down

0 comments on commit 4326aef

Please sign in to comment.