VirtualBox

Changeset 59377 in vbox


Ignore:
Timestamp:
Jan 18, 2016 1:41:06 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105068
Message:

FE/Qt: Qt5 migration (part 61): Reworking keyboard-handler: Cleanup for X11.

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

Legend:

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

    r59373 r59377  
    813813bool UIKeyboardHandler::x11EventFilter(XEvent *pEvent, ulong uScreenId)
    814814{
    815     /* Check if some system event should be filtered-out.
    816      * Returning 'true' means filtering-out,
    817      * Returning 'false' means passing event to Qt. */
    818     bool fResult = false; /* Pass to Qt by default: */
     815    /* Check if some system event should be filtered out.
     816     * Returning @c true means filtering-out,
     817     * Returning @c false means passing event to Qt. */
     818    bool fResult = false; /* Pass to Qt by default. */
     819
     820    /* Depending on event type: */
    819821    switch (pEvent->type)
    820822    {
     
    850852            break;
    851853        }
     854        /* Watch for key-events: */
    852855        case XKeyPress:
    853856        case XKeyRelease:
    854857        {
    855             /* Translate the keycode to a PC scan code. */
    856             unsigned scan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
    857 
    858             /* Scancodes 0x00 (no valid translation) and 0x80 are ignored: */
    859             if (!(scan & 0x7F))
     858            /* Translate the keycode to a PC scan code: */
     859            unsigned uScan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
     860
     861            /* Scan codes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */
     862            if (!(uScan & 0x7F))
    860863            {
    861864                fResult = true;
     
    874877            }
    875878
    876             KeySym ks = ::wrapXkbKeycodeToKeysym(pEvent->xkey.display, pEvent->xkey.keycode, 0, 0);
    877 
    878             int flags = 0;
    879             if (scan >> 8)
    880                 flags |= KeyExtended;
     879            /* Calculate flags: */
     880            int iFlags = 0;
     881            if (uScan >> 8)
     882                iFlags |= KeyExtended;
    881883            if (pEvent->type == XKeyPress)
    882                 flags |= KeyPressed;
     884                iFlags |= KeyPressed;
    883885
    884886            /* Remove the extended flag: */
    885             scan &= 0x7F;
    886 
    887             /* Special Korean keys must send scancode 0xF1/0xF2 when pressed and nothing
    888              * when released.
    889              */
    890             if (scan == 0x71 || scan == 0x72)
    891             {
    892                 if (pEvent->type == XKeyRelease)  /* Ignore. */
     887            uScan &= 0x7F;
     888
     889            /* Special Korean keys must send scan code 0xF1/0xF2
     890             * when pressed and nothing when released. */
     891            if (uScan == 0x71 || uScan == 0x72)
     892            {
     893                if (pEvent->type == XKeyRelease)
    893894                {
    894895                    fResult = true;
    895896                    break;
    896897                }
    897                 scan |= 0x80;   /* Re-create the bizarre scancode. */
    898             }
    899 
     898                /* Re-create the bizarre scan code: */
     899                uScan |= 0x80;
     900            }
     901
     902            /* Translate the keycode to a keysym: */
     903            KeySym ks = ::wrapXkbKeycodeToKeysym(pEvent->xkey.display, pEvent->xkey.keycode, 0, 0);
     904
     905            /* Update special flags: */
    900906            switch (ks)
    901907            {
    902908                case XK_Print:
    903                     flags |= KeyPrint;
     909                    iFlags |= KeyPrint;
    904910                    break;
    905911                case XK_Pause:
     
    907913                    {
    908914                        ks = XK_Break;
    909                         flags |= KeyExtended;
    910                         scan = 0x46;
     915                        iFlags |= KeyExtended;
     916                        uScan = 0x46;
    911917                    }
    912918                    else
    913                         flags |= KeyPause;
     919                        iFlags |= KeyPause;
    914920                    break;
    915921            }
    916922
    917             fResult = keyEvent(ks, scan, flags, uScreenId);
     923            /* Finally, handle parsed key-event: */
     924            fResult = keyEvent(ks, uScan, iFlags, uScreenId);
     925
     926            break;
    918927        }
    919928        default:
    920929            break;
    921930    }
     931
    922932    /* Return result: */
    923933    return fResult;
     
    15131523
    15141524    /* If some key was pressed or some previously pressed key was released =>
    1515      * we are updating the list of pressed keys and preparing scancodes: */
     1525     * we are updating the list of pressed keys and preparing scan codes: */
    15161526    if ((fFlags & KeyPressed) || (m_pressedKeys[uScan] & uWhatPressed))
    15171527    {
     
    15221532                fixModifierState(pCodes, puCodesCount);
    15231533
    1524         /* Prepend 'extended' scancode if needed: */
     1534        /* Prepend 'extended' scan code if needed: */
    15251535        if (fFlags & KeyExtended)
    15261536            pCodes[(*puCodesCount)++] = 0xE0;
     
    15291539        if (fFlags & KeyPressed)
    15301540        {
    1531             /* Append scancode: */
     1541            /* Append scan code: */
    15321542            pCodes[(*puCodesCount)++] = uScan;
    15331543            m_pressedKeys[uScan] |= uWhatPressed;
     
    15361546        else if (m_pressedKeys[uScan] & uWhatPressed)
    15371547        {
    1538             /* Append scancode: */
     1548            /* Append scan code: */
    15391549            pCodes[(*puCodesCount)++] = uScan | 0x80;
    15401550            m_pressedKeys[uScan] &= ~uWhatPressed;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r59372 r59377  
    17791779bool UIMachineView::x11Event(XEvent *pEvent)
    17801780{
     1781    /* Make sure arguments valid: */
    17811782    AssertPtrReturn(pEvent, false);
    17821783
     
    17871788    switch (pEvent->type)
    17881789    {
     1790        /* Watch for focus-events: */
    17891791        case XFocusIn:
    17901792        case XFocusOut:
     1793        /* Watch for key-events: */
    17911794        case XKeyPress:
    17921795        case XKeyRelease:
     
    18061809    }
    18071810
     1811    /* Return result: */
    18081812    return fResult;
    18091813}
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