summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-06-18 09:52:19 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-06-19 08:13:36 +0200
commitf25bd998a7250bdd6c0cb1ee542757f20092f0a7 (patch)
treed9650ce968b08bba05326ba35b24a867f911f8e0
parent97af1b839c04dbd83b5ba5bec138dd4718d4491a (diff)
Don't return a touchscreen from QPointingDevice::primaryPointingDevice()
This was causing some bogus failures in Qt Quick autotests. Existing APIs like QQuickWindow::mouseGrabberItem() are not really compatible with the idea of a mouse-less system; but perhaps we can revisit this later. Task-number: QTBUG-85114 Change-Id: Id1c2e5894e5cf13a79998aaea28d5f42fad920cf Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--src/gui/kernel/qpointingdevice.cpp24
-rw-r--r--tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp2
2 files changed, 11 insertions, 15 deletions
diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp
index e1a66d522b..5f4b6e0fd8 100644
--- a/src/gui/kernel/qpointingdevice.cpp
+++ b/src/gui/kernel/qpointingdevice.cpp
@@ -301,17 +301,18 @@ QPointingDeviceUniqueId QPointingDevice::uniqueId() const
Returns the primary pointing device (the core pointer, traditionally
assumed to be a mouse) on the given seat \a seatName.
- If multiple pointing devices are registered, this function prefers a
- mouse, touchpad, or touchscreen (in that order) that matches the given
- \a seatName and that does not have another device as its parent.
- Usually only one master or core device does not have a parent device.
+ If multiple pointing devices are registered, this function prefers a mouse
+ or touchpad that matches the given \a seatName and that does not have
+ another device as its parent. Usually only one master or core device does
+ not have a parent device. But if such a device is not found, this function
+ creates a new virtual "core pointer" mouse. Thus Qt continues to work on
+ platforms that are not yet doing input device discovery and registration.
*/
const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& seatName)
{
const auto v = devices();
const QPointingDevice *mouse = nullptr;
const QPointingDevice *touchpad = nullptr;
- const QPointingDevice *touchscreen = nullptr;
for (const QInputDevice *dev : v) {
if (dev->seatName() != seatName)
continue;
@@ -324,13 +325,10 @@ const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& sea
} else if (dev->type() == QInputDevice::DeviceType::TouchPad) {
if (!touchpad || !dev->parent() || dev->parent()->metaObject() != dev->metaObject())
touchpad = static_cast<const QPointingDevice *>(dev);
- } else if (dev->type() == QInputDevice::DeviceType::TouchScreen) {
- if (!touchscreen || !dev->parent() || dev->parent()->metaObject() != dev->metaObject())
- touchscreen = static_cast<const QPointingDevice *>(dev);
}
}
- if (!mouse && !touchpad && !touchscreen) {
- qWarning() << "no pointing devices registered for seat" << seatName
+ if (!mouse && !touchpad) {
+ qWarning() << "no mouse-like devices registered for seat" << seatName
<< "The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default mouse for now.";
mouse = new QPointingDevice(QLatin1String("core pointer"), 1, DeviceType::Mouse,
@@ -339,12 +337,10 @@ const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& sea
return mouse;
}
if (v.length() > 1)
- qCWarning(lcQpaInputDevices) << "core pointer ambiguous for seat" << seatName;
+ qCDebug(lcQpaInputDevices) << "core pointer ambiguous for seat" << seatName;
if (mouse)
return mouse;
- if (touchpad)
- return touchpad;
- return touchscreen;
+ return touchpad;
}
/*!
diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
index e34961aef7..a46a72532a 100644
--- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
+++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
@@ -66,7 +66,7 @@ void tst_QInputDevice::multiSeatDevices()
QVERIFY(!QInputDevicePrivate::fromId(2010)->hasCapability(QInputDevice::Capability::Scroll));
QTest::ignoreMessage(QtWarningMsg, "no keyboards registered for seat \"\" The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default one for now.");
- QTest::ignoreMessage(QtWarningMsg, "no pointing devices registered for seat \"\" The platform plugin should have provided one via "
+ QTest::ignoreMessage(QtWarningMsg, "no mouse-like devices registered for seat \"\" The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default mouse for now.");
QVERIFY(QInputDevice::primaryKeyboard());
QCOMPARE(QInputDevice::primaryKeyboard()->id(), 0);