VirtualBox

Changeset 98503 in vbox for trunk


Ignore:
Timestamp:
Feb 8, 2023 2:13:14 PM (2 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Rework CMouse wrapper usage the way it's fully encapsulated inside UISession.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp

    r98500 r98503  
    6363#include "CKeyboard.h"
    6464#include "CMediumAttachment.h"
     65#include "CMouse.h"
    6566#include "CNATNetwork.h"
    6667#include "CNetworkAdapter.h"
     
    932933        QApplication::translate("UIMessageCenter", "Failed to assign keyboard parameter.") +
    933934        UIErrorString::formatErrorInfo(comKeyboard));
     935}
     936
     937/* static */
     938void UINotificationMessage::cannotChangeMouseParameter(const CMouse &comMouse)
     939{
     940    createMessage(
     941        QApplication::translate("UIMessageCenter", "Mouse failure ..."),
     942        QApplication::translate("UIMessageCenter", "Failed to assign mouse parameter.") +
     943        UIErrorString::formatErrorInfo(comMouse));
    934944}
    935945
  • trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h

    r98500 r98503  
    7373class CEmulatedUSB;
    7474class CKeyboard;
     75class CMouse;
    7576class CNetworkAdapter;
    7677class CVirtualBox;
     
    385386          * @param  comKeyboard  Brings the object parameter being changed for. */
    386387        static void cannotChangeKeyboardParameter(const CKeyboard &comKeyboard);
     388        /** Notifies about inability to change IMouse parameter.
     389          * @param  comMouse  Brings the object parameter being changed for. */
     390        static void cannotChangeMouseParameter(const CMouse &comMouse);
    387391        /** Notifies about inability to change IVirtualSystemDescription parameter.
    388392          * @param  comVsd  Brings the object parameter being changed for. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp

    r98103 r98503  
    4848#include "UIDnDMIMEData.h"
    4949#endif /* VBOX_WITH_DRAG_AND_DROP_GH */
     50#include "UIMachine.h"
    5051#include "UIMessageCenter.h"
    5152#include "UISession.h"
     
    8081
    8182
    82 UIDnDHandler::UIDnDHandler(UISession *pSession, QWidget *pParent)
    83     : m_pSession(pSession)
     83UIDnDHandler::UIDnDHandler(UIMachine *pMachine, UISession *pSession, QWidget *pParent)
     84    : m_pMachine(pMachine)
     85    , m_pSession(pSession)
    8486    , m_pParent(pParent)
    8587    , m_fDataRetrieved(false)
     
    754756        /* Send a mouse event with released mouse buttons into the guest that triggers
    755757         * the "drop" event in our proxy window on the guest. */
    756         AssertPtr(m_pSession);
    757         m_pSession->mouse().PutMouseEvent(0, 0, 0, 0, 0);
     758        m_pMachine->putMouseEvent(0, 0, 0, 0, 0);
    758759
    759760        msgCenter().showModalProgressDialog(progress,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.h

    r98103 r98503  
    4646
    4747class UIDnDMIMEData;
     48class UIMachine;
    4849class UISession;
    4950
     
    5758public:
    5859
    59     UIDnDHandler(UISession *pSession, QWidget *pParent);
     60    UIDnDHandler(UIMachine *pMachine, UISession *pSession, QWidget *pParent);
    6061    virtual ~UIDnDHandler(void);
    6162
     
    133134protected:
    134135
    135     /** Pointer to UI session. */
     136    /** Pointer to machine UI. */
     137    UIMachine        *m_pMachine;
     138    /** Pointer to session UI. */
    136139    UISession        *m_pSession;
    137140    /** Pointer to parent widget. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98500 r98503  
    5959#include "CHostVideoInputDevice.h"
    6060#include "CMachine.h"
     61#include "CMediumAttachment.h"
    6162#include "CNetworkAdapter.h"
    6263#include "CProgress.h"
     
    466467{
    467468    uisession()->putUsageCode(iUsageCode, iUsagePage, fKeyRelease);
     469}
     470
     471void UIMachine::putMouseEvent(LONG iDx, LONG iDy, LONG iDz, LONG iDw, LONG iButtonState)
     472{
     473    uisession()->putMouseEvent(iDx, iDy, iDz, iDw, iButtonState);
     474}
     475
     476void UIMachine::putMouseEventAbsolute(LONG iX, LONG iY, LONG iDz, LONG iDw, LONG iButtonState)
     477{
     478    uisession()->putMouseEventAbsolute(iX, iY, iDz, iDw, iButtonState);
     479}
     480
     481void UIMachine::putEventMultiTouch(LONG iCount, const QVector<LONG64> &contacts, BOOL fIsTouchScreen, ULONG uScanTime)
     482{
     483    uisession()->putEventMultiTouch(iCount, contacts, fIsTouchScreen, uScanTime);
    468484}
    469485
     
    17481764void UIMachine::updateMouseState()
    17491765{
    1750     m_fIsMouseSupportsAbsolute = uisession()->mouse().GetAbsoluteSupported();
    1751     m_fIsMouseSupportsRelative = uisession()->mouse().GetRelativeSupported();
    1752     m_fIsMouseSupportsTouchScreen = uisession()->mouse().GetTouchScreenSupported();
    1753     m_fIsMouseSupportsTouchPad = uisession()->mouse().GetTouchPadSupported();
    1754     m_fIsMouseHostCursorNeeded = uisession()->mouse().GetNeedsHostCursor();
     1766    m_fIsMouseSupportsAbsolute = uisession()->getAbsoluteSupported();
     1767    m_fIsMouseSupportsRelative = uisession()->getRelativeSupported();
     1768    m_fIsMouseSupportsTouchScreen = uisession()->getTouchScreenSupported();
     1769    m_fIsMouseSupportsTouchPad = uisession()->getTouchPadSupported();
     1770    m_fIsMouseHostCursorNeeded = uisession()->getNeedsHostCursor();
    17551771}
    17561772
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98500 r98503  
    4343/* COM includes: */
    4444#include "COMEnums.h"
    45 #include "CMediumAttachment.h"
    4645
    4746/* Forward declarations: */
     
    5049class UISession;
    5150class UIMachineLogic;
     51class CMediumAttachment;
     52class CNetworkAdapter;
     53class CUSBDevice;
     54class CVirtualBoxErrorInfo;
    5255#ifdef VBOX_WS_MAC
    5356 class QMenuBar;
     
    370373        /** Returns mouse-state. */
    371374        int mouseState() const { return m_iMouseState; }
     375
     376        /** Sends relative mouse move event to VM's mouse. */
     377        void putMouseEvent(LONG iDx, LONG iDy, LONG iDz, LONG iDw, LONG iButtonState);
     378        /** Sends absolute mouse move event to VM's mouse. */
     379        void putMouseEventAbsolute(LONG iX, LONG iY, LONG iDz, LONG iDw, LONG iButtonState);
     380        /** Sends multi-touch event to VM's mouse. */
     381        void putEventMultiTouch(LONG iCount, const QVector<LONG64> &contacts, BOOL fIsTouchScreen, ULONG uScanTime);
    372382    /** @} */
    373383
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98500 r98503  
    307307{
    308308    return uisession()->guest();
    309 }
    310 
    311 CMouse& UIMachineLogic::mouse() const
    312 {
    313     return uisession()->mouse();
    314309}
    315310
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r98500 r98503  
    128128    /** Returns the console's guest reference. */
    129129    CGuest& guest() const;
    130     /** Returns the console's mouse reference. */
    131     CMouse& mouse() const;
    132130    /** Returns the console's debugger reference. */
    133131    CMachineDebugger& debugger() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r98450 r98503  
    13281328
    13291329    /* Create the drag and drop handler instance: */
    1330     m_pDnDHandler = new UIDnDHandler(uisession(), this /* pParent */);
     1330    m_pDnDHandler = new UIDnDHandler(uimachine(), uisession(), this /* pParent */);
    13311331    if (m_pDnDHandler)
    13321332    {
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r98451 r98503  
    5959/* COM includes: */
    6060#include "CDisplay.h"
    61 #include "CMouse.h"
    6261
    6362/* Other VBox includes: */
     
    202201
    203202        /* Switch guest mouse to the relative mode: */
    204         mouse().PutMouseEvent(0, 0, 0, 0, 0);
     203        uimachine()->putMouseEvent(0, 0, 0, 0, 0);
    205204
    206205        /* Notify all the listeners: */
     
    409408        releaseMouse();
    410409        /* Also we should switch guest mouse to the absolute mode: */
    411         mouse().PutMouseEventAbsolute(-1, -1, 0, 0, 0);
     410        uimachine()->putMouseEventAbsolute(-1, -1, 0, 0, 0);
    412411    }
    413412#if 0 /* current team's decision is NOT to capture mouse on mouse-absolute mode loosing! */
     
    438437    {
    439438        /* Switch guest mouse to the relative mode: */
    440         mouse().PutMouseEvent(0, 0, 0, 0, 0);
     439        uimachine()->putMouseEvent(0, 0, 0, 0, 0);
    441440    }
    442441#endif
     
    556555{
    557556    return machineLogic()->uisession()->display();
    558 }
    559 
    560 CMouse &UIMouseHandler::mouse() const
    561 {
    562     return machineLogic()->uisession()->mouse();
    563557}
    564558
     
    984978
    985979        /* Pass event to the guest: */
    986         mouse().PutMouseEvent(globalPos.x() - m_lastMousePos.x(),
    987                               globalPos.y() - m_lastMousePos.y(),
    988                               iWheelVertical, iWheelHorizontal, iMouseButtonsState);
     980        uimachine()->putMouseEvent(globalPos.x() - m_lastMousePos.x(),
     981                                   globalPos.y() - m_lastMousePos.y(),
     982                                   iWheelVertical, iWheelHorizontal, iMouseButtonsState);
    989983
    990984#ifdef VBOX_WS_WIN
     
    11521146
    11531147            /* Post absolute mouse-event into guest: */
    1154             mouse().PutMouseEventAbsolute(cpnt.x() + 1, cpnt.y() + 1, iWheelVertical, iWheelHorizontal, iMouseButtonsState);
     1148            uimachine()->putMouseEventAbsolute(cpnt.x() + 1, cpnt.y() + 1, iWheelVertical, iWheelHorizontal, iMouseButtonsState);
    11551149            return true;
    11561150        }
     
    12741268    }
    12751269
    1276     mouse().PutEventMultiTouch(pTouchEvent->touchPoints().size(),
    1277                                contacts,
    1278                                fTouchScreen,
    1279                                (ULONG)RTTimeMilliTS());
     1270    uimachine()->putEventMultiTouch(pTouchEvent->touchPoints().size(),
     1271                                    contacts,
     1272                                    fTouchScreen,
     1273                                    (ULONG)RTTimeMilliTS());
    12801274
    12811275    /* Eat by default? */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r98451 r98503  
    5050class UIMachineWindow;
    5151class CDisplay;
    52 class CMouse;
    5352
    5453
     
    112111    /** Returns the console's display reference. */
    113112    CDisplay &display() const;
    114     /** Returns the console's mouse reference. */
    115     CMouse &mouse() const;
    116113
    117114    /* Event handler for registered machine-view(s): */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98500 r98503  
    304304    if (!comKeyboard.isOk())
    305305        UINotificationMessage::cannotChangeKeyboardParameter(comKeyboard);
     306}
     307
     308BOOL UISession::getAbsoluteSupported()
     309{
     310    return mouse().GetAbsoluteSupported();
     311}
     312
     313BOOL UISession::getRelativeSupported()
     314{
     315    return mouse().GetRelativeSupported();
     316}
     317
     318BOOL UISession::getTouchScreenSupported()
     319{
     320    return mouse().GetTouchScreenSupported();
     321}
     322
     323BOOL UISession::getTouchPadSupported()
     324{
     325    return mouse().GetTouchPadSupported();
     326}
     327
     328BOOL UISession::getNeedsHostCursor()
     329{
     330    return mouse().GetNeedsHostCursor();
     331}
     332
     333void UISession::putMouseEvent(LONG iDx, LONG iDy, LONG iDz, LONG iDw, LONG iButtonState)
     334{
     335    CMouse comMouse = mouse();
     336    comMouse.PutMouseEvent(iDx, iDy, iDz, iDw, iButtonState);
     337    if (!comMouse.isOk())
     338        UINotificationMessage::cannotChangeMouseParameter(comMouse);
     339}
     340
     341void UISession::putMouseEventAbsolute(LONG iX, LONG iY, LONG iDz, LONG iDw, LONG iButtonState)
     342{
     343    CMouse comMouse = mouse();
     344    comMouse.PutMouseEventAbsolute(iX, iY, iDz, iDw, iButtonState);
     345    if (!comMouse.isOk())
     346        UINotificationMessage::cannotChangeMouseParameter(comMouse);
     347}
     348
     349void UISession::putEventMultiTouch(LONG iCount, const QVector<LONG64> &contacts, BOOL fIsTouchScreen, ULONG uScanTime)
     350{
     351    CMouse comMouse = mouse();
     352    comMouse.PutEventMultiTouch(iCount, contacts, fIsTouchScreen, uScanTime);
     353    if (!comMouse.isOk())
     354        UINotificationMessage::cannotChangeMouseParameter(comMouse);
    306355}
    307356
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98500 r98503  
    247247    /** @} */
    248248
     249    /** @name Mouse stuff.
     250     ** @{ */
     251        /** Returns whether VM's mouse supports absolute coordinates. */
     252        BOOL getAbsoluteSupported();
     253        /** Returns whether VM's mouse supports relative coordinates. */
     254        BOOL getRelativeSupported();
     255        /** Returns whether VM's mouse supports touch screen device. */
     256        BOOL getTouchScreenSupported();
     257        /** Returns whether VM's mouse supports touch pad device. */
     258        BOOL getTouchPadSupported();
     259        /** Returns whether VM's mouse requires host cursor. */
     260        BOOL getNeedsHostCursor();
     261
     262        /** Sends relative mouse move event to VM's mouse. */
     263        void putMouseEvent(LONG iDx, LONG iDy, LONG iDz, LONG iDw, LONG iButtonState);
     264        /** Sends absolute mouse move event to VM's mouse. */
     265        void putMouseEventAbsolute(LONG iX, LONG iY, LONG iDz, LONG iDw, LONG iButtonState);
     266        /** Sends multi-touch event to VM's mouse. */
     267        void putEventMultiTouch(LONG iCount, const QVector<LONG64> &contacts, BOOL fIsTouchScreen, ULONG uScanTime);
     268    /** @} */
     269
    249270    /** @name Guest additions stuff.
    250271     ** @{ */
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