VirtualBox

Ignore:
Timestamp:
Dec 23, 2022 2:28:37 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9898: Migrating UIMouseHandler bits to Qt6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r97849 r97857  
    2727
    2828/* Qt includes: */
     29#include <QtMath>
    2930#include <QMouseEvent>
    3031#include <QTimer>
     
    770771                     * guest mouse device at all: */
    771772                    int iDelta = 0;
    772 #ifdef VBOX_IS_QT6_OR_LATER
    773                     Qt::Orientation const enmOrientation = RT_ABS(pWheelEvent->pixelDelta().x())
    774                                                          > RT_ABS(pWheelEvent->pixelDelta().y()) ? Qt::Horizontal : Qt::Vertical;
     773                    const Qt::Orientation enmOrientation = qFabs(pWheelEvent->angleDelta().x())
     774                                                         > qFabs(pWheelEvent->angleDelta().y())
     775                                                         ? Qt::Horizontal
     776                                                         : Qt::Vertical;
    775777                    m_iLastMouseWheelDelta += enmOrientation == Qt::Horizontal
    776                                             ? pWheelEvent->pixelDelta().x() : pWheelEvent->pixelDelta().y();
    777 #else
    778                     m_iLastMouseWheelDelta += pWheelEvent->delta();
    779 #endif
     778                                            ? pWheelEvent->angleDelta().x()
     779                                            : pWheelEvent->angleDelta().y();
    780780                    if (qAbs(m_iLastMouseWheelDelta) >= 120)
    781781                    {
     
    785785                        m_iLastMouseWheelDelta = m_iLastMouseWheelDelta % 120;
    786786                    }
    787                     if (mouseEvent(pWheelEvent->type(), uScreenId,
    788 #ifdef VBOX_IS_QT6_OR_LATER
    789                                    pWheelEvent->position().toPoint(), pWheelEvent->globalPosition().toPoint(),
     787                    if (mouseEvent(pWheelEvent->type(),
     788                                   uScreenId,
     789#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
     790                                   pWheelEvent->position().toPoint(),
    790791#else
    791                                    pWheelEvent->pos(), pWheelEvent->globalPos(),
     792                                   pWheelEvent->pos()
    792793#endif
     794                                   pWheelEvent->globalPosition().toPoint(),
    793795#ifdef VBOX_WS_MAC
    794                                    /* Qt Cocoa is buggy. It always reports a left button pressed when the
    795                                     * mouse wheel event occurs. A workaround is to ask the application which
    796                                     * buttons are pressed currently: */
     796                                   // WORKAROUND:
     797                                   // Qt Cocoa is buggy. It always reports a left button pressed when the
     798                                   // mouse wheel event occurs. A workaround is to ask the application which
     799                                   // buttons are pressed currently:
    797800                                   QApplication::mouseButtons(),
    798801#else /* !VBOX_WS_MAC */
     
    800803#endif /* !VBOX_WS_MAC */
    801804                                   iDelta,
    802 #ifdef VBOX_IS_QT6_OR_LATER
    803805                                   enmOrientation)
    804 #else
    805                                    pWheelEvent->orientation())
    806 #endif
    807806                                   )
    808807                        return true;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette