Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp	(revision 39021)
@@ -184,5 +184,5 @@
         return E_POINTER;
     *pbSupported = TRUE;
-    QSize screen = m_pMachineView->desktopGeometry();
+    QSize screen = m_pMachineView->maxGuestSize();
     if ((screen.width() != 0) && (uWidth > (ULONG)screen.width()))
         *pbSupported = FALSE;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 39021)
@@ -160,6 +160,6 @@
     AssertMsg(newSize.isValid(), ("Size should be valid!\n"));
 
-    /* Store the new size */
-    storeConsoleSize(newSize.width(), newSize.height());
+    /* Store the new hint */
+    storeHintForGuestSizePolicy(newSize.width(), newSize.height());
     /* Send new size-hint to the guest: */
     session().GetConsole().GetDisplay().SetVideoModeHint(newSize.width(), newSize.height(), 0, screenId());
@@ -238,5 +238,5 @@
     , m_pFrameBuffer(0)
     , m_previousState(KMachineState_Null)
-    , m_desktopGeometryType(DesktopGeo_Invalid)
+    , m_maxGuestSizePolicy(MaxGuestSizePolicy_Invalid)
 #ifdef VBOX_WITH_VIDEOHWACCEL
     , m_fAccelerate2DVideo(bAccelerate2DVideo)
@@ -480,16 +480,16 @@
     /* Global settings: */
     {
-        /* Remember the desktop geometry and register for geometry
-         * change events for telling the guest about video modes we like: */
-        QString desktopGeometry = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");
-        if ((desktopGeometry == QString::null) || (desktopGeometry == "auto"))
-            setDesktopGeometry(DesktopGeo_Automatic, 0, 0);
-        else if (desktopGeometry == "any")
-            setDesktopGeometry(DesktopGeo_Any, 0, 0);
-        else
-        {
-            int width = desktopGeometry.section(',', 0, 0).toInt();
-            int height = desktopGeometry.section(',', 1, 1).toInt();
-            setDesktopGeometry(DesktopGeo_Fixed, width, height);
+        /* Remember the maximum guest size policy for telling the guest about
+         * video modes we like: */
+        QString maxGuestSize = vboxGlobal().settings().publicProperty("GUI/MaxGuestResolution");
+        if ((maxGuestSize == QString::null) || (maxGuestSize == "auto"))
+            setMaxGuestSizePolicy(MaxGuestSizePolicy_Automatic, 0, 0);
+        else if (maxGuestSize == "any")
+            setMaxGuestSizePolicy(MaxGuestSizePolicy_Any, 0, 0);
+        else  /** @todo Mea culpa, but what about error checking? */
+        {
+            int width  = maxGuestSize.section(',', 0, 0).toInt();
+            int height = maxGuestSize.section(',', 1, 1).toInt();
+            setMaxGuestSizePolicy(MaxGuestSizePolicy_Fixed, width, height);
         }
     }
@@ -596,21 +596,22 @@
 }
 
