summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@qt.io>2017-08-30 12:32:29 +0200
committerGatis Paeglis <gatis.paeglis@qt.io>2017-09-05 14:16:38 +0000
commit35ed524d9226cb705081737652d72d5cbb86e6c6 (patch)
tree10b3a9b313c0ddf4d2447d701765da5d3db0d22c /src/platformsupport/input
parent4250993c4280b80f472af77efa6cf77410b383c1 (diff)
evdev*,libinput: use functor-based connections
This results in less boilerplate code, among other benefits that come with functor-based connections. Simple expressions have been converted to use lambda. Change-Id: I6887980524027eada24beed95e6f9ba43f0fc8d5 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport/input')
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp2
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h2
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp6
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h2
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp3
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h5
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp30
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h4
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h3
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp7
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp7
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h2
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler.cpp14
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler_p.h6
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard_p.h3
18 files changed, 43 insertions, 59 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 562e7e2821..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()
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
index 79156645da..6cad4b9173 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
@@ -66,13 +66,12 @@ 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(QPoint delta);
-private slots:
- void readMouseData();
-
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 6264e4ada2..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()
@@ -153,11 +159,12 @@ void QEvdevMouseManager::handleWheelEvent(QPoint delta)
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(QPoint)), this, SLOT(handleWheelEvent(QPoint)));
+ 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 7cabfac0d8..10703655b3 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
@@ -64,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(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_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 8cce403b31..df2c079f24 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -229,7 +229,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;
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..142492ff02 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();
@@ -236,9 +239,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..6e01f972a4 100644
--- a/src/platformsupport/input/libinput/qlibinputhandler_p.h
+++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h
@@ -74,14 +74,12 @@ public:
QLibInputHandler(const QString &key, const QString &spec);
~QLibInputHandler();
+ void onReadyRead();
+
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: