VirtualBox

Changeset 37364 in vbox


Ignore:
Timestamp:
Jun 7, 2011 8:23:51 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72134
Message:

FE/Qt: only grab the keyboard focus when a non-modifier key (or the host combination) is pressed

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

Legend:

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

    r37348 r37364  
    491491                    if (pEvent->type == XFocusIn)
    492492                    {
     493#if 0
    493494                        /* Capture keyboard by chosen view number: */
    494495                        captureKeyboard(uScreenId);
     
    496497                        if (isAutoCaptureDisabled())
    497498                            setAutoCaptureDisabled(false);
     499#endif
    498500                    }
    499501                    else
     
    602604            break;
    603605        }
     606#if 0
    604607        case KMachineState_Running:
    605608        {
     
    626629            break;
    627630        }
     631#endif
    628632        default:
    629633            break;
     
    826830        switch (pEvent->type())
    827831        {
     832#if 0
    828833            case QEvent::FocusIn:
    829834                if (isSessionRunning())
     
    842847                }
    843848                break;
     849#endif
    844850            case QEvent::FocusOut:
    845851                /* Release keyboard: */
     
    11411147/**
    11421148 * Handle a non-special (C-A-D, pause, print) key press or release
    1143  * @returns true if handling should stop here, false otherwise
     1149 * @returns true if handling should stop here (spurious event), false otherwise
    11441150 */
    11451151bool UIKeyboardHandler::keyEventHandleNormal(int iKey, uint8_t uScan, int fFlags, LONG *pCodes, uint *puCodesCount)
     
    11901196        return true;
    11911197    return false;
     1198}
     1199
     1200/** Capture the keyboard if a non-modifier key was pressed. */
     1201void UIKeyboardHandler::keyEventHandleCapturing(uint8_t uScan, int fFlags,
     1202                                                ulong uScreenId)
     1203{
     1204    if (   (fFlags & KeyPressed)
     1205        && uScan != 0x1d /* ctrl */ && uScan != 0x2a /* left shift */
     1206        && uScan != 0x36 /* right shift */ && uScan != 0x38 /* alt */
     1207        && uScan != 0x5b /* left win */ && uScan != 0x5c /* right win */)
     1208    {
     1209        /* Capture keyboard by chosen view number: */
     1210        captureKeyboard(uScreenId);
     1211        /* Reset the single-time disable capture flag: */
     1212        if (isAutoCaptureDisabled())
     1213            setAutoCaptureDisabled(false);
     1214    }
    11921215}
    11931216
     
    13931416                return true;
    13941417    }
     1418   
     1419    /* This must come before host key handling */
     1420    keyEventHandleCapturing(uScan, fFlags, uScreenId);
    13951421
    13961422    /* Process the host-combo funtionality: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r37348 r37364  
    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);
    128129    bool keyEventHostComboHandled(int iKey, wchar_t *pUniKey, bool isHostComboStateChanged, bool *pfResult);
    129130    void keyEventHandleHostComboRelease(ulong uScreenId);
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