VirtualBox

Ignore:
Timestamp:
Jul 9, 2008 8:57:15 AM (16 years ago)
Author:
vboxsync
Message:

FE/Qt: improved heuristics for automatic maximum guest resolution

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

Legend:

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

    r10112 r10395  
    219219    {
    220220        DesktopGeo_Invalid = 0, DesktopGeo_Fixed,
    221         DesktopGeo_Automatic, DesktopGeo_Any, DesktopGeo_Unchanged
     221        DesktopGeo_Automatic, DesktopGeo_Any
    222222    };
    223223
    224224    void setDesktopGeometry (DesktopGeo aGeo, int aWidth, int aHeight);
    225225    void setDesktopGeoHint (int aWidth, int aHeight);
     226    void calculateDesktopGeometry();
    226227    void maybeRestrictMinimumSize();
    227228
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r10371 r10395  
    35933593            LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height()));
    35943594
    3595             /* Increase the maximum allowed size to the new size if needed */
     3595            /* Increase the maximum allowed size to the new size if needed.
     3596             * We also recalculate the desktop geometry if this is determined
     3597             * automatically.  In fact, we only need this on the first resize,
     3598             * but it is done every time to keep the code simpler. */
    35963599            setDesktopGeoHint (sz.width(), sz.height());
     3600            calculateDesktopGeometry();
    35973601
    35983602            mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
     
    36013605}
    36023606
     3607
     3608/* If the desktop geometry is set automatically, this will update it. */
    36033609void VBoxConsoleView::doResizeDesktop (int)
    36043610{
    3605     /* If the desktop geometry is set automatically, this will update it. */
    3606     setDesktopGeometry (DesktopGeo_Unchanged, 0, 0);
     3611    calculateDesktopGeometry();
    36073612}
    36083613
    36093614/**
    3610  * Set the maximum size allowed for the guest desktop.  This can either be
    3611  * a fixed maximum size, or a lower bound on the maximum.  In the second case,
    3612  * the maximum will be set to the available desktop area minus 100 pixels each
    3613  * way, or to the specified lower bound, whichever is greater.
     3615 * Remember a geometry hint sent by the console window.  This is used to
     3616 * determine the maximum supported guest resolution in the @a desktopGeometry
     3617 * method.  A hint will always override other restrictions.
    36143618 *
    3615  * @param aWidth  The maximum width for the guest screen (fixed geometry) or a
    3616  *                lower bound for the maximum
    3617  * @param aHeight The maximum height for the guest screen (fixed geometry)
    3618  *                or a lower bound for the maximum
     3619 * @param aWidth  width of the resolution hint
     3620 * @param aHeight height of the resolution hint
    36193621 */
    36203622void VBoxConsoleView::setDesktopGeoHint (int aWidth, int aHeight)
     
    36253627
    36263628/**
    3627  * Set initial desktop geometry restrictions on the guest framebuffer.  These
    3628  * determine the maximum size the guest framebuffer can take on.  Note that
    3629  * a hint from the host will always override these restrictions.
     3629 * Do initial setup of desktop geometry restrictions on the guest framebuffer.
     3630 * These determine the maximum size the guest framebuffer can take on.
    36303631 *
    3631  * @param aGeo    Values: fixed - the guest has a fixed maximum framebuffer
    3632  *                        size automatic - we recalculate the maximum size
    3633  *                        ourselves any - any size is allowed
     3632 * @note a hint from the host will always override these restrictions.
     3633 *
     3634 * @param aGeo    Fixed -     the guest has a fixed maximum framebuffer size
     3635 *                Automatic - we calculate the maximum size ourselves.  The
     3636 *                            calculations will not actually be done until
     3637 *                            @a calculateDesktopGeometry is called, since
     3638 *                            we don't initially have the information needed.
     3639 *                Any -       any size is allowed
    36343640 * @param aWidth  The maximum width for the guest screen or zero for no change
    36353641 *                (only used for fixed geometry)
     
    36423648                      (aGeo == DesktopGeo_Fixed ? "Fixed" :
    36433649                       aGeo == DesktopGeo_Automatic ? "Automatic" :
    3644                        aGeo == DesktopGeo_Any ? "Any" :
    3645                        aGeo == DesktopGeo_Unchanged ? "Unchanged" : "Invalid"),
     3650                       aGeo == DesktopGeo_Any ? "Any" : "Invalid"),
    36463651                      aWidth, aHeight));
    3647     Assert ((aGeo != DesktopGeo_Unchanged) || (mDesktopGeo != DesktopGeo_Invalid));
    3648     if (DesktopGeo_Unchanged == aGeo)
    3649         aGeo = mDesktopGeo;
    36503652    switch (aGeo)
    36513653    {
     
    36543656            if (aWidth != 0 && aHeight != 0)
    36553657                mDesktopGeometry = QRect (0, 0, aWidth, aHeight);
     3658            else
     3659                mDesktopGeometry = QRect (0, 0, 0, 0);
    36563660            setDesktopGeoHint (0, 0);
    36573661            break;
    36583662        case DesktopGeo_Automatic:
    3659         {
    36603663            mDesktopGeo = DesktopGeo_Automatic;
    3661             QRect desktop = QApplication::desktop()->screenGeometry (this);
    3662             mDesktopGeometry = QRect (0, 0, desktop.width() - 100, desktop.height() - 100);
    3663             LogFlowThisFunc (("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100));
     3664            mDesktopGeometry = QRect (0, 0, 0, 0);
    36643665            setDesktopGeoHint (0, 0);
    36653666            break;
    3666         }
    36673667        case DesktopGeo_Any:
    36683668            mDesktopGeo = DesktopGeo_Any;
     
    36723672            AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo));
    36733673            mDesktopGeo = DesktopGeo_Invalid;
     3674    }
     3675}
     3676
     3677
     3678/**
     3679 * If we are in automatic mode, the geometry restrictions will be recalculated.
     3680 * This is needed in particular on the first widget resize, as we can't
     3681 * calculate them correctly before that.
     3682 *
     3683 * @note a hint from the host will always override these restrictions.
     3684 * @note we can't do calculations on the fly when they are needed, because
     3685 *       they require querying the X server on X11 hosts and this must be done
     3686 *       from within the GUI thread, due to the single threadedness of Xlib.
     3687 */
     3688void VBoxConsoleView::calculateDesktopGeometry()
     3689{
     3690    LogFlowThisFunc (("Entering\n"));
     3691    /* This method should not get called until we have initially set up the */
     3692    Assert ((mDesktopGeo != DesktopGeo_Invalid));
     3693    /* If we are not doing automatic geometry calculation then there is
     3694     * nothing to do. */
     3695    if (DesktopGeo_Automatic == mDesktopGeo)
     3696    {
     3697        /* Available geometry of the desktop.  If the desktop is a single
     3698         * screen, this will exclude space taken up by desktop taskbars
     3699         * and things, but this is unfortunately not true for the more
     3700         * complex case of a desktop spanning multiple screens. */
     3701        QRect desktop = QApplication::desktop()->availableGeometry (this);
     3702        /* The area taken up by the console window on the desktop,
     3703         * including window frame, title and menu bar and whatnot. */
     3704        QRect frame = mMainWnd->frameGeometry();
     3705        /* The area taken up by the console window, minus all
     3706         * decorations. */
     3707        QRect window = mMainWnd->centralWidget()->geometry();
     3708        /* To work out how big we can make the console window while still
     3709         * fitting on the desktop, we calculate desktop - frame + window.
     3710         * This works because the difference between frame and window
     3711         * (or at least its width and height) is a constant. */
     3712        mDesktopGeometry =
     3713            QRect (0, 0, desktop.width() - frame.width() + window.width(),
     3714                   desktop.height() - frame.height() + window.height());
     3715        LogFlowThisFunc (("Setting %d, %d\n", mDesktopGeometry.width(),
     3716                           mDesktopGeometry.height()));
    36743717    }
    36753718}
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