Port away from deprecated QWheelEvent position methods

Those are gone in Qt6 (unlike similarly named methods for other
event types).
This commit is contained in:
Volker Krause 2022-03-09 17:28:31 +01:00
parent 51250cfb4a
commit eee16b01a4
3 changed files with 9 additions and 9 deletions

View file

@ -134,8 +134,8 @@ void InputEventsTest::testInitWheelEvent()
Qt::ShiftModifier | Qt::ControlModifier, InputRedirection::PointerAxisSourceWheel, 300, &d);
// compare QWheelEvent contract
QCOMPARE(event.type(), QEvent::Wheel);
QCOMPARE(event.posF(), QPointF(100, 200));
QCOMPARE(event.globalPosF(), QPointF(100, 200));
QCOMPARE(event.position(), QPointF(100, 200));
QCOMPARE(event.globalPosition(), QPointF(100, 200));
QCOMPARE(event.buttons(), Qt::LeftButton | Qt::RightButton);
QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier);
QCOMPARE(event.timestamp(), 300ul);

View file

@ -1006,7 +1006,7 @@ std::pair<bool, bool> performClientWheelAction(QWheelEvent *event, AbstractClien
}
}
if (wasAction) {
return std::make_pair(wasAction, !c->performMouseCommand(command, event->globalPos()));
return std::make_pair(wasAction, !c->performMouseCommand(command, event->globalPosition().toPoint()));
}
return std::make_pair(wasAction, false);
}
@ -1032,7 +1032,7 @@ class InternalWindowEventFilter : public InputEventFilter {
return false;
}
QWindow *internal = static_cast<InternalClient *>(input()->pointer()->focus())->internalWindow();
const QPointF localPos = event->globalPosF() - internal->position();
const QPointF localPos = event->globalPosition() - internal->position();
const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical;
const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y();
QWheelEvent wheelEvent(localPos, event->globalPosF(), QPoint(),
@ -1228,10 +1228,10 @@ public:
return actionResult.second;
}
}
const QPointF localPos = event->globalPosF() - decoration->client()->pos();
const QPointF localPos = event->globalPosition() - decoration->client()->pos();
const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical;
const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y();
QWheelEvent e(localPos, event->globalPosF(), QPoint(),
QWheelEvent e(localPos, event->globalPosition(), QPoint(),
event->angleDelta(),
delta,
orientation,
@ -1244,7 +1244,7 @@ public:
}
if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) {
decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1),
event->globalPosF().toPoint());
event->globalPosition().toPoint());
}
return true;
}

View file

@ -322,8 +322,8 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e)
case QEvent::Wheel:
{
QWheelEvent *we = static_cast<QWheelEvent *>(e);
const QPointF widgetPos = d->m_view->mapFromGlobal(we->pos());
QWheelEvent cloneEvent(widgetPos, we->globalPosF(), we->pixelDelta(), we->angleDelta(), we->buttons(),
const QPointF widgetPos = d->m_view->mapFromGlobal(we->position().toPoint());
QWheelEvent cloneEvent(widgetPos, we->globalPosition(), we->pixelDelta(), we->angleDelta(), we->buttons(),
we->modifiers(), we->phase(), we->inverted());
QCoreApplication::sendEvent(d->m_view, &cloneEvent);
e->setAccepted(cloneEvent.isAccepted());