VirtualBox

Changeset 37716 in vbox for trunk


Ignore:
Timestamp:
Jun 30, 2011 4:34:13 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: reverted r72134 and follow-ups for now

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

Legend:

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

    r37423 r37716  
    191191            case UIVisualStateType_Seamless:
    192192            {
    193                 /* Keyboard grabbing can fail temporarily because some keyboard shortcut is still grabbed by window manager. */
    194                 if (XGrabKeyboard(QX11Info::display(), m_windows[m_iKeyboardCaptureViewIndex]->machineWindow()->winId(), False, GrabModeAsync, GrabModeAsync, CurrentTime))
    195                     m_fIsKeyboardCaptured = false;
     193                /* Keyboard grabbing can fail because of some keyboard shortcut is still grabbed by window manager.
     194                 * We can't be sure this shortcut will be released at all, so we will retry to grab keyboard for 50 times,
     195                 * and after we will just ignore that issue: */
     196                int cTriesLeft = 50;
     197                while (cTriesLeft && XGrabKeyboard(QX11Info::display(), m_windows[m_iKeyboardCaptureViewIndex]->machineWindow()->winId(), False, GrabModeAsync, GrabModeAsync, CurrentTime)) { --cTriesLeft; }
    196198                break;
    197199            }
     
    210212
    211213        /* Notify all the listeners: */
    212         if (m_fIsKeyboardCaptured)
    213             emit keyboardStateChanged(keyboardState());
     214        emit keyboardStateChanged(keyboardState());
    214215    }
    215216}
     
    482483         * and this hack is probably not necessary anymore. So disable it for Qt >= 4.5.0. */
    483484        case XFocusOut:
     485        case XFocusIn:
    484486        {
    485487            if (isSessionRunning())
     
    487489                if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
    488490                {
    489                     /* Release keyboard: */
    490                     releaseKeyboard();
    491                     /* And all pressed keys including host-one: */
    492                     releaseAllPressedKeys(true);
     491                    if (pEvent->type == XFocusIn)
     492                    {
     493                        /* Capture keyboard by chosen view number: */
     494                        captureKeyboard(uScreenId);
     495                        /* Reset the single-time disable capture flag: */
     496                        if (isAutoCaptureDisabled())
     497                            setAutoCaptureDisabled(false);
     498                    }
     499                    else
     500                    {
     501                        /* Release keyboard: */
     502                        releaseKeyboard();
     503                        /* And all pressed keys including host-one: */
     504                        releaseAllPressedKeys(true);
     505                    }
    493506                }
    494507            }
     
    587600            /* And all pressed keys except the host-one : */
    588601            releaseAllPressedKeys(false /* release host-key? */);
     602            break;
     603        }
     604        case KMachineState_Running:
     605        {
     606            /* Capture the keyboard by the first focused view: */
     607            QList<ulong> theListOfViewIds = m_views.keys();
     608            for (int i = 0; i < theListOfViewIds.size(); ++i)
     609            {
     610                if (viewHasFocus(theListOfViewIds[i]))
     611                {
     612                    /* Capture keyboard: */
     613#ifdef Q_WS_WIN
     614                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
     615                        GetAncestor(m_views[theListOfViewIds[i]]->winId(), GA_ROOT) == GetForegroundWindow())
     616#else /* Q_WS_WIN */
     617                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
     618#endif /* !Q_WS_WIN */
     619                        captureKeyboard(theListOfViewIds[i]);
     620                    /* Reset the single-time disable capture flag: */
     621                    if (isAutoCaptureDisabled())
     622                        setAutoCaptureDisabled(false);
     623                    break;
     624                }
     625            }
    589626            break;
    590627        }
     
    789826        switch (pEvent->type())
    790827        {
     828            case QEvent::FocusIn:
     829                if (isSessionRunning())
     830                {
     831                    /* Capture keyboard: */
     832#ifdef Q_WS_WIN
     833                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally() &&
     834                        GetAncestor(pWatchedView->winId(), GA_ROOT) == GetForegroundWindow())
     835#else /* Q_WS_WIN */
     836                    if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
     837#endif /* !Q_WS_WIN */
     838                        captureKeyboard(uScreenId);
     839                    /* Reset the single-time disable capture flag: */
     840                    if (isAutoCaptureDisabled())
     841                        setAutoCaptureDisabled(false);
     842                }
     843                break;
    791844            case QEvent::FocusOut:
    792845                /* Release keyboard: */
     
    10881141/**
    10891142 * Handle a non-special (C-A-D, pause, print) key press or release
    1090  * @returns true if handling should stop here (spurious event), false otherwise
     1143 * @returns true if handling should stop here, false otherwise
    10911144 */
    10921145bool UIKeyboardHandler::keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount)
     
    11371190        return true;
    11381191    return false;
    1139 }
    1140 
    1141 /** Capture the keyboard if a non-modifier key was pressed. */
    1142 void UIKeyboardHandler::keyEventHandleCapturing(uint8_t uScan, int fFlags,
    1143                                                 ulong uScreenId)
    1144 {
    1145     if (   (fFlags & KeyPressed)
    1146         && uScan != 0x1d /* ctrl */ && uScan != 0x2a /* left shift */
    1147         && uScan != 0x36 /* right shift */ && uScan != 0x38 /* alt */
    1148         && uScan != 0x5b /* left win */ && uScan != 0x5c /* right win */)
    1149     {
    1150         /* Capture keyboard by chosen view number: */
    1151         if (!isAutoCaptureDisabled() && autoCaptureSetGlobally())
    1152             captureKeyboard(uScreenId);
    1153         /* Reset the single-time disable capture flag: */
    1154         if (isAutoCaptureDisabled())
    1155             setAutoCaptureDisabled(false);
    1156     }
    11571192}
    11581193
     
    13591394    }
    13601395
    1361     /* This must come before host key handling */
    1362     keyEventHandleCapturing(uScan, fFlags, uScreenId);
    1363 
    13641396    /* Process the host-combo funtionality: */
    13651397    if (fFlags & KeyPressed)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r37364 r37716  
    126126    bool keyEventCADHandled(uint8_t uScan);
    127127    bool keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount);
    128     void keyEventHandleCapturing(uint8_t uScan, int fFlags, ulong uScreenId);
    129128    bool keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult);
    130129    void keyEventHandleHostComboRelease(ulong uScreenId);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.ui

    r37368 r37716  
    8282    <widget class="QCheckBox" name="m_pEnableAutoGrabCheckbox">
    8383     <property name="whatsThis">
    84       <string>When checked, the keyboard will be captured automatically when you start typing into the virtual machine, preventing the host system from reacting to key combinations such as Alt-Tab.  When the keyboard is not captured the virtual machine may not see certain key combinations.</string>
     84      <string>When checked, the keyboard is automatically captured every time the VM window is activated. When the keyboard is captured, all keystrokes (including system ones like Alt-Tab) are directed to the VM.</string>
    8585     </property>
    8686     <property name="text">
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