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

workaround qt 5.12 bug for simulated rightbutton mouse events #10869

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/mixxxapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class QMouseEventEditable : public QMouseEvent {
void setButton(Qt::MouseButton button) {
b = button;
}
// We also use this class to modify erroneous mouseState. See
// MixxxApplication::notify(...) for details.
void setButtons(Qt::MouseButtons mouseState) {
this->mouseState = mouseState;
}
};

} // anonymous namespace
Expand Down Expand Up @@ -117,6 +122,13 @@ bool MixxxApplication::notify(QObject* target, QEvent* event) {
mouseEvent->setButton(Qt::RightButton);
m_rightPressedButtons++;
}
if (mouseEvent->button() == Qt::RightButton && mouseEvent->buttons() == Qt::LeftButton) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workarounds for specific Qt releases should be enclosed in #ifef guards and restricted to only the Qt versions that are actually affected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. it also also platform specific, so i will guard that too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you search the code you will find some common patterns involving QT_VERSION_CHECK etc.

// Workaround for a bug in Qt 5.12 qnsview_mouse.mm, where the wrong value is
// assigned to the event's mouseState for simulated rightbutton press events
// (using ctrl+leftbotton), which results in a missing release event for that
// press event.
mouseEvent->setButtons(Qt::RightButton);
}
break;
}
case QEvent::MouseButtonRelease: {
Expand Down