posChanged = true;
} else if (data->code == ABS_WHEEL) { // vertical scroll
// data->value: 1 == up, -1 == down
- int delta = 120 * data->value;
- QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
- QPoint(m_x, m_y),
- delta, Qt::Vertical);
+ const int delta = 120 * data->value;
+ emit handleWheelEvent(delta, Qt::Vertical);
} else if (data->code == ABS_THROTTLE) { // horizontal scroll
// data->value: 1 == right, -1 == left
- int delta = 120 * -data->value;
- QWindowSystemInterface::handleWheelEvent(0, QPoint(m_x, m_y),
- QPoint(m_x, m_y),
- delta, Qt::Horizontal);
+ const int delta = 120 * -data->value;
+ emit handleWheelEvent(delta, Qt::Horizontal);
}
} else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
// We care about touchpads only, not touchscreens -> don't map to button press.
signals:
void handleMouseEvent(int x, int y, Qt::MouseButtons buttons);
+ void handleWheelEvent(int delta, Qt::Orientation orientation);
private slots:
void readMouseData();
#endif
}
+void QEvdevMouseManager::handleWheelEvent(int delta, Qt::Orientation orientation)
+{
+ QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
+ QWindowSystemInterface::handleWheelEvent(0, pos, pos, delta, orientation);
+
+#ifdef QT_QPA_MOUSEMANAGER_DEBUG
+ qDebug("mouse wheel event %dx%d %d %d", pos.x(), pos.y(), delta, int(orientation));
+#endif
+}
+
void QEvdevMouseManager::addMouse(const QString &deviceNode)
{
#ifdef QT_QPA_MOUSEMANAGER_DEBUG
handler = QEvdevMouseHandler::create(deviceNode, m_spec);
if (handler) {
connect(handler, SIGNAL(handleMouseEvent(int, int, Qt::MouseButtons)), this, SLOT(handleMouseEvent(int, int, Qt::MouseButtons)));
+ connect(handler, SIGNAL(handleWheelEvent(int, Qt::Orientation)), this, SLOT(handleWheelEvent(int, Qt::Orientation)));
m_mice.insert(deviceNode, handler);
} else {
qWarning("Failed to open mouse");
public slots:
void handleMouseEvent(int x, int y, Qt::MouseButtons buttons);
+ void handleWheelEvent(int delta, Qt::Orientation orientation);
private slots:
void addMouse(const QString &deviceNode = QString());