VirtualBox

Ignore:
Timestamp:
Aug 22, 2016 2:58:33 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110322
Message:

FE/Qt: bugref:8151: Runtime UI: Finally, we can again unify all the stuff in 'capture keyboard' functionality; Also standardize the comments with 'release keyboard' functionality.

File:
1 edited

Legend:

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

    r63610 r63612  
    261261    if (m_views.contains(uScreenId))
    262262    {
    263 #if defined(VBOX_WS_MAC)
    264 
    265         /* On Mac, keyboard grabbing is ineffective,
    266          * a low-level keyboard-hook is used instead.
    267          * It is being installed on focus-in event and uninstalled on focus-out.
    268          * S.a. UIKeyboardHandler::eventFilter for more information.
    269          *
    270          * Besides that, we do not grab the keyboard as soon as it is captured,
    271          * but delay it for 300 milliseconds after the formal capture.
    272          * We do it mainly to have the common behavior under all
    273          * hosts and X11 is forced to behave that way. */
    274 
    275         /* Delay finalising capture for 300 milliseconds: */
    276         QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard()));
    277 
    278 #elif defined(VBOX_WS_WIN)
    279 
    280         /* On Win, keyboard grabbing is ineffective,
    281          * a low-level keyboard-hook is used instead.
    282          * It is being installed on focus-in event and uninstalled on focus-out.
    283          * S.a. UIKeyboardHandler::eventFilter for more information.
    284          *
    285          * Besides that, we do not grab the keyboard as soon as it is captured,
    286          * but delay it for 300 milliseconds after the formal capture.
    287          * We do it mainly to have the common behavior under all
    288          * hosts and X11 is forced to behave that way. */
    289 
    290         /* Delay finalising capture for 300 milliseconds: */
    291         QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard()));
    292 
    293 #elif defined(VBOX_WS_X11)
    294 # if QT_VERSION < 0x050000
    295 
    296         /* Nothing for now. */
    297 
    298 # else /* QT_VERSION >= 0x050000 */
    299 
     263        /* Remember which screen wishes to capture the keyboard: */
     264        m_iKeyboardCaptureViewIndex = uScreenId;
     265
     266#if QT_VERSION < 0x050000
     267        /* Finalise keyboard capture: */
     268        finaliseCaptureKeyboard();
     269#else
    300270        /* On X11, we do not grab the keyboard as soon as it is captured, but delay it
    301271         * for 300 milliseconds after the formal capture. We do this for several reasons:
     
    306276         * - Second, grabbing the keyboard immediately on focus change upsets some window managers,
    307277         *   they give us the focus then try to grab the keyboard themselves, and sulk if they fail
    308          *   by refusing to e.g. drag a window using its title bar. */
    309 
    310         /* Delay finalising capture for 300 milliseconds: */
     278         *   by refusing to e.g. drag a window using its title bar.
     279         *
     280         * IMPORTANT! We do the same under all other hosts as well mainly to have the
     281         *            common behavior everywhere while X11 is forced to behave that way. */
    311282        QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard()));
    312 
    313 # endif /* QT_VERSION >= 0x050000 */
    314 #else
    315 
    316         /* Nothing for now. */
    317 
    318 #endif
    319 
    320         /* Remember which screen wishes to capture the keyboard: */
    321         m_iKeyboardCaptureViewIndex = uScreenId;
    322 
    323 #if QT_VERSION < 0x050000
    324         /* Finalise keyboard capture: */
    325         finaliseCaptureKeyboard();
    326283#endif
    327284    }
     
    343300#if defined(VBOX_WS_MAC)
    344301
    345         /* On Mac, we are not just using the Qt stuff to grab the keyboard,
     302        /* On Mac, keyboard grabbing is ineffective, a low-level keyboard-hook is used instead.
     303         * It is being installed on focus-in event and uninstalled on focus-out.
     304         * S.a. UIKeyboardHandler::eventFilter for more information. */
     305
     306        /* Besides that, we are not just using the Qt stuff to grab the keyboard,
    346307         * we also disable global hot keys and enable watching
    347308         * modifiers (for right/left separation). */
    348 
    349309        /// @todo Is that really needed?
    350310        ::DarwinDisableGlobalHotKeys(true);
     
    353313#elif defined(VBOX_WS_WIN)
    354314
    355         /* Nothing for now. */
     315        /* On Win, keyboard grabbing is ineffective, a low-level keyboard-hook is used instead.
     316         * It is being installed on focus-in event and uninstalled on focus-out.
     317         * S.a. UIKeyboardHandler::eventFilter for more information. */
    356318
    357319#elif defined(VBOX_WS_X11)
     
    360322        /* On X11, we are using passive XGrabKey for normal (windowed) mode
    361323         * instead of XGrabKeyboard (called by QWidget::grabKeyboard()) because
    362          * XGrabKeyboard causes a problem under metacity - a window cannot be
    363          * moved using the mouse if it is currently actively grabbing the keyboard;
     324         * XGrabKeyboard causes a problem under metacity - a window cannot be moved
     325         * using the mouse if it is currently actively grabbing the keyboard;
    364326         * For static modes we are using usual (active) keyboard grabbing. */
    365327
     
    458420#if defined(VBOX_WS_MAC)
    459421
    460         /* On Mac, keyboard grabbing is ineffective,
    461          * a low-level keyboard-hook is used instead.
     422        /* On Mac, keyboard grabbing is ineffective, a low-level keyboard-hook is used instead.
    462423         * It is being installed on focus-in event and uninstalled on focus-out.
    463424         * S.a. UIKeyboardHandler::eventFilter for more information. */
    464425
    465         /* On Mac, we also
    466          * use the Qt method to release the keyboard,
    467          * enable global hot keys and
    468          * disable watching modifiers (for right/left separation). */
     426        /* Besides that, we are not just using the Qt stuff to ungrab the keyboard,
     427         * we also enable global hot keys and disable watching
     428         * modifiers (for right/left separation). */
    469429        /// @todo Is that really needed?
    470430        ::DarwinDisableGlobalHotKeys(false);
     
    473433#elif defined(VBOX_WS_WIN)
    474434
    475         /* On Win, keyboard grabbing is ineffective,
    476          * a low-level keyboard-hook is used instead.
     435        /* On Win, keyboard grabbing is ineffective, a low-level keyboard-hook is used instead.
    477436         * It is being installed on focus-in event and uninstalled on focus-out.
    478437         * S.a. UIKeyboardHandler::eventFilter for more information. */
     
    482441
    483442        /* On X11, we are using passive XGrabKey for normal (windowed) mode
    484          * instead of XGrabKeyboard (called by QWidget::grabKeyboard())
    485          * because XGrabKeyboard causes a problem under metacity - a window cannot be moved
     443         * instead of XGrabKeyboard (called by QWidget::grabKeyboard()) because
     444         * XGrabKeyboard causes a problem under metacity - a window cannot be moved
    486445         * using the mouse if it is currently actively grabbing the keyboard;
    487446         * For static modes we are using usual (active) keyboard grabbing. */
     447
    488448        switch (machineLogic()->visualStateType())
    489449        {
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