VirtualBox

Changeset 8888

Show
Ignore:
Timestamp:
05/16/08 14:15:58 (3 months ago)
Author:
vboxsync
Message:

Frontends/VirtualBox: created a configuration setting for the maximum guest resolution allowed (see #2787c27-36)

Files:

Legend:

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

    r8440 r8888  
    197197private: 
    198198 
    199     void setDesktopGeometry(int minWidth, int minHeight); 
     199    enum meDesktopGeo { 
     200        invalid = 0, fixed, automatic, any, unchanged 
     201    }; 
     202    void setDesktopGeometry(meDesktopGeo type, int width, int height); 
     203    void setDesktopGeoHint(int width, int height); 
    200204    void maybeRestrictMinimumSize(); 
    201205 
     
    284288    CGImageRef mVirtualBoxLogo; 
    285289#endif 
     290    meDesktopGeo mDesktopGeoType; 
    286291    QRect mDesktopGeometry; 
     292    QRect mLastSizeHint; 
    287293}; 
    288294 
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobalSettings.h

    r8155 r8888  
    4545    QString guiFeatures; 
    4646    QString languageId; 
     47    QString maxGuestRes; 
    4748 
    4849    friend class VBoxGlobalSettings; 
     
    5859    Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures) 
    5960    Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId) 
     61    Q_PROPERTY (QString maxGuestRes READ maxGuestRes WRITE setMaxGuestRes) 
    6062 
    6163public: 
     
    9294    { 
    9395        mData()->languageId = aLanguageId; 
     96    } 
     97 
     98    QString maxGuestRes() const { return data()->maxGuestRes; } 
     99    void setMaxGuestRes (const QString &aMaxGuestRes) 
     100    { 
     101        mData()->maxGuestRes = aMaxGuestRes; 
    94102    } 
    95103 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r8779 r8888  
    646646    , mVirtualBoxLogo (NULL) 
    647647#endif 
     648    , mDesktopGeoType(invalid) 
    648649{ 
    649650    Assert (!mConsole.isNull() && 
     
    769770       events for telling the guest about video modes we like. */ 
    770771 
    771     doResizeDesktop(0); 
     772    QString desktopGeometry = vboxGlobal().settings() 
     773                                  .publicProperty("GUI/MaxGuestResolution"); 
     774    if (   (QString::null == desktopGeometry) 
     775        || ("auto" == desktopGeometry) 
     776       ) 
     777        setDesktopGeometry(automatic, 0, 0); 
     778    else if ("any" == desktopGeometry) 
     779        setDesktopGeometry(any, 0, 0); 
     780    else 
     781    { 
     782        int width = desktopGeometry.section(',', 0, 0).toInt(); 
     783        int height = desktopGeometry.section(',', 1, 1).toInt(); 
     784        setDesktopGeometry(fixed, width, height); 
     785    } 
    772786    connect (QApplication::desktop(), SIGNAL(workAreaResized(int)), 
    773787             this, SLOT(doResizeDesktop(int))); 
     
    22672281 
    22682282/** 
    2269  * Get the current desktop geometry for the console view widget 
     2283 * Get the current available desktop geometry for the console/framebuffer 
    22702284 * 
    2271  * @returns the geometry 
     2285 * @returns the geometry.  An empty rectangle means unrestricted. 
    22722286 */ 
    22732287QRect VBoxConsoleView::getDesktopGeometry() 
    22742288{ 
    2275     return mDesktopGeometry; 
     2289    QRect rc; 
     2290    switch (mDesktopGeoType) 
     2291    { 
     2292    case fixed: 
     2293    case automatic: 
     2294        rc = QRect (0, 0, RT_MAX(mDesktopGeometry.width(), mLastSizeHint.width()), 
     2295                    RT_MAX(mDesktopGeometry.height(), mLastSizeHint.height())); 
     2296        break; 
     2297    case any: 
     2298        rc = QRect (0, 0, 0, 0); 
     2299        break; 
     2300    default: 
     2301        AssertMsgFailed (("Bad geometry type %d\n", mDesktopGeoType)); 
     2302    } 
     2303    return rc; 
    22762304} 
    22772305 
     
    35313559 
    35323560        /* Increase the desktop geometry if needed */ 
    3533         setDesktopGeometry(sz.width(), sz.height()); 
     3561        setDesktopGeoHint(sz.width(), sz.height()); 
    35343562 
    35353563        if (mAutoresizeGuest) 
     
    35403568void VBoxConsoleView::doResizeDesktop (int) 
    35413569{ 
    3542     setDesktopGeometry(0, 0); 
     3570    /* If the desktop geometry is set automatically, this will update it. */ 
     3571    setDesktopGeometry(unchanged, 0, 0); 
    35433572} 
    35443573 
    35453574/** 
    3546  * Set the maximum size allowed for the guest desktop to the available area 
    3547  * minus 100 pixels each way, or to the specified minimum width and height, 
    3548  * whichever is greater. 
     3575 * Set the maximum size allowed for the guest desktop.  This can either be 
     3576 * a fixed maximum size, or a lower bound on the maximum.  In the second case, 
     3577 * the maximum will be set to the available desktop area minus 100 pixels each 
     3578 * way, or to the specified lower bound, whichever is greater. 
    35493579 * 
    3550  * @param minWidth   The width that the guest screen should at least be 
    3551  *                   allowed to increase to 
    3552  * @param minHeight  The height that the guest screen should at least be 
    3553  *                   allowed to increase to 
     3580 * @param fixed   Are the parameters a fixed geometry size or a lower bound? 
     3581 * @param width   The maximum width for the guest screen (fixed geometry) 
     3582 *                or a lower bound for the maximum 
     3583 * @param height  The maximum height for the guest screen (fixed geometry) 
     3584 *                or a lower bound for the maximum 
    35543585 */ 
    3555 void VBoxConsoleView::setDesktopGeometry(int minWidth, int minHeight) 
    3556 
    3557     LogFlowThisFunc(("minWidth=%d, minHeight=%d\n", minWidth, minHeight)); 
    3558     QRect desktopGeometry = QApplication::desktop()->screenGeometry (this); 
    3559     int width = desktopGeometry.width(); 
    3560     if (width - 100 < minWidth) 
    3561         width = minWidth; 
    3562     else 
    3563         width = width - 100; 
    3564     int height = desktopGeometry.height(); 
    3565     if (height - 100 < minHeight) 
    3566         height = minHeight; 
    3567     else 
    3568         height = height - 100; 
    3569     LogFlowThisFunc(("Setting %d, %d\n", width, height)); 
    3570     mDesktopGeometry = QRect(0, 0, width, height); 
    3571 
    3572  
     3586void VBoxConsoleView::setDesktopGeoHint(int width, int height) 
     3587
     3588    LogFlowThisFunc(("width=%d, height=%d\n", width, height)); 
     3589    mLastSizeHint = QRect (0, 0, width, height); 
     3590
     3591 
     3592/** 
     3593 * Set initial desktop geometry restrictions on the guest framebuffer.  These 
     3594 * determine the maximum size the guest framebuffer can take on.  Note that 
     3595 * a hint from the host will always override these restrictions. 
     3596 * 
     3597 * @param type    Values: fixed - the guest has a fixed maximum framebuffer size 
     3598 *                        automatic - we recalculate the maximum size ourselves 
     3599 *                        any - any size is allowed 
     3600 * @param width   The maximum width for the guest screen or zero for no change 
     3601 *                (only used for fixed geometry) 
     3602 * @param height  The maximum height for the guest screen or zero for no change 
     3603 *                (only used for fixed geometry) 
     3604 */ 
     3605void VBoxConsoleView::setDesktopGeometry(meDesktopGeo type, int width, int height) 
     3606
     3607    LogFlowThisFunc (("type = %s, width=%d, height=%d\n", 
     3608                      (fixed == type ? "fixed" 
     3609                           : (automatic == type ? "automatic" 
     3610                                 : (any == type ? "any" 
     3611                                       : (unchanged == type ? "unchanged" : "invalid") 
     3612                                   ) 
     3613                             ) 
     3614                      ), width, height 
     3615                    )); 
     3616    Assert((type != unchanged) || (mDesktopGeoType != invalid)); 
     3617    if (unchanged == type) 
     3618        type = mDesktopGeoType; 
     3619    switch (type) 
     3620    { 
     3621    case fixed: 
     3622        mDesktopGeoType = fixed; 
     3623        if ((0 != width ) && (0 != height)) 
     3624            mDesktopGeometry = QRect (0, 0, width, height); 
     3625        setDesktopGeoHint (0, 0); 
     3626        break; 
     3627    case automatic: 
     3628    { 
     3629        mDesktopGeoType = automatic; 
     3630        QRect desktop = QApplication::desktop()->screenGeometry (this); 
     3631        mDesktopGeometry = QRect(0, 0, desktop.width() - 100, desktop.height() - 100); 
     3632        LogFlowThisFunc(("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100)); 
     3633        setDesktopGeoHint (0, 0); 
     3634        break; 
     3635    } 
     3636    case any: 
     3637        mDesktopGeoType = any; 
     3638        mDesktopGeometry = QRect (0, 0, 0, 0); 
     3639        break; 
     3640    default: 
     3641        AssertMsgFailed(("Invalid desktop geometry type %d\n", type)); 
     3642        mDesktopGeoType = invalid; 
     3643    } 
     3644
    35733645 
    35743646/** 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp

    r8155 r8888  
    206206    *aSupported = TRUE; 
    207207    QRect screen = mView->getDesktopGeometry(); 
    208     if (aWidth > (ULONG) screen.width()) 
     208    if (   (screen.width() != 0) 
     209        && (aWidth > (ULONG) screen.width()) 
     210       ) 
    209211        *aSupported = FALSE; 
    210     if (aHeight > (ULONG) screen.height()) 
     212    if (   (screen.height() != 0) 
     213        && (aHeight > (ULONG) screen.height()) 
     214       ) 
    211215        *aSupported = FALSE; 
    212216    LogFlowThisFunc(("returning aSupported=%d\n", *aSupported)); 
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobalSettings.cpp

    r8155 r8888  
    6060    guiFeatures = QString::null; 
    6161    languageId  = QString::null; 
     62    maxGuestRes = "auto"; 
    6263} 
    6364 
     
    6869    guiFeatures = that.guiFeatures; 
    6970    languageId  = that.languageId; 
     71    maxGuestRes = that.maxGuestRes; 
    7072} 
    7173 
     
    8082         autoCapture == that.autoCapture && 
    8183         guiFeatures == that.guiFeatures && 
    82          languageId  == that.languageId); 
     84         languageId  == that.languageId && 
     85         maxGuestRes == that.maxGuestRes); 
    8386} 
    8487 
     
    105108    { "GUI/Customizations",     "guiFeatures",  "\\S+", true }, 
    106109    { "GUI/LanguageID",         "languageId",   gVBoxLangIDRegExp, true }, 
     110    { "GUI/MaxGuestResolution", "maxGuestRes",  "\\d*[1-9]\\d*,\\d*[1-9]\\d*|any|auto", true } 
    107111}; 
    108112 
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h

    r8440 r8888  
    215215private: 
    216216 
    217     void setDesktopGeometry(int minWidth, int minHeight); 
     217    enum meDesktopGeo { 
     218        invalid = 0, fixed, automatic, any, unchanged 
     219    }; 
     220    void setDesktopGeometry(meDesktopGeo type, int width, int height); 
     221    void setDesktopGeoHint(int width, int height); 
    218222    void maybeRestrictMinimumSize(); 
    219223 
     
    301305    CGImageRef mVirtualBoxLogo; 
    302306#endif 
     307    meDesktopGeo mDesktopGeoType; 
    303308    QRect mDesktopGeometry; 
     309    QRect mLastSizeHint; 
    304310}; 
    305311 
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobalSettings.h

    r8155 r8888  
    4646    QString guiFeatures; 
    4747    QString languageId; 
     48    QString maxGuestRes; 
    4849 
    4950    friend class VBoxGlobalSettings; 
     
    5960    Q_PROPERTY (QString guiFeatures READ guiFeatures WRITE setGuiFeatures) 
    6061    Q_PROPERTY (QString languageId READ languageId WRITE setLanguageId) 
     62    Q_PROPERTY (QString maxGuestRes READ maxGuestRes WRITE setMaxGuestRes) 
    6163 
    6264public: 
     
    9395    { 
    9496        mData()->languageId = aLanguageId; 
     97    } 
     98 
     99    QString maxGuestRes() const { return data()->maxGuestRes; } 
     100    void setMaxGuestRes (const QString &aMaxGuestRes) 
     101    { 
     102        mData()->maxGuestRes = aMaxGuestRes; 
    95103    } 
    96104 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r8866 r8888  
    667667    , mVirtualBoxLogo (NULL) 
    668668#endif 
     669    , mDesktopGeoType(invalid) 
    669670{ 
    670671    Assert (!mConsole.isNull() && 
     
    798799       events for telling the guest about video modes we like. */ 
    799800 
    800     doResizeDesktop(0); 
     801    QString desktopGeometry = vboxGlobal().settings() 
     802                                  .publicProperty("GUI/MaxGuestResolution"); 
     803    if (   (QString::null == desktopGeometry) 
     804        || ("auto" == desktopGeometry) 
     805       ) 
     806        setDesktopGeometry(automatic, 0, 0); 
     807    else if ("any" == desktopGeometry) 
     808        setDesktopGeometry(any, 0, 0); 
     809    else 
     810    { 
     811        int width = desktopGeometry.section(',', 0, 0).toInt(); 
     812        int height = desktopGeometry.section(',', 1, 1).toInt(); 
     813        setDesktopGeometry(fixed, width, height); 
     814    } 
    801815    connect (QApplication::desktop(), SIGNAL(workAreaResized(int)), 
    802816             this, SLOT(doResizeDesktop(int))); 
     
    22892303 
    22902304/** 
    2291  * Get the current desktop geometry for the console view widget 
     2305 * Get the current available desktop geometry for the console/framebuffer 
    22922306 * 
    2293  * @returns the geometry 
     2307 * @returns the geometry.  An empty rectangle means unrestricted. 
    22942308 */ 
    22952309QRect VBoxConsoleView::getDesktopGeometry() 
    22962310{ 
    2297     return mDesktopGeometry; 
     2311    QRect rc; 
     2312    switch (mDesktopGeoType) 
     2313    { 
     2314    case fixed: 
     2315    case automatic: 
     2316        rc = QRect (0, 0, RT_MAX(mDesktopGeometry.width(), mLastSizeHint.width()), 
     2317                    RT_MAX(mDesktopGeometry.height(), mLastSizeHint.height())); 
     2318        break; 
     2319    case any: 
     2320        rc = QRect (0, 0, 0, 0); 
     2321        break; 
     2322    default: 
     2323        AssertMsgFailed (("Bad geometry type %d\n", mDesktopGeoType)); 
     2324    } 
     2325    return rc; 
    22982326} 
    22992327 
     
    35453573 
    35463574        /* Increase the desktop geometry if needed */ 
    3547         setDesktopGeometry(sz.width(), sz.height()); 
     3575        setDesktopGeoHint(sz.width(), sz.height()); 
    35483576 
    35493577        if (mAutoresizeGuest) 
     
    35543582void VBoxConsoleView::doResizeDesktop (int) 
    35553583{ 
    3556     setDesktopGeometry(0, 0); 
     3584    /* If the desktop geometry is set automatically, this will update it. */ 
     3585    setDesktopGeometry(unchanged, 0, 0); 
    35573586} 
    35583587 
    35593588/** 
    3560  * Set the maximum size allowed for the guest desktop to the available area 
    3561  * minus 100 pixels each way, or to the specified minimum width and height, 
    3562  * whichever is greater. 
     3589 * Set the maximum size allowed for the guest desktop.  This can either be 
     3590 * a fixed maximum size, or a lower bound on the maximum.  In the second case, 
     3591 * the maximum will be set to the available desktop area minus 100 pixels each 
     3592 * way, or to the specified lower bound, whichever is greater. 
    35633593 * 
    3564  * @param minWidth   The width that the guest screen should at least be 
    3565  *                   allowed to increase to 
    3566  * @param minHeight  The height that the guest screen should at least be 
    3567  *                   allowed to increase to 
     3594 * @param fixed   Are the parameters a fixed geometry size or a lower bound? 
     3595 * @param width   The maximum width for the guest screen (fixed geometry) 
     3596 *                or a lower bound for the maximum 
     3597 * @param height  The maximum height for the guest screen (fixed geometry) 
     3598 *                or a lower bound for the maximum 
    35683599 */ 
    3569 void VBoxConsoleView::setDesktopGeometry(int minWidth, int minHeight) 
    3570 
    3571     LogFlowThisFunc(("minWidth=%d, minHeight=%d\n", minWidth, minHeight)); 
    3572     QRect desktopGeometry = QApplication::desktop()->screenGeometry (this); 
    3573     int width = desktopGeometry.width(); 
    3574     if (width - 100 < minWidth) 
    3575         width = minWidth; 
    3576     else 
    3577         width = width - 100; 
    3578     int height = desktopGeometry.height(); 
    3579     if (height - 100 < minHeight) 
    3580         height = minHeight; 
    3581     else 
    3582         height = height - 100; 
    3583     LogFlowThisFunc(("Setting %d, %d\n", width, height)); 
    3584     mDesktopGeometry = QRect(0, 0, width, height); 
    3585 
    3586  
     3600void VBoxConsoleView::setDesktopGeoHint(int width, int height) 
     3601
     3602    LogFlowThisFunc(("width=%d, height=%d\n", width, height)); 
     3603    mLastSizeHint = QRect (0, 0, width, height); 
     3604
     3605 
     3606/** 
     3607 * Set initial desktop geometry restrictions on the guest framebuffer.  These 
     3608 * determine the maximum size the guest framebuffer can take on.  Note that 
     3609 * a hint from the host will always override these restrictions. 
     3610 * 
     3611 * @param type    Values: fixed - the guest has a fixed maximum framebuffer size 
     3612 *                        automatic - we recalculate the maximum size ourselves 
     3613 *                        any - any size is allowed 
     3614 * @param width   The maximum width for the guest screen or zero for no change 
     3615 *                (only used for fixed geometry) 
     3616 * @param height  The maximum height for the guest screen or zero for no change 
     3617 *                (only used for fixed geometry) 
     3618 */ 
     3619void VBoxConsoleView::setDesktopGeometry(meDesktopGeo type, int width, int height) 
     3620
     3621    LogFlowThisFunc (("type = %s, width=%d, height=%d\n", 
     3622                      (fixed == type ? "fixed" 
     3623                           : (automatic == type ? "automatic" 
     3624                                 : (any == type ? "any" 
     3625                                       : (unchanged == type ? "unchanged" : "invalid") 
     3626                                   ) 
     3627                             ) 
     3628                      ), width, height 
     3629                    )); 
     3630    Assert((type != unchanged) || (mDesktopGeoType != invalid)); 
     3631    if (unchanged == type) 
     3632        type = mDesktopGeoType; 
     3633    switch (type) 
     3634    { 
     3635    case fixed: 
     3636        mDesktopGeoType = fixed; 
     3637        if ((0 != width ) && (0 != height)) 
     3638            mDesktopGeometry = QRect (0, 0, width, height); 
     3639        setDesktopGeoHint (0, 0); 
     3640        break; 
     3641    case automatic: 
     3642    { 
     3643        mDesktopGeoType = automatic; 
     3644        QRect desktop = QApplication::desktop()->screenGeometry (this); 
     3645        mDesktopGeometry = QRect(0, 0, desktop.width() - 100, desktop.height() - 100); 
     3646        LogFlowThisFunc(("Setting %d, %d\n", desktop.width() - 100, desktop.height() - 100)); 
     3647        setDesktopGeoHint (0, 0); 
     3648        break; 
     3649    } 
     3650    case any: 
     3651        mDesktopGeoType = any; 
     3652        mDesktopGeometry = QRect (0, 0, 0, 0); 
     3653        break; 
     3654    default: 
     3655        AssertMsgFailed(("Invalid desktop geometry type %d\n", type)); 
     3656        mDesktopGeoType = invalid; 
     3657    } 
     3658
    35873659 
    35883660/** 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxFrameBuffer.cpp

    r8155 r8888  
    207207    *aSupported = TRUE; 
    208208    QRect screen = mView->getDesktopGeometry(); 
    209     if (aWidth > (ULONG) screen.width()) 
     209    if (   (screen.width() != 0) 
     210        && (aWidth > (ULONG) screen.width()) 
     211       ) 
    210212        *aSupported = FALSE; 
    211     if (aHeight > (ULONG) screen.height()) 
     213    if (   (screen.height() != 0) 
     214        && (aHeight > (ULONG) screen.height()) 
     215       ) 
    212216        *aSupported = FALSE; 
    213217    LogFlowThisFunc(("returning aSupported=%d\n", *aSupported)); 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobalSettings.cpp

    r8155 r8888  
    5959    guiFeatures = QString::null; 
    6060    languageId  = QString::null; 
     61    maxGuestRes = "auto"; 
    6162} 
    6263 
     
    6768    guiFeatures = that.guiFeatures; 
    6869    languageId  = that.languageId; 
     70    maxGuestRes = that.maxGuestRes; 
    6971} 
    7072 
     
    7981         autoCapture == that.autoCapture && 
    8082         guiFeatures == that.guiFeatures && 
    81          languageId  == that.languageId); 
     83         languageId  == that.languageId && 
     84         maxGuestRes == that.maxGuestRes); 
    8285} 
    8386 
     
    104107    { "GUI/Customizations",     "guiFeatures",  "\\S+", true }, 
    105108    { "GUI/LanguageID",         "languageId",   gVBoxLangIDRegExp, true }, 
     109    { "GUI/MaxGuestResolution", "maxGuestRes",  "\\d*[1-9]\\d*,\\d*[1-9]\\d*|any|auto", true } 
    106110}; 
    107111 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy