xcb,evdevmouse: don't use qpa compatibility functions

Change-Id: If3f474dcb6ee117c6dd26cd56fd4ad8d39e60e1f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Gatis Paeglis 2017-05-29 10:59:18 +02:00
parent c3a115b90d
commit 41ae544c40
5 changed files with 30 additions and 17 deletions

View File

@ -236,6 +236,7 @@ void QEvdevMouseHandler::readMouseData()
posChanged = true;
}
} else if (data->type == EV_REL) {
QPoint delta;
if (data->code == REL_X) {
m_x += data->value;
posChanged = true;
@ -244,12 +245,18 @@ void QEvdevMouseHandler::readMouseData()
posChanged = true;
} else if (data->code == ABS_WHEEL) { // vertical scroll
// data->value: 1 == up, -1 == down
const int delta = 120 * data->value;
emit handleWheelEvent(delta, Qt::Vertical);
if (data->value == 1)
delta.setY(120);
else
delta.setY(-120);
emit handleWheelEvent(delta);
} else if (data->code == ABS_THROTTLE) { // horizontal scroll
// data->value: 1 == right, -1 == left
const int delta = 120 * -data->value;
emit handleWheelEvent(delta, Qt::Horizontal);
if (data->value == 1)
delta.setX(-120);
else
delta.setX(120);
emit handleWheelEvent(delta);
}
} else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
// We care about touchpads only, not touchscreens -> don't map to button press.

View File

@ -53,6 +53,7 @@
#include <QObject>
#include <QString>
#include <QPoint>
QT_BEGIN_NAMESPACE
@ -67,7 +68,7 @@ public:
signals:
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
void handleWheelEvent(int delta, Qt::Orientation orientation);
void handleWheelEvent(QPoint delta);
private slots:
void readMouseData();

View File

@ -144,10 +144,10 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto
QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, QGuiApplication::keyboardModifiers());
}
void QEvdevMouseManager::handleWheelEvent(int delta, Qt::Orientation orientation)
void QEvdevMouseManager::handleWheelEvent(QPoint delta)
{
QPoint pos(m_x + m_xoffset, m_y + m_yoffset);
QWindowSystemInterface::handleWheelEvent(0, pos, pos, delta, orientation, QGuiApplication::keyboardModifiers());
QWindowSystemInterface::handleWheelEvent(0, pos, pos, QPoint(), delta, QGuiApplication::keyboardModifiers());
}
void QEvdevMouseManager::addMouse(const QString &deviceNode)
@ -157,7 +157,7 @@ void QEvdevMouseManager::addMouse(const QString &deviceNode)
handler = QEvdevMouseHandler::create(deviceNode, m_spec);
if (handler) {
connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons)));
connect(handler, SIGNAL(handleWheelEvent(int,Qt::Orientation)), this, SLOT(handleWheelEvent(int,Qt::Orientation)));
connect(handler, SIGNAL(handleWheelEvent(QPoint)), this, SLOT(handleWheelEvent(QPoint)));
m_mice.insert(deviceNode, handler);
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
QInputDeviceManager::DeviceTypePointer, m_mice.count());

View File

@ -56,6 +56,7 @@
#include <QObject>
#include <QHash>
#include <QSocketNotifier>
#include <QPoint>
QT_BEGIN_NAMESPACE
@ -70,7 +71,7 @@ public:
public slots:
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
void handleWheelEvent(int delta, Qt::Orientation orientation);
void handleWheelEvent(QPoint delta);
private slots:
void addMouse(const QString &deviceNode = QString());

View File

@ -2190,14 +2190,18 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in
if (isWheel) {
if (!connection()->isAtLeastXI21()) {
// Logic borrowed from qapplication_x11.cpp
int delta = 120 * ((detail == 4 || detail == 6) ? 1 : -1);
bool hor = (((detail == 4 || detail == 5)
&& (modifiers & Qt::AltModifier))
|| (detail == 6 || detail == 7));
QWindowSystemInterface::handleWheelEvent(window(), timestamp,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical, modifiers);
QPoint angleDelta;
if (detail == 4)
angleDelta.setY(120);
else if (detail == 5)
angleDelta.setY(-120);
else if (detail == 6)
angleDelta.setX(120);
else if (detail == 7)
angleDelta.setX(-120);
if (modifiers & Qt::AltModifier)
std::swap(angleDelta.rx(), angleDelta.ry());
QWindowSystemInterface::handleWheelEvent(window(), timestamp, local, global, QPoint(), angleDelta, modifiers);
}
return;
}