VirtualBox

Changeset 37348 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 7, 2011 1:26:46 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72112
Message:

FE/Qt: UIKeyboardHandler refactoring

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

Legend:

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

    r37322 r37348  
    485485        case XFocusIn:
    486486        {
    487             if (uisession()->isRunning())
     487            if (isSessionRunning())
    488488            {
    489489                if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
     
    494494                        captureKeyboard(uScreenId);
    495495                        /* Reset the single-time disable capture flag: */
    496                         if (uisession()->isAutoCaptureDisabled())
    497                             uisession()->setAutoCaptureDisabled(false);
     496                        if (isAutoCaptureDisabled())
     497                            setAutoCaptureDisabled(false);
    498498                    }
    499499                    else
     
    608608            for (int i = 0; i < theListOfViewIds.size(); ++i)
    609609            {
    610                 if (m_views[theListOfViewIds[i]]->hasFocus())
     610                if (viewHasFocus(theListOfViewIds[i]))
    611611                {
    612612                    /* Capture keyboard: */
    613613#ifdef Q_WS_WIN
    614                     if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture() &&
     614                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
    615615                        GetAncestor(m_views[theListOfViewIds[i]]->winId(), GA_ROOT) == GetForegroundWindow())
    616616#else /* Q_WS_WIN */
    617                     if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture())
     617                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
    618618#endif /* !Q_WS_WIN */
    619619                        captureKeyboard(theListOfViewIds[i]);
    620620                    /* Reset the single-time disable capture flag: */
    621                     if (uisession()->isAutoCaptureDisabled())
    622                         uisession()->setAutoCaptureDisabled(false);
     621                    if (isAutoCaptureDisabled())
     622                        setAutoCaptureDisabled(false);
    623623                    break;
    624624                }
     
    827827        {
    828828            case QEvent::FocusIn:
    829                 if (uisession()->isRunning())
     829                if (isSessionRunning())
    830830                {
    831831                    /* Capture keyboard: */
    832832#ifdef Q_WS_WIN
    833                     if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture() &&
     833                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
    834834                        GetAncestor(pWatchedView->winId(), GA_ROOT) == GetForegroundWindow())
    835835#else /* Q_WS_WIN */
    836                     if (!uisession()->isAutoCaptureDisabled() && m_globalSettings.autoCapture())
     836                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
    837837#endif /* !Q_WS_WIN */
    838838                        captureKeyboard(uScreenId);
    839839                    /* Reset the single-time disable capture flag: */
    840                     if (uisession()->isAutoCaptureDisabled())
    841                         uisession()->setAutoCaptureDisabled(false);
     840                    if (isAutoCaptureDisabled())
     841                        setAutoCaptureDisabled(false);
    842842                }
    843843                break;
    844844            case QEvent::FocusOut:
    845845                /* Release keyboard: */
    846                 if (uisession()->isRunning())
     846                if (isSessionRunning())
    847847                    releaseKeyboard();
    848848                /* And all pressed keys: */
     
    11281128         * to the host when the user forgets the Host Key. Note that it's always possible
    11291129         * to send C-A-D to the guest using the Host+Del combination: */
    1130         if (uisession()->isRunning() && m_fIsKeyboardCaptured)
     1130        if (isSessionRunning() && m_fIsKeyboardCaptured)
    11311131        {
    11321132            releaseKeyboard();
     
    12071207            m_bIsHostComboAlone = true;
    12081208            m_bIsHostComboProcessed = false;
    1209             if (uisession()->isRunning())
     1209            if (isSessionRunning())
    12101210                saveKeyStates();
    12111211        }
     
    12411241        if (m_bIsHostComboAlone && !m_bIsHostComboProcessed)
    12421242        {
    1243             if (uisession()->isRunning())
     1243            if (isSessionRunning())
    12441244            {
    12451245                bool ok = true;
     
    12491249                     * this dialog is dismissed because the capture state is to be
    12501250                     * defined by the dialog result itself: */
    1251                     uisession()->setAutoCaptureDisabled(true);
     1251                    setAutoCaptureDisabled(true);
    12521252                    bool fIsAutoConfirmed = false;
    12531253                    ok = vboxProblem().confirmInputCapture(&fIsAutoConfirmed);
    12541254                    if (fIsAutoConfirmed)
    1255                         uisession()->setAutoCaptureDisabled(false);
     1255                        setAutoCaptureDisabled(false);
    12561256                    /* Otherwise, the disable flag will be reset in the next
    12571257                     * machine-view's focus-in event (since may happen asynchronously
     
    12801280            }
    12811281        }
    1282         if (uisession()->isRunning())
     1282        if (isSessionRunning())
    12831283            sendChangedKeyStates();
    12841284    }
     
    16131613}
    16141614
     1615bool UIKeyboardHandler::isAutoCaptureDisabled()
     1616{
     1617    return uisession()->isAutoCaptureDisabled();
     1618}
     1619
     1620void UIKeyboardHandler::setAutoCaptureDisabled(bool fIsAutoCaptureDisabled)
     1621{
     1622    uisession()->setAutoCaptureDisabled(fIsAutoCaptureDisabled);
     1623}
     1624
     1625bool UIKeyboardHandler::autoCaptureSetGlobally()
     1626{
     1627    return m_globalSettings.autoCapture();
     1628}
     1629
     1630bool UIKeyboardHandler::viewHasFocus(ulong uScreenId)
     1631{
     1632    return m_views[uScreenId]->hasFocus();
     1633}
     1634
     1635bool UIKeyboardHandler::isSessionRunning()
     1636{
     1637    return uisession()->isRunning();
     1638}
     1639
    16151640UIMachineWindow* UIKeyboardHandler::isItListenedWindow(QObject *pWatchedObject) const
    16161641{
     
    16461671    return pResultView;
    16471672}
    1648 
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r37322 r37348  
    137137    void saveKeyStates();
    138138    void sendChangedKeyStates();
     139    bool isAutoCaptureDisabled();
     140    void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled);
     141    bool autoCaptureSetGlobally();
     142    bool viewHasFocus(ulong uScreenId);
     143    bool isSessionRunning();
    139144
    140145    UIMachineWindow* isItListenedWindow(QObject *pWatchedObject) const;
Note: See TracChangeset for help on using the changeset viewer.

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