Pass modifier and button information down the call stack
Gets rid of calls to QGuiApplication::mouseButtons and QGuiApplication::keyboardModifiers. Task-number: QTBUG-73829 Change-Id: Idba978fe8db21622ca05c4882c74fd2792b119e5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
117a5aa744
commit
01d30f8399
@ -213,7 +213,7 @@ public:
|
|||||||
mouseTarget = nullptr;
|
mouseTarget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollerBecameActive()
|
void scrollerBecameActive(Qt::KeyboardModifiers eventModifiers, Qt::MouseButtons eventButtons)
|
||||||
{
|
{
|
||||||
if (pressDelayEvent) {
|
if (pressDelayEvent) {
|
||||||
// we still haven't even sent the press, so just throw it away now
|
// we still haven't even sent the press, so just throw it away now
|
||||||
@ -246,8 +246,8 @@ public:
|
|||||||
|
|
||||||
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
|
qFGDebug() << "QFG: sending a fake mouse release at far-far-away to " << mouseTarget;
|
||||||
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
|
QMouseEvent re(QEvent::MouseButtonRelease, QPoint(), farFarAway, farFarAway,
|
||||||
mouseButton, QGuiApplication::mouseButtons() & ~mouseButton,
|
mouseButton, eventButtons & ~mouseButton,
|
||||||
QGuiApplication::keyboardModifiers(), mouseEventSource);
|
eventModifiers, mouseEventSource);
|
||||||
sendMouseEvent(&re, RegrabMouseAfterwards);
|
sendMouseEvent(&re, RegrabMouseAfterwards);
|
||||||
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
|
// don't clear the mouseTarget just yet, since we need to explicitly ungrab the mouse on release!
|
||||||
}
|
}
|
||||||
@ -429,6 +429,8 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
|
|||||||
|
|
||||||
// qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
|
// qFGDebug() << "FlickGesture "<<state<<"watched:"<<watched<<"receiver"<<d->receiver<<"event"<<event->type()<<"button"<<button;
|
||||||
|
|
||||||
|
Qt::KeyboardModifiers keyboardModifiers = Qt::NoModifier;
|
||||||
|
Qt::MouseButtons mouseButtons = Qt::NoButton;
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
@ -437,6 +439,8 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
|
|||||||
return Ignore;
|
return Ignore;
|
||||||
if (button != Qt::NoButton) {
|
if (button != Qt::NoButton) {
|
||||||
me = static_cast<const QMouseEvent *>(event);
|
me = static_cast<const QMouseEvent *>(event);
|
||||||
|
keyboardModifiers = me->modifiers();
|
||||||
|
mouseButtons = me->buttons();
|
||||||
globalPos = me->globalPosition().toPoint();
|
globalPos = me->globalPosition().toPoint();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -448,6 +452,8 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
|
|||||||
return Ignore;
|
return Ignore;
|
||||||
if (button != Qt::NoButton) {
|
if (button != Qt::NoButton) {
|
||||||
gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
|
gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
|
||||||
|
keyboardModifiers = gsme->modifiers();
|
||||||
|
mouseButtons = gsme->buttons();
|
||||||
globalPos = gsme->screenPos();
|
globalPos = gsme->screenPos();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -457,6 +463,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
|
|||||||
case QEvent::TouchUpdate:
|
case QEvent::TouchUpdate:
|
||||||
if (button == Qt::NoButton) {
|
if (button == Qt::NoButton) {
|
||||||
te = static_cast<const QTouchEvent *>(event);
|
te = static_cast<const QTouchEvent *>(event);
|
||||||
|
keyboardModifiers = te->modifiers();
|
||||||
if (!te->touchPoints().isEmpty())
|
if (!te->touchPoints().isEmpty())
|
||||||
globalPos = te->touchPoints().at(0).globalPosition().toPoint();
|
globalPos = te->touchPoints().at(0).globalPosition().toPoint();
|
||||||
}
|
}
|
||||||
@ -634,7 +641,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
|
|||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
|
if (!scrollerWasDragging && !scrollerWasScrolling && scrollerIsActive)
|
||||||
PressDelayHandler::instance()->scrollerBecameActive();
|
PressDelayHandler::instance()->scrollerBecameActive(keyboardModifiers, mouseButtons);
|
||||||
else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
|
else if (scrollerWasScrolling && (scroller->state() == QScroller::Dragging || scroller->state() == QScroller::Inactive))
|
||||||
PressDelayHandler::instance()->scrollerWasIntercepted();
|
PressDelayHandler::instance()->scrollerWasIntercepted();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user