-QSize UIMachineView::desktopGeometry() const
-{
-    QSize geometry;
-    switch (m_desktopGeometryType)
-    {
-        case DesktopGeo_Fixed:
-        case DesktopGeo_Automatic:
-            geometry = QSize(qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
-                             qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
-            break;
-        case DesktopGeo_Any:
-            geometry = QSize(0, 0);
+QSize UIMachineView::maxGuestSize() const
+{
+    QSize maxSize;
+    switch (m_maxGuestSizePolicy)
+    {
+        case MaxGuestSizePolicy_Fixed:
+        case MaxGuestSizePolicy_Automatic:
+            maxSize = QSize(qMax(m_fixedMaxGuestSize.width(), m_storedGuestHintSize.width()),
+                             qMax(m_fixedMaxGuestSize.height(), m_storedGuestHintSize.height()));
+            break;
+        case MaxGuestSizePolicy_Any:
+            maxSize = QSize(0, 0);
             break;
         default:
-            AssertMsgFailed(("Bad geometry type %d!\n", m_desktopGeometryType));
-    }
-    return geometry;
+            AssertMsgFailed(("Invalid maximum guest size policy %d!\n",
+                             m_maxGuestSizePolicy));
+    }
+    return maxSize;
 }
 
@@ -650,35 +651,37 @@
 }
 
-void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight)
-{
-    switch (geometry)
-    {
-        case DesktopGeo_Fixed:
-            m_desktopGeometryType = DesktopGeo_Fixed;
-            if (aWidth != 0 && aHeight != 0)
-                m_desktopGeometry = QSize(aWidth, aHeight);
+void UIMachineView::setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax,
+                                          int chMax)
+{
+    switch (policy)
+    {
+        case MaxGuestSizePolicy_Fixed:
+            m_maxGuestSizePolicy = MaxGuestSizePolicy_Fixed;
+            if (cwMax != 0 && chMax != 0)
+                m_fixedMaxGuestSize = QSize(cwMax, chMax);
             else
-                m_desktopGeometry = QSize(0, 0);
-            storeConsoleSize(0, 0);
-            break;
-        case DesktopGeo_Automatic:
-            m_desktopGeometryType = DesktopGeo_Automatic;
-            m_desktopGeometry = QSize(0, 0);
-            storeConsoleSize(0, 0);
-            break;
-        case DesktopGeo_Any:
-            m_desktopGeometryType = DesktopGeo_Any;
-            m_desktopGeometry = QSize(0, 0);
+                m_fixedMaxGuestSize = QSize(0, 0);
+            storeHintForGuestSizePolicy(0, 0);
+            break;
+        case MaxGuestSizePolicy_Automatic:
+            m_maxGuestSizePolicy = MaxGuestSizePolicy_Automatic;
+            m_fixedMaxGuestSize = QSize(0, 0);
+            storeHintForGuestSizePolicy(0, 0);
+            break;
+        case MaxGuestSizePolicy_Any:
+            m_maxGuestSizePolicy = MaxGuestSizePolicy_Any;
+            m_fixedMaxGuestSize = QSize(0, 0);
             break;
         default:
-            AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry));
-            m_desktopGeometryType = DesktopGeo_Invalid;
-    }
-}
-
-void UIMachineView::storeConsoleSize(int iWidth, int iHeight)
-{
-    if (m_desktopGeometryType == DesktopGeo_Automatic)
-        m_storedConsoleSize = QSize(iWidth, iHeight);
+            AssertMsgFailed(("Invalid maximum guest size policy %d\n",
+                             policy));
+            m_maxGuestSizePolicy = MaxGuestSizePolicy_Invalid;
+    }
+}
+
+void UIMachineView::storeHintForGuestSizePolicy(int cWidth, int cHeight)
+{
+    if (m_maxGuestSizePolicy == MaxGuestSizePolicy_Automatic)
+        m_storedGuestHintSize = QSize(cWidth, cHeight);
 }
 
@@ -889,8 +892,8 @@
     session().GetConsole().GetDisplay().ResizeCompleted(screenId());
 
-    /* We also recalculate the desktop geometry if this is determined
-     * automatically. In fact, we only need this on the first resize,
-     * but it is done every time to keep the code simpler. */
-    calculateDesktopGeometry();
+    /* We also recalculate the maximum guest size if necessary.  In fact we
+     * only need this on the first resize, but it is done every time to keep
+     * the code simpler. */
+    calculateMaxGuestSize();
 
     /* Emit a signal about guest was resized: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 39021)
@@ -44,6 +44,18 @@
 public:
 
-    /* Desktop geometry types: */
-    enum DesktopGeo { DesktopGeo_Invalid = 0, DesktopGeo_Fixed, DesktopGeo_Automatic, DesktopGeo_Any };
+    /** Policy for determining which guest resolutions we wish to
+     * handle.  We also accept anything smaller than the current
+     * resolution. */
+    enum MaxGuestSizePolicy
+    {
+        /** Policy not set correctly. */
+        MaxGuestSizePolicy_Invalid = 0,
+        /** Anything up to a fixed size. */
+        MaxGuestSizePolicy_Fixed,
+        /** Anything up to available space on the host desktop. */
+        MaxGuestSizePolicy_Automatic,
+        /** We accept anything. */
+        MaxGuestSizePolicy_Any
+    };
 
     /* Factory function to create machine-view: */
