VirtualBox

Ignore:
Timestamp:
Oct 18, 2011 3:10:13 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: semantic refactoring and documentation: desktop geometry -> maximum guest size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r38992 r39021  
    160160    AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
    161161
    162     /* Store the new size */
    163     storeConsoleSize(newSize.width(), newSize.height());
     162    /* Store the new hint */
     163    storeHintForGuestSizePolicy(newSize.width(), newSize.height());
    164164    /* Send new size-hint to the guest: */
    165165    session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
     
    238238    , m_pFrameBuffer(0)
    239239    , m_previousState(KMachineState_Null)
    240     , m_desktopGeometryType(DesktopGeo_Invalid)
     240    , m_maxGuestSizePolicy(MaxGuestSizePolicy_Invalid)
    241241#ifdef VBOX_WITH_VIDEOHWACCEL
    242242    , m_fAccelerate2DVideo(bAccelerate2DVideo)
     
    480480    /* Global settings: */
    481481    {
    482         /* Remember the desktop geometry and register for geometry
    483          * change events for telling the guest about video modes we like: */
    484         QString desktopGeometry = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");
    485         if ((desktopGeometry == QString::null) || (desktopGeometry == "auto"))
    486             setDesktopGeometry(DesktopGeo_Automatic, 0, 0);
    487         else if (desktopGeometry == "any")
    488             setDesktopGeometry(DesktopGeo_Any, 0, 0);
    489         else
    490         {
    491             int width = desktopGeometry.section(',', 0, 0).toInt();
    492             int height = desktopGeometry.section(',', 1, 1).toInt();
    493             setDesktopGeometry(DesktopGeo_Fixed, width, height);
     482        /* Remember the maximum guest size policy for telling the guest about
     483         * video modes we like: */
     484        QString maxGuestSize = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");
     485        if ((maxGuestSize == QString::null) || (maxGuestSize == "auto"))
     486            setMaxGuestSizePolicy(MaxGuestSizePolicy_Automatic, 0, 0);
     487        else if (maxGuestSize == "any")
     488            setMaxGuestSizePolicy(MaxGuestSizePolicy_Any, 0, 0);
     489        else  /** @todo Mea culpa, but what about error checking? */
     490        {
     491            int width  = maxGuestSize.section(',', 0, 0).toInt();
     492            int height = maxGuestSize.section(',', 1, 1).toInt();
     493            setMaxGuestSizePolicy(MaxGuestSizePolicy_Fixed, width, height);
    494494        }
    495495    }
     
    596596}
    597597
    598 QSize UIMachineView::desktopGeometry() const
    599 {
    600     QSize geometry;
    601     switch (m_desktopGeometryType)
    602     {
    603         case DesktopGeo_Fixed:
    604         case DesktopGeo_Automatic:
    605             geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
    606                              qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
    607             break;
    608         case DesktopGeo_Any:
    609             geometry = QSize(0, 0);
     598QSize UIMachineView::maxGuestSize() const
     599{
     600    QSize maxSize;
     601    switch (m_maxGuestSizePolicy)
     602    {
     603        case MaxGuestSizePolicy_Fixed:
     604        case MaxGuestSizePolicy_Automatic:
     605            maxSize = QSize(qMax(m_fixedMaxGuestSize.width(), m_storedGuestHintSize.width()),
     606                             qMax(m_fixedMaxGuestSize.height(), m_storedGuestHintSize.height()));
     607            break;
     608        case MaxGuestSizePolicy_Any:
     609            maxSize = QSize(0, 0);
    610610            break;
    611611        default:
    612             AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType));
    613     }
    614     return geometry;
     612            AssertMsgFailed(("Invalid maximum guest size policy %d!\n",
     613                             m_maxGuestSizePolicy));
     614    }
     615    return maxSize;
    615616}
    616617
     
    650651}
    651652
    652 void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight)
    653 {
    654     switch (geometry)
    655     {
    656         case DesktopGeo_Fixed:
    657             m_desktopGeometryType = DesktopGeo_Fixed;
    658             if (aWidth != 0 && aHeight != 0)
    659                 m_desktopGeometry = QSize(aWidth, aHeight);
     653void UIMachineView::setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax,
     654                                          int chMax)
     655{
     656    switch (policy)
     657    {
     658        case MaxGuestSizePolicy_Fixed:
     659            m_maxGuestSizePolicy = MaxGuestSizePolicy_Fixed;
     660            if (cwMax != 0 && chMax != 0)
     661                m_fixedMaxGuestSize = QSize(cwMax, chMax);
    660662            else
    661                 m_desktopGeometry = QSize(0, 0);
    662             storeConsoleSize(0, 0);
    663             break;
    664         case DesktopGeo_Automatic:
    665             m_desktopGeometryType = DesktopGeo_Automatic;
    666             m_desktopGeometry = QSize(0, 0);
    667             storeConsoleSize(0, 0);
    668             break;
    669         case DesktopGeo_Any:
    670             m_desktopGeometryType = DesktopGeo_Any;
    671             m_desktopGeometry = QSize(0, 0);
     663                m_fixedMaxGuestSize = QSize(0, 0);
     664            storeHintForGuestSizePolicy(0, 0);
     665            break;
     666        case MaxGuestSizePolicy_Automatic:
     667            m_maxGuestSizePolicy = MaxGuestSizePolicy_Automatic;
     668            m_fixedMaxGuestSize = QSize(0, 0);
     669            storeHintForGuestSizePolicy(0, 0);
     670            break;
     671        case MaxGuestSizePolicy_Any:
     672            m_maxGuestSizePolicy = MaxGuestSizePolicy_Any;
     673            m_fixedMaxGuestSize = QSize(0, 0);
    672674            break;
    673675        default:
    674             AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry));
    675             m_desktopGeometryType = DesktopGeo_Invalid;
    676     }
    677 }
    678 
    679 void UIMachineView::storeConsoleSize(int iWidth, int iHeight)
    680 {
    681     if (m_desktopGeometryType == DesktopGeo_Automatic)
    682         m_storedConsoleSize = QSize(iWidth, iHeight);
     676            AssertMsgFailed(("Invalid maximum guest size policy %d\n",
     677                             policy));
     678            m_maxGuestSizePolicy = MaxGuestSizePolicy_Invalid;
     679    }
     680}
     681
     682void UIMachineView::storeHintForGuestSizePolicy(int cWidth, int cHeight)
     683{
     684    if (m_maxGuestSizePolicy == MaxGuestSizePolicy_Automatic)
     685        m_storedGuestHintSize = QSize(cWidth, cHeight);
    683686}
    684687
     
    889892    session().GetConsole().GetDisplay().ResizeCompleted(screenId());
    890893
    891     /* We also recalculate the desktop geometry if this is determined
    892      * automatically. In fact, we only need this on the first resize,
    893      * but it is done every time to keep the code simpler. */
    894     calculateDesktopGeometry();
     894    /* We also recalculate the maximum guest size if necessary.  In fact we
     895     * only need this on the first resize, but it is done every time to keep
     896     * the code simpler. */
     897    calculateMaxGuestSize();
    895898
    896899    /* Emit a signal about guest was resized: */
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