VirtualBox

Changeset 45504 in vbox


Ignore:
Timestamp:
Apr 12, 2013 7:31:24 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Keyboard handler: Install MacOS X keyboard-hook on 'focus-in' event instead of 'window-activated' event.

File:
1 edited

Legend:

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

    r45368 r45504  
    800800                break;
    801801            }
    802 #elif defined(Q_WS_MAC)
    803             case QEvent::WindowActivate:
    804             {
    805                 /* If keyboard event handler is NOT currently installed;
    806                  * Or installed but NOT for that window: */
     802#endif
     803            default:
     804                break;
     805        }
     806    }
     807
     808    else
     809
     810    /* Check if pWatchedObject object is view: */
     811    if (UIMachineView *pWatchedView = isItListenedView(pWatchedObject))
     812    {
     813        /* Get corresponding screen index: */
     814        ulong uScreenId = m_views.key(pWatchedView);
     815        NOREF(uScreenId);
     816        /* Handle view events: */
     817        switch (pEvent->type())
     818        {
     819            case QEvent::FocusIn:
     820            {
     821#ifdef Q_WS_MAC
     822                /* If keyboard-event handler is NOT currently installed;
     823                 * Or installed but NOT for that view: */
    807824                if (m_iKeyboardGrabViewIndex != (int)uScreenId)
    808825                {
    809                     /* If keyboard event handler is NOT currently installed: */
     826                    /* If keyboard-event handler is NOT currently installed: */
    810827                    if (m_iKeyboardGrabViewIndex == -1)
    811828                    {
    812                         /* Install the keyboard event handler: */
     829                        /* Install the keyboard-event handler: */
    813830                        darwinGrabKeyboardEvents(true);
    814831                    }
     
    816833                    m_iKeyboardGrabViewIndex = uScreenId;
    817834                }
    818                 break;
    819             }
    820             case QEvent::WindowDeactivate:
    821             {
    822                 /* If keyboard event handler is installed exactly for that window: */
    823                 if (m_iKeyboardGrabViewIndex == (int)uScreenId)
    824                 {
    825                     /* Remove the keyboard event handler: */
    826                     darwinGrabKeyboardEvents(false);
    827                     /* Update the id: */
    828                     m_iKeyboardGrabViewIndex = -1;
    829                 }
    830                 break;
    831             }
    832 #endif
    833             default:
    834                 break;
    835         }
    836     }
    837 
    838     else
    839 
    840     /* Check if pWatchedObject object is view: */
    841     if (UIMachineView *pWatchedView = isItListenedView(pWatchedObject))
    842     {
    843         /* Get corresponding screen index: */
    844         ulong uScreenId = m_views.key(pWatchedView);
    845         NOREF(uScreenId);
    846         /* Handle view events: */
    847         switch (pEvent->type())
    848         {
    849             case QEvent::FocusIn:
     835#endif /* Q_WS_MAC */
     836
    850837                if (isSessionRunning())
    851838                {
     
    863850                }
    864851                break;
     852            }
    865853            case QEvent::FocusOut:
     854            {
     855#ifdef Q_WS_MAC
     856                /* If keyboard-event handler is installed for that view: */
     857                if (m_iKeyboardGrabViewIndex == (int)uScreenId)
     858                {
     859                    /* Remove the keyboard-event handler: */
     860                    darwinGrabKeyboardEvents(false);
     861                    /* Update the id: */
     862                    m_iKeyboardGrabViewIndex = -1;
     863                }
     864#endif /* Q_WS_MAC */
     865
    866866                /* Release keyboard: */
    867867                if (isSessionRunning())
     
    870870                releaseAllPressedKeys(true);
    871871                break;
     872            }
    872873            case QEvent::KeyPress:
    873874            case QEvent::KeyRelease:
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