diff options
Diffstat (limited to 'src/platformsupport/input')
13 files changed, 53 insertions, 36 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 960f1d2f12..2d6426db7f 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -71,7 +71,7 @@ void QFdContainer::reset() Q_DECL_NOTHROW } QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile) - : m_device(device), m_fd(fd.release()), m_notify(Q_NULLPTR), + : m_device(device), m_fd(fd.release()), m_notify(nullptr), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff), m_no_zap(disableZap), m_do_compose(enableCompose), m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0) @@ -172,7 +172,7 @@ void QEvdevKeyboardHandler::readKeycode() // by the above error over and over again. if (errno == ENODEV) { delete m_notify; - m_notify = Q_NULLPTR; + m_notify = nullptr; m_fd.reset(); } return; diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 8614de066f..04372ae4d9 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -184,7 +184,7 @@ void QEvdevMouseHandler::sendMouseEvent() m_prevInvalid = false; } - emit handleMouseEvent(x, y, m_abs, m_buttons); + emit handleMouseEvent(x, y, m_abs, m_buttons, m_button, m_eventType); m_prevx = m_x; m_prevy = m_y; @@ -210,7 +210,7 @@ void QEvdevMouseHandler::readMouseData() // by the above error over and over again. if (errno == ENODEV) { delete m_notify; - m_notify = Q_NULLPTR; + m_notify = nullptr; qt_safe_close(m_fd); m_fd = -1; } @@ -286,6 +286,8 @@ void QEvdevMouseHandler::readMouseData() case 0x11f: button = Qt::ExtraButton13; break; } m_buttons.setFlag(button, data->value); + m_button = button; + m_eventType = data->value == 0 ? QEvent::MouseButtonRelease : QEvent::MouseButtonPress; btnChanged = true; } else if (data->type == EV_SYN && data->code == SYN_REPORT) { if (btnChanged) { @@ -293,6 +295,7 @@ void QEvdevMouseHandler::readMouseData() sendMouseEvent(); pendingMouseEvent = false; } else if (posChanged) { + m_eventType = QEvent::MouseMove; posChanged = false; if (m_compression) { pendingMouseEvent = true; diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 6cad4b9173..c7f2b04eb2 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -54,6 +54,7 @@ #include <QObject> #include <QString> #include <QPoint> +#include <QEvent> QT_BEGIN_NAMESPACE @@ -69,7 +70,8 @@ public: void readMouseData(); signals: - void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); + void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons, + Qt::MouseButton button, QEvent::Type type); void handleWheelEvent(QPoint delta); private: @@ -86,6 +88,8 @@ private: bool m_abs; bool m_compression; Qt::MouseButtons m_buttons; + Qt::MouseButton m_button; + QEvent::Type m_eventType; int m_jitterLimitSquared; bool m_prevInvalid; int m_hardwareWidth; diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index ba94bcd460..5264736dd6 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -131,7 +131,8 @@ void QEvdevMouseManager::clampPosition() m_y = g.bottom() - m_yoffset; } -void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons) +void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons, + Qt::MouseButton button, QEvent::Type type) { // update current absolute coordinates if (!abs) { @@ -147,7 +148,8 @@ void QEvdevMouseManager::handleMouseEvent(int x, int y, bool abs, Qt::MouseButto QPoint pos(m_x + m_xoffset, m_y + m_yoffset); // Cannot track the keyboard modifiers ourselves here. Instead, report the // modifiers from the last key event that has been seen by QGuiApplication. - QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, QGuiApplication::keyboardModifiers()); + Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + QWindowSystemInterface::handleMouseEvent(0, pos, pos, buttons, button, type, mods); } void QEvdevMouseManager::handleWheelEvent(QPoint delta) diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index 10703655b3..13a8e3dec5 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -68,7 +68,8 @@ public: QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevMouseManager(); - void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); + void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons, + Qt::MouseButton button, QEvent::Type type); void handleWheelEvent(QPoint delta); void addMouse(const QString &deviceNode = QString()); diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h index 8d848d6ebb..66e821117a 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h @@ -85,7 +85,7 @@ class QEvdevTabletHandlerThread : public QDaemonThread public: explicit QEvdevTabletHandlerThread(const QString &device, const QString &spec, QObject *parent = 0); ~QEvdevTabletHandlerThread(); - void run() Q_DECL_OVERRIDE; + void run() override; QEvdevTabletHandler *handler() { return m_handler; } private: diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index c7595cf2b3..0ab4c65c45 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -192,9 +192,9 @@ static inline bool testBit(long bit, const long *array) #endif QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const QString &spec, QObject *parent) - : QObject(parent), m_notify(Q_NULLPTR), m_fd(-1), d(Q_NULLPTR), m_device(Q_NULLPTR) + : QObject(parent), m_notify(nullptr), m_fd(-1), d(nullptr), m_device(nullptr) #if QT_CONFIG(mtdev) - , m_mtdev(Q_NULLPTR) + , m_mtdev(nullptr) #endif { setObjectName(QLatin1String("Evdev Touch Handler")); @@ -427,7 +427,7 @@ err: qErrnoWarning(errno, "evdevtouch: Could not read from input device"); if (errno == ENODEV) { // device got disconnected -> stop reading delete m_notify; - m_notify = Q_NULLPTR; + m_notify = nullptr; QT_CLOSE(m_fd); m_fd = -1; @@ -466,7 +466,7 @@ void QEvdevTouchScreenHandler::unregisterTouchDevice() delete m_device; } - m_device = Q_NULLPTR; + m_device = nullptr; } void QEvdevTouchScreenData::addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates) @@ -781,13 +781,13 @@ void QEvdevTouchScreenData::reportPoints() if (m_filtered) emit q->touchPointsUpdated(); else - QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, q->touchDevice(), m_touchPoints); + QWindowSystemInterface::handleTouchEvent(nullptr, q->touchDevice(), m_touchPoints); } QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent) - : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(Q_NULLPTR), m_touchDeviceRegistered(false) + : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(nullptr), m_touchDeviceRegistered(false) , m_touchUpdatePending(false) - , m_filterWindow(Q_NULLPTR) + , m_filterWindow(nullptr) , m_touchRate(-1) { start(); @@ -812,7 +812,7 @@ void QEvdevTouchScreenHandlerThread::run() exec(); delete m_handler; - m_handler = Q_NULLPTR; + m_handler = nullptr; } bool QEvdevTouchScreenHandlerThread::isTouchDeviceRegistered() const @@ -953,7 +953,7 @@ void QEvdevTouchScreenHandlerThread::filterAndSendTouchPoints() m_filteredPoints = filteredPoints; - QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, + QWindowSystemInterface::handleTouchEvent(nullptr, m_handler->touchDevice(), points); } diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h index a0b689a89e..56308d0352 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h @@ -75,7 +75,7 @@ class QEvdevTouchScreenHandler : public QObject Q_OBJECT public: - explicit QEvdevTouchScreenHandler(const QString &device, const QString &spec = QString(), QObject *parent = Q_NULLPTR); + explicit QEvdevTouchScreenHandler(const QString &device, const QString &spec = QString(), QObject *parent = nullptr); ~QEvdevTouchScreenHandler(); QTouchDevice *touchDevice() const; @@ -107,13 +107,13 @@ class QEvdevTouchScreenHandlerThread : public QDaemonThread { Q_OBJECT public: - explicit QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent = Q_NULLPTR); + explicit QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent = nullptr); ~QEvdevTouchScreenHandlerThread(); - void run() Q_DECL_OVERRIDE; + void run() override; bool isTouchDeviceRegistered() const; - bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; + bool eventFilter(QObject *object, QEvent *event) override; void scheduleTouchPointUpdate(); diff --git a/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp b/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp index 8089a6e38b..e472693077 100644 --- a/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp +++ b/src/platformsupport/input/integrityhid/qintegrityhidmanager.cpp @@ -75,8 +75,8 @@ public: { CheckSuccess(gh_hid_close(handle)); }; - void process_event(void) Q_DECL_OVERRIDE; - void async_wait(void) Q_DECL_OVERRIDE; + void process_event(void) override; + void async_wait(void) override; HIDDriver *get_driver(void) { return driver; }; HIDHandle get_handle(void) { return handle; }; private: @@ -94,8 +94,8 @@ public: { qDeleteAll(devices); }; - void process_event(void) Q_DECL_OVERRIDE; - void async_wait(void) Q_DECL_OVERRIDE; + void process_event(void) override; + void async_wait(void) override; void find_devices(void); private: QHash<Value, HIDDeviceHandler *> devices; diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 733cf7d409..52eaa18f4b 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -94,7 +94,7 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec) if (Q_UNLIKELY(!m_udev)) qFatal("Failed to get udev context for libinput"); - m_li = libinput_udev_create_context(&liInterface, Q_NULLPTR, m_udev); + m_li = libinput_udev_create_context(&liInterface, nullptr, m_udev); if (Q_UNLIKELY(!m_li)) qFatal("Failed to get libinput context"); @@ -140,7 +140,7 @@ void QLibInputHandler::onReadyRead() } libinput_event *ev; - while ((ev = libinput_get_event(m_li)) != Q_NULLPTR) { + while ((ev = libinput_get_event(m_li)) != nullptr) { processEvent(ev); libinput_event_destroy(ev); } diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp index f14a2e8f04..21f7fde7c8 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard.cpp +++ b/src/platformsupport/input/libinput/qlibinputkeyboard.cpp @@ -143,7 +143,7 @@ QLibInputKeyboard::QLibInputKeyboard() qWarning("Failed to create xkb context"); return; } - m_keymap = xkb_keymap_new_from_names(m_ctx, Q_NULLPTR, XKB_KEYMAP_COMPILE_NO_FLAGS); + m_keymap = xkb_keymap_new_from_names(m_ctx, nullptr, XKB_KEYMAP_COMPILE_NO_FLAGS); if (!m_keymap) { qWarning("Failed to compile keymap"); return; @@ -211,7 +211,7 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e) xkb_state_update_key(m_state, k, pressed ? XKB_KEY_DOWN : XKB_KEY_UP); - QWindowSystemInterface::handleExtendedKeyEvent(Q_NULLPTR, + QWindowSystemInterface::handleExtendedKeyEvent(nullptr, pressed ? QEvent::KeyPress : QEvent::KeyRelease, qtkey, mods, k, sym, mods, text); @@ -237,7 +237,7 @@ void QLibInputKeyboard::processKey(libinput_event_keyboard *e) #ifndef QT_NO_XKBCOMMON_EVDEV void QLibInputKeyboard::handleRepeat() { - QWindowSystemInterface::handleExtendedKeyEvent(Q_NULLPTR, QEvent::KeyPress, + QWindowSystemInterface::handleExtendedKeyEvent(nullptr, QEvent::KeyPress, m_repeatData.qtkey, m_repeatData.mods, m_repeatData.nativeScanCode, m_repeatData.virtualKey, m_repeatData.nativeMods, m_repeatData.unicodeText, true, m_repeatData.repeatCount); diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index 6879d0cd83..12379a83fa 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -39,6 +39,7 @@ #include "qlibinputpointer_p.h" #include <libinput.h> +#include <QtCore/QEvent> #include <QtGui/QGuiApplication> #include <QtGui/QScreen> #include <qpa/qwindowsysteminterface.h> @@ -78,7 +79,10 @@ void QLibInputPointer::processButton(libinput_event_pointer *e) m_buttons.setFlag(button, pressed); - QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers()); + QEvent::Type type = pressed ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease; + Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + + QWindowSystemInterface::handleMouseEvent(nullptr, m_pos, m_pos, m_buttons, button, type, mods); } void QLibInputPointer::processMotion(libinput_event_pointer *e) @@ -91,7 +95,10 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e) m_pos.setX(qBound(g.left(), qRound(m_pos.x() + dx), g.right())); m_pos.setY(qBound(g.top(), qRound(m_pos.y() + dy), g.bottom())); - QWindowSystemInterface::handleMouseEvent(Q_NULLPTR, m_pos, m_pos, m_buttons, QGuiApplication::keyboardModifiers()); + Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + + QWindowSystemInterface::handleMouseEvent(nullptr, m_pos, m_pos, m_buttons, + Qt::NoButton, QEvent::MouseMove, mods); } void QLibInputPointer::processAxis(libinput_event_pointer *e) diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp index 42925a18e1..a65bc91c39 100644 --- a/src/platformsupport/input/libinput/qlibinputtouch.cpp +++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp @@ -53,7 +53,7 @@ QWindowSystemInterface::TouchPoint *QLibInputTouch::DeviceState::point(int32_t s if (m_points.at(i).id == id) return &m_points[i]; - return Q_NULLPTR; + return nullptr; } QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e) @@ -150,7 +150,7 @@ void QLibInputTouch::processTouchCancel(libinput_event_touch *e) { DeviceState *state = deviceState(e); if (state->m_touchDevice) - QWindowSystemInterface::handleTouchCancelEvent(Q_NULLPTR, state->m_touchDevice, QGuiApplication::keyboardModifiers()); + QWindowSystemInterface::handleTouchCancelEvent(nullptr, state->m_touchDevice, QGuiApplication::keyboardModifiers()); else qWarning("TouchCancel without registered device"); } @@ -165,7 +165,7 @@ void QLibInputTouch::processTouchFrame(libinput_event_touch *e) if (state->m_points.isEmpty()) return; - QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, state->m_touchDevice, state->m_points, + QWindowSystemInterface::handleTouchEvent(nullptr, state->m_touchDevice, state->m_points, QGuiApplication::keyboardModifiers()); for (int i = 0; i < state->m_points.count(); ++i) { |