@@ -123,12 +135,24 @@
     UIFrameBuffer* frameBuffer() const { return m_pFrameBuffer; }
     const QPixmap& pauseShot() const { return m_pauseShot; }
-    QSize storedConsoleSize() const { return m_storedConsoleSize; }
-    DesktopGeo desktopGeometryType() const { return m_desktopGeometryType; }
-    QSize desktopGeometry() const;
+    /** Helper to retrieve the last non-fullscreen guest size hint
+     * sent.  @note Currently unused. */
+    QSize storedGuestHintSize() const { return m_storedGuestHintSize; }
+    /** What policy are we currently applying for limiting guest
+     * resolutions? */
+    MaxGuestSizePolicy maxGuestSizePolicy() const
+    { return m_maxGuestSizePolicy; }
+    /** The maximum guest resolution which we currently wish to handle.
+     * @note This must be safely called from another thread.
+     * @todo So make it atomic.
+     */
+    QSize maxGuestSize() const;
+    /** Retrieve the last non-fullscreen guest size hint (from extra data).
+     */
     QSize guestSizeHint();
 
     /* Protected setters: */
-    void setDesktopGeometry(DesktopGeo geometry, int iWidth, int iHeight);
-    void storeConsoleSize(int iWidth, int iHeight);
+    void setMaxGuestSizePolicy(MaxGuestSizePolicy policy, int cwMax,
+                               int chMax);
+    void storeHintForGuestSizePolicy(int cWidth, int cHeight);
     void storeGuestSizeHint(const QSize &sizeHint);
 
@@ -137,6 +161,9 @@
     virtual void takePauseShotSnapshot();
     virtual void resetPauseShot() { m_pauseShot = QPixmap(); }
-    virtual QRect workingArea() = 0;
-    virtual void calculateDesktopGeometry() = 0;
+    /** The available area on the current screen for application windows. */
+    virtual QRect workingArea() const = 0;
+    /** Calculate how big the guest desktop can be while still fitting on one
+     * host screen. */
+    virtual void calculateMaxGuestSize() = 0;
     virtual void maybeRestrictMinimumSize() = 0;
     virtual void updateSliders();
@@ -176,7 +203,12 @@
     KMachineState m_previousState;
 
-    DesktopGeo m_desktopGeometryType;
-    QSize m_desktopGeometry;
-    QSize m_storedConsoleSize;
+    /** The policy for calculating the maximum guest resolution we wish to
+     * support. */
+    MaxGuestSizePolicy m_maxGuestSizePolicy;
+    /** The maximum guest size for fixed size policy. */
+    QSize m_fixedMaxGuestSize;
+    /** The last guest size hint sent out, used for calculating the maximum
+     * supported guest resolution. */
+    QSize m_storedGuestHintSize;
 
 #ifdef VBOX_WITH_VIDEOHWACCEL
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.cpp	(revision 39021)
@@ -95,6 +95,6 @@
 void UIMachineViewFullscreen::sltDesktopResized()
 {
-    /* If the desktop geometry is set automatically, this will update it: */
-    calculateDesktopGeometry();
+    /* Recalculate the maximum guest size if necessary. */
+    calculateMaxGuestSize();
 }
 
@@ -197,5 +197,5 @@
 }
 
-QRect UIMachineViewFullscreen::workingArea()
+QRect UIMachineViewFullscreen::workingArea() const
 {
     /* Get corresponding screen: */
@@ -205,11 +205,11 @@
 }
 
