Store the primary status in the touch point flags.
For some reason the primary bit has previously been encoded in the touch point state, even though it has nothing to do with the regular states like Pressed, Released, etc. The value is now stored in the recently introduced flags member of the touch points. This also reduces the need for error-prone internal masking of the state value. The structure used by QWindowSystemInterface::handleTouchEvent also becomes cleaner because the primary status can now be set in the flags member and the isPrimary bool can be dropped. Change-Id: I1da2cb99154afd97e1e3a5943ab115cae3a8232f Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>bb10
parent
67be01ae50
commit
6f1c4fb342
|
|
@ -1495,10 +1495,7 @@ public:
|
|||
TouchPointPressed = 0x01,
|
||||
TouchPointMoved = 0x02,
|
||||
TouchPointStationary = 0x04,
|
||||
TouchPointReleased = 0x08,
|
||||
TouchPointStateMask = 0x0f,
|
||||
|
||||
TouchPointPrimary = 0x10
|
||||
TouchPointReleased = 0x08
|
||||
};
|
||||
Q_DECLARE_FLAGS(TouchPointStates, TouchPointState)
|
||||
|
||||
|
|
|
|||
|
|
@ -3441,9 +3441,6 @@ QWindowStateChangeEvent::~QWindowStateChangeEvent()
|
|||
\value TouchPointMoved The touch point moved.
|
||||
\value TouchPointStationary The touch point did not move.
|
||||
\value TouchPointReleased The touch point was released.
|
||||
|
||||
\omitvalue TouchPointStateMask
|
||||
\omitvalue TouchPointPrimary
|
||||
*/
|
||||
|
||||
/*! \enum QTouchEvent::DeviceType
|
||||
|
|
@ -3623,7 +3620,7 @@ int QTouchEvent::TouchPoint::id() const
|
|||
*/
|
||||
Qt::TouchPointState QTouchEvent::TouchPoint::state() const
|
||||
{
|
||||
return Qt::TouchPointState(int(d->state) & Qt::TouchPointStateMask);
|
||||
return Qt::TouchPointState(int(d->state));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -3632,7 +3629,7 @@ Qt::TouchPointState QTouchEvent::TouchPoint::state() const
|
|||
*/
|
||||
bool QTouchEvent::TouchPoint::isPrimary() const
|
||||
{
|
||||
return (d->state & Qt::TouchPointPrimary) != 0;
|
||||
return (d->flags & Primary) != 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -694,7 +694,8 @@ public:
|
|||
{
|
||||
public:
|
||||
enum InfoFlag {
|
||||
Pen = 0x0001
|
||||
Primary = 0x0001,
|
||||
Pen = 0x0002
|
||||
};
|
||||
Q_DECLARE_FLAGS(InfoFlags, InfoFlag)
|
||||
|
||||
|
|
|
|||
|
|
@ -914,8 +914,6 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
|
|||
|
||||
StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()];
|
||||
maskAndPoints.first |= touchPoint.state();
|
||||
if (touchPoint.isPrimary())
|
||||
maskAndPoints.first |= Qt::TouchPointPrimary;
|
||||
maskAndPoints.second.append(touchPoint);
|
||||
}
|
||||
|
||||
|
|
@ -928,7 +926,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
|
|||
QWindow *w = it.key();
|
||||
|
||||
QEvent::Type eventType;
|
||||
switch (it.value().first & Qt::TouchPointStateMask) {
|
||||
switch (it.value().first) {
|
||||
case Qt::TouchPointPressed:
|
||||
eventType = QEvent::TouchBegin;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -245,11 +245,7 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo
|
|||
p.setId(point->id);
|
||||
p.setPressure(point->pressure);
|
||||
states |= point->state;
|
||||
Qt::TouchPointStates state = point->state;
|
||||
if (point->isPrimary) {
|
||||
state |= Qt::TouchPointPrimary;
|
||||
}
|
||||
p.setState(state);
|
||||
p.setState(point->state);
|
||||
|
||||
const QPointF screenPos = point->area.center();
|
||||
p.setScreenPos(screenPos);
|
||||
|
|
|
|||
|
|
@ -86,9 +86,8 @@ public:
|
|||
static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
|
||||
|
||||
struct TouchPoint {
|
||||
TouchPoint() : id(0), isPrimary(false), pressure(0), state(Qt::TouchPointStationary), flags(0) { }
|
||||
TouchPoint() : id(0), pressure(0), state(Qt::TouchPointStationary), flags(0) { }
|
||||
int id; // for application use
|
||||
bool isPrimary; // for application use
|
||||
QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
|
||||
QRectF area; // the touched area, centered at position in screen coordinates
|
||||
qreal pressure; // 0 to 1
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void QTouchEventSenderQPA::touch_point(const QList<QWindowSystemInterface::Touch
|
|||
tp.area = QRect(wx, wy, tp.area.width() * sizeRatio, tp.area.height() * sizeRatio);
|
||||
|
||||
#ifdef POINT_DEBUG
|
||||
qDebug() << " " << i << tp.area << tp.state << tp.id << tp.isPrimary << tp.pressure;
|
||||
qDebug() << " " << i << tp.area << tp.state << tp.id << tp.flags << tp.pressure;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ public:
|
|||
int y;
|
||||
int maj;
|
||||
Qt::TouchPointState state;
|
||||
bool primary;
|
||||
Contact() : trackingId(0), x(0), y(0), maj(1), state(Qt::TouchPointPressed), primary(false) { }
|
||||
QTouchEvent::TouchPoint::InfoFlags flags;
|
||||
Contact() : trackingId(0), x(0), y(0), maj(1), state(Qt::TouchPointPressed), flags(0) { }
|
||||
};
|
||||
QMap<int, Contact> m_contacts, m_lastContacts;
|
||||
Contact m_currentData;
|
||||
|
|
@ -219,7 +219,8 @@ void QTouchScreenData::processInputEvent(input_event *data)
|
|||
m_currentData.y = data->value;
|
||||
} else if (data->code == ABS_MT_TRACKING_ID) {
|
||||
m_currentData.trackingId = data->value;
|
||||
m_currentData.primary = m_contacts.isEmpty();
|
||||
if (m_contacts.isEmpty())
|
||||
m_currentData.flags |= QTouchEvent::TouchPoint::Primary;
|
||||
} else if (data->code == ABS_MT_TOUCH_MAJOR) {
|
||||
m_currentData.maj = data->value;
|
||||
if (data->value == 0)
|
||||
|
|
@ -238,7 +239,7 @@ void QTouchScreenData::processInputEvent(input_event *data)
|
|||
it != ite; ++it) {
|
||||
QWindowSystemInterface::TouchPoint tp;
|
||||
tp.id = it->trackingId;
|
||||
tp.isPrimary = it->primary;
|
||||
tp.flags = it->flags;
|
||||
tp.pressure = it->state == Qt::TouchPointReleased ? 0 : 1;
|
||||
|
||||
if (m_lastContacts.contains(it->trackingId)) {
|
||||
|
|
@ -323,7 +324,7 @@ void QTouchScreenData::dump()
|
|||
qDebug() << "touch event" << eventType;
|
||||
foreach (const QWindowSystemInterface::TouchPoint &tp, m_touchPoints) {
|
||||
const char *pointState;
|
||||
switch (tp.state & Qt::TouchPointStateMask) {
|
||||
switch (tp.state) {
|
||||
case Qt::TouchPointPressed:
|
||||
pointState = "pressed";
|
||||
break;
|
||||
|
|
@ -341,7 +342,7 @@ void QTouchScreenData::dump()
|
|||
break;
|
||||
}
|
||||
qDebug() << " " << tp.id << tp.area << pointState << tp.normalPosition
|
||||
<< tp.pressure << tp.isPrimary << tp.area.center();
|
||||
<< tp.pressure << tp.flags << tp.area.center();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ QCocoaTouch::~QCocoaTouch()
|
|||
void QCocoaTouch::updateTouchData(NSTouch *nstouch, NSTouchPhase phase)
|
||||
{
|
||||
_touchPoint.state = toTouchPointState(phase);
|
||||
_touchPoint.isPrimary = (_touchCount == 1);
|
||||
if (_touchCount == 1)
|
||||
_touchPoint.flags |= QTouchEvent::TouchPoint::Primary;
|
||||
|
||||
// From the normalized position on the trackpad, calculate
|
||||
// where on screen the touchpoint should be according to the
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||
const TOUCHINPUT &winTouchInput = winTouchInputs[i];
|
||||
QTouchPoint touchPoint;
|
||||
touchPoint.pressure = 1.0;
|
||||
touchPoint.isPrimary = (winTouchInput.dwFlags & TOUCHEVENTF_PRIMARY) != 0;
|
||||
if ((winTouchInput.dwFlags & TOUCHEVENTF_PRIMARY) != 0)
|
||||
touchPoint.flags |= QTouchEvent::TouchPoint::Primary;
|
||||
touchPoint.id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1);
|
||||
if (touchPoint.id == -1) {
|
||||
touchPoint.id = m_touchInputIDToTouchPointID.size();
|
||||
|
|
@ -275,7 +276,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
|
|||
QWindowsContext::user32dll.closeTouchInputHandle((HANDLE) msg.lParam);
|
||||
|
||||
// all touch points released, forget the ids we've seen, they may not be reused
|
||||
if ((allStates & Qt::TouchPointStateMask) == Qt::TouchPointReleased)
|
||||
if (allStates == Qt::TouchPointReleased)
|
||||
m_touchInputIDToTouchPointID.clear();
|
||||
|
||||
if (!m_touchDevice) {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,8 @@ void QXcbConnection::handleGenericEvent(xcb_ge_event_t *event)
|
|||
for (int i = 0; i < m_xinputData->xiMaxContacts; ++i) {
|
||||
QWindowSystemInterface::TouchPoint tp;
|
||||
tp.id = i;
|
||||
tp.isPrimary = (i == 0);
|
||||
if (i == 0)
|
||||
tp.flags |= QTouchEvent::TouchPoint::Primary;
|
||||
tp.state = Qt::TouchPointReleased;
|
||||
touchPoints << tp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ namespace QTest
|
|||
{
|
||||
QWindowSystemInterface::TouchPoint p;
|
||||
p.id = pt.id();
|
||||
p.isPrimary = pt.isPrimary();
|
||||
p.flags = pt.flags();
|
||||
p.normalPosition = pt.screenRect().topLeft();
|
||||
p.area = pt.screenRect();
|
||||
p.pressure = pt.pressure();
|
||||
|
|
|
|||
|
|
@ -5316,8 +5316,6 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
|
|||
|
||||
StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()];
|
||||
maskAndPoints.first |= touchPoint.state();
|
||||
if (touchPoint.isPrimary())
|
||||
maskAndPoints.first |= Qt::TouchPointPrimary;
|
||||
maskAndPoints.second.append(touchPoint);
|
||||
}
|
||||
|
||||
|
|
@ -5332,7 +5330,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
|
|||
continue;
|
||||
|
||||
QEvent::Type eventType;
|
||||
switch (it.value().first & Qt::TouchPointStateMask) {
|
||||
switch (it.value().first) {
|
||||
case Qt::TouchPointPressed:
|
||||
eventType = QEvent::TouchBegin;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue