Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 27419)
@@ -979,4 +979,29 @@
 }
 
+void VBoxProblemReporter::cannotSwitchScreenInSeamless(quint64 minVRAM)
+{
+    message(mainMachineWindowShown(), Error,
+            tr("<p>Could not change the guest screen to this host screen "
+               "due to insufficient guest video memory.</p>"
+               "<p>You should configure the virtual machine to have at "
+               "least <b>%1</b> of video memory.</p>")
+            .arg(VBoxGlobal::formatSize(minVRAM)));
+}
+
+int VBoxProblemReporter::cannotSwitchScreenInFullscreen(quint64 minVRAM)
+{
+    return message(mainMachineWindowShown(), Warning,
+                   tr("<p>Could not change the guest screen to this host screen "
+                      "due to insufficient guest video memory.</p>"
+                      "<p>You should configure the virtual machine to have at "
+                      "least <b>%1</b> of video memory.</p>"
+                      "<p>Press <b>Ignore</b> to switch the screen anyway "
+                      "or press <b>Cancel</b> to cancel the operation.</p>")
+                   .arg(VBoxGlobal::formatSize(minVRAM)),
+                   0, /* aAutoConfirmId */
+                   QIMessageBox::Ignore | QIMessageBox::Default,
+                   QIMessageBox::Cancel | QIMessageBox::Escape);
+}
+
 int VBoxProblemReporter::cannotEnterFullscreenMode()
 {
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h	(revision 27419)
@@ -226,4 +226,6 @@
     int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
                                    ULONG aBpp, ULONG64 aMinVRAM);
+    void cannotSwitchScreenInSeamless(quint64 minVRAM);
+    int cannotSwitchScreenInFullscreen(quint64 minVRAM);
 
     int cannotEnterFullscreenMode();
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.cpp	(revision 27419)
@@ -27,4 +27,6 @@
 #include "UIActionsPool.h"
 #include "UIMachineLogic.h"
+#include "UISession.h"
+#include "VBoxProblemReporter.h"
 
 /* Global includes */
@@ -129,4 +131,9 @@
 }
 
+quint64 UIMultiScreenLayout::memoryRequirements() const
+{
+    return memoryRequirements(m_pScreenMap);
+}
+
 void UIMultiScreenLayout::sltScreenLayoutChanged(QAction *pAction)
 {
@@ -136,12 +143,41 @@
 
     CMachine machine = m_pMachineLogic->session().GetMachine();
+    QMap<int,int> *pTmpMap = new QMap<int,int>(*m_pScreenMap);
     /* Search for the virtual screen which is currently displayed on the
      * requested host screen. When there is one found, we swap both. */
-    int r = m_pScreenMap->key(cHostScreen, -1);
+    int r = pTmpMap->key(cHostScreen, -1);
     if (r != -1)
-        m_pScreenMap->insert(r, m_pScreenMap->value(cGuestScreen));
+        pTmpMap->insert(r, pTmpMap->value(cGuestScreen));
     /* Set the new host screen */
-    m_pScreenMap->insert(cGuestScreen, cHostScreen);
-
+    pTmpMap->insert(cGuestScreen, cHostScreen);
+
+    bool fSuccess = true;
+    if (m_pMachineLogic->uisession()->isGuestAdditionsActive())
+    {
+        quint64 availBits = machine.GetVRAMSize() /* VRAM */
+            * _1M /* MB to bytes */
+            * 8; /* to bits */
+        quint64 usedBits = memoryRequirements(pTmpMap);
+
+        fSuccess = availBits >= usedBits;
+        if (!fSuccess)
+        {
+            /* We have to little video memory for the new layout, so say it to the
+             * user and revert all changes. */
+            if (m_pMachineLogic->visualStateType() == UIVisualStateType_Seamless)
+                vboxProblem().cannotSwitchScreenInSeamless((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
+            else
+                fSuccess = vboxProblem().cannotSwitchScreenInFullscreen((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M) != QIMessageBox::Cancel;
+        }
+    }
+    if (fSuccess)
+    {
+        /* Swap the temporary with the previous map. */
+        delete m_pScreenMap;
+        m_pScreenMap = pTmpMap;
+    }
+
+    /* Update the menu items. Even if we can't switch we have to revert the
+     * menu items. */
     QList<QAction*> actions = m_pMachineLogic->actionsPool()->action(UIActionIndex_Menu_View)->menu()->actions();
     /* Update the settings. */
@@ -160,5 +196,23 @@
     }
 
-    emit screenLayoutChanged();
-}
-
+    /* On success inform the observer. */
+    if (fSuccess)
+        emit screenLayoutChanged();
+}
+
+quint64 UIMultiScreenLayout::memoryRequirements(const QMap<int, int> *pScreenLayout) const
+{
+    int guestBpp = m_pMachineLogic->uisession()->session().GetConsole().GetDisplay().GetBitsPerPixel();
+    quint64 usedBits = 0;
+    for (int i = 0; i < m_cGuestScreens; ++ i)
+    {
+        QRect screen = QApplication::desktop()->availableGeometry(pScreenLayout->value(i, 0));
+        usedBits += screen.width() * /* display width */
+                    screen.height() * /* display height */
+                    guestBpp + /* guest bits per pixel */
+                    _1M * 8; /* current cache per screen - may be changed in future */
+    }
+    usedBits += 4096 * 8; /* adapter info */
+    return usedBits;
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMultiScreenLayout.h	(revision 27419)
@@ -46,4 +46,5 @@
     int guestScreenCount() const;
     int hostScreenForGuestScreen(int screenId) const;
+    quint64 memoryRequirements() const;
 
 signals:
@@ -55,4 +56,6 @@
 
 private:
+
+    quint64 memoryRequirements(const QMap<int, int> *pScreenLayout) const;
 
     /* Private member vars */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 27419)
@@ -68,5 +68,4 @@
     /* Temporary get a machine object: */
     const CMachine &machine = uisession()->session().GetMachine();
-    const CConsole &console = uisession()->session().GetConsole();
 
     int cHostScreens = m_pScreenLayout->hostScreenCount();
@@ -84,26 +83,11 @@
     if (uisession()->isGuestAdditionsActive())
     {
-        ULONG64 availBits = machine.GetVRAMSize() /* VRAM */
-                          * _1M /* MB to bytes */
-                          * 8; /* to bits */
-        ULONG guestBpp = console.GetDisplay().GetBitsPerPixel();
-        ULONG64 usedBits = 0;
-        for (int i = 0; i < cGuestScreens; ++ i)
-        {
-            // TODO_NEW_CORE: really take the screen geometry into account the
-            // different fb will be displayed. */
-            QRect screen = QApplication::desktop()->screenGeometry(i);
-            usedBits += screen.width() /* display width */
-                      * screen.height() /* display height */
-                      * guestBpp
-                      + _1M * 8; /* current cache per screen - may be changed in future */
-        }
-        usedBits += 4096 * 8; /* adapter info */
-
+        quint64 availBits = machine.GetVRAMSize() /* VRAM */
+                            * _1M /* MB to bytes */
+                            * 8; /* to bits */
+        quint64 usedBits = m_pScreenLayout->memoryRequirements();
         if (availBits < usedBits)
         {
-//            int result = vboxProblem().cannotEnterFullscreenMode(screen.width(), screen.height(), guestBpp,
-//                                                                 (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
-            int result = vboxProblem().cannotEnterFullscreenMode(0, 0, guestBpp,
+            int result = vboxProblem().cannotEnterFullscreenMode(0, 0, 0,
                                                                  (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
             if (result == QIMessageBox::Cancel)
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp	(revision 27418)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp	(revision 27419)
@@ -66,5 +66,4 @@
     /* Temporary get a machine object: */
     const CMachine &machine = uisession()->session().GetMachine();
-    const CConsole &console = uisession()->session().GetConsole();
 
     int cHostScreens = m_pScreenLayout->hostScreenCount();
@@ -82,26 +81,11 @@
     if (uisession()->isGuestAdditionsActive())
     {
-        ULONG64 availBits = machine.GetVRAMSize() /* VRAM */
-                          * _1M /* MB to bytes */
-                          * 8; /* to bits */
-        ULONG guestBpp = console.GetDisplay().GetBitsPerPixel();
-        ULONG64 usedBits = 0;
-        for (int i = 0; i < cGuestScreens; ++ i)
-        {
-            // TODO_NEW_CORE: really take the screen geometry into account the
-            // different fb will be displayed. */
-            QRect screen = QApplication::desktop()->availableGeometry(i);
-            usedBits += screen.width() /* display width */
-                      * screen.height() /* display height */
-                      * guestBpp
-                      + _1M * 8; /* current cache per screen - may be changed in future */
-        }
-        usedBits += 4096 * 8; /* adapter info */
-
+        quint64 availBits = machine.GetVRAMSize() /* VRAM */
+                            * _1M /* MB to bytes */
+                            * 8; /* to bits */
+        quint64 usedBits = m_pScreenLayout->memoryRequirements();
         if (availBits < usedBits)
         {
-//          vboxProblem().cannotEnterSeamlessMode(screen.width(), screen.height(), guestBpp,
-//                                                (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
-            vboxProblem().cannotEnterSeamlessMode(0, 0, guestBpp,
+            vboxProblem().cannotEnterSeamlessMode(0, 0, 0,
                                                   (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
             return false;
