Add QInputDevice::availableVirtualGeometry()
This property tells what part of the virtual desktop the input device can access. This is not a one-to-one mapping with a QScreen, because a Wacom tablet might be configured to access a whole desktop, a whole screen, or an area corresponding to the drawing area of one window; a mouse normally can access the whole desktop (so QScreen::virtualGeometry() would be identical to QInputDevice::availableVirtualGeometry()); a touchscreen normally is mapped to one screen but could be mapped differently; etc. It's possible to find the intersection of the rectangular area with the screen(s) that it overlaps, though. Task-number: QTBUG-78839 Change-Id: I9040e20fb5a3dec8a9a0dd827735826c4c1eea38 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
parent
8dd6957cd7
commit
546e44d473
@ -112,6 +112,29 @@ QInputDevice::QInputDevice(QInputDevicePrivate &d, QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the region within the \l{QScreen::availableVirtualGeometry}{virtual desktop}
|
||||
that this device can access.
|
||||
|
||||
For example a \l {QInputDevice::DeviceType::TouchScreen}{TouchScreen} input
|
||||
device is fixed in place upon a single physical screen, and usually
|
||||
calibrated so that this area is the same as QScreen::geometry(); whereas a
|
||||
\l {QInputDevice::DeviceType::Mouse}{Mouse} can probably access all screens
|
||||
on the virtual desktop. A Wacom graphics tablet may be configured in a way
|
||||
that it's mapped to all screens, or only to the screen where the user
|
||||
prefers to create drawings, or to the window in which drawing occurs.
|
||||
A \l {QInputDevice::DeviceType::Stylus}{Stylus} device that is integrated
|
||||
with a touchscreen may be physically limited to that screen.
|
||||
|
||||
If the returned rectangle is \l {null}{QRect::isNull()}, it means this device
|
||||
can access the entire virtual desktop.
|
||||
*/
|
||||
QRect QInputDevice::availableVirtualGeometry() const
|
||||
{
|
||||
Q_D(const QInputDevice);
|
||||
return d->availableVirtualGeometry;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the device name.
|
||||
|
||||
|
@ -58,6 +58,7 @@ class Q_GUI_EXPORT QInputDevice : public QObject
|
||||
Q_PROPERTY(Capabilities capabilities READ capabilities CONSTANT)
|
||||
Q_PROPERTY(qint64 id READ id CONSTANT)
|
||||
Q_PROPERTY(QString seatName READ seatName CONSTANT)
|
||||
Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry NOTIFY availableVirtualGeometryChanged)
|
||||
|
||||
public:
|
||||
enum class DeviceType : qint16 {
|
||||
@ -106,12 +107,16 @@ public:
|
||||
bool hasCapability(Capability cap) const;
|
||||
qint64 id() const;
|
||||
QString seatName() const;
|
||||
QRect availableVirtualGeometry() const;
|
||||
|
||||
static QList<const QInputDevice *> devices();
|
||||
static const QInputDevice *primaryKeyboard(const QString& seatName = QString());
|
||||
|
||||
bool operator==(const QInputDevice &other) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void availableVirtualGeometryChanged(QRect area);
|
||||
|
||||
protected:
|
||||
QInputDevice(QInputDevicePrivate &d, QObject *parent = nullptr);
|
||||
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
QString name;
|
||||
QString seatName;
|
||||
QString busId;
|
||||
QRect availableVirtualGeometry;
|
||||
void *extra = nullptr; // The QPA plugin can store arbitrary device-specific data here
|
||||
void *qqExtra = nullptr; // Qt Quick can store arbitrary device-specific data here
|
||||
qint64 id = 0;
|
||||
@ -89,6 +90,17 @@ public:
|
||||
static bool isRegistered(const QInputDevice *dev);
|
||||
static const QInputDevice *fromId(qint64 id); // window system ID (e.g. xinput id), not QPointingDeviceUniqueId
|
||||
|
||||
void setAvailableVirtualGeometry(QRect a)
|
||||
{
|
||||
if (a == availableVirtualGeometry)
|
||||
return;
|
||||
|
||||
availableVirtualGeometry = a;
|
||||
capabilities |= qint32(QInputDevice::Capability::NormalizedPosition);
|
||||
Q_Q(QInputDevice);
|
||||
emit q->availableVirtualGeometryChanged(availableVirtualGeometry);
|
||||
}
|
||||
|
||||
inline static QInputDevicePrivate *get(QInputDevice *q)
|
||||
{
|
||||
return static_cast<QInputDevicePrivate *>(QObjectPrivate::get(q));
|
||||
|
Loading…
x
Reference in New Issue
Block a user