VirtualBox

Changeset 61954 in vbox


Ignore:
Timestamp:
Jun 30, 2016 10:51:51 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108397
Message:

bugref:6947: FE/Qt: Problem with Alt key up event in Windows guests when Alt-Tab-ing away from guest: replace the 0xFE scan code injection on loss of focus with a Ctrl-Shift-Alt down then up sequence. Hopefully this will be less confusing overall for guests, though there is probably no perfect solution.

File:
1 edited

Legend:

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

    r61945 r61954  
    467467    bool fSentRESEND = false;
    468468
    469     /* Send a dummy scan code (RESEND) to prevent the guest OS from recognizing
     469    /* Send a dummy modifier sequence to prevent the guest OS from recognizing
    470470     * a single key click (for ex., Alt) and performing an unwanted action
    471471     * (for ex., activating the menu) when we release all pressed keys below.
    472      * Note, that it's just a guess that sending RESEND will give the desired
    473      * effect :), but at least it works with NT and W2k guests. */
     472     * This is just a work-around and is likely to fail in some cases.  We are
     473     * not aware of any ideal solution.  Historically we sent an 0xFE scan code,
     474     * but this is a real key release code on Brazilian keyboards. */
    474475    for (uint i = 0; i < SIZEOF_ARRAY (m_pressedKeys); i++)
    475476    {
    476         if (m_pressedKeys[i] & IsKeyPressed)
     477        if ((m_pressedKeys[i] & IsKeyPressed) || (m_pressedKeys[i] & IsExtKeyPressed))
    477478        {
    478479            if (!fSentRESEND)
    479480            {
    480                 keyboard().PutScancode(0xFE);
     481                LONG aCodes[] = { 0x1D,  0x2A, 0x38, 0x9D, 0xAA, 0xB8 };
     482                QVector <LONG> codes(RT_ELEMENTS(aCodes));
     483                for (unsigned i = 0; i < RT_ELEMENTS(aCodes); ++i)
     484                    codes[i] = aCodes[i];
     485                keyboard().PutScancodes(codes);
     486                m_pressedKeys[0x1D] = m_pressedKeys[0x2A] = m_pressedKeys[0x38] = 0;
    481487                fSentRESEND = true;
    482488            }
    483             keyboard().PutScancode(i | 0x80);
    484         }
    485         else if (m_pressedKeys[i] & IsExtKeyPressed)
    486         {
    487             if (!fSentRESEND)
    488             {
    489                 keyboard().PutScancode(0xFE);
    490                 fSentRESEND = true;
    491             }
    492             QVector <LONG> codes(2);
    493             codes[0] = 0xE0;
    494             codes[1] = i | 0x80;
    495             keyboard().PutScancodes(codes);
     489            if (m_pressedKeys[i] & IsKeyPressed)
     490                keyboard().PutScancode(i | 0x80);
     491            else
     492            {
     493                QVector <LONG> codes(2);
     494                codes[0] = 0xE0;
     495                codes[1] = i | 0x80;
     496                keyboard().PutScancodes(codes);
     497            }
    496498        }
    497499        m_pressedKeys[i] = 0;
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