-void UIMachineViewFullscreen::calculateDesktopGeometry()
+void UIMachineViewFullscreen::calculateMaxGuestSize()
 {
     /* This method should not get called until we have initially set up the desktop geometry type: */
-    Assert((desktopGeometryType() != DesktopGeo_Invalid));
-    /* If we are not doing automatic geometry calculation then there is nothing to do: */
-    if (desktopGeometryType() == DesktopGeo_Automatic)
-        m_desktopGeometry = workingArea().size();
+    Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid));
+    /* If we are not doing automatic adjustment then there is nothing to do. */
+    if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic)
+        m_fixedMaxGuestSize = workingArea().size();
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineViewFullscreen.h	(revision 39021)
@@ -70,6 +70,6 @@
     /* Private helpers: */
     void normalizeGeometry(bool /* fAdjustPosition */) {}
-    QRect workingArea();
-    void calculateDesktopGeometry();
+    QRect workingArea() const;
+    void calculateMaxGuestSize();
     void maybeRestrictMinimumSize();
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp	(revision 39021)
@@ -98,6 +98,6 @@
 void UIMachineViewNormal::sltDesktopResized()
 {
-    /* If the desktop geometry is set automatically, this will update it: */
-    calculateDesktopGeometry();
+    /* Recalculate the maximum guest size if necessary. */
+    calculateMaxGuestSize();
 }
 
@@ -297,15 +297,16 @@
 }
 
-QRect UIMachineViewNormal::workingArea()
+QRect UIMachineViewNormal::workingArea() const
 {
     return QApplication::desktop()->availableGeometry(this);
 }
 
-void UIMachineViewNormal::calculateDesktopGeometry()
-{
-    /* This method should not get called until we have initially set up the desktop geometry type: */
-    Assert((desktopGeometryType() != DesktopGeo_Invalid));
-    /* If we are not doing automatic geometry calculation then there is nothing to do: */
-    if (desktopGeometryType() == DesktopGeo_Automatic)
+void UIMachineViewNormal::calculateMaxGuestSize()
+{
+    /* This method should not get called until we have initially set up the
+     * maximum guest size policy. */
+    Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid));
+    /* If we are not doing automatic adjustment then there is nothing to do. */
+    if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic)
     {
         /* The area taken up by the machine window on the desktop,
@@ -318,6 +319,10 @@
          * This works because the difference between machine window and machine central widget
          * (or at least its width and height) is a constant. */
-        m_desktopGeometry = QSize(workingArea().width() - (windowGeo.width() - centralWidgetGeo.width()),
-                                  workingArea().height() - (windowGeo.height() - centralWidgetGeo.height()));
+        m_fixedMaxGuestSize = QSize(  workingArea().width()
+                                    - (windowGeo.width()
+                                    - centralWidgetGeo.width()),
+                                      workingArea().height()
+                                    - (windowGeo.height()
+                                    - centralWidgetGeo.height()));
     }
 }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h	(revision 39021)
@@ -79,6 +79,6 @@
     /* Private helpers: */
     void normalizeGeometry(bool fAdjustPosition);
-    QRect workingArea();
-    void calculateDesktopGeometry();
+    QRect workingArea() const;
+    void calculateMaxGuestSize();
     void maybeRestrictMinimumSize();
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.cpp	(revision 39021)
@@ -154,6 +154,6 @@
 void UIMachineViewScale::sltDesktopResized()
 {
-    /* If the desktop geometry is set automatically, this will update it: */
-    calculateDesktopGeometry();
+    /* Recalculate the maximum guest size if necessary. */
+    calculateMaxGuestSize();
 }
 
@@ -186,8 +186,8 @@
             session().GetConsole().GetDisplay().ResizeCompleted(screenId());
 
-            /* We also recalculate the desktop geometry if this is determined
-             * automatically.  In fact, we only need this on the first resize,
-             * but it is done every time to keep the code simpler. */
-            calculateDesktopGeometry();
+            /* We also recalculate the maximum guest size if necessary.  In
+             * fact we only need this on the first resize, but it is done
+             * every time to keep the code simpler. */
+            calculateMaxGuestSize();
 
             /* Emit a signal about guest was resized: */
@@ -363,15 +363,16 @@
 }
 
