xcb: Map touch points to screen coordinates
Add QPointF overloads for QXcbScreen::mapToNative() and QXcbScreen::mapFromNative(). Use mapFromNative() to map the coordinates of a touch point to screen coordinates as we do it for mouse events. It fixes touch events when QT_DEVICE_PIXEL_RATIO is set. Change-Id: Id8362cda526e0f837b76899eba21d9bfc895988c Task-number: QTBUG-44840 Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>bb10
parent
de81159574
commit
36df3305f9
|
|
@ -562,10 +562,12 @@ void QXcbConnection::xi2ProcessTouch(void *xiDevEvent, QXcbWindow *platformWindo
|
|||
dev->touchPoints[tp.id] = tp;
|
||||
}
|
||||
QWindowSystemInterface::TouchPoint &touchPoint = dev->touchPoints[xiDeviceEvent->detail];
|
||||
qreal x = fixed1616ToReal(xiDeviceEvent->root_x);
|
||||
qreal y = fixed1616ToReal(xiDeviceEvent->root_y);
|
||||
QXcbScreen* screen = platformWindow->xcbScreen();
|
||||
QPointF pos = screen->mapFromNative(QPointF(fixed1616ToReal(xiDeviceEvent->root_x),
|
||||
fixed1616ToReal(xiDeviceEvent->root_y)));
|
||||
qreal x = pos.x();
|
||||
qreal y = pos.y();
|
||||
qreal nx = -1.0, ny = -1.0, d = 0.0;
|
||||
QXcbScreen* screen = m_screens.at(0);
|
||||
for (int i = 0; i < dev->xiDeviceInfo->num_classes; ++i) {
|
||||
XIAnyClassInfo *classinfo = dev->xiDeviceInfo->classes[i];
|
||||
if (classinfo->type == XIValuatorClass) {
|
||||
|
|
|
|||
|
|
@ -282,6 +282,18 @@ QPoint QXcbScreen::mapFromNative(const QPoint &pos) const
|
|||
return (pos - m_nativeGeometry.topLeft()) / dpr + m_geometry.topLeft();
|
||||
}
|
||||
|
||||
QPointF QXcbScreen::mapToNative(const QPointF &pos) const
|
||||
{
|
||||
const int dpr = int(devicePixelRatio());
|
||||
return (pos - m_geometry.topLeft()) * dpr + m_nativeGeometry.topLeft();
|
||||
}
|
||||
|
||||
QPointF QXcbScreen::mapFromNative(const QPointF &pos) const
|
||||
{
|
||||
const int dpr = int(devicePixelRatio());
|
||||
return (pos - m_nativeGeometry.topLeft()) / dpr + m_geometry.topLeft();
|
||||
}
|
||||
|
||||
QRect QXcbScreen::mapToNative(const QRect &rect) const
|
||||
{
|
||||
const int dpr = int(devicePixelRatio());
|
||||
|
|
|
|||
|
|
@ -143,6 +143,8 @@ public:
|
|||
|
||||
QPoint mapToNative(const QPoint &pos) const;
|
||||
QPoint mapFromNative(const QPoint &pos) const;
|
||||
QPointF mapToNative(const QPointF &pos) const;
|
||||
QPointF mapFromNative(const QPointF &pos) const;
|
||||
QRect mapToNative(const QRect &rect) const;
|
||||
QRect mapFromNative(const QRect &rect) const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue