VirtualBox

Changeset 30074 in vbox


Ignore:
Timestamp:
Jun 7, 2010 1:59:57 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt: 4977: Second try to fix keyboard capture issue with metacity

File:
1 edited

Legend:

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

    r29992 r30074  
    25162516        return;
    25172517
    2518     /* On Win32, keyboard grabbing is ineffective, a low-level keyboard hook is used instead.
    2519      * On X11, we use XGrabKey instead of XGrabKeyboard (called by QWidget::grabKeyboard())
    2520      * because the latter causes problems under metacity 2.16 (in particular, due to a bug,
    2521      * a window cannot be moved using the mouse if it is currently grabing the keyboard).
    2522      * On Mac OS X, we use the Qt methods + disabling global hot keys + watching modifiers
     2518#if defined(Q_WS_WIN32)
     2519    /* On Win32, keyboard grabbing is ineffective, a low-level keyboard hook is used instead. */
     2520#elif defined(Q_WS_X11)
     2521    /* On X11, we are using passive XGrabKey for normal (windowed) mode
     2522     * instead of XGrabKeyboard (called by QWidget::grabKeyboard())
     2523     * because XGrabKeyboard causes a problem under metacity - a window cannot be moved
     2524     * using the mouse if it is currently actively grabing the keyboard;
     2525     * For static modes we are using usual (active) keyboard grabbing. */
     2526    switch (machineLogic()->visualStateType())
     2527    {
     2528        /* If window is moveable we are making passive keyboard grab: */
     2529        case UIVisualStateType_Normal:
     2530        {
     2531            if (fCapture)
     2532                XGrabKey(QX11Info::display(), AnyKey, AnyModifier, machineWindowWrapper()->machineWindow()->winId(), False, GrabModeAsync, GrabModeAsync);
     2533            else
     2534                XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, machineWindowWrapper()->machineWindow()->winId());
     2535            break;
     2536        }
     2537        /* If window is NOT moveable we are making active keyboard grab: */
     2538        case UIVisualStateType_Fullscreen:
     2539        case UIVisualStateType_Seamless:
     2540        {
     2541            if (fCapture)
     2542                XGrabKeyboard(QX11Info::display(), machineWindowWrapper()->machineWindow()->winId(), False, GrabModeAsync, GrabModeAsync, CurrentTime);
     2543            else
     2544                XUngrabKeyboard(QX11Info::display(), CurrentTime);
     2545            break;
     2546        }
     2547        /* Should we try to grab keyboard in default case? I think - NO. */
     2548        default:
     2549            break;
     2550    }
     2551#elif defined(Q_WS_MAC)
     2552    /* On Mac OS X, we use the Qt methods + disabling global hot keys + watching modifiers
    25232553     * (for right/left separation). */
    2524 #if defined(Q_WS_WIN32)
    2525     /**/
    2526 #elif defined(Q_WS_X11)
    2527         if (fCapture)
    2528             XGrabKey(QX11Info::display(), AnyKey, AnyModifier, winId(), False, GrabModeAsync, GrabModeAsync);
    2529         else
    2530             XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, winId());
    2531 #elif defined(Q_WS_MAC)
    25322554    if (fCapture)
    25332555    {
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