VirtualBox

Changeset 9036 in vbox for trunk


Ignore:
Timestamp:
May 21, 2008 7:34:43 PM (17 years ago)
Author:
vboxsync
Message:

2800: "FE/Qt: Switch to fullscreen does not work reliably":
Latest fullscreen/seamless fix.

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

Legend:

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

    r8902 r9036  
    9898    void fixModifierState (LONG *codes, uint *count);
    9999
    100     void toggleFSMode();
     100    void toggleFSMode (const QSize &aSize = QSize());
    101101
    102102    void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; }
     
    249249
    250250    QTimer *resize_hint_timer;
    251     QTimer *mToggleFSModeTimer;
    252251
    253252    VBoxDefs::RenderMode mode;
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleWnd.h

    r8813 r9036  
    190190    void dbgLoggingToggled (bool);
    191191
    192     void onEnterFullscreen();
    193192    void onExitFullscreen();
    194     void exitFullscreen();
    195     void exitSeamless();
     193    void unlockActionsSwitch();
    196194
    197195    void setViewInSeamlessMode (const QRect &aTargetRect);
     
    329327    bool mIsSeamlessSupported : 1;
    330328    bool mIsGraphicsSupported : 1;
     329    bool mIsWaitingModeResize : 1;
    331330    int normal_wflags;
    332331    bool was_max : 1;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r8902 r9036  
    684684             this, SLOT (doResizeHint()));
    685685
    686     /* This timer is used as 'last resort' which toggles f/s mode
    687        in case of guest additions are not responding. */
    688     mToggleFSModeTimer = new QTimer (this);
    689     connect (mToggleFSModeTimer, SIGNAL (timeout()),
    690              this, SIGNAL (resizeHintDone()));
    691 
    692686    /* setup rendering */
    693687
     
    783777        setDesktopGeometry (DesktopGeo_Fixed, width, height);
    784778    }
    785     connect (QApplication::desktop(), SIGNAL (workAreaResized (int)),
     779    connect (QApplication::desktop(), SIGNAL (resized (int)),
    786780             this, SLOT (doResizeDesktop (int)));
    787781
     
    10711065                LogFlow (("VBoxDefs::ResizeEventType: %d x %d x %d bpp\n",
    10721066                          re->width(), re->height(), re->bitsPerPixel()));
    1073 
    1074                 if (mToggleFSModeTimer->isActive())
    1075                     mToggleFSModeTimer->stop();
    10761067
    10771068                /* do frame buffer dependent resize */
     
    22512242 *  Called on enter/exit seamless/fullscreen mode.
    22522243 */
    2253 void VBoxConsoleView::toggleFSMode()
     2244void VBoxConsoleView::toggleFSMode (const QSize &aSize)
    22542245{
    22552246    if ((mIsAdditionsActive && mAutoresizeGuest) ||
    22562247        mMainWnd->isTrueFullscreen())
    22572248    {
    2258         QSize newSize = QSize();
    2259         if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless())
    2260         {
    2261             mNormalSize = frameSize();
     2249        QSize newSize;
     2250        if (aSize.isValid())
     2251        {
     2252            mNormalSize = aSize;
    22622253            newSize = maximumSize();
    22632254        }
     
    22662257        doResizeHint (newSize);
    22672258    }
    2268     /* Currently there is 2000 msec pause before timer transfers
    2269      * console into desired mode "if GA are active and auto-resize
    2270      * feature enabled" and 100 msec pause before it transfers
    2271      * console into this mode "if GA are not active or auto-resize
    2272      * feature disabled". 100 msec pause required for resizing
    2273      * before normalizing geometry. */
    2274     mToggleFSModeTimer->start (mIsAdditionsActive && mAutoresizeGuest ?
    2275         2000 : 100, true);
    2276 
    2277     /// @todo (r=dsen) perform roll-back after 'entering' mode in case
    2278     //                 we got no resizing response from the guest.
    22792259}
    22802260
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp

    r9028 r9036  
    122122    , mIsSeamlessSupported (false)
    123123    , mIsGraphicsSupported (false)
     124    , mIsWaitingModeResize (false)
    124125    , normal_wflags (getWFlags())
    125126    , was_max (false)
     
    10341035
    10351036/**
    1036  *  This slot is called just after entering the fullscreen/seamless mode,
    1037  *  when the console was resized to required size.
    1038  */
    1039 void VBoxConsoleWnd::onEnterFullscreen()
    1040 {
    1041     disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
    1042     /* It isn't guaranteed that the guest os set the video mode that
    1043      * we requested. So after all the resizing stuff set the clipping
    1044      * mask and the spacing shifter to the corresponding values. */
    1045     setViewInSeamlessMode (QRect (console->mapToGlobal (QPoint (0, 0)), console->size()));
    1046 #ifdef Q_WS_MAC
    1047     if (!mIsSeamless)
    1048     {
    1049         /* Fade back to the normal gamma */
    1050         CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
    1051         CGReleaseDisplayFadeReservation (mFadeToken);
    1052     }
    1053 #endif
    1054 
    1055     vmSeamlessAction->setEnabled (mIsSeamless);
    1056     vmFullscreenAction->setEnabled (mIsFullscreen);
    1057     if (mIsSeamless)
    1058         connect (console, SIGNAL (resizeHintDone()),
    1059                  this, SLOT (exitSeamless()));
    1060     /* disabled for now */
    1061     //else if (mIsFullscreen)
    1062     //    connect (console, SIGNAL (resizeHintDone()),
    1063     //             this, SLOT (exitFullscreen()));
    1064 }
    1065 
    1066 /**
    10671037 *  This slot is called just after leaving the fullscreen/seamless mode,
    10681038 *  when the console was resized to previous size.
     
    10701040void VBoxConsoleWnd::onExitFullscreen()
    10711041{
    1072     disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
     1042    console->setIgnoreMainwndResize (false);
     1043}
     1044
     1045void VBoxConsoleWnd::unlockActionsSwitch()
     1046{
     1047    if (mIsSeamless)
     1048        vmSeamlessAction->setEnabled (true);
     1049    else if (mIsFullscreen)
     1050        vmFullscreenAction->setEnabled (true);
     1051    else
     1052    {
     1053        vmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported);
     1054        vmFullscreenAction->setEnabled (true);
     1055    }
     1056
    10731057#ifdef Q_WS_MAC
    10741058    if (!mIsSeamless)
     
    10791063    }
    10801064#endif
    1081 
    1082     vmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported);
    1083     vmFullscreenAction->setEnabled (true);
    1084 
    1085     console->setIgnoreMainwndResize (false);
    1086     console->normalizeGeometry (true /* adjustPosition */);
    1087 }
    1088 
    1089 /**
    1090  *  This slot is called if the guest changes resolution while in fullscreen
    1091  *  mode.
    1092  */
    1093 void VBoxConsoleWnd::exitFullscreen()
    1094 {
    1095     Assert (0); /* disabled for now */
    1096     if (mIsFullscreen && vmFullscreenAction->isEnabled())
    1097         vmFullscreenAction->toggle();
    1098 }
    1099 
    1100 /**
    1101  *  This slot is called if the guest changes resolution while in seamless
    1102  *  mode.
    1103  */
    1104 void VBoxConsoleWnd::exitSeamless()
    1105 {
    1106     if (mIsSeamless && vmSeamlessAction->isEnabled())
    1107         vmSeamlessAction->toggle();
    11081065}
    11091066
     
    11581115            QResizeEvent *re = (QResizeEvent *) e;
    11591116
    1160             if (!isMaximized() && !isTrueFullscreen() && !isTrueSeamless())
     1117            if (!mIsWaitingModeResize && !isMaximized() &&
     1118                !isTrueFullscreen() && !isTrueSeamless())
    11611119            {
    11621120                normal_size = re->size();
     
    11641122                dbgAdjustRelativePos();
    11651123#endif
     1124            }
     1125
     1126            if (mIsWaitingModeResize)
     1127            {
     1128                if (!mIsFullscreen && !mIsSeamless)
     1129                {
     1130                    mIsWaitingModeResize = false;
     1131                    QTimer::singleShot (0, this, SLOT (onExitFullscreen()));
     1132                }
    11661133            }
    11671134            break;
     
    19751942bool VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless)
    19761943{
    1977     disconnect (console, SIGNAL (resizeHintDone()), 0, 0);
    1978     /* Check if the Guest Video RAM enough for the fullscreen/seamless mode. */
     1944    QSize initialSize = size();
    19791945    if (aSeamless || console->isAutoresizeGuestActive())
    19801946    {
     
    20732039    bool wasHidden = isHidden();
    20742040
     2041    /* Temporarily disable the mode-related action to make sure
     2042     * user can not leave the mode before he enter it and inside out. */
     2043    aSeamless ? vmSeamlessAction->setEnabled (false) :
     2044                vmFullscreenAction->setEnabled (false);
     2045
     2046    /* Calculate initial console size */
     2047    QSize consoleSize;
     2048
    20752049    if (aOn)
    20762050    {
    2077         /* Temporarily disable the mode-related action to make sure
    2078          * user can not leave the mode before he enter it. */
    2079         aSeamless ? vmSeamlessAction->setEnabled (false) :
    2080                     vmFullscreenAction->setEnabled (false);
     2051        consoleSize = console->frameSize();
     2052        consoleSize -= QSize (console->frameWidth() * 2, console->frameWidth() * 2);
     2053
    20812054        /* Toggle console to manual resize mode. */
    20822055        console->setIgnoreMainwndResize (true);
    2083         connect (console, SIGNAL (resizeHintDone()),
    2084                  this, SLOT (onEnterFullscreen()));
    20852056
    20862057        /* Memorize the maximized state. */
     
    21042075         * we requested. So after all the resizing stuff set the clipping
    21052076         * mask and the spacing shifter to the corresponding values. */
    2106         setViewInSeamlessMode (dtw->availableGeometry (this));
     2077        if (aSeamless)
     2078            setViewInSeamlessMode (scrGeo);
    21072079
    21082080#ifdef Q_WS_WIN32
     
    21452117        console->setHScrollBarMode (QScrollView::AlwaysOff);
    21462118
    2147         /* Going fullscreen */
    2148         setWindowState (windowState() ^ WindowFullScreen);
    21492119#ifdef Q_WS_MAC /* setMask seems to not include the far border pixels. */
    21502120//        QRect maskRect = dtw->screenGeometry (this);
     
    21802150//        setMask (dtw->screenGeometry (this));
    21812151#endif
    2182 
    2183         qApp->processEvents();
    2184         console->toggleFSMode();
    21852152    }
    21862153    else
    21872154    {
    2188         /* Temporarily disable the mode-related action to make sure
    2189          * user can not enter the mode before he leave it. */
    2190         aSeamless ? vmSeamlessAction->setEnabled (false) :
    2191                     vmFullscreenAction->setEnabled (false);
    2192         /* Toggle console to manual resize mode. */
    2193         connect (console, SIGNAL (resizeHintDone()), this, SLOT (onExitFullscreen()));
    2194 
    2195         /* Reset the shifting spacer. */
     2155        /* Reset the shifting spacers. */
    21962156        mShiftingSpacerLeft->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    21972157        mShiftingSpacerTop->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
     
    22362196            ((QWidget *) obj)->show();
    22372197        hidden_children.clear();
    2238 
    2239         /* Going normal || maximized */
    2240         setWindowState (windowState() ^ WindowFullScreen);
    2241 
    2242         qApp->processEvents();
    2243         console->toggleFSMode();
    2244     }
     2198    }
     2199
     2200    /* Process all console attributes changes and sub-widget hidings */
     2201    qApp->processEvents();
     2202
     2203    /* Send guest size hint */
     2204    console->toggleFSMode (consoleSize);
     2205
     2206    /* Waiting for host resize if it awaited during mode entering/exiting */
     2207    if ((mIsFullscreen || mIsSeamless) && (consoleSize != initialSize))
     2208        mIsWaitingModeResize = true;
     2209
     2210    if (!mIsWaitingModeResize)
     2211        onExitFullscreen();
     2212
     2213    setWindowState (windowState() ^ WindowFullScreen);
     2214
     2215    /* Unlock FS actions locked during modes toggling */
     2216    QTimer::singleShot (300, this, SLOT (unlockActionsSwitch()));
    22452217
    22462218#ifdef Q_WS_MAC /* wasHidden is wrong on the mac it seems. */
     
    22762248void VBoxConsoleWnd::setViewInSeamlessMode (const QRect &aTargetRect)
    22772249{
    2278         LogFlowThisFunc(("mIsSeamless=%s\n", mIsSeamless ? "true" : "false"));
    2279     if (mIsSeamless)
    2280     {
    2281         /* It isn't guaranteed that the guest os set the video mode that
    2282          * we requested. So after all the resizing stuff set the clipping
    2283          * mask and the spacing shifter to the corresponding values. */
    2284         QDesktopWidget *dtw = QApplication::desktop();
    2285         QRect sRect = dtw->screenGeometry (this);
    2286         QRect aRect (aTargetRect);
    2287         mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), QSize::ScaleFree);
     2250    /* It isn't guaranteed that the guest os set the video mode that
     2251     * we requested. So after all the resizing stuff set the clipping
     2252     * mask and the spacing shifter to the corresponding values. */
     2253    QDesktopWidget *dtw = QApplication::desktop();
     2254    QRect sRect = dtw->screenGeometry (this);
     2255    QRect aRect (aTargetRect);
     2256    mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), QSize::ScaleFree);
    22882257#ifdef Q_WS_MAC
    2289         /* On mac os x this isn't necessary cause the screen starts
    2290          * by y=0 always regardless if there is the global menubar or not. */
    2291         aRect.setRect (aRect.left(), 0, aRect.width(), aRect.height() + aRect.top());
     2258    /* On mac os x this isn't necessary cause the screen starts
     2259     * by y=0 always regardless if there is the global menubar or not. */
     2260    aRect.setRect (aRect.left(), 0, aRect.width(), aRect.height() + aRect.top());
    22922261#endif // Q_WS_MAC
    2293         /* Set the clipping mask */
    2294         mStrictedRegion = aRect;
    2295         /* Set the shifting spacer */
    2296         mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0,
    2297                                          QSizePolicy::Fixed, QSizePolicy::Preferred);
    2298         mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()),
    2299                                         QSizePolicy::Preferred, QSizePolicy::Fixed);
    2300         mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0,
    2301                                           QSizePolicy::Fixed, QSizePolicy::Preferred);
    2302         mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()),
    2303                                            QSizePolicy::Preferred, QSizePolicy::Fixed);
    2304     }
    2305     LogFlowFuncLeave();
     2262    /* Set the clipping mask */
     2263    mStrictedRegion = aRect;
     2264    /* Set the shifting spacer */
     2265    mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0,
     2266                                     QSizePolicy::Fixed, QSizePolicy::Preferred);
     2267    mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()),
     2268                                    QSizePolicy::Preferred, QSizePolicy::Fixed);
     2269    mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0,
     2270                                      QSizePolicy::Fixed, QSizePolicy::Preferred);
     2271    mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()),
     2272                                       QSizePolicy::Preferred, QSizePolicy::Fixed);
    23062273}
    23072274
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