diff options
Diffstat (limited to 'src/platformsupport/input')
20 files changed, 78 insertions, 90 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 5c87cb7c9c..960f1d2f12 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -87,7 +87,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer // socket notifier for events on the keyboard device m_notify = new QSocketNotifier(m_fd.get(), QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readKeycode())); + connect(m_notify, &QSocketNotifier::activated, this, &QEvdevKeyboardHandler::readKeycode); } QEvdevKeyboardHandler::~QEvdevKeyboardHandler() diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 1ec4915855..7c64c4febb 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -145,7 +145,6 @@ public: class QEvdevKeyboardHandler : public QObject { - Q_OBJECT public: QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile); ~QEvdevKeyboardHandler(); @@ -190,7 +189,6 @@ public: bool loadKeymap(const QString &file); void unloadKeymap(); -private slots: void readKeycode(); KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 94ebae8f42..85e6a80879 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -88,8 +88,10 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & for (const QString &device : devices) addKeyboard(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString))); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevKeyboardManager::addKeyboard); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevKeyboardManager::removeKeyboard); } } } diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index d2e34fead3..27ea7e468e 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -63,14 +63,12 @@ QT_BEGIN_NAMESPACE class QEvdevKeyboardManager : public QObject { - Q_OBJECT public: QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevKeyboardManager(); void loadKeymap(const QString &file); -private slots: void addKeyboard(const QString &deviceNode = QString()); void removeKeyboard(const QString &deviceNode); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 9b4bcf1575..8614de066f 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -116,7 +116,8 @@ QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, // socket notifier for events on the mouse device m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); + connect(m_notify, &QSocketNotifier::activated, + this, &QEvdevMouseHandler::readMouseData); } QEvdevMouseHandler::~QEvdevMouseHandler() @@ -236,6 +237,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 +246,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. diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index eb34334b12..6cad4b9173 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -53,6 +53,7 @@ #include <QObject> #include <QString> +#include <QPoint> QT_BEGIN_NAMESPACE @@ -65,12 +66,11 @@ public: static QEvdevMouseHandler *create(const QString &device, const QString &specification); ~QEvdevMouseHandler(); + void readMouseData(); + signals: void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); - void handleWheelEvent(int delta, Qt::Orientation orientation); - -private slots: - void readMouseData(); + void handleWheelEvent(QPoint delta); private: QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index b2f3fe5787..ba94bcd460 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -94,13 +94,19 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif for (const QString &device : devices) addMouse(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString))); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevMouseManager::addMouse); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevMouseManager::removeMouse); } } - connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)), - this, SLOT(handleCursorPositionChange(QPoint))); + QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) { + m_x = pos.x(); + m_y = pos.y(); + clampPosition(); + }); } QEvdevMouseManager::~QEvdevMouseManager() @@ -144,20 +150,21 @@ 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) { qCDebug(qLcEvdevMouse) << "Adding mouse at" << deviceNode; - QEvdevMouseHandler *handler; - handler = QEvdevMouseHandler::create(deviceNode, m_spec); + QEvdevMouseHandler *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, &QEvdevMouseHandler::handleMouseEvent, + this, &QEvdevMouseManager::handleMouseEvent); + connect(handler, &QEvdevMouseHandler::handleWheelEvent, + this, &QEvdevMouseManager::handleWheelEvent); m_mice.insert(deviceNode, handler); QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( QInputDeviceManager::DeviceTypePointer, m_mice.count()); @@ -178,11 +185,4 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode) } } -void QEvdevMouseManager::handleCursorPositionChange(const QPoint &pos) -{ - m_x = pos.x(); - m_y = pos.y(); - clampPosition(); -} - QT_END_NAMESPACE diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index 08b5409d31..10703655b3 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -56,6 +56,7 @@ #include <QObject> #include <QHash> #include <QSocketNotifier> +#include <QPoint> QT_BEGIN_NAMESPACE @@ -63,19 +64,15 @@ class QDeviceDiscovery; class QEvdevMouseManager : public QObject { - Q_OBJECT public: QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevMouseManager(); -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()); void removeMouse(const QString &deviceNode); - void handleCursorPositionChange(const QPoint &pos); private: void clampPosition(); diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp index cfc17a79c3..dbab2f6a24 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp @@ -149,9 +149,11 @@ void QEvdevTabletData::report() qreal pressure = pressureRange ? (state.p - minValues.p) / qreal(pressureRange) : qreal(1); if (state.down || state.lastReportDown) { - QWindowSystemInterface::handleTabletEvent(0, state.down, QPointF(), globalPos, + QWindowSystemInterface::handleTabletEvent(0, QPointF(), globalPos, QTabletEvent::Stylus, pointer, - pressure, 0, 0, 0, 0, 0, q->deviceId(), qGuiApp->keyboardModifiers()); + state.down ? Qt::LeftButton : Qt::NoButton, + pressure, 0, 0, 0, 0, 0, q->deviceId(), + qGuiApp->keyboardModifiers()); } if (state.lastReportTool && !state.tool) diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h index 20dfda89f7..8d848d6ebb 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h @@ -63,15 +63,12 @@ class QEvdevTabletData; class QEvdevTabletHandler : public QObject { - Q_OBJECT - public: explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = 0); ~QEvdevTabletHandler(); qint64 deviceId() const; -private slots: void readData(); private: diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index 4b00424e92..90949408ac 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -88,8 +88,11 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); for (const QString &device : devices) addDevice(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); + + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevTabletManager::addDevice); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevTabletManager::removeDevice); } } } diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h index d166c06cf3..cde91c55aa 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h @@ -62,12 +62,10 @@ class QEvdevTabletHandlerThread; class QEvdevTabletManager : public QObject { - Q_OBJECT public: QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = 0); ~QEvdevTabletManager(); -private slots: void addDevice(const QString &deviceNode); void removeDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 5d839cced7..c7595cf2b3 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -231,7 +231,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const if (m_fd >= 0) { m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData())); + connect(m_notify, &QSocketNotifier::activated, this, &QEvdevTouchScreenHandler::readData); } else { qErrnoWarning(errno, "evdevtouch: Cannot open input device %s", qPrintable(device)); return; @@ -885,7 +885,7 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() } QList<QWindowSystemInterface::TouchPoint> points = m_handler->d->m_touchPoints; - const QList<QWindowSystemInterface::TouchPoint> &lastPoints = m_handler->d->m_lastTouchPoints; + QList<QWindowSystemInterface::TouchPoint> lastPoints = m_handler->d->m_lastTouchPoints; m_handler->d->m_mutex.unlock(); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h index d22aca3266..a0b689a89e 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h @@ -82,7 +82,6 @@ public: bool isFiltered() const; -private slots: void readData(); signals: @@ -116,7 +115,6 @@ public: bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; -public slots: void scheduleTouchPointUpdate(); signals: diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index ab71d08fb1..4cacbf03e5 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -88,8 +88,11 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); for (const QString &device : devices) addDevice(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); + + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevTouchManager::addDevice); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevTouchManager::removeDevice); } } } diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h index 84e857ca57..e524c516f1 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h @@ -62,12 +62,10 @@ class QEvdevTouchScreenHandlerThread; class QEvdevTouchManager : public QObject { - Q_OBJECT public: QEvdevTouchManager(const QString &key, const QString &spec, QObject *parent = 0); ~QEvdevTouchManager(); -private slots: void addDevice(const QString &deviceNode); void removeDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 961eb3539f..733cf7d409 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -107,14 +107,17 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec) m_liFd = libinput_get_fd(m_li); m_notifier.reset(new QSocketNotifier(m_liFd, QSocketNotifier::Read)); - connect(m_notifier.data(), SIGNAL(activated(int)), SLOT(onReadyRead())); + + connect(m_notifier.data(), &QSocketNotifier::activated, this, &QLibInputHandler::onReadyRead); m_pointer.reset(new QLibInputPointer); m_keyboard.reset(new QLibInputKeyboard); m_touch.reset(new QLibInputTouch); - connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)), - this, SLOT(onCursorPositionChangeRequested(QPoint))); + QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) { + m_pointer->setPos(pos); + }); // Process the initial burst of DEVICE_ADDED events. onReadyRead(); @@ -154,10 +157,6 @@ void QLibInputHandler::processEvent(libinput_event *ev) // This is not just for hotplugging, it is also called for each input // device libinput reads from on startup. Hence it is suitable for doing // touch device registration. - const char *sysname = libinput_device_get_sysname(dev); // node name without path - const char *name = libinput_device_get_name(dev); - emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name)); - QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( QGuiApplicationPrivate::inputDeviceManager()); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { @@ -180,10 +179,6 @@ void QLibInputHandler::processEvent(libinput_event *ev) } case LIBINPUT_EVENT_DEVICE_REMOVED: { - const char *sysname = libinput_device_get_sysname(dev); - const char *name = libinput_device_get_name(dev); - emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name)); - QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( QGuiApplicationPrivate::inputDeviceManager()); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { @@ -236,9 +231,4 @@ void QLibInputHandler::processEvent(libinput_event *ev) } } -void QLibInputHandler::onCursorPositionChangeRequested(const QPoint &pos) -{ - m_pointer->setPos(pos); -} - QT_END_NAMESPACE diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h index f3dcf0f0be..ac7a267a4d 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler_p.h +++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h @@ -68,19 +68,11 @@ class QLibInputTouch; class QLibInputHandler : public QObject { - Q_OBJECT - public: QLibInputHandler(const QString &key, const QString &spec); ~QLibInputHandler(); -signals: - void deviceAdded(const QString &sysname, const QString &name); - void deviceRemoved(const QString &sysname, const QString &name); - -private slots: void onReadyRead(); - void onCursorPositionChangeRequested(const QPoint &pos); private: void processEvent(libinput_event *ev); diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h index 12a3eb06eb..b7ee8a363f 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h +++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h @@ -64,8 +64,6 @@ QT_BEGIN_NAMESPACE class QLibInputKeyboard : public QObject { - Q_OBJECT - public: QLibInputKeyboard(); ~QLibInputKeyboard(); @@ -73,7 +71,6 @@ public: void processKey(libinput_event_keyboard *e); #ifndef QT_NO_XKBCOMMON_EVDEV -private slots: void handleRepeat(); private: diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index bdeac8db7e..6879d0cd83 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -96,21 +96,28 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e) void QLibInputPointer::processAxis(libinput_event_pointer *e) { + double value; // default axis value is 15 degrees per wheel click + QPoint angleDelta; #if !QT_CONFIG(libinput_axis_api) - const double v = libinput_event_pointer_get_axis_value(e) * 120; - const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL - ? Qt::Vertical : Qt::Horizontal; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), ori, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e); + if (libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) + angleDelta.setY(qRound(value)); + else + angleDelta.setX(qRound(value)); #else if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { - const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) * 120; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Vertical, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + angleDelta.setY(qRound(value)); } if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { - const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) * 120; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Horizontal, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + angleDelta.setX(qRound(value)); } #endif + const int factor = 8; + angleDelta *= -factor; + Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods); } void QLibInputPointer::setPos(const QPoint &pos) |