VirtualBox

Changeset 63609 in vbox


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

FE/Qt: bugref:8151: Runtime UI: Use the 'delayed keyboard capture' approach on Mac OS X.

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

Legend:

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

    r63608 r63609  
    4040#  include <QX11Info>
    4141# endif
    42 # if !defined(VBOX_WS_MAC) && QT_VERSION >= 0x050000
     42# if QT_VERSION >= 0x050000
    4343#   include <QTimer>
    4444# endif
     
    266266         * a low-level keyboard-hook is used instead.
    267267         * It is being installed on focus-in event and uninstalled on focus-out.
    268          * S.a. UIKeyboardHandler::eventFilter for more information. */
    269 
    270         /* On Mac, we also
    271          * use the Qt method to grab the keyboard,
    272          * disable global hot keys and
    273          * enable watching modifiers (for right/left separation). */
    274         /// @todo Is that really needed?
    275         ::DarwinDisableGlobalHotKeys(true);
    276         m_views[uScreenId]->grabKeyboard();
     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()));
    277277
    278278#elif defined(VBOX_WS_WIN)
     
    360360        m_iKeyboardCaptureViewIndex = uScreenId;
    361361
    362 #if defined(VBOX_WS_MAC) || QT_VERSION < 0x050000
     362#if QT_VERSION < 0x050000
    363363        /* Finalise keyboard capture: */
    364364        finaliseCaptureKeyboard();
     
    380380    if (m_views.contains(m_iKeyboardCaptureViewIndex))
    381381    {
    382 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     382#if defined(VBOX_WS_MAC)
     383
     384        /* On Mac, we are not just using the Qt stuff to grab the keyboard,
     385         * we also disable global hot keys and enable watching
     386         * modifiers (for right/left separation). */
     387
     388        /// @todo Is that really needed?
     389        ::DarwinDisableGlobalHotKeys(true);
     390        m_views[m_iKeyboardCaptureViewIndex]->grabKeyboard();
     391
     392#elif defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
    383393
    384394        /* On X11, we are using XCB stuff to grab the keyboard.
     
    15171527}
    15181528
    1519 #if !defined(VBOX_WS_MAC) && QT_VERSION >= 0x050000
     1529#if QT_VERSION >= 0x050000
    15201530void UIKeyboardHandler::sltFinaliseCaptureKeyboard()
    15211531{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r63608 r63609  
    2020
    2121/* Qt includes: */
     22#include <QtGlobal>
    2223#include <QMap>
    2324#include <QObject>
     
    133134    virtual void sltMachineStateChanged();
    134135
    135 #if !defined(VBOX_WS_MAC) && QT_VERSION >= 0x050000
     136#if QT_VERSION >= 0x050000
    136137    /** Finalises keyboard capture. */
    137138    void sltFinaliseCaptureKeyboard();
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