vcl/inc/qt5/QtWidget.hxx | 10 +++++----- vcl/qt5/QtWidget.cxx | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-)
New commits: commit 004f6c08a5f63b0da428bd0fbcbee5330fff53a0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sat Apr 12 11:55:32 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sun Apr 13 19:16:12 2025 +0200 qt: Simplify QtWidget::fillSalAbstractMouseEvent Make the method non-static and use m_rFrame directly instead of passing it as a param in all callers. Change-Id: Id36fb2df3d9118c69ab561d614e2122f727e0c55 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184089 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index 86d99264fc08..3be0dfb558cf 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -51,9 +51,9 @@ class QtWidget : public QWidget static bool handleGestureEvent(const QtFrame& rFrame, QGestureEvent* pGestureEvent); static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*); static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*); - static void fillSalAbstractMouseEvent(const QtFrame& rFrame, const QInputEvent* pQEvent, - const QPoint& rPos, Qt::MouseButtons eButtons, int nWidth, - SalAbstractMouseEvent& aSalEvent); + void fillSalAbstractMouseEvent(const QInputEvent* pQEvent, const QPoint& rPos, + Qt::MouseButtons eButtons, int nWidth, + SalAbstractMouseEvent& aSalEvent) const; virtual bool event(QEvent*) override; diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index c2a12c32dcfd..a00cc4257515 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -73,11 +73,11 @@ void QtWidget::fakeResize() resizeEvent(&aEvent); } -void QtWidget::fillSalAbstractMouseEvent(const QtFrame& rFrame, const QInputEvent* pQEvent, - const QPoint& rPos, Qt::MouseButtons eButtons, int nWidth, - SalAbstractMouseEvent& aSalEvent) +void QtWidget::fillSalAbstractMouseEvent(const QInputEvent* pQEvent, const QPoint& rPos, + Qt::MouseButtons eButtons, int nWidth, + SalAbstractMouseEvent& aSalEvent) const { - const qreal fRatio = rFrame.devicePixelRatioF(); + const qreal fRatio = m_rFrame.devicePixelRatioF(); const Point aPos = toPoint(rPos * fRatio); aSalEvent.mnX = QGuiApplication::isLeftToRight() ? aPos.X() : round(nWidth * fRatio) - aPos.X(); @@ -86,13 +86,13 @@ void QtWidget::fillSalAbstractMouseEvent(const QtFrame& rFrame, const QInputEven aSalEvent.mnCode = toVclKeyboardModifiers(pQEvent->modifiers()) | toVclMouseButtons(eButtons); } -#define FILL_SAME(rFrame, nWidth) \ - fillSalAbstractMouseEvent(rFrame, pEvent, pEvent->pos(), pEvent->buttons(), nWidth, aEvent) +#define FILL_SAME(nWidth) \ + fillSalAbstractMouseEvent(pEvent, pEvent->pos(), pEvent->buttons(), nWidth, aEvent) void QtWidget::handleMouseButtonEvent(const QMouseEvent* pEvent) const { SalMouseEvent aEvent; - FILL_SAME(m_rFrame, m_rFrame.GetQWidget()->width()); + FILL_SAME(m_rFrame.GetQWidget()->width()); switch (pEvent->button()) { @@ -130,7 +130,7 @@ void QtWidget::mouseReleaseEvent(QMouseEvent* pEvent) { handleMouseButtonEvent(p void QtWidget::mouseMoveEvent(QMouseEvent* pEvent) { SalMouseEvent aEvent; - FILL_SAME(m_rFrame, width()); + FILL_SAME(width()); aEvent.mnButton = 0; @@ -176,8 +176,8 @@ void QtWidget::enterEvent(QEvent* pEvent) void QtWidget::wheelEvent(QWheelEvent* pEvent) { SalWheelMouseEvent aEvent; - fillSalAbstractMouseEvent(m_rFrame, pEvent, pEvent->position().toPoint(), pEvent->buttons(), - width(), aEvent); + fillSalAbstractMouseEvent(pEvent, pEvent->position().toPoint(), pEvent->buttons(), width(), + aEvent); // mouse wheel ticks are 120, which we map to 3 lines. // we have to accumulate for touch scroll to keep track of the absolute delta. commit 8e429e752c70dcdc2620f0d844f6fc07a9673a35 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Sat Apr 12 11:51:39 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sun Apr 13 19:16:05 2025 +0200 qt: Simplify QtWidget::handleMouseButtonEvent Make the method private, non-static and use m_rFrame directly instead of passing it as a param in all callers. Change-Id: I6f7ffcc8c147187cdbbc0588cd3c7b866f40b80f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184088 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtWidget.hxx b/vcl/inc/qt5/QtWidget.hxx index 0f7029d5482d..86d99264fc08 100644 --- a/vcl/inc/qt5/QtWidget.hxx +++ b/vcl/inc/qt5/QtWidget.hxx @@ -46,6 +46,8 @@ class QtWidget : public QWidget static void commitText(QtFrame&, const QString& aText); static void deleteReplacementText(const QtFrame& rFrame, int nReplacementStart, int nReplacementLength); + // mouse events are always accepted + void handleMouseButtonEvent(const QMouseEvent*) const; static bool handleGestureEvent(const QtFrame& rFrame, QGestureEvent* pGestureEvent); static bool handleKeyEvent(QtFrame&, const QWidget&, QKeyEvent*); static void handleMouseEnterLeaveEvents(const QtFrame&, QEvent*); @@ -95,8 +97,6 @@ public: static bool handleEvent(QtFrame&, QWidget&, QEvent*); // key events might be propagated further down => call base on false static inline bool handleKeyReleaseEvent(QtFrame&, const QWidget&, QKeyEvent*); - // mouse events are always accepted - static void handleMouseButtonEvent(const QtFrame&, const QMouseEvent*); }; bool QtWidget::handleKeyReleaseEvent(QtFrame& rFrame, const QWidget& rWidget, QKeyEvent* pEvent) diff --git a/vcl/qt5/QtWidget.cxx b/vcl/qt5/QtWidget.cxx index f3543a14d0e5..c2a12c32dcfd 100644 --- a/vcl/qt5/QtWidget.cxx +++ b/vcl/qt5/QtWidget.cxx @@ -89,10 +89,10 @@ void QtWidget::fillSalAbstractMouseEvent(const QtFrame& rFrame, const QInputEven #define FILL_SAME(rFrame, nWidth) \ fillSalAbstractMouseEvent(rFrame, pEvent, pEvent->pos(), pEvent->buttons(), nWidth, aEvent) -void QtWidget::handleMouseButtonEvent(const QtFrame& rFrame, const QMouseEvent* pEvent) +void QtWidget::handleMouseButtonEvent(const QMouseEvent* pEvent) const { SalMouseEvent aEvent; - FILL_SAME(rFrame, rFrame.GetQWidget()->width()); + FILL_SAME(m_rFrame, m_rFrame.GetQWidget()->width()); switch (pEvent->button()) { @@ -114,18 +114,18 @@ void QtWidget::handleMouseButtonEvent(const QtFrame& rFrame, const QMouseEvent* nEventType = SalEvent::MouseButtonDown; else nEventType = SalEvent::MouseButtonUp; - rFrame.CallCallback(nEventType, &aEvent); + m_rFrame.CallCallback(nEventType, &aEvent); } void QtWidget::mousePressEvent(QMouseEvent* pEvent) { - handleMouseButtonEvent(m_rFrame, pEvent); + handleMouseButtonEvent(pEvent); if (m_rFrame.isPopup() && !geometry().translated(geometry().topLeft() * -1).contains(pEvent->pos())) closePopup(); } -void QtWidget::mouseReleaseEvent(QMouseEvent* pEvent) { handleMouseButtonEvent(m_rFrame, pEvent); } +void QtWidget::mouseReleaseEvent(QMouseEvent* pEvent) { handleMouseButtonEvent(pEvent); } void QtWidget::mouseMoveEvent(QMouseEvent* pEvent) {