summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/input/evdevtablet/qevdevtablet.cpp')
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablet.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
index bd513e4b53..749cfcd8cc 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
@@ -56,6 +56,7 @@ class QEvdevTabletData
public:
QEvdevTabletData(QEvdevTabletHandler *q_ptr);
bool queryLimits();
+ void testGrab();
void processInputEvent(input_event *ev);
void reportProximityEnter();
void reportProximityLeave();
@@ -120,6 +121,15 @@ bool QEvdevTabletData::queryLimits()
return ok;
}
+void QEvdevTabletData::testGrab()
+{
+ bool grabSuccess = !ioctl(fd, EVIOCGRAB, (void *) 1);
+ if (grabSuccess)
+ ioctl(fd, EVIOCGRAB, (void *) 0);
+ else
+ qWarning("evdevtablet: ERROR: The device is grabbed by another process. No events will be read.");
+}
+
void QEvdevTabletData::processInputEvent(input_event *ev)
{
if (ev->type == EV_ABS) {
@@ -232,9 +242,14 @@ QEvdevTabletHandler::QEvdevTabletHandler(const QString &spec, QObject *parent)
if (!dev.isEmpty()) {
qDebug("evdevtablet: using %s", qPrintable(dev));
d->fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
- if (d->fd >= 0 && d->queryLimits()) {
- d->notifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, this);
- connect(d->notifier, SIGNAL(activated(int)), this, SLOT(readData()));
+ if (d->fd >= 0) {
+ d->testGrab();
+ if (d->queryLimits()) {
+ d->notifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, this);
+ connect(d->notifier, SIGNAL(activated(int)), this, SLOT(readData()));
+ }
+ } else {
+ qErrnoWarning(errno, "evdevtablet: Cannot open input device");
}
}
}