evdevmouse: send correct event position for wheel events
The current position for mouse events is synchronized in the mousemanager, thus the wheel event needs to pick the event position from there. Change-Id: I1e73a0154b596885c7092f0a74e6dd448deb428c Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
This commit is contained in:
parent
612fae1ae6
commit
16548ce85e
@ -172,16 +172,12 @@ void QEvdevMouseHandler::readMouseData()
|
||||
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.
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
|
||||
signals:
|
||||
void handleMouseEvent(int x, int y, Qt::MouseButtons buttons);
|
||||
void handleWheelEvent(int delta, Qt::Orientation orientation);
|
||||
|
||||
private slots:
|
||||
void readMouseData();
|
||||
|
@ -132,6 +132,16 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, Qt::MouseButtons buttons
|
||||
#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
|
||||
@ -142,6 +152,7 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode)
|
||||
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");
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user