7#include <QtGui/QGuiApplication>
8#include <QtGui/QPointingDevice>
9#include <QtGui/QScreen>
10#include <QtGui/QPointingDevice>
11#include <QtGui/private/qhighdpiscaling_p.h>
12#include <QtGui/private/qpointingdevice_p.h>
21 const int id =
qMax(0, slot);
23 for (
int i = 0;
i < m_points.size(); ++
i)
24 if (m_points.at(
i).id ==
id)
30QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e)
32 libinput_device *dev = libinput_event_get_device(libinput_event_touch_get_base_event(e));
33 return &m_devState[dev];
36QRect QLibInputTouch::screenGeometry(DeviceState *
state)
39 if (!
state->m_screenName.isEmpty()) {
43 if (
s->name() ==
state->m_screenName) {
55QPointF QLibInputTouch::getPos(libinput_event_touch *e)
59 const double x = libinput_event_touch_get_x_transformed(e, geom.
width());
60 const double y = libinput_event_touch_get_y_transformed(e, geom.
height());
66 if (libinput_device_config_calibration_has_matrix(dev)) {
76 for (
int i = 0;
i < 6;
i++) {
80 qCWarning(qLcLibInput,
"Invalid matrix entry %d %s ",
i,
list[
i].constData());
84 if (libinput_device_config_calibration_set_matrix(dev,
matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS)
85 qCWarning(qLcLibInput,
"Failed to set libinput calibration matrix ");
88 qCWarning(qLcLibInput,
"Touch device doesn't support matrix");
93 struct udev_device *udev_device;
94 udev_device = libinput_device_get_udev_device(dev);
98 qCDebug(qLcLibInput,
"libinput: registerDevice %s - %s",
104 m_devState[dev].m_screenName =
mapping->screenNameForDeviceNode(devNode);
105 if (!m_devState[dev].m_screenName.
isEmpty()) {
106 geom = screenGeometry(&m_devState[dev]);
107 qCDebug(qLcLibInput) <<
"libinput: Mapping device" << devNode
108 <<
"to screen" << m_devState[dev].m_screenName
109 <<
"with geometry" << geom;
120 devPriv->setAvailableVirtualGeometry(geom);
133 int slot = libinput_event_touch_get_slot(e);
134 DeviceState *
state = deviceState(e);
142 newTp.area =
QRect(0, 0, 8, 8);
143 newTp.area.moveCenter(getPos(e));
144 state->m_points.append(newTp);
145 qCDebug(qLcLibInputEvents) <<
"touch down" << newTp;
151 int slot = libinput_event_touch_get_slot(e);
152 DeviceState *
state = deviceState(e);
164 tp->
state = tmpState;
165 qCDebug(qLcLibInputEvents) <<
"touch move" << tp;
167 qWarning(
"Inconsistent touch state (got 'motion' without 'down')");
173 int slot = libinput_event_touch_get_slot(e);
174 DeviceState *
state = deviceState(e);
179 QEventPoint::States
s;
180 for (
int i = 0;
i <
state->m_points.size(); ++
i)
181 s |=
state->m_points.at(
i).state;
182 qCDebug(qLcLibInputEvents) <<
"touch up" <<
s << tp;
186 qCDebug(qLcLibInputEvents,
"waiting for all points to be released");
188 qWarning(
"Inconsistent touch state (got 'up' without 'down')");
194 DeviceState *
state = deviceState(e);
195 qCDebug(qLcLibInputEvents) <<
"touch cancel" <<
state->m_points;
196 if (
state->m_touchDevice)
199 qWarning(
"TouchCancel without registered device");
204 DeviceState *
state = deviceState(e);
205 if (!
state->m_touchDevice) {
206 qWarning(
"TouchFrame without registered device");
209 qCDebug(qLcLibInputEvents) <<
"touch frame" <<
state->m_points;
210 if (
state->m_points.isEmpty())
216 for (
int i = 0;
i <
state->m_points.size(); ++
i) {
219 state->m_points.removeAt(
i--);
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
QByteArray simplified() const &
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays.
State
Specifies the state of this event point.
QScreen * primaryScreen
the primary (or default) screen of the application.
static Qt::KeyboardModifiers keyboardModifiers()
Returns the current state of the modifier keys on the keyboard.
static QList< QScreen * > screens()
Returns a list of all the screens associated with the windowing system the application is connected t...
bool isEmpty() const noexcept
Returns true if the hash contains no items; otherwise returns false.
qsizetype length() const noexcept
static QOutputMapping * get()
\inmodule QtCore\reentrant
static QPointingDevicePrivate * get(QPointingDevice *q)
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
constexpr void moveCenter(const QPointF &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QScreen class is used to query screen properties. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QWindowSystemInterface provides an event queue for the QPA platform.
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static void registerInputDevice(const QInputDevice *device)
T toNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLenum GLenum GLenum GLenum mapping
#define qPrintable(string)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)