From 4aed6a149abfacdf41b16e94968634dacbbcfc6d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 17 Oct 2024 03:10:48 +0200 Subject: [PATCH] port away from deprecated globalPos method --- autotests/integration/internal_window.cpp | 8 ++++---- autotests/libinput/input_event_test.cpp | 2 +- src/effect/quickeffect.cpp | 2 +- src/onscreennotification.cpp | 2 +- src/plugins/mouseclick/mouseclick.cpp | 2 +- src/popup_input_filter.cpp | 4 ++-- src/screenedge.cpp | 8 ++++---- src/tabbox/tabbox.cpp | 4 ++-- tests/renderingservertest.cpp | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index 22d9ef30d1..7f10999a11 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -128,20 +128,20 @@ bool HelperWindow::event(QEvent *event) void HelperWindow::mouseMoveEvent(QMouseEvent *event) { - m_latestGlobalMousePos = event->globalPos(); - Q_EMIT mouseMoved(event->globalPos()); + m_latestGlobalMousePos = event->globalPosition().toPoint(); + Q_EMIT mouseMoved(m_latestGlobalMousePos); } void HelperWindow::mousePressEvent(QMouseEvent *event) { - m_latestGlobalMousePos = event->globalPos(); + m_latestGlobalMousePos = event->globalPosition().toPoint(); m_pressedButtons = event->buttons(); Q_EMIT mousePressed(); } void HelperWindow::mouseReleaseEvent(QMouseEvent *event) { - m_latestGlobalMousePos = event->globalPos(); + m_latestGlobalMousePos = event->globalPosition().toPoint(); m_pressedButtons = event->buttons(); Q_EMIT mouseReleased(); } diff --git a/autotests/libinput/input_event_test.cpp b/autotests/libinput/input_event_test.cpp index d3ccb0d456..f719318941 100644 --- a/autotests/libinput/input_event_test.cpp +++ b/autotests/libinput/input_event_test.cpp @@ -56,7 +56,7 @@ void InputEventsTest::testInitMouseEvent() Qt::ShiftModifier | Qt::ControlModifier, 300ms, QPointF(1, 2), QPointF(3, 4), &d, false); // and verify the contract of QMouseEvent QCOMPARE(event.type(), type); - QCOMPARE(event.globalPos(), QPoint(100, 200)); + QCOMPARE(event.globalPosition(), QPoint(100, 200)); QCOMPARE(event.screenPos(), QPointF(100, 200)); QCOMPARE(event.localPos(), QPointF(100, 200)); QCOMPARE(event.button(), Qt::LeftButton); diff --git a/src/effect/quickeffect.cpp b/src/effect/quickeffect.cpp index 03a2e3a0a3..e418579269 100644 --- a/src/effect/quickeffect.cpp +++ b/src/effect/quickeffect.cpp @@ -546,7 +546,7 @@ void QuickSceneEffect::windowInputMouseEvent(QEvent *event) QPoint globalPosition; if (QMouseEvent *mouseEvent = dynamic_cast(event)) { buttons = mouseEvent->buttons(); - globalPosition = mouseEvent->globalPos(); + globalPosition = mouseEvent->globalPosition().toPoint(); } else if (QWheelEvent *wheelEvent = dynamic_cast(event)) { buttons = wheelEvent->buttons(); globalPosition = wheelEvent->globalPosition().toPoint(); diff --git a/src/onscreennotification.cpp b/src/onscreennotification.cpp index 0f3690e727..15354862e4 100644 --- a/src/onscreennotification.cpp +++ b/src/onscreennotification.cpp @@ -49,7 +49,7 @@ void OnScreenNotificationInputEventSpy::pointerEvent(MouseEvent *event) return; } - m_parent->setContainsPointer(m_parent->geometry().contains(event->globalPos())); + m_parent->setContainsPointer(m_parent->geometry().contains(event->globalPosition().toPoint())); } OnScreenNotification::OnScreenNotification(QObject *parent) diff --git a/src/plugins/mouseclick/mouseclick.cpp b/src/plugins/mouseclick/mouseclick.cpp index 0675a748a1..b46366692d 100644 --- a/src/plugins/mouseclick/mouseclick.cpp +++ b/src/plugins/mouseclick/mouseclick.cpp @@ -349,7 +349,7 @@ bool MouseClickEffect::tabletToolEvent(QTabletEvent *event) default: break; } - tabletEvent.m_globalPosition = event->globalPos(); + tabletEvent.m_globalPosition = event->globalPosition(); tabletEvent.m_pressure = event->pressure(); return false; diff --git a/src/popup_input_filter.cpp b/src/popup_input_filter.cpp index 9d8a852a24..5a25c4676d 100644 --- a/src/popup_input_filter.cpp +++ b/src/popup_input_filter.cpp @@ -54,7 +54,7 @@ bool PopupInputFilter::pointerEvent(MouseEvent *event, quint32 nativeButton) return false; } if (event->type() == QMouseEvent::MouseButtonPress) { - auto pointerFocus = input()->findToplevel(event->globalPos()); + auto pointerFocus = input()->findToplevel(event->globalPosition()); if (!pointerFocus || !Window::belongToSameApplication(pointerFocus, m_popupWindows.constLast())) { // a press on a window (or no window) not belonging to the popup window cancelPopups(); @@ -63,7 +63,7 @@ bool PopupInputFilter::pointerEvent(MouseEvent *event, quint32 nativeButton) } if (pointerFocus && pointerFocus->isDecorated()) { // test whether it is on the decoration - if (!exclusiveContains(pointerFocus->clientGeometry(), event->globalPos())) { + if (!exclusiveContains(pointerFocus->clientGeometry(), event->globalPosition())) { cancelPopups(); return true; } diff --git a/src/screenedge.cpp b/src/screenedge.cpp index f48dddf6d8..771b4c67d2 100644 --- a/src/screenedge.cpp +++ b/src/screenedge.cpp @@ -1481,11 +1481,11 @@ bool ScreenEdges::isEntered(QMouseEvent *event) } continue; } - if (edge->approachGeometry().contains(event->globalPos())) { + if (edge->approachGeometry().contains(event->globalPosition().toPoint())) { if (!edge->isApproaching()) { edge->startApproaching(); } else { - edge->updateApproaching(event->globalPos()); + edge->updateApproaching(event->globalPosition()); } } else { if (edge->isApproaching()) { @@ -1493,7 +1493,7 @@ bool ScreenEdges::isEntered(QMouseEvent *event) } } // always send event to all edges so that they can update their state - if (edge->check(event->globalPos(), QDateTime::fromMSecsSinceEpoch(event->timestamp(), Qt::UTC))) { + if (edge->check(event->globalPosition().toPoint(), QDateTime::fromMSecsSinceEpoch(event->timestamp(), Qt::UTC))) { if (edge->client()) { activatedForClient = true; } @@ -1502,7 +1502,7 @@ bool ScreenEdges::isEntered(QMouseEvent *event) if (activatedForClient) { for (const auto &edge : m_edges) { if (edge->client()) { - edge->markAsTriggered(event->globalPos(), QDateTime::fromMSecsSinceEpoch(event->timestamp(), Qt::UTC)); + edge->markAsTriggered(event->globalPosition().toPoint(), QDateTime::fromMSecsSinceEpoch(event->timestamp(), Qt::UTC)); } } } diff --git a/src/tabbox/tabbox.cpp b/src/tabbox/tabbox.cpp index 58bffb4294..42d80f77d3 100644 --- a/src/tabbox/tabbox.cpp +++ b/src/tabbox/tabbox.cpp @@ -622,14 +622,14 @@ bool TabBox::handleMouseEvent(QMouseEvent *event) } switch (event->type()) { case QEvent::MouseMove: - if (!m_tabBox->containsPos(event->globalPos())) { + if (!m_tabBox->containsPos(event->globalPosition().toPoint())) { // filter out all events which are not on the TabBox window. // We don't want windows to react on the mouse events return true; } return false; case QEvent::MouseButtonPress: - if ((!m_isShown && isDisplayed()) || !m_tabBox->containsPos(event->globalPos())) { + if ((!m_isShown && isDisplayed()) || !m_tabBox->containsPos(event->globalPosition().toPoint())) { close(); // click outside closes tab return true; } diff --git a/tests/renderingservertest.cpp b/tests/renderingservertest.cpp index 3935891f3f..484c44b334 100644 --- a/tests/renderingservertest.cpp +++ b/tests/renderingservertest.cpp @@ -200,7 +200,7 @@ void CompositorWindow::mousePressEvent(QMouseEvent *event) QWidget::mousePressEvent(event); if (!m_seat->focusedPointerSurface()) { if (!m_stackingOrder.isEmpty()) { - m_seat->notifyPointerEnter(m_stackingOrder.last()->surface(), event->globalPos()); + m_seat->notifyPointerEnter(m_stackingOrder.last()->surface(), event->globalPosition()); } } m_seat->setTimestamp(std::chrono::milliseconds(event->timestamp()));