VirtualBox

Changeset 98983 in vbox for trunk


Ignore:
Timestamp:
Mar 15, 2023 12:06:02 PM (23 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking UIKeyboardHandler a bit; First of all, we should notify UIMachine with actual keyboard-state when machine-state is changed to/from Null state; Besides that, a bit of cleanup.

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

Legend:

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

    r98501 r98983  
    204204{
    205205    /* Do NOT capture the keyboard if it is already captured: */
    206     if (m_fIsKeyboardCaptured)
     206    if (m_fKeyboardCaptured)
    207207    {
    208208        /* Make sure the right screen had captured the keyboard: */
     
    236236{
    237237    /* Do NOT capture the keyboard if it is already captured: */
    238     if (m_fIsKeyboardCaptured)
     238    if (m_fKeyboardCaptured)
    239239        return true;
    240240
     
    326326
    327327        /* Store new keyboard-captured state value: */
    328         m_fIsKeyboardCaptured = true;
     328        m_fKeyboardCaptured = true;
    329329
    330330        /* Notify all the listeners: */
     
    340340{
    341341    /* Do NOT release the keyboard if it is already released: */
    342     if (!m_fIsKeyboardCaptured)
     342    if (!m_fKeyboardCaptured)
    343343    {
    344344        /* If a delayed capture is scheduled then cancel it: */
     
    396396
    397397        /* Store new keyboard-captured state value: */
    398         m_fIsKeyboardCaptured = false;
     398        m_fKeyboardCaptured = false;
    399399
    400400        /* Notify all the listeners: */
     
    454454    if (aReleaseHostKey)
    455455    {
    456         m_bIsHostComboPressed = false;
     456        m_fHostComboPressed = false;
    457457        m_pressedHostComboKeys.clear();
    458458    }
     
    476476int UIKeyboardHandler::state() const
    477477{
    478     return (m_fIsKeyboardCaptured ? UIKeyboardStateType_KeyboardCaptured : 0) |
    479            (m_bIsHostComboPressed ? UIKeyboardStateType_HostKeyPressed : 0) |
     478    return (m_fKeyboardCaptured ? UIKeyboardStateType_KeyboardCaptured : 0) |
     479           (m_fHostComboPressed ? UIKeyboardStateType_HostKeyPressed : 0) |
    480480           (m_fHostKeyComboPressInserted ? UIKeyboardStateType_HostKeyPressedInsertion : 0);
    481481}
     
    793793             * shortcuts for example). So send it directly to the window with the
    794794             * special flag in the reserved area of lParam (to avoid recursion). */
    795             if (!fResult && m_fIsKeyboardCaptured)
     795            if (!fResult && m_fKeyboardCaptured)
    796796            {
    797797                ::SendMessage(pMsg->hwnd, pMsg->message,
     
    906906void UIKeyboardHandler::sltMachineStateChanged()
    907907{
    908     /* Get machine state: */
    909     KMachineState state = uimachine()->machineState();
     908    /* Get previous and cached machine states: */
     909    const KMachineState enmPreviousState = uimachine()->machineStatePrevious();
     910    const KMachineState enmState = uimachine()->machineState();
     911
     912    /* Notify all the listeners that machine state was [de]initialized: */
     913    if (   enmPreviousState == KMachineState_Null
     914        || enmState == KMachineState_Null)
     915        emit sigStateChange(state());
     916
    910917    /* Handle particular machine states: */
    911     switch (state)
     918    switch (enmState)
    912919    {
    913920        case KMachineState_Paused:
     
    952959     * if we are not in paused VM state already: */
    953960    if (machineLogic()->activeMachineWindow() &&
    954         state != KMachineState_Paused &&
    955         state != KMachineState_TeleportingPausedVM)
     961        enmState != KMachineState_Paused &&
     962        enmState != KMachineState_TeleportingPausedVM)
    956963        UINotificationMessage::forgetAboutPausedVMInput();
    957964}
     
    972979    , m_pMachineLogic(pMachineLogic)
    973980    , m_iKeyboardCaptureViewIndex(-1)
    974     , m_fIsKeyboardCaptured(false)
    975     , m_bIsHostComboPressed(false)
     981    , m_fKeyboardCaptured(false)
     982    , m_fHostComboPressed(false)
    976983    , m_bIsHostComboAlone(false)
    977984    , m_bIsHostComboProcessed(false)
     
    12111218                QKeyEvent *pKeyEvent = static_cast<QKeyEvent*>(pEvent);
    12121219
    1213                 if (m_bIsHostComboPressed && pEvent->type() == QEvent::KeyPress)
     1220                if (m_fHostComboPressed && pEvent->type() == QEvent::KeyPress)
    12141221                {
    12151222                    /* Passing F1-F12 keys to the guest: */
     
    12371244                    actionPool()->processHotKey(QKeySequence(pKeyEvent->key()));
    12381245                }
    1239                 else if (!m_bIsHostComboPressed && pEvent->type() == QEvent::KeyRelease)
     1246                else if (!m_fHostComboPressed && pEvent->type() == QEvent::KeyRelease)
    12401247                {
    12411248                    /* Show a possible warning on key release which seems to be more expected by the end user: */
     
    13541361     * captured, but is being released under the capture. Detect this situation
    13551362     * and do not pass on the key press to the virtual machine. */
    1356 /** @todo r=bird: Why do this complicated test before the simple m_fIsKeyboardCaptured one? */
     1363/** @todo r=bird: Why do this complicated test before the simple m_fKeyboardCaptured one? */
    13571364    uint8_t what_pressed =      (event.flags & 0x01)
    13581365                             && (event.vkCode != VK_RSHIFT)
     
    13661373        return false;
    13671374
    1368     if (!m_fIsKeyboardCaptured)
     1375    if (!m_fKeyboardCaptured)
    13691376        return false;
    13701377
     
    14131420         * to the host when the user forgets the Host Key. Note that it's always possible
    14141421         * to send C-A-D to the guest using the Host+Del combination: */
    1415         if (isSessionRunning() && m_fIsKeyboardCaptured)
     1422        if (isSessionRunning() && m_fKeyboardCaptured)
    14161423        {
    14171424            releaseKeyboard();
     
    14631470
    14641471        /* Update keyboard-captured flag: */
    1465         if (m_fIsKeyboardCaptured)
     1472        if (m_fKeyboardCaptured)
    14661473            m_pressedKeys[uScan] |= IsKbdCaptured;
    14671474        else
     
    14901497    if (isHostComboStateChanged)
    14911498    {
    1492         if (!m_bIsHostComboPressed)
    1493         {
    1494             m_bIsHostComboPressed = true;
     1499        if (!m_fHostComboPressed)
     1500        {
     1501            m_fHostComboPressed = true;
    14951502            m_bIsHostComboAlone = true;
    14961503            m_bIsHostComboProcessed = false;
     
    15011508    else
    15021509    {
    1503         if (m_bIsHostComboPressed)
     1510        if (m_fHostComboPressed)
    15041511        {
    15051512            if (m_bIsHostComboAlone)
     
    15231530void UIKeyboardHandler::keyEventHandleHostComboRelease(ulong uScreenId)
    15241531{
    1525     if (m_bIsHostComboPressed)
    1526     {
    1527         m_bIsHostComboPressed = false;
     1532    if (m_fHostComboPressed)
     1533    {
     1534        m_fHostComboPressed = false;
    15281535        /* Capturing/releasing keyboard/mouse if necessary: */
    15291536        if (m_bIsHostComboAlone && !m_bIsHostComboProcessed)
     
    15321539            {
    15331540                bool ok = true;
    1534                 if (!m_fIsKeyboardCaptured)
     1541                if (!m_fKeyboardCaptured)
    15351542                {
    15361543                    /* Temporarily disable auto-capture that will take place after
     
    15521559                                         || !uimachine()->isMouseIntegrated();
    15531560
    1554                     if (m_fIsKeyboardCaptured)
     1561                    if (m_fKeyboardCaptured)
    15551562                    {
    15561563                        releaseKeyboard();
     
    15961603            if (!m_pressedHostComboKeys.contains(iKey))
    15971604                m_pressedHostComboKeys.insert(iKey, uScan);
    1598             else if (m_bIsHostComboPressed)
     1605            else if (m_fHostComboPressed)
    15991606                return true;
    16001607        }
     
    16201627
    16211628    /* Check if currently pressed/released key had changed host-combo state: */
    1622     const bool isHostComboStateChanged = (!m_bIsHostComboPressed &&  fIsFullHostComboPresent) ||
    1623                                          ( m_bIsHostComboPressed && !fIsFullHostComboPresent);
     1629    const bool isHostComboStateChanged = (!m_fHostComboPressed &&  fIsFullHostComboPresent) ||
     1630                                         ( m_fHostComboPressed && !fIsFullHostComboPresent);
    16241631
    16251632#ifdef VBOX_WS_WIN
    1626     if (m_bIsHostComboPressed || isHostComboStateChanged)
     1633    if (m_fHostComboPressed || isHostComboStateChanged)
    16271634    {
    16281635        /* Currently this is used in winKeyboardEvent() only: */
    1629         m_fIsHostkeyInCapture = m_fIsKeyboardCaptured;
     1636        m_fIsHostkeyInCapture = m_fKeyboardCaptured;
    16301637    }
    16311638#endif /* VBOX_WS_WIN */
     
    16441651    uint uCodesCount = 0;
    16451652    uint8_t uWhatPressed = fFlags & KeyExtended ? IsExtKeyPressed : IsKeyPressed;
    1646     if ((!m_bIsHostComboPressed && !isHostComboStateChanged) ||
    1647         ( m_bIsHostComboPressed &&  isHostComboStateChanged) ||
     1653    if ((!m_fHostComboPressed && !isHostComboStateChanged) ||
     1654        ( m_fHostComboPressed &&  isHostComboStateChanged) ||
    16481655        (!(fFlags & KeyPressed) && (m_pressedKeys[uScan] & uWhatPressed)))
    16491656    {
     
    16981705        else
    16991706        {
    1700             if (m_bIsHostComboPressed)
     1707            if (m_fHostComboPressed)
    17011708                m_bIsHostComboAlone = true;
    17021709        }
     
    17201727
    17211728        /* If full host-key sequence was just finalized: */
    1722         if (isHostComboStateChanged && m_bIsHostComboPressed)
     1729        if (isHostComboStateChanged && m_fHostComboPressed)
    17231730        {
    17241731            /* We have to make guest to release pressed keys from the host-combination: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r98500 r98983  
    9696
    9797    /* Some getters required by side-code: */
    98     bool isHostKeyPressed() const { return m_bIsHostComboPressed; }
     98    bool isHostKeyPressed() const { return m_fHostComboPressed; }
    9999#ifdef VBOX_WS_MAC
    100100    bool isHostKeyAlone() const { return m_bIsHostComboAlone; }
     
    201201    QMap<int, uint8_t> m_pressedHostComboKeys;
    202202
    203     bool m_fIsKeyboardCaptured : 1;
    204     bool m_bIsHostComboPressed : 1;
     203    bool m_fKeyboardCaptured : 1;
     204    bool m_fHostComboPressed : 1;
    205205    bool m_bIsHostComboAlone : 1;
    206206    bool m_bIsHostComboProcessed : 1;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98967 r98983  
    324324    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(fServerEnabled);
    325325    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false);
     326}
     327
     328KMachineState UIMachine::machineStatePrevious() const
     329{
     330    return uisession()->machineStatePrevious();
    326331}
    327332
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98940 r98983  
    232232    /** @name Machine-state stuff.
    233233     ** @{ */
     234        /** Returns previous machine state. */
     235        KMachineState machineStatePrevious() const;
    234236        /** Returns cached machine state. */
    235237        KMachineState machineState() const;
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