diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-05-29 17:32:46 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-07-13 11:30:40 +0000 |
commit | 7499d4404f9eb7223674cd0523f35eff1be7c1c9 (patch) | |
tree | 6b89754be808b1d99efb4394f0d7fd738780e088 /src/plugins/platforms/xcb/qxcbconnection.h | |
parent | 545458cb77c532500f859764f78eaf35b49c8005 (diff) |
xcb: don't keep objects for disconnected touch devices
... as XI2 reuses device ids and we might end up with some bogus
objects in m_touchDevices (the same touch device after reconnecting
might have a new device id).
With this patch, m_touchDevices is handled similarly to tablets
and scolling devices. This patch also removes unnecessary calls
to X (XIQueryDevice). We already have device information available
for all devices when populating m_touchDevices list, so calling
XIQueryDevice again for every device id (which we haven't already
concluded to be a tablet device) is a redundant round trip to X.
For consistency with other device types, extend touch device data
structure to store the necessary device details, instead of holding
pointers to XIDeviceInfo. And allocate touch device objects on
stack instead of heap, also for the consistency reasons (this way
we won't need to special case m_touchDevices when running some
management task on _all_ devices, e.g. removing a device with id=n
when it was disconnected).
Change-Id: I9f6edfaf24da911dd21ec45cd48dfdd6d0dcdf8b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.h')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index fd77d56588..846c491401 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -79,7 +79,6 @@ #define XCB_USE_XINPUT22 // XI 2.2 adds multi-point touch support #endif #endif -struct XInput2TouchDeviceData; #endif // QT_CONFIG(xinput2) struct xcb_randr_get_output_info_reply_t; @@ -518,7 +517,7 @@ public: #ifdef XCB_USE_XINPUT22 bool xi2MouseEvents() const; - bool isTouchScreen(int id) const; + bool isTouchScreen(int id); #endif protected: @@ -556,9 +555,27 @@ private: bool m_xi2Enabled = false; int m_xi2Minor = 2; void initializeXInput2(); - void finalizeXInput2(); void xi2SetupDevices(); - XInput2TouchDeviceData *touchDeviceForId(int id); + struct TouchDeviceData { + QTouchDevice *qtTouchDevice = nullptr; + QHash<int, QWindowSystemInterface::TouchPoint> touchPoints; + QHash<int, QPointF> pointPressedPosition; // in screen coordinates where each point was pressed + struct ValuatorClassInfo { + double min = 0; + double max = 0; + int number = -1; + QXcbAtom::Atom label; + }; + QVector<ValuatorClassInfo> valuatorInfo; + + // Stuff that is relevant only for touchpads + QPointF firstPressedPosition; // in screen coordinates where the first point was pressed + QPointF firstPressedNormalPosition; // device coordinates (0 to 1, 0 to 1) where the first point was pressed + QSizeF size; // device size in mm + bool providesTouchOrientation = false; + }; + TouchDeviceData *populateTouchDevices(void *info); + TouchDeviceData *touchDeviceForId(int id); void xi2HandleEvent(xcb_ge_event_t *event); void xi2HandleHierachyEvent(void *event); void xi2HandleDeviceChangedEvent(void *event); @@ -637,8 +654,9 @@ private: void *m_xlib_display = nullptr; #endif QXcbEventReader *m_reader = nullptr; + #if QT_CONFIG(xinput2) - QHash<int, XInput2TouchDeviceData*> m_touchDevices; + QHash<int, TouchDeviceData> m_touchDevices; #ifdef XCB_USE_XINPUT22 struct StartSystemResizeInfo { xcb_window_t window; |