VirtualBox

Changeset 52014 in vbox


Ignore:
Timestamp:
Jul 14, 2014 11:16:43 AM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 3646: Make sure keyboard/mouse indicators are properly updated when recreated at runtime.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
9 edited

Legend:

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

    r51995 r52014  
    783783public:
    784784
    785     /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    786     UIIndicatorMouse(CSession &session)
    787         : UISessionStateStatusBarIndicator(session)
     785    /** Constructor, using @a pSession for state-update routine. */
     786    UIIndicatorMouse(UISession *pSession)
     787        : UISessionStateStatusBarIndicator(pSession->session())
    788788    {
    789789        /* Assign state-icons: */
     
    793793        setStateIcon(3, UIIconPool::iconSet(":/mouse_can_seamless_16px.png"));
    794794        setStateIcon(4, UIIconPool::iconSet(":/mouse_can_seamless_uncaptured_16px.png"));
     795        /* Configure connection: */
     796        connect(pSession, SIGNAL(sigMouseStateChange(int)), this, SLOT(setState(int)));
     797        setState(pSession->mouseState());
    795798        /* Translate finally: */
    796799        retranslateUi();
     
    840843public:
    841844
    842     /** Constructor, passes @a session to the UISessionStateStatusBarIndicator constructor. */
    843     UIIndicatorKeyboard(CSession &session)
    844         : UISessionStateStatusBarIndicator(session)
     845    /** Constructor, using @a pSession for state-update routine. */
     846    UIIndicatorKeyboard(UISession *pSession)
     847        : UISessionStateStatusBarIndicator(pSession->session())
    845848    {
    846849        /* Assign state-icons: */
     
    849852        setStateIcon(2, UIIconPool::iconSet(":/hostkey_pressed_16px.png"));
    850853        setStateIcon(3, UIIconPool::iconSet(":/hostkey_captured_pressed_16px.png"));
     854        /* Configure connection: */
     855        connect(pSession, SIGNAL(sigKeyboardStateChange(int)), this, SLOT(setState(int)));
     856        setState(pSession->keyboardState());
    851857        /* Translate finally: */
    852858        retranslateUi();
     
    10651071                case IndicatorType_VideoCapture:      m_pool[indicatorType] = new UIIndicatorVideoCapture(m_session);  break;
    10661072                case IndicatorType_Features:          m_pool[indicatorType] = new UIIndicatorFeatures(m_session);      break;
    1067                 case IndicatorType_Mouse:             m_pool[indicatorType] = new UIIndicatorMouse(m_session);         break;
    1068                 case IndicatorType_Keyboard:          m_pool[indicatorType] = new UIIndicatorKeyboard(m_session);      break;
     1073                case IndicatorType_Mouse:             m_pool[indicatorType] = new UIIndicatorMouse(m_pSession);        break;
     1074                case IndicatorType_Keyboard:          m_pool[indicatorType] = new UIIndicatorKeyboard(m_pSession);     break;
    10691075                case IndicatorType_KeyboardExtension: m_pool[indicatorType] = new UIIndicatorKeyboardExtension;        break;
    10701076                default: break;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r51595 r52014  
    220220
    221221        /* Notify all the listeners: */
    222         emit keyboardStateChanged(keyboardState());
     222        emit sigStateChange(state());
    223223    }
    224224}
     
    275275
    276276        /* Notify all the listeners: */
    277         emit keyboardStateChanged(keyboardState());
     277        emit sigStateChange(state());
    278278    }
    279279}
     
    332332#endif
    333333
    334     emit keyboardStateChanged(keyboardState());
     334    /* Notify all the listeners: */
     335    emit sigStateChange(state());
    335336}
    336337
    337338/* Current keyboard state: */
    338 int UIKeyboardHandler::keyboardState() const
     339int UIKeyboardHandler::state() const
    339340{
    340341    return (m_fIsKeyboardCaptured ? UIViewStateType_KeyboardCaptured : 0) |
     
    15221523    }
    15231524
    1524     /* Notify all listeners: */
    1525     emit keyboardStateChanged(keyboardState());
     1525    /* Notify all the listeners: */
     1526    emit sigStateChange(state());
    15261527
    15271528    /* If the VM is NOT paused: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r51595 r52014  
    5151    Q_OBJECT;
    5252
     53signals:
     54
     55    /** Notifies listeners about state-change. */
     56    void sigStateChange(int iState);
     57
    5358public:
    5459
     
    6772
    6873    /* Current keyboard state: */
    69     int keyboardState() const;
     74    int state() const;
    7075
    7176    /* Some getters required by side-code: */
     
    8893    bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
    8994#endif
    90 
    91 signals:
    92 
    93     /* Notifies listeners about keyboard state-change: */
    94     void keyboardStateChanged(int iNewState);
    9595
    9696protected slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r51671 r52014  
    685685void UIMachineLogic::setKeyboardHandler(UIKeyboardHandler *pKeyboardHandler)
    686686{
     687    /* Set new handler: */
    687688    m_pKeyboardHandler = pKeyboardHandler;
     689    /* Connect to session: */
     690    connect(m_pKeyboardHandler, SIGNAL(sigStateChange(int)),
     691            uisession(), SLOT(setKeyboardState(int)));
    688692}
    689693
    690694void UIMachineLogic::setMouseHandler(UIMouseHandler *pMouseHandler)
    691695{
     696    /* Set new handler: */
    692697    m_pMouseHandler = pMouseHandler;
     698    /* Connect to session: */
     699    connect(m_pMouseHandler, SIGNAL(sigStateChange(int)),
     700            uisession(), SLOT(setMouseState(int)));
    693701}
    694702
     
    955963void UIMachineLogic::prepareHandlers()
    956964{
    957     /* Create keyboard-handler: */
     965    /* Create handlers: */
    958966    setKeyboardHandler(UIKeyboardHandler::create(this, visualStateType()));
    959 
    960     /* Create mouse-handler: */
    961967    setMouseHandler(UIMouseHandler::create(this, visualStateType()));
     968
     969    /* Update UI session values with current: */
     970    uisession()->setKeyboardState(keyboardHandler()->state());
     971    uisession()->setMouseState(mouseHandler()->state());
    962972}
    963973
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r51693 r52014  
    201201        mouse.PutMouseEvent(0, 0, 0, 0, 0);
    202202
    203         /* Emit signal if required: */
    204         emit mouseStateChanged(mouseState());
     203        /* Notify all the listeners: */
     204        emit sigStateChange(state());
    205205    }
    206206}
     
    233233        m_iMouseCaptureViewIndex = -1;
    234234
    235         /* Emit signal if required: */
    236         emit mouseStateChanged(mouseState());
     235        /* Notify all the listeners: */
     236        emit sigStateChange(state());
    237237    }
    238238}
     
    253253
    254254/* Current mouse state: */
    255 int UIMouseHandler::mouseState() const
     255int UIMouseHandler::state() const
    256256{
    257257    return (uisession()->isMouseCaptured() ? UIMouseStateType_MouseCaptured : 0) |
     
    294294{
    295295    /* Get machine state: */
    296     KMachineState state = uisession()->machineState();
     296    KMachineState machineState = uisession()->machineState();
    297297    /* Handle particular machine states: */
    298     switch (state)
     298    switch (machineState)
    299299    {
    300300        case KMachineState_Paused:
     
    313313     * if we are not in paused VM state already: */
    314314    if (machineLogic()->activeMachineWindow() &&
    315         state != KMachineState_Paused &&
    316         state != KMachineState_TeleportingPausedVM)
     315        machineState != KMachineState_Paused &&
     316        machineState != KMachineState_TeleportingPausedVM)
    317317        popupCenter().forgetAboutPausedVMInput(machineLogic()->activeMachineWindow());
    318318
    319     // TODO: Is it really required?
    320     /* Notify all listeners: */
    321     emit mouseStateChanged(mouseState());
     319    /* Notify all the listeners: */
     320    emit sigStateChange(state());
    322321}
    323322
     
    376375    }
    377376
    378     /* Notify all listeners: */
    379     emit mouseStateChanged(mouseState());
     377    /* Notify all the listeners: */
     378    emit sigStateChange(state());
    380379}
    381380
     
    456455    /* Mouse pointer shape state-change updaters: */
    457456    connect(uisession(), SIGNAL(sigMousePointerShapeChange()), this, SLOT(sltMousePointerShapeChanged()));
    458     connect(this, SIGNAL(mouseStateChanged(int)), this, SLOT(sltMousePointerShapeChanged()));
     457    connect(this, SIGNAL(sigStateChange(int)), this, SLOT(sltMousePointerShapeChanged()));
    459458
    460459    /* Initialize: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r51187 r52014  
    4747    Q_OBJECT;
    4848
     49signals:
     50
     51    /** Notifies listeners about state-change. */
     52    void sigStateChange(int iState);
     53
    4954public:
    5055
     
    6570
    6671    /* Current mouse state: */
    67     int mouseState() const;
     72    int state() const;
    6873
    6974#ifdef Q_WS_X11
    7075    bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
    7176#endif /* Q_WS_X11 */
    72 
    73 signals:
    74 
    75     /* Notifies listeners about mouse state-change: */
    76     void mouseStateChanged(int iNewState);
    7777
    7878protected slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r51593 r52014  
    190190
    191191    /* Keyboard getters: */
     192    /** Returns keyboard-state. */
     193    int keyboardState() const { return m_iKeyboardState; }
    192194    bool isNumLock() const { return m_fNumLock; }
    193195    bool isCapsLock() const { return m_fCapsLock; }
     
    197199
    198200    /* Mouse getters: */
     201    /** Returns mouse-state. */
     202    int mouseState() const { return m_iMouseState; }
    199203    bool isMouseSupportsAbsolute() const { return m_fIsMouseSupportsAbsolute; }
    200204    bool isMouseSupportsRelative() const { return m_fIsMouseSupportsRelative; }
     
    243247
    244248    /* Console callback signals: */
     249    /** Notifies listeners about keyboard state-change. */
     250    void sigKeyboardStateChange(int iState);
     251    /** Notifies listeners about mouse state-change. */
     252    void sigMouseStateChange(int iState);
    245253    void sigMousePointerShapeChange();
    246254    void sigMouseCapabilityChange();
     
    273281    void sltInstallGuestAdditionsFrom(const QString &strSource);
    274282
     283    /** Defines @a iKeyboardState. */
     284    void setKeyboardState(int iKeyboardState) { m_iKeyboardState = iKeyboardState; emit sigKeyboardStateChange(m_iKeyboardState); }
     285
     286    /** Defines @a iMouseState. */
     287    void setMouseState(int iMouseState) { m_iMouseState = iMouseState; emit sigMouseStateChange(m_iMouseState); }
     288
    275289private slots:
    276290
     
    445459
    446460    /* Keyboard flags: */
     461    /** Holds the keyboard-state. */
     462    int m_iKeyboardState;
    447463    bool m_fNumLock : 1;
    448464    bool m_fCapsLock : 1;
     
    452468
    453469    /* Mouse flags: */
     470    /** Holds the mouse-state. */
     471    int m_iMouseState;
    454472    bool m_fIsMouseSupportsAbsolute : 1;
    455473    bool m_fIsMouseSupportsRelative : 1;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r51992 r52014  
    232232}
    233233
    234 void UIMachineWindowNormal::prepareHandlers()
    235 {
    236     /* Call to base-class: */
    237     UIMachineWindow::prepareHandlers();
    238 
    239     /* Get keyboard/mouse indicators: */
    240     QIStateStatusBarIndicator *pKeyboardIndicator =
    241         qobject_cast<QIStateStatusBarIndicator*>(m_pIndicatorsPool->indicator(IndicatorType_Keyboard));
    242     QIStateStatusBarIndicator *pMouseIndicator =
    243         qobject_cast<QIStateStatusBarIndicator*>(m_pIndicatorsPool->indicator(IndicatorType_Mouse));
    244 
    245     /* Connect keyboard/mouse state-change handlers: */
    246     if (pKeyboardIndicator)
    247         connect(machineLogic()->keyboardHandler(), SIGNAL(keyboardStateChanged(int)),
    248                 pKeyboardIndicator, SLOT(setState(int)));
    249     if (pMouseIndicator)
    250         connect(machineLogic()->mouseHandler(), SIGNAL(mouseStateChanged(int)),
    251                 pMouseIndicator, SLOT(setState(int)));
    252 
    253     /* Early initialize created connections: */
    254     if (pKeyboardIndicator)
    255         pKeyboardIndicator->setState(machineLogic()->keyboardHandler()->keyboardState());
    256     if (pMouseIndicator)
    257         pMouseIndicator->setState(machineLogic()->mouseHandler()->mouseState());
    258 }
    259 
    260234void UIMachineWindowNormal::loadSettings()
    261235{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h

    r51992 r52014  
    6464    void prepareStatusBar();
    6565    void prepareVisualState();
    66     void prepareHandlers();
    6766    void loadSettings();
    6867
    6968    /* Cleanup helpers: */
    7069    void saveSettings();
    71     //void cleanupHandlers() {}
    7270    //coid cleanupVisualState() {}
    7371    //void cleanupStatusBar() {}
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