VirtualBox

Changeset 5973 in vbox for trunk


Ignore:
Timestamp:
Dec 5, 2007 9:41:22 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
26551
Message:

FE/Qt: Fixed a couple of stuck host key regressions (see #2496, r26142).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r5803 r5973  
    7575    void normalizeGeometry (bool adjustPosition = false);
    7676
    77     CConsole &console() { return cconsole; }
     77    CConsole &console() { return mConsole; }
    7878
    7979    bool pause (bool on);
     
    135135    };
    136136
    137     void focusEvent (bool aHasFocus);
     137    void focusEvent (bool aHasFocus, bool aReleaseHostKey = true);
    138138    bool keyEvent (int aKey, uint8_t aScan, int aFlags,
    139139                   wchar_t *aUniKey = NULL);
     
    172172    void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
    173173
    174     void releaseAllPressedKeys (bool aReleaseHostkey = true);
     174    void releaseAllPressedKeys (bool aReleaseHostKey = true);
    175175    void saveKeyStates();
    176176    void sendChangedKeyStates();
     
    192192    void maybeRestrictMinimumSize();
    193193
    194     VBoxConsoleWnd *mainwnd;
    195 
    196     CConsole cconsole;
     194    VBoxConsoleWnd *mMainWnd;
     195
     196    CConsole mConsole;
    197197
    198198    const VBoxGlobalSettings &gs;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r5826 r5973  
    596596                                  QWidget *parent, const char *name, WFlags f)
    597597    : QScrollView (parent, name, f | WStaticContents | WNoAutoErase)
    598     , mainwnd (mainWnd)
    599     , cconsole (console)
     598    , mMainWnd (mainWnd)
     599    , mConsole (console)
    600600    , gs (vboxGlobal().settings())
    601601    , attached (false)
     
    626626#endif
    627627{
    628     Assert (!cconsole.isNull() &&
    629             !cconsole.GetDisplay().isNull() &&
    630             !cconsole.GetKeyboard().isNull() &&
    631             !cconsole.GetMouse().isNull());
     628    Assert (!mConsole.isNull() &&
     629            !mConsole.GetDisplay().isNull() &&
     630            !mConsole.GetKeyboard().isNull() &&
     631            !mConsole.GetMouse().isNull());
    632632
    633633    /* enable MouseMove events */
     
    641641
    642642    /* to fix some focus issues */
    643     mainwnd->menuBar()->installEventFilter (this);
     643    mMainWnd->menuBar()->installEventFilter (this);
    644644
    645645    /* we want to be notified on some parent's events */
    646     mainwnd->installEventFilter (this);
     646    mMainWnd->installEventFilter (this);
    647647
    648648#ifdef Q_WS_X11
     
    663663    /* setup rendering */
    664664
    665     CDisplay display = cconsole.GetDisplay();
     665    CDisplay display = mConsole.GetDisplay();
    666666    Assert (!display.isNull());
    667667
     
    727727    /* setup the callback */
    728728    mCallback = CConsoleCallback (new VBoxConsoleCallback (this));
    729     cconsole.RegisterCallback (mCallback);
    730     AssertWrapperOk (cconsole);
     729    mConsole.RegisterCallback (mCallback);
     730    AssertWrapperOk (mConsole);
    731731
    732732    viewport()->setEraseColor (black);
     
    767767    {
    768768        /* detach our framebuffer from Display */
    769         CDisplay display = cconsole.GetDisplay();
     769        CDisplay display = mConsole.GetDisplay();
    770770        Assert (!display.isNull());
    771771        display.SetupInternalFramebuffer (0);
     
    774774    }
    775775
    776     cconsole.UnregisterCallback (mCallback);
     776    mConsole.UnregisterCallback (mCallback);
    777777}
    778778
     
    786786    if (mode == VBoxDefs::TimerMode)
    787787    {
    788         CDisplay display = cconsole.GetDisplay();
     788        CDisplay display = mConsole.GetDisplay();
    789789        return QSize (display.GetWidth() + frameWidth() * 2,
    790790                      display.GetHeight() + frameWidth() * 2);
     
    847847    /* Make no normalizeGeometry in case we are in manual resize
    848848     * mode or main window is maximized */
    849     if (mainwnd->isMaximized() || mainwnd->isFullScreen())
     849    if (mMainWnd->isMaximized() || mMainWnd->isFullScreen())
    850850        return;
    851851
     
    896896
    897897    if (on)
    898         cconsole.Pause();
     898        mConsole.Pause();
    899899    else
    900         cconsole.Resume();
    901 
    902     bool ok = cconsole.isOk();
     900        mConsole.Resume();
     901
     902    bool ok = mConsole.isOk();
    903903    if (!ok)
    904904    {
    905905        if (on)
    906             vboxProblem().cannotPauseMachine (cconsole);
     906            vboxProblem().cannotPauseMachine (mConsole);
    907907        else
    908             vboxProblem().cannotResumeMachine (cconsole);
     908            vboxProblem().cannotResumeMachine (mConsole);
    909909    }
    910910
     
    10001000                if (isRunning())
    10011001                    focusEvent (false);
     1002                else
     1003                {
     1004                    /* release the host key even when paused */
     1005                    mIsHostkeyPressed = false;
     1006                    emitKeyboardStateChanged();
     1007                }
    10021008                break;
    10031009            }
     
    10421048
    10431049                /* report to the VM thread that we finished resizing */
    1044                 cconsole.GetDisplay().ResizeCompleted (0);
     1050                mConsole.GetDisplay().ResizeCompleted (0);
    10451051
    10461052                mIgnoreMainwndResize = oldIgnoreMainwndResize;
     
    10501056
    10511057                /* update geometry after entering fullscreen | seamless */
    1052                 if (mainwnd->isTrueFullscreen() || mainwnd->isTrueSeamless())
     1058                if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless())
    10531059                    updateGeometry();
    10541060
     
    10641070                                     re->y() - contentsY(),
    10651071                                     re->width(), re->height(), false);
    1066                 /*cconsole.GetDisplay().UpdateCompleted(); - the event was acked already */
     1072                /* mConsole.GetDisplay().UpdateCompleted(); - the event was acked already */
    10671073                return true;
    10681074            }
     
    10721078            {
    10731079                VBoxSetRegionEvent *sre = (VBoxSetRegionEvent*) e;
    1074                 if (mainwnd->isTrueSeamless() &&
     1080                if (mMainWnd->isTrueSeamless() &&
    10751081                    sre->region() != mLastVisibleRegion)
    10761082                {
    10771083                    mLastVisibleRegion = sre->region();
    1078                     mainwnd->setMask (sre->region());
     1084                    mMainWnd->setMask (sre->region());
    10791085                }
    10801086                else if (!mLastVisibleRegion.isNull() &&
    1081                          !mainwnd->isTrueSeamless())
     1087                         !mMainWnd->isTrueSeamless())
    10821088                    mLastVisibleRegion = QRegion();
    10831089                return true;
     
    11041110                    if (mouse_absolute)
    11051111                    {
    1106                         CMouse mouse = cconsole.GetMouse();
     1112                        CMouse mouse = mConsole.GetMouse();
    11071113                        mouse.PutMouseEventAbsolute (-1, -1, 0, 0);
    11081114                        captureMouse (false, false);
     
    11141120                }
    11151121                if (me->needsHostCursor())
    1116                     mainwnd->setMouseIntegrationLocked (false);
     1122                    mMainWnd->setMouseIntegrationLocked (false);
    11171123                return true;
    11181124            }
     
    11771183                 */
    11781184                QWidgetList *list = QApplication::topLevelWidgets ();
    1179                 bool destroyed = list->find (mainwnd) < 0;
     1185                bool destroyed = list->find (mMainWnd) < 0;
    11801186                delete list;
    1181                 if (!destroyed && mainwnd->statusBar())
    1182                     mainwnd->statusBar()->clear();
     1187                if (!destroyed && mMainWnd->statusBar())
     1188                    mMainWnd->statusBar()->clear();
    11831189
    11841190                return true;
     
    12091215                    if (ue->attached())
    12101216                        vboxProblem().cannotAttachUSBDevice (
    1211                             cconsole,
     1217                            mConsole,
    12121218                            vboxGlobal().details (ue->device()), ue->error());
    12131219                    else
    12141220                        vboxProblem().cannotDetachUSBDevice (
    1215                             cconsole,
     1221                            mConsole,
    12161222                            vboxGlobal().details (ue->device()), ue->error());
    12171223                }
     
    12311237            {
    12321238                RuntimeErrorEvent *ee = (RuntimeErrorEvent *) e;
    1233                 vboxProblem().showRuntimeError (cconsole, ee->fatal(),
     1239                vboxProblem().showRuntimeError (mConsole, ee->fatal(),
    12341240                                                ee->errorID(), ee->message());
    12351241                return true;
     
    12621268                            Assert (0);
    12631269
    1264                         CKeyboard keyboard = cconsole.GetKeyboard();
     1270                        CKeyboard keyboard = mConsole.GetKeyboard();
    12651271                        Assert (!keyboard.isNull());
    12661272                        keyboard.PutScancodes (combo, 6);
     
    12691275                    {
    12701276                        /* activate the main menu */
    1271                         if (mainwnd->isTrueSeamless() || mainwnd->isTrueFullscreen())
    1272                             mainwnd->popupMainMenu (mouse_captured);
     1277                        if (mMainWnd->isTrueSeamless() || mMainWnd->isTrueFullscreen())
     1278                            mMainWnd->popupMainMenu (mouse_captured);
    12731279                        else
    1274                             mainwnd->menuBar()->setFocus();
     1280                            mMainWnd->menuBar()->setFocus();
    12751281                    }
    12761282                    else
     
    12791285                         * (as in case of non-alphanumeric keys) */
    12801286                        processHotKey (QKeySequence (ke->key()),
    1281                                        mainwnd->menuBar());
     1287                                       mMainWnd->menuBar());
    12821288                    }
    12831289                }
     
    13591365        }
    13601366    }
    1361     else if (watched == mainwnd)
     1367    else if (watched == mMainWnd)
    13621368    {
    13631369        switch (e->type())
     
    14221428        }
    14231429    }
    1424     else if (watched == mainwnd->menuBar())
     1430    else if (watched == mMainWnd->menuBar())
    14251431    {
    14261432        /*
     
    14421448                QKeyEvent *ke = (QKeyEvent *) e;
    14431449                if (ke->key() == Key_Escape && !(ke->state() & KeyButtonMask))
    1444                     if (mainwnd->menuBar()->hasFocus())
     1450                    if (mMainWnd->menuBar()->hasFocus())
    14451451                        setFocus();
    14461452                break;
     
    14691475    sprintf (buf, "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X",
    14701476             event.vkCode, event.scanCode, event.flags, event.dwExtraInfo);
    1471     mainwnd->statusBar()->message (buf);
     1477    mMainWnd->statusBar()->message (buf);
    14721478#endif
    14731479
     
    15411547             ((msg->lParam >> 30) & 0x1),
    15421548             ((msg->lParam >> 31) & 0x1));
    1543     mainwnd->statusBar()->message (buf);
     1549    mMainWnd->statusBar()->message (buf);
    15441550    LogFlow (("%s\n", buf));
    15451551#endif
     
    16431649                 CHAR4FROMMP (aMsg->mp1), SHORT1FROMMP (aMsg->mp2),
    16441650                 SHORT2FROMMP (aMsg->mp2));
    1645         mainwnd->statusBar()->message (buf);
     1651        mMainWnd->statusBar()->message (buf);
    16461652        LogFlow (("%s\n", buf));
    16471653    }
     
    17521758             event->type == XKeyPress ? 1 : 0, event->xkey.keycode,
    17531759             event->xkey.state, wineKeyboardInfo.dwFlags, wineKeyboardInfo.wScan);
    1754     mainwnd->statusBar()->message (buf);
     1760    mMainWnd->statusBar()->message (buf);
    17551761    LogFlow (("### %s\n", buf));
    17561762#endif
     
    19491955 *  input in situations similar to gaining or losing focus.
    19501956 *
    1951  *  @param aHasFocus True if the window got focus and false otherwise.
     1957 *  @param aHasFocus        true if the window got focus and false otherwise.
     1958 *  @param aReleaseHostKey  true to release the host key (used only when
     1959 *                          @a aHasFocus is false.
    19521960 */
    1953 void VBoxConsoleView::focusEvent (bool aHasFocus)
     1961void VBoxConsoleView::focusEvent (bool aHasFocus,
     1962                                  bool aReleaseHostKey /* = true */)
    19541963{
    19551964    if (aHasFocus)
     
    19801989        captureMouse (false);
    19811990        captureKbd (false, false);
    1982         releaseAllPressedKeys (!aHasFocus);
     1991        releaseAllPressedKeys (aReleaseHostKey);
    19831992    }
    19841993}
     
    20732082    {
    20742083        QSize newSize = QSize();
    2075         if (mainwnd->isTrueFullscreen() || mainwnd->isTrueSeamless())
     2084        if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless())
    20762085        {
    20772086            mNormalSize = frameSize();
     
    21032112        sprintf (buf, "aKey=%08X aScan=%02X aFlags=%08X",
    21042113                 aKey, aScan, aFlags);
    2105         mainwnd->statusBar()->message (buf);
     2114        mMainWnd->statusBar()->message (buf);
    21062115    }
    21072116#endif
     
    23012310                processed = processHotKey (QKeySequence (UNICODE_ACCEL +
    23022311                                                QChar (ch).upper().unicode()),
    2303                                            mainwnd->menuBar());
     2312                                           mMainWnd->menuBar());
    23042313        }
    23052314        delete[] list;
     
    23212330                processed = processHotKey (QKeySequence (UNICODE_ACCEL +
    23222331                                                c.upper().unicode()),
    2323                                            mainwnd->menuBar());
     2332                                           mMainWnd->menuBar());
    23242333            }
    23252334        }
     
    23282337            processed = processHotKey (QKeySequence (UNICODE_ACCEL +
    23292338                                                     QChar (aUniKey [0]).upper().unicode()),
    2330                                        mainwnd->menuBar());
     2339                                       mMainWnd->menuBar());
    23312340
    23322341        /* Don't consider the hot key as pressed since the guest never saw
     
    23492358    }
    23502359
    2351     CKeyboard keyboard = cconsole.GetKeyboard();
     2360    CKeyboard keyboard = mConsole.GetKeyboard();
    23522361    Assert (!keyboard.isNull());
    23532362
     
    23632372        for (uint i = 0; i < count; ++ i)
    23642373            sprintf (buf + strlen (buf), "%02X ", codes [i]);
    2365         mainwnd->statusBar()->message (buf);
     2374        mMainWnd->statusBar()->message (buf);
    23662375        LogFlow (("%s\n", buf));
    23672376    }
     
    23912400             aType, aPos.x(), aPos.y(), aButton, aState, aStateAfter,
    23922401             aWheelDelta, aWheelDir);
    2393     mainwnd->statusBar()->message (buf);
     2402    mMainWnd->statusBar()->message (buf);
    23942403#else
    23952404    Q_UNUSED (aButton);
     
    24212430#endif
    24222431
    2423         CMouse mouse = cconsole.GetMouse();
     2432        CMouse mouse = mConsole.GetMouse();
    24242433        mouse.PutMouseEvent (aGlobalPos.x() - last_pos.x(),
    24252434                             aGlobalPos.y() - last_pos.y(),
     
    25222531            DarwinCursorSet (&mDarwinCursor);
    25232532#endif
    2524         if (mainwnd->isTrueFullscreen())
     2533        if (mMainWnd->isTrueFullscreen())
    25252534        {
    25262535            if (mode != VBoxDefs::SDLMode)
     
    25712580            else if (cpnt.y() >= ch) cpnt.setY (ch - 1);
    25722581
    2573             CMouse mouse = cconsole.GetMouse();
     2582            CMouse mouse = mConsole.GetMouse();
    25742583            mouse.PutMouseEventAbsolute (cpnt.x() + 1, cpnt.y() + 1,
    25752584                                         wheel, state);
     
    26282637                 */
    26292638                QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), 32, 0);
    2630                 CDisplay dsp = cconsole.GetDisplay();
     2639                CDisplay dsp = mConsole.GetDisplay();
    26312640                dsp.TakeScreenShot (shot.bits(), shot.width(), shot.height());
    26322641                /*
     
    26492658            /* reuse the focus event handler to uncapture everything */
    26502659            if (hasFocus())
    2651                 focusEvent (false);
     2660                focusEvent (false /* aHasFocus*/, false /* aReleaseHostKey */);
    26522661            break;
    26532662        }
     
    26642673                     *  the viewport through IFramebuffer::NotifyUpdate)
    26652674                     */
    2666                     CDisplay dsp = cconsole.GetDisplay();
     2675                    CDisplay dsp = mConsole.GetDisplay();
    26672676                    dsp.InvalidateAndUpdate();
    26682677                }
     
    26702679            /* reuse the focus event handler to capture input */
    26712680            if (hasFocus())
    2672                 focusEvent (true);
     2681                focusEvent (true /* aHasFocus */);
    26732682            break;
    26742683        }
     
    26832692{
    26842693#if defined (VBOX_GUI_USE_REFRESH_TIMER)
    2685     if ( mode == VBoxDefs::TimerMode ) {
    2686         FRAMEBUF_DEBUG_START( xxx );
     2694    if (mode == VBoxDefs::TimerMode)
     2695    {
     2696        FRAMEBUF_DEBUG_START (xxx);
    26872697        QSize last_sz = pm.size();
    2688         bool rc = display_to_pixmap( cconsole, pm );
    2689         if ( rc ) {
    2690             if ( pm.size() != last_sz ) {
     2698        bool rc = display_to_pixmap (mConsole, pm);
     2699        if (rc)
     2700        {
     2701            if (pm.size() != last_sz)
     2702            {
    26912703                int pw = pm.width(), ph = pm.height();
    2692                 resizeContents( pw, ph );
     2704                resizeContents (pw, ph);
    26932705                updateGeometry();
    2694                 setMaximumSize( sizeHint() );
    2695                 // let our toplevel widget calculate its sizeHint properly
    2696                 QApplication::sendPostedEvents( 0, QEvent::LayoutHint );
     2706                setMaximumSize (sizeHint());
     2707                /* let our toplevel widget calculate its sizeHint properly */
     2708                QApplication::sendPostedEvents (0, QEvent::LayoutHint);
    26972709                normalizeGeometry();
    2698             } else {
    2699                 // the alternative is to update, so we will be repainted
    2700                 // on the next event loop iteration. currently disabled.
    2701                 //updateContents();
    2702                 repaintContents( false );
    2703             }
    2704         }
    2705         if ( rc )
    2706             FRAMEBUF_DEBUG_STOP( xxx, pm.width(), pm.height() );
     2710            }
     2711            else
     2712            {
     2713                /* the alternative is to update, so we will be repainted
     2714                 * on the next event loop iteration. currently disabled.
     2715                 * updateContents(); */
     2716                repaintContents (false);
     2717            }
     2718        }
     2719        if (rc)
     2720            FRAMEBUF_DEBUG_STOP (xxx, pm.width(), pm.height());
    27072721    }
    27082722    else
    27092723#endif
    2710         repaintContents( false );
     2724        repaintContents (false);
    27112725}
    27122726
     
    28502864#endif
    28512865        /* release mouse buttons */
    2852         CMouse mouse = cconsole.GetMouse();
     2866        CMouse mouse = mConsole.GetMouse();
    28532867        mouse.PutMouseEvent (0, 0, 0, 0);
    28542868    }
     
    29152929}
    29162930
    2917 void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostkey)
     2931/**
     2932 * Send the KEY BREAK code to the VM for all currently pressed keys.
     2933 *
     2934 * @param aReleaseHostKey @c true to set the host key state to unpressed.
     2935 */
     2936void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostKey)
    29182937{
    29192938    AssertMsg (attached, ("Console must be attached"));
    29202939
    2921     CKeyboard keyboard = cconsole.GetKeyboard();
     2940    CKeyboard keyboard = mConsole.GetKeyboard();
    29222941    bool fSentRESEND = false;
    29232942
    2924     // send a dummy scan code (RESEND) to prevent the guest OS from recognizing
    2925     // a single key click (for ex., Alt) and performing an unwanted action
    2926     // (for ex., activating the menu) when we release all pressed keys below.
    2927     // Note, that it's just a guess that sending RESEND will give the desired
    2928     // effect :), but at least it works with NT and W2k guests.
    2929 
    2930     // @TODO Sending 0xFE is responsible for the warning
     2943    /* send a dummy scan code (RESEND) to prevent the guest OS from recognizing
     2944     * a single key click (for ex., Alt) and performing an unwanted action
     2945     * (for ex., activating the menu) when we release all pressed keys below.
     2946     * Note, that it's just a guess that sending RESEND will give the desired
     2947     * effect :), but at least it works with NT and W2k guests. */
     2948
     2949    /// @todo Sending 0xFE is responsible for the warning
    29312950    //
    29322951    //         ``atkbd.c: Spurious NAK on isa0060/serio0. Some program might
     
    29362955    //       send this command unless we really have to release any key modifier.
    29372956    //                                                                    --frank
     2957
    29382958    for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); i++)
    29392959    {
     
    29622982    }
    29632983
    2964     if (aReleaseHostkey)
     2984    if (aReleaseHostKey)
    29652985        mIsHostkeyPressed = false;
    29662986
     
    29863006
    29873007    LONG codes [2];
    2988     CKeyboard keyboard = cconsole.GetKeyboard();
     3008    CKeyboard keyboard = mConsole.GetKeyboard();
    29893009    for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); ++ i)
    29903010    {
     
    33263346         * We assume here that the centralWidget() contains this view only
    33273347         * and gives it all available space. */
    3328         QSize sz (aToSize.isValid() ? aToSize : mainwnd->centralWidget()->size());
     3348        QSize sz (aToSize.isValid() ? aToSize : mMainWnd->centralWidget()->size());
    33293349        if (!aToSize.isValid())
    33303350            sz -= QSize (frameWidth() * 2, frameWidth() * 2);
    33313351        LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height()));
    33323352
    3333         cconsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
     3353        mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
    33343354    }
    33353355}
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