VirtualBox

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

FE/Qt: improved heuristics for automatic maximum guest resolution

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

Legend:

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

    r9067 r10395  
    202202    {
    203203        DesktopGeo_Invalid = 0, DesktopGeo_Fixed,
    204         DesktopGeo_Automatic, DesktopGeo_Any, DesktopGeo_Unchanged
     204        DesktopGeo_Automatic, DesktopGeo_Any
    205205    };
    206206
    207207    void setDesktopGeometry (DesktopGeo aGeo, int aWidth, int aHeight);
    208208    void setDesktopGeoHint (int aWidth, int aHeight);
     209    void calculateDesktopGeometry();
    209210    void maybeRestrictMinimumSize();
    210211
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r9076 r10395  
    35703570            LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height()));
    35713571
    3572             /* Increase the maximum allowed size to the new size if needed */
     3572            /* Increase the maximum allowed size to the new size if needed.
     3573             * We also recalculate the desktop geometry if this is determined
     3574             * automatically.  In fact, we only need this on the first resize,
     3575             * but it is done every time to keep the code simpler. */
    35733576            setDesktopGeoHint (sz.width(), sz.height());
     3577            calculateDesktopGeometry();
    35743578
    35753579            mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
     
    35783582}
    35793583
     3584
     3585/* If the desktop geometry is set automatically, this will update it. */
    35803586void VBoxConsoleView::doResizeDesktop (int)
    35813587{
    3582     /* If the desktop geometry is set automatically, this will update it. */
    3583     setDesktopGeometry (DesktopGeo_Unchanged, 0, 0);
     3588    calculateDesktopGeometry();
    35843589}
    35853590
    35863591/**
    3587  * Set the maximum size allowed for the guest desktop.  This can either be
    3588  * a fixed maximum size, or a lower bound on the maximum.  In the second case,
    3589  * the maximum will be set to the available desktop area minus 100 pixels each
    3590  * way, or to the specified lower bound, whichever is greater.
     3592 * Remember a geometry hint sent by the console window.  This is used to
     3593 * determine the maximum supported guest resolution in the @a desktopGeometry
     3594 * method.  A hint will always override other restrictions.
    35913595 *
    3592  * @param aWidth  The maximum width for the guest screen (fixed geometry) or a
    3593  *                lower bound for the maximum
    3594  * @param aHeight The maximum height for the guest screen (fixed geometry)
    3595  *                or a lower bound for the maximum
     3596 * @param aWidth  width of the resolution hint
     3597 * @param aHeight height of the resolution hint
    35963598 */
    35973599void VBoxConsoleView::setDesktopGeoHint (int aWidth, int aHeight)
     
    36013603}
    36023604
     3605
    36033606/**
    3604  * Set initial desktop geometry restrictions on the guest framebuffer.  These
    3605  * determine the maximum size the guest framebuffer can take on.  Note that
    3606  * a hint from the host will always override these restrictions.
     3607 * Do initial setup of desktop geometry restrictions on the guest framebuffer.
     3608 * These determine the maximum size the guest framebuffer can take on.
    36073609 *
    3608  * @param aGeo    Values: fixed - the guest has a fixed maximum framebuffer
    3609  *                        size automatic - we recalculate the maximum size
    3610  *                        ourselves any - any size is allowed
     3610 * @note a hint from the host will always override these restrictions.
     3611 *
     3612 * @param aGeo    Fixed -     the guest has a fixed maximum framebuffer size
     3613 *                Automatic - we calculate the maximum size ourselves.  The
     3614 *                            calculations will not actually be done until
     3615 *                            @a calculateDesktopGeometry is called, since
     3616 *                            we don't initially have the information needed.
     3617 *                Any -       any size is allowed
    36113618 * @param aWidth  The maximum width for the guest screen or zero for no change
    36123619 *                (only used for fixed geometry)
     
    36193626                      (aGeo == DesktopGeo_Fixed ? "Fixed" :
    36203627                       aGeo == DesktopGeo_Automatic ? "Automatic" :
    3621                        aGeo == DesktopGeo_Any ? "Any" :
    3622                        aGeo == DesktopGeo_Unchanged ? "Unchanged" : "Invalid"),
     3628                       aGeo == DesktopGeo_Any ? "Any" : "Invalid"),
    36233629                      aWidth, aHeight));
    3624     Assert ((aGeo != DesktopGeo_Unchanged) || (mDesktopGeo != DesktopGeo_Invalid));
    3625     if (DesktopGeo_Unchanged == aGeo)
    3626         aGeo = mDesktopGeo;
    36273630    switch (aGeo)
    36283631    {
     
    36313634            if (aWidth != 0 && aHeight != 0)
    36323635                mDesktopGeometry = QRect (0, 0, aWidth, aHeight);
     3636            else
     3637                mDesktopGeometry = QRect (0, 0, 0, 0);
    36333638            setDesktopGeoHint (0, 0);
    36343639            break;
    36353640        case DesktopGeo_Automatic:
    3636         {
    36373641            mDesktopGeo = DesktopGeo_Automatic;
    3638             QRect desktop = QApplication::desktop()->screenGeometry (this);
    3639             mDesktopGeometry = QRect (0, 0, desktop.width() - 100, desktop.height() - 100);
    3640             LogFlowThisFunc (("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100));
     3642            mDesktopGeometry = QRect (0, 0, 0, 0);
    36413643            setDesktopGeoHint (0, 0);
    36423644            break;
    3643         }
    36443645        case DesktopGeo_Any:
    36453646            mDesktopGeo = DesktopGeo_Any;
     
    36493650            AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo));
    36503651            mDesktopGeo = DesktopGeo_Invalid;
     3652    }
     3653}
     3654
     3655
     3656/**
     3657 * If we are in automatic mode, the geometry restrictions will be recalculated.
     3658 * This is needed in particular on the first widget resize, as we can't
     3659 * calculate them correctly before that.
     3660 *
     3661 * @note a hint from the host will always override these restrictions.
     3662 * @note we can't do calculations on the fly when they are needed, because
     3663 *       they require querying the X server on X11 hosts and this must be done
     3664 *       from within the GUI thread, due to the single threadedness of Xlib.
     3665 */
     3666void VBoxConsoleView::calculateDesktopGeometry()
     3667{
     3668    LogFlowThisFunc (("Entering\n"));
     3669    /* This method should not get called until we have initially set up the */
     3670    Assert ((mDesktopGeo != DesktopGeo_Invalid));
     3671    /* If we are not doing automatic geometry calculation then there is
     3672     * nothing to do. */
     3673    if (DesktopGeo_Automatic == mDesktopGeo)
     3674    {
     3675        /* Available geometry of the desktop.  If the desktop is a single
     3676         * screen, this will exclude space taken up by desktop taskbars
     3677         * and things, but this is unfortunately not true for the more
     3678         * complex case of a desktop spanning multiple screens. */
     3679        QRect desktop = QApplication::desktop()->availableGeometry (this);
     3680        /* The area taken up by the console window on the desktop,
     3681         * including window frame, title and menu bar and whatnot. */
     3682        QRect frame = mMainWnd->frameGeometry();
     3683        /* The area taken up by the console window, minus all
     3684         * decorations. */
     3685        QRect window = mMainWnd->centralWidget()->geometry();
     3686        /* To work out how big we can make the console window while still
     3687         * fitting on the desktop, we calculate desktop - frame + window.
     3688         * This works because the difference between frame and window
     3689         * (or at least its width and height) is a constant. */
     3690        mDesktopGeometry =
     3691            QRect (0, 0, desktop.width() - frame.width() + window.width(),
     3692                   desktop.height() - frame.height() + window.height());
     3693        LogFlowThisFunc (("Setting %d, %d\n", mDesktopGeometry.width(),
     3694                           mDesktopGeometry.height()));
    36513695    }
    36523696}
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