-QRect UIMachineViewScale::workingArea()
+QRect UIMachineViewScale::workingArea() const
 {
     return QApplication::desktop()->availableGeometry(this);
 }
 
-void UIMachineViewScale::calculateDesktopGeometry()
-{
-    /* This method should not get called until we have initially set up the desktop geometry type: */
-    Assert((desktopGeometryType() != DesktopGeo_Invalid));
-    /* If we are not doing automatic geometry calculation then there is nothing to do: */
-    if (desktopGeometryType() == DesktopGeo_Automatic)
+void UIMachineViewScale::calculateMaxGuestSize()
+{
+    /* This method should not get called until we have initially set up the
+     * maximum guest size policy. */
+    Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid));
+    /* If we are not doing automatic adjustment then there is nothing to do. */
+    if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic)
     {
         /* The area taken up by the machine window on the desktop,
@@ -384,6 +385,10 @@
          * This works because the difference between machine window and machine central widget
          * (or at least its width and height) is a constant. */
-        m_desktopGeometry = QSize(workingArea().width() - (windowGeo.width() - centralWidgetGeo.width()),
-                                  workingArea().height() - (windowGeo.height() - centralWidgetGeo.height()));
+        m_fixedMaxGuestSize = QSize(  workingArea().width()
+                                    - (windowGeo.width()
+                                    - centralWidgetGeo.width()),
+                                      workingArea().height()
+                                    - (windowGeo.height()
+                                    - centralWidgetGeo.height()));
     }
 }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineViewScale.h	(revision 39021)
@@ -71,6 +71,6 @@
     QSize sizeHint() const;
     void normalizeGeometry(bool /* fAdjustPosition */) {}
-    QRect workingArea();
-    void calculateDesktopGeometry();
+    QRect workingArea() const;
+    void calculateMaxGuestSize();
     void maybeRestrictMinimumSize() {}
     void updateSliders();
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.cpp	(revision 39021)
@@ -96,8 +96,12 @@
 void UIMachineViewSeamless::sltDesktopResized()
 {
-    // TODO: Try to resize framebuffer according new desktop size, exit seamless if resize is failed!
-
-    /* If the desktop geometry is set automatically, this will update it: */
-    calculateDesktopGeometry();
+    /** @todo Try to resize framebuffer according new desktop size,
+     *        exit seamless if resize is failed! */
+    /** @todo Check whether this isn't already fixed elsewhere.
+     *        I don't think that it is the GUI's job to check that
+     *        the resize succeeded though. */
+
+    /* Recalculate the maximum guest size if necessary. */
+    calculateMaxGuestSize();
 }
 
@@ -215,5 +219,5 @@
 }
 
-QRect UIMachineViewSeamless::workingArea()
+QRect UIMachineViewSeamless::workingArea() const
 {
     /* Get corresponding screen: */
@@ -223,11 +227,11 @@
 }
 
-void UIMachineViewSeamless::calculateDesktopGeometry()
+void UIMachineViewSeamless::calculateMaxGuestSize()
 {
     /* This method should not get called until we have initially set up the desktop geometry type: */
-    Assert((desktopGeometryType() != DesktopGeo_Invalid));
-    /* If we are not doing automatic geometry calculation then there is nothing to do: */
-    if (desktopGeometryType() == DesktopGeo_Automatic)
-        m_desktopGeometry = workingArea().size();
-}
-
+    Assert((maxGuestSizePolicy() != MaxGuestSizePolicy_Invalid));
+    /* If we are not doing automatic adjustment then there is nothing to do. */
+    if (maxGuestSizePolicy() == MaxGuestSizePolicy_Automatic)
+        m_fixedMaxGuestSize = workingArea().size();
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h	(revision 39020)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineViewSeamless.h	(revision 39021)
@@ -74,6 +74,6 @@
     /* Private helpers: */
     void normalizeGeometry(bool /* fAdjustPosition */) {}
-    QRect workingArea();
-    void calculateDesktopGeometry();
+    QRect workingArea() const;
+    void calculateMaxGuestSize();
     void maybeRestrictMinimumSize() {}
 
