Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix horizontal scroll using trackpad gesture #435

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/details/QCefViewPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,14 @@ QCefViewPrivate::onViewWheelEvent(QWheelEvent* event)
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 (qAbs(d.x()) > qAbs(d.y())) {
d.setY(0);
} else {
d.setX(0);
}

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

Expand Down
Loading