Index: trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIStateIndicator.h	(revision 26773)
@@ -49,6 +49,6 @@
 public slots:
 
-    void setState (int aState);
-    void setState (bool aState) { setState ((int) aState); }
+    virtual void setState (int aState);
+    virtual void setState (bool aState) { setState ((int) aState); }
 
 signals:
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIIndicatorsPool.cpp	(revision 26773)
@@ -26,4 +26,5 @@
 #include "VBoxGlobal.h"
 #include "COMDefs.h"
+#include "UIMachineDefs.h"
 #include "QIWithRetranslateUI.h"
 
@@ -551,4 +552,20 @@
     }
 
+public slots:
+
+    void setState(int iState)
+    {
+        if ((iState & UIMouseStateType_MouseAbsoluteDisabled) &&
+            (iState & UIMouseStateType_MouseAbsolute) &&
+            !(iState & UIMouseStateType_MouseCaptured))
+        {
+            QIStateIndicator::setState(4);
+        }
+        else
+        {
+            QIStateIndicator::setState(iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured));
+        }
+    }
+
 protected:
     /* For compatibility reason we do it here, later this should be moved to
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 26773)
@@ -243,5 +243,5 @@
 };
 
-#if 0
+#if 0 // TODO: Rework additions downloader logic!
 class UIAdditionsDownloader : public VBoxDownloaderWgt
 {
@@ -369,23 +369,20 @@
                                UIActionsPool *pActionsPool,
                                UIVisualStateType visualStateType)
-    /* Initialize parent class: */
     : QObject(pParent)
-    /* Initialize protected members: */
-    , m_pMachineWindowContainer(0)
-    /* Initialize private members: */
     , m_pSession(pSession)
     , m_pActionsPool(pActionsPool)
     , m_machineState(KMachineState_Null)
     , m_visualStateType(visualStateType)
-    /* Action groups: */
+    , m_pMachineWindowWrapper(0)
     , m_pRunningActions(0)
     , m_pRunningOrPausedActions(0)
-    /* Bool flags: */
-    , m_bIsFirstTimeStarted(false)
-    , m_bIsOpenViewFinished(false)
-    , m_bIsGraphicsSupported(false)
-    , m_bIsSeamlessSupported(false)
-    , m_bIsAutoSaveMedia(true)
-    , m_bIsPreventAutoClose(false)
+    , m_fIsFirstTimeStarted(false)
+    , m_fIsIgnoringRutimeMediums(false)
+    , m_fIsAdditionsActive(false)
+    , m_fIsGuestSupportsGraphics(false)
+    , m_fIsGuestSupportsSeamless(false)
+    , m_fIsMouseSupportsAbsolute(false)
+    , m_fIsHostCursorNeeded(false)
+    , m_fIsPreventAutoClose(false)
 {
 }
@@ -399,10 +396,25 @@
 }
 
+CSession& UIMachineLogic::session()
+{
+    return m_pSession->session();
+}
+
 void UIMachineLogic::prepareConsoleConnections()
 {
+    /* Machine state-change updater: */
     connect(uisession(), SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));
+
+    /* Guest additions state-change updater: */
     connect(uisession(), SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
+
+    /* Mouse capability state-change updater: */
+    connect(uisession(), SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool)));
+
+    /* USB devices state-change updater: */
     connect(uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)),
             this, SLOT(sltUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)));
+
+    /* Runtime errors notifier: */
     connect(uisession(), SIGNAL(sigRuntimeError(bool, const QString &, const QString &)),
             this, SLOT(sltRuntimeError(bool, const QString &, const QString &)));
@@ -423,7 +435,8 @@
     m_pRunningOrPausedActions->setExclusive(false);
 
-    /* Move actions into first group: */
+    /* Move actions into running actions group: */
     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_Seamless));
+    m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
     m_pRunningActions->addAction(actionsPool()->action(UIActionIndex_Simple_TypeCAD));
@@ -439,6 +452,5 @@
 #endif
 
-    /* Move actions into second group: */
-    m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
+    /* Move actions into running-n-paused actions group: */
     m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Menu_MouseIntegration));
     m_pRunningOrPausedActions->addAction(actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
@@ -460,5 +472,5 @@
 void UIMachineLogic::prepareActionConnections()
 {
-    /* "Machine" actions connections */
+    /* "Machine" actions connections: */
     connect(actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize), SIGNAL(toggled(bool)),
             this, SLOT(sltToggleGuestAutoresize(bool)));
@@ -486,5 +498,5 @@
             this, SLOT(sltClose()));
 
-    /* "Devices" actions connections */
+    /* "Devices" actions connections: */
     connect(actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu(), SIGNAL(aboutToShow()),
             this, SLOT(sltPrepareStorageMenu()));
@@ -503,5 +515,5 @@
 
 #ifdef VBOX_WITH_DEBUGGER_GUI
-    /* "Debug" actions connections */
+    /* "Debug" actions connections: */
     connect(actionsPool()->action(UIActionIndex_Menu_Debug)->menu(), SIGNAL(aboutToShow()),
             this, SLOT(sltPrepareDebugMenu()));
@@ -566,9 +578,9 @@
         strSettings = machine.GetExtraData(VBoxDefs::GUI_FirstRun);
         if (strSettings == "yes")
-            m_bIsFirstTimeStarted = true;
+            m_fIsFirstTimeStarted = true;
 
         strSettings = machine.GetExtraData(VBoxDefs::GUI_SaveMountedAtRuntime);
         if (strSettings == "no")
-            m_bIsAutoSaveMedia = false;
+            m_fIsIgnoringRutimeMediums = true;
     }
 
@@ -615,4 +627,22 @@
         }
     }
+
+#if 0
+    /* Dynamical property settings: */
+    {
+        /* Load dynamical properties: */
+        m_machineState = uisession()->property("MachineLogic/MachineState").value<KMachineState>();
+        m_fIsAdditionsActive = uisession()->property("MachineLogic/IsAdditionsActive").toBool();
+        m_fIsGuestSupportsGraphics = uisession()->property("MachineLogic/IsGuestSupportsGraphics").toBool();
+        m_fIsGuestSupportsSeamless = uisession()->property("MachineLogic/IsGuestSupportsSeamless").toBool();
+        m_fIsMouseSupportsAbsolute = uisession()->property("MachineLogic/IsMouseSupportsAbsolute").toBool();
+        m_fIsHostCursorNeeded = uisession()->property("MachineLogic/IsHostCursorNeeded").toBool();
+
+        /* Update relative things: */
+        updateMachineState();
+        updateAdditionsState();
+        updateMouseCapability();
+    }
+#endif
 }
 
@@ -632,157 +662,146 @@
         //machine.SetExtraData(VBoxDefs::GUI_MiniToolBarAutoHide, mMiniToolBar->isAutoHide() ? "on" : "off");
     }
-}
-
-CSession& UIMachineLogic::session()
-{
-    return m_pSession->session();
-}
-
-void UIMachineLogic::sltMachineStateChanged(KMachineState newMachineState)
-{
-    if (m_machineState != newMachineState)
-    {
-        /* Variable flags: */
-        bool bIsRunning = newMachineState == KMachineState_Running ||
-                          newMachineState == KMachineState_Teleporting ||
-                          newMachineState == KMachineState_LiveSnapshotting;
-        bool bIsRunningOrPaused = bIsRunning ||
-                                  newMachineState == KMachineState_Paused;
-
-        /* Update action groups: */
-        m_pRunningActions->setEnabled(bIsRunning);
-        m_pRunningOrPausedActions->setEnabled(bIsRunningOrPaused);
-
-        /* Do we have GURU? */
-        bool bIsGuruMeditation = false;
-
-        switch (newMachineState)
-        {
-            case KMachineState_Stuck:
+
+#if 0
+    /* Dynamical property settings: */
+    {
+        /* Save dynamical properties: */
+        uisession()->setProperty("MachineLogic/MachineState", QVariant::fromValue(machineState()));
+        uisession()->setProperty("MachineLogic/IsAdditionsActive", m_fIsAdditionsActive);
+        uisession()->setProperty("MachineLogic/IsGuestSupportsGraphics", m_fIsGuestSupportsGraphics);
+        uisession()->setProperty("MachineLogic/IsGuestSupportsSeamless", m_fIsGuestSupportsSeamless);
+        uisession()->setProperty("MachineLogic/IsMouseSupportsAbsolute", m_fIsMouseSupportsAbsolute);
+        uisession()->setProperty("MachineLogic/IsHostCursorNeeded", m_fIsHostCursorNeeded);
+    }
+#endif
+}
+
+void UIMachineLogic::updateMachineState()
+{
+    /* State flags: */
+    bool fIsRunning = machineState() == KMachineState_Running ||
+                      machineState() == KMachineState_Teleporting ||
+                      machineState() == KMachineState_LiveSnapshotting;
+    bool fIsRunningOrPaused = fIsRunning ||
+                              machineState() == KMachineState_Paused;
+
+    /* Update action groups: */
+    m_pRunningActions->setEnabled(fIsRunning);
+    m_pRunningOrPausedActions->setEnabled(fIsRunningOrPaused);
+
+    /* Do we have GURU? */
+    bool fIsGuruMeditation = false;
+
+    switch (machineState())
+    {
+        case KMachineState_Stuck:
+        {
+            /* We will handle GURU later: */
+            fIsGuruMeditation = true;
+            break;
+        }
+        case KMachineState_Paused:
+        {
+            QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
+            if (!pPauseAction->isChecked())
             {
-                bIsGuruMeditation = true;
-                break;
+                /* Was paused from CSession side: */
+                pPauseAction->blockSignals(true);
+                pPauseAction->setChecked(true);
+                pPauseAction->blockSignals(false);
             }
-            case KMachineState_Paused:
+            break;
+        }
+        case KMachineState_Running:
+        case KMachineState_Teleporting:
+        case KMachineState_LiveSnapshotting:
+        {
+            QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
+            if (pPauseAction->isChecked())
             {
-                /* Was paused from CMachine side? */
-                QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
-                if (!pPauseAction->isChecked())
-                {
-                    pPauseAction->blockSignals(true);
-                    pPauseAction->setChecked(true);
-                    pPauseAction->blockSignals(false);
-                }
-                break;
+                /* Was resumed from CSession side: */
+                pPauseAction->blockSignals(true);
+                pPauseAction->setChecked(false);
+                pPauseAction->blockSignals(false);
             }
-            case KMachineState_Running:
-            case KMachineState_Teleporting:
-            case KMachineState_LiveSnapshotting:
-            {
-                /* Was started from CMachine side? */
-                QAction *pPauseAction = actionsPool()->action(UIActionIndex_Toggle_Pause);
-                if (isPaused() && pPauseAction->isChecked())
-                {
-                    pPauseAction->blockSignals(true);
-                    pPauseAction->setChecked(false);
-                    pPauseAction->blockSignals(false);
-                }
-                break;
-            }
+            break;
+        }
 #ifdef Q_WS_X11
-            case KMachineState_Starting:
-            case KMachineState_Restoring:
-            case KMachineState_TeleportingIn:
-            {
-                /* The keyboard handler may wish to do some release logging on startup.
-                 * Tell it that the logger is now active. */
-                doXKeyboardLogging(QX11Info::display());
-                break;
-            }
-#endif
-            default:
-                break;
-        }
-
-        /* Now storing new state: */
-        m_machineState = newMachineState;
-
-        /* Close VM if was closed someway: */
-        if (m_machineState == KMachineState_PoweredOff || m_machineState == KMachineState_Saved ||
-            m_machineState == KMachineState_Teleported || m_machineState == KMachineState_Aborted)
-        {
-            /* VM has been powered off or saved or aborted, no matter internally or externally.
-             * We must *safely* close the console window unless auto closure is disabled: */
-            if (!m_bIsPreventAutoClose)
-                machineWindowWrapper()->sltTryClose();
-        }
-
-        /* Process GURU: */
-        if (bIsGuruMeditation)
-        {
-            if (machineWindowWrapper()->machineView())
-                machineWindowWrapper()->machineView()->setIgnoreGuestResize(true);
-
-            CConsole console = session().GetConsole();
-            QString strLogFolder = console.GetMachine().GetLogFolder();
-
-            /* Take the screenshot for debugging purposes and save it */
-            QString strFileName = strLogFolder + "/VBox.png";
-            CDisplay display = console.GetDisplay();
-            QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
-            display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
-            shot.save(QFile::encodeName(strFileName), "PNG");
-
-            /* Warn the user about GURU: */
-            if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
-            {
-                qApp->processEvents();
-                console.PowerDown();
-                if (!console.isOk())
-                    vboxProblem().cannotStopMachine(console);
-            }
-        }
+        case KMachineState_Starting:
+        case KMachineState_Restoring:
+        case KMachineState_TeleportingIn:
+        {
+            /* The keyboard handler may wish to do some release logging on startup.
+             * Tell it that the logger is now active. */
+            doXKeyboardLogging(QX11Info::display());
+            break;
+        }
+#endif
+        default:
+            break;
+    }
+
+    /* Close VM if was closed someway: */
+    if (machineState() == KMachineState_PoweredOff || machineState() == KMachineState_Saved ||
+        machineState() == KMachineState_Teleported || machineState() == KMachineState_Aborted)
+    {
+        /* VM has been powered off or saved or aborted, no matter internally or externally.
+         * We must *safely* close the console window unless auto closure is disabled: */
+        sltClose();
+        return;
+    }
+
+    /* Process GURU: */
+    if (fIsGuruMeditation)
+    {
+        if (machineWindowWrapper()->machineView())
+            machineWindowWrapper()->machineView()->setIgnoreGuestResize(true);
+
+        CConsole console = session().GetConsole();
+        QString strLogFolder = console.GetMachine().GetLogFolder();
+
+        /* Take the screenshot for debugging purposes and save it */
+        QString strFileName = strLogFolder + "/VBox.png";
+        CDisplay display = console.GetDisplay();
+        QImage shot = QImage(display.GetWidth(), display.GetHeight(), QImage::Format_RGB32);
+        display.TakeScreenShot(shot.bits(), shot.width(), shot.height());
+        shot.save(QFile::encodeName(strFileName), "PNG");
+
+        /* Warn the user about GURU: */
+        if (vboxProblem().remindAboutGuruMeditation(console, QDir::toNativeSeparators(strLogFolder)))
+        {
+            qApp->processEvents();
+            console.PowerDown();
+            if (!console.isOk())
+                vboxProblem().cannotStopMachine(console);
+        }
+    }
 
 #ifdef Q_WS_MAC
-        /* Update Dock Overlay: */
-        if (   machineWindowWrapper()
-            && machineWindowWrapper()->machineView())
-            machineWindowWrapper()->machineView()->updateDockOverlay();
+    /* Update Dock Overlay: */
+    if (machineWindowWrapper() && machineWindowWrapper()->machineView())
+        machineWindowWrapper()->machineView()->updateDockOverlay();
 #endif /* Q_WS_MAC */
-    }
-}
-
-void UIMachineLogic::sltAdditionsStateChanged()
-{
-    /* Get console guest: */
+}
+
+void UIMachineLogic::updateAdditionsState()
+{
+    /* Update action groups: */
+    actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics);
+    actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless);
+
+#if 0 // TODO: Enter seamless if necessary!
+    /* If seamless mode should be enabled then check if it is enabled currently and re-enable it if open-view procedure is finished */
+    if (actionsPool()->action(UIActionIndex_Toggle_Seamless)->isChecked() &&
+        m_fIsAdditionsActive && m_fIsGuestSupportsGraphics && m_fIsGuestSupportsSeamless)
+        toggleFullscreenMode(true, true);
+#endif
+
+    /* Check the GA version only in case of additions are active: */
+    if (!m_fIsAdditionsActive)
+        return;
+
+    /* Check the Guest Additions version and warn the user about possible compatibility issues in case if the installed version is outdated. */
     CGuest guest = session().GetConsole().GetGuest();
-
-    /* Variable flags: */
-    bool bIsActive = guest.GetAdditionsActive();
-    bool bIsGraphicsSupported = guest.GetSupportsGraphics();
-    bool bIsSeamlessSupported = guest.GetSupportsSeamless();
-
-    /* Update action groups: */
-    actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize)->setEnabled(bIsActive && bIsGraphicsSupported);
-    actionsPool()->action(UIActionIndex_Toggle_Seamless)->setEnabled(bIsActive && bIsGraphicsSupported && bIsSeamlessSupported);
-
-    /* Store new values: */
-    m_bIsSeamlessSupported = bIsSeamlessSupported;
-    m_bIsGraphicsSupported = bIsGraphicsSupported;
-
-#if 0 // TODO: Re-activate seamless if necessary!
-    /* If seamless mode should be enabled then check if it is enabled currently and re-enable it if open-view procedure is finished */
-    if ((m_bIsSeamlessSupported != bIsSeamlessSupported) || (m_bIsGraphicsSupported != bIsGraphicsSupported))
-    {
-        if (actionsPool()->action(UIActionIndex_Toggle_Seamless)->isChecked() && m_bIsOpenViewFinished && bIsGraphicsSupported && bIsSeamlessSupported)
-            toggleFullscreenMode(true, true);
-    }
-#endif
-
-    /* Check the GA version only in case of additions are active: */
-    if (!bIsActive)
-        return;
-
-    /* Check the Guest Additions version and warn the user about possible compatibility issues in case if the installed version is outdated. */
     QString strVersion = guest.GetAdditionsVersion();
     uint uVersion = strVersion.toUInt();
@@ -804,4 +823,64 @@
 }
 
+void UIMachineLogic::updateMouseCapability()
+{
+    /* Update related things: */
+    QAction *pAction = actionsPool()->action(UIActionIndex_Toggle_MouseIntegration);
+    pAction->setEnabled(m_fIsMouseSupportsAbsolute && !m_fIsHostCursorNeeded);
+    pAction->setChecked(m_fIsHostCursorNeeded || pAction->isChecked());
+}
+
+void UIMachineLogic::sltMachineStateChanged(KMachineState state)
+{
+    /* Check if something had changed: */
+    if (m_machineState != state)
+    {
+        /* Store new data: */
+        m_machineState = state;
+
+        /* Update machine state: */
+        updateMachineState();
+    }
+}
+
+void UIMachineLogic::sltAdditionsStateChanged()
+{
+    /* Get our guest: */
+    CGuest guest = session().GetConsole().GetGuest();
+
+    /* Variable flags: */
+    bool fIsAdditionsActive = guest.GetAdditionsActive();
+    bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics();
+    bool fIsGuestSupportsSeamless = guest.GetSupportsSeamless();
+
+    /* Check if something had changed: */
+    if (m_fIsAdditionsActive != fIsAdditionsActive ||
+        m_fIsGuestSupportsGraphics != fIsGuestSupportsGraphics ||
+        m_fIsGuestSupportsSeamless != fIsGuestSupportsSeamless)
+    {
+        /* Store new data: */
+        m_fIsAdditionsActive = fIsAdditionsActive;
+        m_fIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
+        m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless;
+
+        /* Update additions state: */
+        updateAdditionsState();
+    }
+}
+
+void UIMachineLogic::sltMouseCapabilityChanged(bool fIsSupportsAbsolute, bool fIsHostCursorNeeded)
+{
+    /* Check if something is changed: */
+    if (m_fIsMouseSupportsAbsolute != fIsSupportsAbsolute || m_fIsHostCursorNeeded != fIsHostCursorNeeded)
+    {
+        /* Store new data: */
+        m_fIsMouseSupportsAbsolute = fIsSupportsAbsolute;
+        m_fIsHostCursorNeeded = fIsHostCursorNeeded;
+
+        /* Update mouse capability: */
+        updateMouseCapability();
+    }
+}
+
 void UIMachineLogic::sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error)
 {
@@ -822,5 +901,5 @@
 }
 
-void UIMachineLogic::sltToggleGuestAutoresize(bool /* bEnabled */)
+void UIMachineLogic::sltToggleGuestAutoresize(bool bEnabled)
 {
     /* Do not process if window or view is missing! */
@@ -828,5 +907,5 @@
         return;
 
-    // TODO: Enable/Disable guest-autoresize for machine view! */
+    machineWindowWrapper()->machineView()->setGuestAutoresizeEnabled(bEnabled);
 }
 
@@ -887,5 +966,5 @@
 
     /* Remember the paused state. */
-    bool bWasPaused = m_machineState == KMachineState_Paused;
+    bool bWasPaused = machineState() == KMachineState_Paused;
     if (!bWasPaused)
     {
@@ -978,5 +1057,5 @@
 
     /* Close machine window: */
-    machineWindowWrapper()->machineWindow()->close();
+    machineWindowWrapper()->sltTryClose();
 }
 
@@ -1230,5 +1309,5 @@
 
     /* Save medium mounted at runtime */
-    if (wasMounted && m_bIsAutoSaveMedia)
+    if (wasMounted && !m_fIsIgnoringRutimeMediums)
     {
         machine.SaveSettings();
@@ -1440,9 +1519,4 @@
 }
 #endif
-
-void UIMachineLogic::sltMouseStateChanged(int iState)
-{
-    actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setEnabled(iState & UIMouseStateType_MouseAbsolute);
-}
 
 bool UIMachineLogic::pause(bool bOn)
@@ -1545,5 +1619,5 @@
 
         /* Save medium mounted at runtime */
-        if (isMounted && m_bIsAutoSaveMedia)
+        if (isMounted && !m_fIsIgnoringRutimeMediums)
         {
             machine.SaveSettings();
@@ -1753,5 +1827,5 @@
         mIsFullscreen = aOn;
         mVmAdjustWindowAction->setEnabled (!aOn);
-        mVmSeamlessAction->setEnabled (!aOn && m_bIsSeamlessSupported && m_bIsGraphicsSupported);
+        mVmSeamlessAction->setEnabled (!aOn && m_fIsGuestSupportsSeamless && m_fIsGuestSupportsGraphics);
     }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 26773)
@@ -55,8 +55,12 @@
     UIActionsPool* actionsPool() { return m_pActionsPool; }
     UIVisualStateType visualStateType() const { return m_visualStateType; }
-    UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowContainer; }
+    UIMachineWindow* machineWindowWrapper() { return m_pMachineWindowWrapper; }
     KMachineState machineState() const { return m_machineState; }
-    bool isPaused() const { return m_machineState == KMachineState_Paused ||
-                            m_machineState == KMachineState_TeleportingPausedVM; }
+    bool isPaused() const { return machineState() == KMachineState_Paused ||
+                                   machineState() == KMachineState_TeleportingPausedVM; }
+    bool isPreventAutoClose() const { return m_fIsPreventAutoClose; }
+
+    /* Public setters: */
+    void setPreventAutoClose(bool fIsPreventAutoClose) { m_fIsPreventAutoClose = fIsPreventAutoClose; }
 
 protected:
@@ -69,4 +73,15 @@
     virtual ~UIMachineLogic();
 
+    /* Protected getters: */
+    CSession& session();
+    bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
+
+    /* Protected setters: */
+    void setMachineWindowWrapper(UIMachineWindow *pMachineWindowWrapper) { m_pMachineWindowWrapper = pMachineWindowWrapper; }
+
+    /* Console related routines: */
+    bool pause() { return pause(true); }
+    bool unpause() { return pause(false); }
+
     /* Prepare helpers: */
     virtual void prepareConsoleConnections();
@@ -78,33 +93,24 @@
     /* Cleanup helpers: */
     virtual void saveLogicSettings();
-    //virtual void cleanupRequiredFeatures();
-    //virtual void cleanupActionConnections();
-    //virtual void cleanupActionGroups();
-    //virtual void cleanupConsoleConnections();
-
-    /* Protected getters: */
-    CSession& session();
-    bool isFirstTimeStarted() const { return m_bIsFirstTimeStarted; }
-    bool isPreventAutoClose() const { return m_bIsPreventAutoClose; }
-
-    /* Pretected setters: */
-    void setMachineState(KMachineState state) { m_machineState = state; }
-    void setPreventAutoClose(bool bIsPreventAutoClose) { m_bIsPreventAutoClose = bIsPreventAutoClose; }
-    void setOpenViewFinished(bool bIsOpenViewFinished) { m_bIsOpenViewFinished = bIsOpenViewFinished; }
-
-    /* Console related routines: */
-    bool pause() { return pause(true); }
-    bool unpause() { return pause(false); }
-
-    /* Protected variables: */
-    UIMachineWindow *m_pMachineWindowContainer;
+    virtual void cleanupRequiredFeatures() {}
+    virtual void cleanupActionConnections() {}
+    virtual void cleanupActionGroups() {}
+    virtual void cleanupConsoleConnections() {}
+
+    /* Update helpers: */
+    virtual void updateMachineState();
+    virtual void updateAdditionsState();
+    virtual void updateMouseCapability();
+
+protected slots:
+
+    /* Console callback handlers: */
+    virtual void sltMachineStateChanged(KMachineState machineState);
+    virtual void sltAdditionsStateChanged();
+    virtual void sltMouseCapabilityChanged(bool fIsSupportsAbsolute, bool fNeedsHostCursor);
+    virtual void sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
+    virtual void sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
 
 private slots:
-
-    /* Console callback handlers: */
-    void sltMachineStateChanged(KMachineState newMachineState);
-    void sltAdditionsStateChanged();
-    void sltUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
-    void sltRuntimeError(bool bIsFatal, const QString &strErrorId, const QString &strMessage);
 
     /* "Machine" menu funtionality */
@@ -140,7 +146,4 @@
 #endif
 
-    /* Machine view handlers: */
-    void sltMouseStateChanged(int iState);
-
 private:
 
@@ -157,17 +160,17 @@
     KMachineState m_machineState;
     UIVisualStateType m_visualStateType;
+    UIMachineWindow *m_pMachineWindowWrapper;
 
     QActionGroup *m_pRunningActions;
     QActionGroup *m_pRunningOrPausedActions;
 
-    bool m_bIsFirstTimeStarted : 1;
-    bool m_bIsOpenViewFinished : 1;
-    bool m_bIsGraphicsSupported : 1;
-    bool m_bIsSeamlessSupported : 1;
-    bool m_bIsAutoSaveMedia : 1;
-    bool m_bIsPreventAutoClose : 1;
-
-    /* Friend classes: */
-    friend class UIMachineWindow;
+    bool m_fIsFirstTimeStarted : 1;
+    bool m_fIsIgnoringRutimeMediums : 1;
+    bool m_fIsAdditionsActive : 1;
+    bool m_fIsGuestSupportsGraphics : 1;
+    bool m_fIsGuestSupportsSeamless : 1;
+    bool m_fIsMouseSupportsAbsolute : 1;
+    bool m_fIsHostCursorNeeded : 1;
+    bool m_fIsPreventAutoClose : 1;
 
 #ifdef VBOX_WITH_DEBUGGER_GUI
@@ -182,4 +185,7 @@
 #endif
 
+    /* Friend classes: */
+    friend class UIMachineWindow;
+
 #if 0 // TODO: Where to move that?
 # ifdef Q_WS_MAC
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 26773)
@@ -85,17 +85,17 @@
 #endif /* defined (Q_WS_MAC) */
 
-/** Menu activation event */
+/* Menu activation event */
 class ActivateMenuEvent : public QEvent
 {
 public:
 
-    ActivateMenuEvent (QAction *aData)
+    ActivateMenuEvent (QAction *pAction)
         : QEvent((QEvent::Type)VBoxDefs::ActivateMenuEventType)
-        , mAction(aData) {}
-    QAction *action() const { return mAction; }
+        , m_pAction(pAction) {}
+    QAction* action() const { return m_pAction; }
 
 private:
 
-    QAction *mAction;
+    QAction *m_pAction;
 };
 
@@ -106,5 +106,5 @@
     VBoxViewport(QWidget *pParent) : QWidget(pParent)
     {
-        /* No need for background drawing */
+        /* No need for background drawing: */
         setAttribute(Qt::WA_OpaquePaintEvent);
     }
@@ -160,4 +160,17 @@
     }
     return view;
+}
+
+int UIMachineView::keyboardState() const
+{
+    return (m_bIsKeyboardCaptured ? UIViewStateType_KeyboardCaptured : 0) |
+           (m_bIsHostkeyPressed ? UIViewStateType_HostKeyPressed : 0);
+}
+
+int UIMachineView::mouseState() const
+{
+    return (m_bIsMouseCaptured ? UIMouseStateType_MouseCaptured : 0) |
+           (m_bIsMouseAbsolute ? UIMouseStateType_MouseAbsolute : 0) |
+           (m_bIsMouseIntegrated ? 0 : UIMouseStateType_MouseAbsoluteDisabled);
 }
 
@@ -200,5 +213,4 @@
                             )
     : QAbstractScrollArea(pMachineWindow->machineWindow())
-    /* Private members: */
     , m_pMachineWindow(pMachineWindow)
     , m_console(pMachineWindow->machineLogic()->uisession()->session().GetConsole())
@@ -218,15 +230,16 @@
     , m_bIsMouseAbsolute(false)
     , m_bIsMouseIntegrated(true)
+    , m_fIsHideHostPointer(true)
     , m_bIsHostkeyPressed(false)
     , m_bIsHostkeyAlone (false)
+    , m_bIsHostkeyInCapture(false)
     , m_bIsGuestSupportsGraphics(false)
     , m_bIsMachineWindowResizeIgnored(true)
     , m_bIsFrameBufferResizeIgnored(false)
     , m_bIsGuestResizeIgnored(false)
-    , m_numLock(false)
-    , m_scrollLock(false)
-    , m_capsLock(false)
-    , m_fPassCAD (false)
-    , m_fHideHostPointer(true)
+    , m_fNumLock(false)
+    , m_fCapsLock(false)
+    , m_fScrollLock(false)
+    , m_fPassCAD(false)
 #ifdef VBOX_WITH_VIDEOHWACCEL
     , m_fAccelerate2DVideo(bAccelerate2DVideo)
@@ -239,7 +252,7 @@
     , m_darwinEventHandlerRef(NULL)
 # endif /* !QT_MAC_USE_COCOA */
-    , m_darwinKeyModifiers (0)
+    , m_darwinKeyModifiers(0)
     , m_fKeyboardGrabbed (false)
-    , mDockIconEnabled (true)
+    , mDockIconEnabled(true)
 #endif
     , m_desktopGeometryType(DesktopGeo_Invalid)
@@ -255,7 +268,6 @@
 {
 #ifdef VBOX_WITH_DEBUGGER
-    /** @todo figure out a more proper fix. */
-    /* HACK ALERT! Really ugly workaround for the resizing to 9x1 done
-     *             by DevVGA if provoked before power on. */
+    // TODO: Fix all DEBUGGER stuff!
+    /* HACK ALERT! Really ugly workaround for the resizing to 9x1 done by DevVGA if provoked before power on. */
     QSize fb(m_pFrameBuffer->width(), m_pFrameBuffer->height());
     if ((fb.width() < 16 || fb.height() < 16) && (vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled()))
@@ -305,6 +317,6 @@
         case DesktopGeo_Automatic:
             geometry = QRect(0, 0,
-                            qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
-                            qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
+                             qMax(m_desktopGeometry.width(), m_storedConsoleSize.width()),
+                             qMax(m_desktopGeometry.height(), m_storedConsoleSize.height()));
             break;
         case DesktopGeo_Any:
@@ -339,11 +351,11 @@
          * (or at least its width and height) is a constant. */
         m_desktopGeometry = QRect(0, 0, desktop.width() - frame.width() + window.width(),
-                                       desktop.height() - frame.height() + window.height());
-    }
-}
-
-void UIMachineView::setDesktopGeometry(DesktopGeo aGeo, int aWidth, int aHeight)
-{
-    switch (aGeo)
+                                        desktop.height() - frame.height() + window.height());
+    }
+}
+
+void UIMachineView::setDesktopGeometry(DesktopGeo geometry, int aWidth, int aHeight)
+{
+    switch (geometry)
     {
         case DesktopGeo_Fixed:
@@ -365,5 +377,5 @@
             break;
         default:
-            AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo));
+            AssertMsgFailed(("Invalid desktop geometry type %d\n", geometry));
             m_desktopGeometryType = DesktopGeo_Invalid;
     }
@@ -476,5 +488,5 @@
 {
     /* Prepare view frame: */
-    setFrameStyle(QFrame::NoFrame);
+    //setFrameStyle(QFrame::NoFrame);
 
     /* Pressed keys: */
@@ -573,11 +585,22 @@
 void UIMachineView::prepareConsoleConnections()
 {
+    /* UISession notifier: */
     UISession *sender = machineWindowWrapper()->machineLogic()->uisession();
+
+    /* Machine state-change updater: */
+    connect(sender, SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltMachineStateChanged(KMachineState)));
+
+    /* Guest additions state-change updater: */
+    connect(sender, SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChanged()));
+
+    /* Keyboard LEDs state-change updater: */
+    connect(sender, SIGNAL(sigKeyboardLedsChange(bool, bool, bool)), this, SLOT(sltKeyboardLedsChanged(bool, bool, bool)));
+
+    /* Mouse pointer shape state-change updater: */
     connect(sender, SIGNAL(sigMousePointerShapeChange(bool, bool, uint, uint, uint, uint, const uchar *)),
-            this, SLOT(sltMousePointerShapeChange(bool, bool, uint, uint, uint, uint, const uchar *)));
-    connect(sender, SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChange(bool, bool)));
-    connect(sender, SIGNAL(sigKeyboardLedsChange(bool, bool, bool)), this, SLOT(sltKeyboardLedsChange(bool, bool, bool)));
-    connect(sender, SIGNAL(sigStateChange(KMachineState)), this, SLOT(sltStateChange(KMachineState)));
-    connect(sender, SIGNAL(sigAdditionsStateChange()), this, SLOT(sltAdditionsStateChange()));
+            this, SLOT(sltMousePointerShapeChanged(bool, bool, uint, uint, uint, uint, const uchar *)));
+
+    /* Mouse capability state-change updater: */
+    connect(sender, SIGNAL(sigMouseCapabilityChange(bool, bool)), this, SLOT(sltMouseCapabilityChanged(bool, bool)));
 }
 
@@ -599,5 +622,5 @@
             setDesktopGeometry(DesktopGeo_Fixed, width, height);
         }
-        connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(doResizeDesktop(int)));
+        connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(sltDesktopResized()));
 
 #ifdef Q_WS_X11
@@ -614,4 +637,61 @@
             m_fPassCAD = true;
     }
+
+#if 0
+    /* Dynamical property settings: */
+    {
+        /* Get loader: */
+        UISession *loader = machineWindowWrapper()->machineLogic()->uisession();
+
+        /* Load dynamical properties: */
+        m_machineState = loader->property("MachineView/MachineState").value<KMachineState>();
+        m_uNumLockAdaptionCnt = loader->property("MachineView/NumLockAdaptionCnt").toUInt();
+        m_uCapsLockAdaptionCnt = loader->property("MachineView/CapsLockAdaptionCnt").toUInt();
+        m_bIsAutoCaptureDisabled = loader->property("MachineView/IsAutoCaptureDisabled").toBool();
+        m_bIsKeyboardCaptured = loader->property("MachineView/IsKeyboardCaptured").toBool();
+        m_bIsMouseCaptured = loader->property("MachineView/IsMouseCaptured").toBool();
+        m_bIsMouseAbsolute = loader->property("MachineView/IsMouseAbsolute").toBool();
+        m_bIsMouseIntegrated = loader->property("MachineView/IsMouseIntegrated").toBool();
+        m_fIsHideHostPointer = loader->property("MachineView/IsHideHostPointer").toBool();
+        m_bIsHostkeyInCapture = loader->property("MachineView/IsHostkeyInCapture").toBool();
+        m_bIsGuestSupportsGraphics = loader->property("MachineView/IsGuestSupportsGraphics").toBool();
+        m_fNumLock = loader->property("MachineView/IsNumLock").toBool();
+        m_fCapsLock = loader->property("MachineView/IsCapsLock").toBool();
+        m_fScrollLock = loader->property("MachineView/IsScrollLock").toBool();
+
+        /* Update related things: */
+        updateMachineState();
+        updateAdditionsState();
+        updateMousePointerShape();
+        updateMouseCapability();
+    }
+#endif
+}
+
+void UIMachineView::saveMachineViewSettings()
+{
+#if 0
+    /* Dynamical property settings: */
+    {
+        /* Get saver: */
+        UISession *saver = machineWindowWrapper()->machineLogic()->uisession();
+
+        /* Save dynamical properties: */
+        saver->setProperty("MachineView/MachineState", QVariant::fromValue(machineState()));
+        saver->setProperty("MachineView/NumLockAdaptionCnt", m_uNumLockAdaptionCnt);
+        saver->setProperty("MachineView/CapsLockAdaptionCnt", m_uCapsLockAdaptionCnt);
+        saver->setProperty("MachineView/IsAutoCaptureDisabled", m_bIsAutoCaptureDisabled);
+        saver->setProperty("MachineView/IsKeyboardCaptured", m_bIsKeyboardCaptured);
+        saver->setProperty("MachineView/IsMouseCaptured", m_bIsMouseCaptured);
+        saver->setProperty("MachineView/IsMouseAbsolute", m_bIsMouseAbsolute);
+        saver->setProperty("MachineView/IsMouseIntegrated", m_bIsMouseIntegrated);
+        saver->setProperty("MachineView/IsHideHostPointer", m_fIsHideHostPointer);
+        saver->setProperty("MachineView/IsHostkeyInCapture", m_bIsHostkeyInCapture);
+        saver->setProperty("MachineView/IsGuestSupportsGraphics", m_bIsGuestSupportsGraphics);
+        saver->setProperty("MachineView/IsNumLock", m_fNumLock);
+        saver->setProperty("MachineView/IsCapsLock", m_fCapsLock);
+        saver->setProperty("MachineView/IsScrollLock", m_fScrollLock);
+    }
+#endif
 }
 
@@ -647,5 +727,4 @@
 void UIMachineView::cleanupFrameBuffer()
 {
-    /* Cleanup: */
     if (m_pFrameBuffer)
     {
@@ -659,60 +738,7 @@
 }
 
-void UIMachineView::sltMousePointerShapeChange(bool fIsVisible, bool fHasAlpha,
-                                               uint uXHot, uint uYHot, uint uWidth, uint uHeight,
-                                               const uchar *pShapeData)
-{
-    if (m_bIsMouseAbsolute)
-    {
-        /* Do we have new shape data? */
-        if (pShapeData)
-            setPointerShape(pShapeData, fHasAlpha, uXHot, uYHot, uWidth, uHeight);
-
-        /* Should we hide/show pointer? */
-        if (fIsVisible)
-            viewport()->setCursor(m_lastCursor);
-        else
-            viewport()->setCursor(Qt::BlankCursor);
-    }
-    m_fHideHostPointer = !fIsVisible;
-}
-
-void UIMachineView::sltMouseCapabilityChange(bool bIsSupportsAbsolute, bool bNeedsHostCursor)
-{
-    if (m_bIsMouseAbsolute != bIsSupportsAbsolute)
-    {
-        m_bIsMouseAbsolute = bIsSupportsAbsolute;
-        /* Correct the mouse capture state and reset the cursor to the default shape if necessary: */
-        if (m_bIsMouseAbsolute)
-        {
-            CMouse mouse = m_console.GetMouse();
-            mouse.PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);
-            captureMouse(false, false);
-        }
-        else
-            viewport()->unsetCursor();
-        emitMouseStateChanged();
-        vboxProblem().remindAboutMouseIntegration(m_bIsMouseAbsolute);
-    }
-    if (bNeedsHostCursor)
-        setMouseIntegrationLocked(false);
-    else
-        setMouseIntegrationLocked(true);
-}
-
-void UIMachineView::sltKeyboardLedsChange(bool bNumLock, bool bCapsLock, bool bScrollLock)
-{
-    if (bNumLock != m_numLock)
-        m_uNumLockAdaptionCnt = 2;
-    if (bCapsLock != m_capsLock)
-        m_uCapsLockAdaptionCnt = 2;
-    m_numLock    = bNumLock;
-    m_capsLock   = bCapsLock;
-    m_scrollLock = bScrollLock;
-}
-
-void UIMachineView::sltStateChange(KMachineState state)
-{
-    switch (state)
+void UIMachineView::updateMachineState()
+{
+    switch (machineState())
     {
         case KMachineState_Paused:
@@ -720,5 +746,5 @@
         {
             if (mode() != VBoxDefs::TimerMode &&  m_pFrameBuffer &&
-                (state != KMachineState_TeleportingPausedVM || m_machineState != KMachineState_Teleporting))
+                (machineState() != KMachineState_TeleportingPausedVM || machineState() != KMachineState_Teleporting))
             {
                 /* Take a screen snapshot. Note that TakeScreenShot() always needs a 32bpp image: */
@@ -746,5 +772,5 @@
         case KMachineState_Running:
         {
-            if (m_machineState == KMachineState_Paused || m_machineState == KMachineState_TeleportingPausedVM)
+            if (machineState() == KMachineState_Paused || machineState() == KMachineState_TeleportingPausedVM)
             {
                 if (mode() != VBoxDefs::TimerMode && m_pFrameBuffer)
@@ -766,12 +792,10 @@
             break;
     }
-
-    m_machineState = state;
-}
-
-void UIMachineView::sltAdditionsStateChange()
-{
-    CGuest guest = console().GetGuest();
-    bool fIsGuestSupportsGraphics = guest.GetSupportsGraphics();
+}
+
+void UIMachineView::updateAdditionsState()
+{
+    /* Check if we should restrict minimum size: */
+    maybeRestrictMinimumSize();
 
 #if 0 // TODO: Do we need this?
@@ -779,13 +803,123 @@
         (machineWindowWrapper()->isTrueSeamless() || machineWindowWrapper()->isTrueFullscreen()))
         mDoResize = true;
-#endif
-    m_bIsGuestSupportsGraphics = fIsGuestSupportsGraphics;
-
-    maybeRestrictMinimumSize();
-
-#if 0 // TODO: Do we need this?
     /* This will only be acted upon if mDoResize is true: */
-    doResizeHint();
-#endif
+    sltPerformGuestResize();
+#endif
+}
+
+void UIMachineView::updateMousePointerShape()
+{
+    if (m_bIsMouseAbsolute)
+    {
+        /* Should we hide/show pointer? */
+        if (m_fIsHideHostPointer)
+            viewport()->setCursor(Qt::BlankCursor);
+        else
+            viewport()->setCursor(m_lastCursor);
+    }
+}
+
+void UIMachineView::updateMouseCapability()
+{
+    /* Correct the mouse capture state and reset the cursor to the default shape if necessary: */
+    if (m_bIsMouseAbsolute)
+    {
+        CMouse mouse = m_console.GetMouse();
+        mouse.PutMouseEventAbsolute(-1, -1, 0, 0 /* Horizontal wheel */, 0);
+        captureMouse(false, false);
+    }
+    else
+        viewport()->unsetCursor();
+
+    /* Notify user about mouse integration state: */
+    vboxProblem().remindAboutMouseIntegration(m_bIsMouseAbsolute);
+
+    /* Notify all watchers: */
+    emitMouseStateChanged();
+}
+
+void UIMachineView::sltMachineStateChanged(KMachineState state)
+{
+    /* Check if something had changed: */
+    if (m_machineState != state)
+    {
+        /* Set new data: */
+        m_machineState = state;
+
+        /* Update depending things: */
+        updateMachineState();
+    }
+}
+
+void UIMachineView::sltAdditionsStateChanged()
+{
+    /* Get new values: */
+    CGuest guest = console().GetGuest();
+    bool bIsGuestSupportsGraphics = guest.GetSupportsGraphics();
+
+    /* Check if something had changed: */
+    if (m_bIsGuestSupportsGraphics != bIsGuestSupportsGraphics)
+    {
+        /* Get new data: */
+        m_bIsGuestSupportsGraphics = bIsGuestSupportsGraphics;
+
+        /* Update depending things: */
+        updateAdditionsState();
+    }
+}
+
+void UIMachineView::sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock)
+{
+    /* Update num lock status: */
+    if (m_fNumLock != bNumLock)
+    {
+        m_fNumLock = bNumLock;
+        m_uNumLockAdaptionCnt = 2;
+    }
+
+    /* Update caps lock status: */
+    if (m_fCapsLock != bCapsLock)
+    {
+        m_fCapsLock = bCapsLock;
+        m_uCapsLockAdaptionCnt = 2;
+    }
+
+    /* Update scroll lock status: */
+    if (m_fScrollLock != bScrollLock)
+        m_fScrollLock = bScrollLock;
+}
+
+void UIMachineView::sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha,
+                                                uint uXHot, uint uYHot, uint uWidth, uint uHeight,
+                                                const uchar *pShapeData)
+{
+    /* Should we show cursor anyway? */
+    m_fIsHideHostPointer = !fIsVisible;
+
+    /* Should we cache shape data? */
+    if (pShapeData)
+        setPointerShape(pShapeData, fHasAlpha, uXHot, uYHot, uWidth, uHeight);
+
+    /* Perform cursor update: */
+    updateMousePointerShape();
+}
+
+void UIMachineView::sltMouseCapabilityChanged(bool bIsSupportsAbsolute, bool /* bNeedsHostCursor */)
+{
+    /* Check if something had changed: */
+    if (m_bIsMouseAbsolute != bIsSupportsAbsolute)
+    {
+        /* Get new data: */
+        m_bIsMouseAbsolute = bIsSupportsAbsolute;
+
+        /* Update depending things: */
+        updateMouseCapability();
+    }
+}
+
+/* If the desktop geometry is set automatically, this will update it: */
+void UIMachineView::sltDesktopResized()
+{
+    calculateDesktopGeometry();
 }
 
@@ -927,5 +1061,5 @@
             calculateDesktopGeometry();
 
-            /* Enable frame-buffer resize watching only now: */
+            /* Enable frame-buffer resize watching: */
             if (m_bIsFrameBufferResizeIgnored)
                 m_bIsFrameBufferResizeIgnored = false;
@@ -1243,5 +1377,5 @@
                 mDoResize = isGuestSupportsGraphics() || machineWindowWrapper()->isTrueFullscreen();
                 if (!m_bIsMachineWindowResizeIgnored && isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
-                    QTimer::singleShot(300, this, SLOT(doResizeHint()));
+                    QTimer::singleShot(300, this, SLOT(sltPerformGuestResize()));
                 break;
             }
@@ -1469,5 +1603,5 @@
     {
         /* Currently this is used in winLowKeyboardEvent() only: */
-        m_bHostkeyInCapture = m_bIsKeyboardCaptured;
+        m_bIsHostkeyInCapture = m_bIsKeyboardCaptured;
     }
 
@@ -1991,5 +2125,5 @@
     uint8_t what_pressed = (event.flags & 0x01) && (event.vkCode != VK_RSHIFT) ? IsExtKeyPressed : IsKeyPressed;
     if ((event.flags & 0x80) /* released */ &&
-        ((event.vkCode == m_globalSettings.hostKey() && !m_bHostkeyInCapture) ||
+        ((event.vkCode == m_globalSettings.hostKey() && !m_bIsHostkeyInCapture) ||
          (m_pressedKeys[event.scanCode] & (IsKbdCaptured | what_pressed)) == what_pressed))
         return false;
@@ -2491,5 +2625,5 @@
     XFreeModifiermap(map);
 
-    if (m_uNumLockAdaptionCnt && (m_numLock ^ !!(uMask & uKeyMaskNum)))
+    if (m_uNumLockAdaptionCnt && (m_fNumLock ^ !!(uMask & uKeyMaskNum)))
     {
         -- m_uNumLockAdaptionCnt;
@@ -2497,5 +2631,5 @@
         piCodes[(*puCount)++] = 0x45 | 0x80;
     }
-    if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(uMask & uKeyMaskCaps)))
+    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(uMask & uKeyMaskCaps)))
     {
         m_uCapsLockAdaptionCnt--;
@@ -2505,5 +2639,5 @@
          * capslock.  For simplicity, only do this if shift is not
          * already held down. */
-        if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
+        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
         {
             piCodes[(*puCount)++] = 0x2a;
@@ -2514,5 +2648,5 @@
 #elif defined(Q_WS_WIN32)
 
-    if (m_uNumLockAdaptionCnt && (m_numLock ^ !!(GetKeyState(VK_NUMLOCK))))
+    if (m_uNumLockAdaptionCnt && (m_fNumLock ^ !!(GetKeyState(VK_NUMLOCK))))
     {
         m_uNumLockAdaptionCnt--;
@@ -2520,5 +2654,5 @@
         piCodes[(*puCount)++] = 0x45 | 0x80;
     }
-    if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(GetKeyState(VK_CAPITAL))))
+    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(GetKeyState(VK_CAPITAL))))
     {
         m_uCapsLockAdaptionCnt--;
@@ -2528,5 +2662,5 @@
          * capslock.  For simplicity, only do this if shift is not
          * already held down. */
-        if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
+        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
         {
             piCodes[(*puCount)++] = 0x2a;
@@ -2538,5 +2672,5 @@
 
     /* if (m_uNumLockAdaptionCnt) ... - NumLock isn't implemented by Mac OS X so ignore it. */
-    if (m_uCapsLockAdaptionCnt && (m_capsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))
+    if (m_uCapsLockAdaptionCnt && (m_fCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))
     {
         m_uCapsLockAdaptionCnt--;
@@ -2546,5 +2680,5 @@
          * capslock.  For simplicity, only do this if shift is not
          * already held down. */
-        if (m_capsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
+        if (m_fCapsLock && !(m_pressedKeys[0x2a] & IsKeyPressed))
         {
             piCodes[(*puCount)++] = 0x2a;
@@ -2600,13 +2734,10 @@
 void UIMachineView::emitKeyboardStateChanged()
 {
-    emit keyboardStateChanged((m_bIsKeyboardCaptured ? UIViewStateType_KeyboardCaptured : 0) |
-                              (m_bIsHostkeyPressed ? UIViewStateType_HostKeyPressed : 0));
+    emit keyboardStateChanged(keyboardState());
 }
 
 void UIMachineView::emitMouseStateChanged()
 {
-    emit mouseStateChanged((m_bIsMouseCaptured ? UIMouseStateType_MouseCaptured : 0) |
-                           (m_bIsMouseAbsolute ? UIMouseStateType_MouseAbsolute : 0) |
-                           (!m_bIsMouseIntegrated ? UIMouseStateType_MouseAbsoluteDisabled : 0));
+    emit mouseStateChanged(mouseState());
 }
 
@@ -3078,10 +3209,4 @@
 }
 
-void UIMachineView::setMouseIntegrationLocked(bool bDisabled)
-{
-    machineWindowWrapper()->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setChecked(false);
-    machineWindowWrapper()->machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration)->setEnabled(bDisabled);
-}
-
 void UIMachineView::dimImage(QImage &img)
 {
@@ -3156,12 +3281,12 @@
      * the overlay stuff only. */
     if (mDockIconEnabled &&
-        (m_machineState == KMachineState_Running ||
-         m_machineState == KMachineState_Paused ||
-         m_machineState == KMachineState_Teleporting ||
-         m_machineState == KMachineState_LiveSnapshotting ||
-         m_machineState == KMachineState_Restoring ||
-         m_machineState == KMachineState_TeleportingPausedVM ||
-         m_machineState == KMachineState_TeleportingIn ||
-         m_machineState == KMachineState_Saving))
+        (machineState() == KMachineState_Running ||
+         machineState() == KMachineState_Paused ||
+         machineState() == KMachineState_Teleporting ||
+         machineState() == KMachineState_LiveSnapshotting ||
+         machineState() == KMachineState_Restoring ||
+         machineState() == KMachineState_TeleportingPausedVM ||
+         machineState() == KMachineState_TeleportingIn ||
+         machineState() == KMachineState_Saving))
         updateDockIcon();
     else
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h	(revision 26773)
@@ -64,7 +64,12 @@
     virtual void normalizeGeometry(bool bAdjustPosition = false) = 0;
 
+    /* Public getters: */
+    int keyboardState() const;
+    int mouseState() const;
+
     /* Public setters: */
     void setIgnoreGuestResize(bool bIgnore) { m_bIsGuestResizeIgnored = bIgnore; }
-    void setMouseIntegrationEnabled(bool bEnabled);
+    virtual void setGuestAutoresizeEnabled(bool bEnabled) = 0;
+    virtual void setMouseIntegrationEnabled(bool bEnabled);
     //void setMachineViewFinalized(bool fTrue = true) { m_bIsMachineWindowResizeIgnored = !fTrue; }
 
@@ -85,11 +90,7 @@
     void resizeHintDone();
 
-protected slots:
-
-    /* Initiate resize request to guest: */
-    virtual void doResizeHint(const QSize &aSize = QSize()) = 0;
-
 protected:
 
+    /* Machine view constructor/destructor: */
     UIMachineView(  UIMachineWindow *pMachineWindow
                   , VBoxDefs::RenderMode renderMode
@@ -108,4 +109,5 @@
 
     /* Protected getters: */
+    KMachineState machineState() const { return m_machineState; }
     VBoxDefs::RenderMode mode() const { return m_mode; }
     QSize sizeHint() const;
@@ -136,19 +138,34 @@
 
     /* Cleanup routines: */
-    //virtual void saveMachineViewSettings();
-    //virtual void cleanupConsoleConnections();
-    //virtual void cleanupFilters();
+    virtual void saveMachineViewSettings();
+    virtual void cleanupConsoleConnections() {}
+    virtual void cleanupFilters() {}
     virtual void cleanupCommon();
     virtual void cleanupFrameBuffer();
 
+    /* Update routines: */
+    virtual void updateMachineState();
+    virtual void updateAdditionsState();
+    virtual void updateMousePointerShape();
+    virtual void updateMouseCapability();
+
+protected slots:
+
+    /* Console callback handlers: */
+    virtual void sltMachineStateChanged(KMachineState state);
+    virtual void sltAdditionsStateChanged();
+    virtual void sltKeyboardLedsChanged(bool bNumLock, bool bCapsLock, bool bScrollLock);
+    virtual void sltMousePointerShapeChanged(bool fIsVisible, bool fHasAlpha,
+                                             uint uXHot, uint uYHot, uint uWidth, uint uHeight,
+                                             const uchar *pShapeData);
+    virtual void sltMouseCapabilityChanged(bool bIsSupportsAbsolute, bool bNeedsHostCursor);
+
+    /* Initiate resize request to guest: */
+    virtual void sltPerformGuestResize(const QSize &aSize = QSize()) = 0;
+
 private slots:
 
-    void sltMousePointerShapeChange(bool fIsVisible, bool fHasAlpha,
-                                    uint uXHot, uint uYHot, uint uWidth, uint uHeight,
-                                    const uchar *pShapeData);
-    void sltMouseCapabilityChange(bool bIsSupportsAbsolute, bool bNeedsHostCursor);
-    void sltKeyboardLedsChange(bool bNumLock, bool bCapsLock, bool bScrollLock);
-    void sltStateChange(KMachineState state);
-    void sltAdditionsStateChange();
+    /* Watch dog for desktop resizes: */
+    void sltDesktopResized();
 
 #ifdef Q_WS_MAC
@@ -213,9 +230,8 @@
     void setPointerShape(const uchar *pShapeData, bool fHasAlpha,
                          uint uXHot, uint uYHot, uint uWidth, uint uHeight);
-    void setMouseIntegrationLocked(bool fDisabled);
 
     /* Private getters: */
     bool isRunning() { return m_machineState == KMachineState_Running || m_machineState == KMachineState_Teleporting || m_machineState == KMachineState_LiveSnapshotting; }
-    bool shouldHideHostPointer() const { return m_bIsMouseCaptured || (m_bIsMouseAbsolute && m_fHideHostPointer); }
+    bool shouldHideHostPointer() const { return m_bIsMouseCaptured || (m_bIsMouseAbsolute && m_fIsHideHostPointer); }
 
     static void dimImage(QImage &img);
@@ -240,6 +256,6 @@
     uint8_t m_pressedKeysCopy[128];
 
-    long m_uNumLockAdaptionCnt;
-    long m_uCapsLockAdaptionCnt;
+    uint m_uNumLockAdaptionCnt;
+    uint m_uCapsLockAdaptionCnt;
 
     bool m_bIsAutoCaptureDisabled : 1;
@@ -248,16 +264,16 @@
     bool m_bIsMouseAbsolute : 1;
     bool m_bIsMouseIntegrated : 1;
+    bool m_fIsHideHostPointer;
     bool m_bIsHostkeyPressed : 1;
     bool m_bIsHostkeyAlone : 1;
-    bool m_bHostkeyInCapture : 1;
+    bool m_bIsHostkeyInCapture : 1;
     bool m_bIsGuestSupportsGraphics : 1;
     bool m_bIsMachineWindowResizeIgnored : 1;
     bool m_bIsFrameBufferResizeIgnored : 1;
     bool m_bIsGuestResizeIgnored : 1;
-    bool m_numLock : 1;
-    bool m_scrollLock : 1;
-    bool m_capsLock : 1;
+    bool m_fNumLock : 1;
+    bool m_fCapsLock : 1;
+    bool m_fScrollLock : 1;
     bool m_fPassCAD;
-    bool m_fHideHostPointer;
 #ifdef VBOX_WITH_VIDEOHWACCEL
     bool m_fAccelerate2DVideo;
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 26773)
@@ -32,4 +32,5 @@
 
 #include "UISession.h"
+#include "UIActionsPool.h"
 #include "UIMachineLogic.h"
 #include "UIMachineWindow.h"
@@ -66,4 +67,8 @@
 void UIMachineWindow::sltTryClose()
 {
+    /* Do not try to close if restricted: */
+    if (machineLogic()->isPreventAutoClose())
+        return;
+
     /* First close any open modal & popup widgets.
      * Use a single shot with timeout 0 to allow the widgets to cleany close and test then again.
@@ -93,4 +98,9 @@
 }
 
+CSession UIMachineWindow::session()
+{
+    return m_pMachineLogic->uisession()->session();
+}
+
 void UIMachineWindow::retranslateUi()
 {
@@ -105,62 +115,4 @@
                               .arg(RTBldCfgRevisionStr())
                               .arg(VBOX_BLEEDING_EDGE);
-#endif
-}
-
-void UIMachineWindow::updateAppearanceOf(int iElement)
-{
-    CMachine machine = session().GetMachine();
-
-    if (iElement & UIVisualElement_WindowCaption)
-    {
-        QString strSnapshotName;
-        if (machine.GetSnapshotCount() > 0)
-        {
-            CSnapshot snapshot = machine.GetCurrentSnapshot();
-            strSnapshotName = " (" + snapshot.GetName() + ")";
-        }
-        QString strMachineName = machine.GetName() + strSnapshotName;
-        if (machineLogic()->machineState() != KMachineState_Null)
-            strMachineName += " [" + vboxGlobal().toString(machineLogic()->machineState()) + "] - ";
-        strMachineName += m_strWindowTitlePrefix;
-        machineWindow()->setWindowTitle(strMachineName);
-
-        // TODO: Move that to fullscreen/seamless update routine:
-        // mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
-    }
-}
-
-void UIMachineWindow::prepareWindowIcon()
-{
-#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
-    /* The default application icon (will be changed to VM-specific icon little bit later):
-     * 1. On Win32, it's built-in to the executable;
-     * 2. On Mac OS X the icon referenced in info.plist is used. */
-    machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png"));
-#endif
-
-#ifndef Q_WS_MAC
-    /* Set the VM-specific application icon except Mac OS X: */
-    machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(session().GetMachine().GetOSTypeId()));
-#endif
-}
-
-void UIMachineWindow::prepareConsoleConnections()
-{
-    QObject::connect(machineLogic()->uisession(), SIGNAL(sigStateChange(KMachineState)),
-                     machineWindow(), SLOT(sltMachineStateChanged(KMachineState)));
-}
-
-void UIMachineWindow::loadWindowSettings()
-{
-#ifdef Q_WS_MAC
-    QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
-    /* Default to true if it is an empty value */
-    bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";
-    if (machineView())
-    {
-        machineView()->setDockIconEnabled(bIsDockIconEnabled);
-        machineView()->updateDockOverlay();
-    }
 #endif
 }
@@ -271,6 +223,5 @@
                     /* Disable auto closure because we want to have a chance to show
                      * the error dialog on save state / power off failure. */
-                    // TODO: process for multiple windows!
-                    //m_bNoAutoClose = true;
+                    machineLogic()->setPreventAutoClose(true);
 
                     CConsole console = session().GetConsole();
@@ -377,6 +328,5 @@
             }
 
-            // TODO: process for multiple windows!
-            //m_bNoAutoClose = false;
+            machineLogic()->setPreventAutoClose(false);
 
             if (machineLogic()->machineState() == KMachineState_PoweredOff ||
@@ -421,11 +371,65 @@
         /* Notify all the top-level dialogs about closing */
         // TODO: Notify about closing!
-        // emit closing();
-    }
-}
-
-CSession UIMachineWindow::session()
-{
-    return m_pMachineLogic->uisession()->session();
+        //emit closing();
+    }
+}
+
+void UIMachineWindow::prepareWindowIcon()
+{
+#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
+    /* The default application icon (will be changed to VM-specific icon little bit later):
+     * 1. On Win32, it's built-in to the executable;
+     * 2. On Mac OS X the icon referenced in info.plist is used. */
+    machineWindow()->setWindowIcon(QIcon(":/VirtualBox_48px.png"));
+#endif
+
+#ifndef Q_WS_MAC
+    /* Set the VM-specific application icon except Mac OS X: */
+    machineWindow()->setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(session().GetMachine().GetOSTypeId()));
+#endif
+}
+
+void UIMachineWindow::prepareConsoleConnections()
+{
+    /* Machine state-change updater: */
+    QObject::connect(machineLogic()->uisession(), SIGNAL(sigStateChange(KMachineState)),
+                     machineWindow(), SLOT(sltMachineStateChanged(KMachineState)));
+}
+
+void UIMachineWindow::loadWindowSettings()
+{
+#ifdef Q_WS_MAC
+    QString testStr = vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
+    /* Default to true if it is an empty value */
+    bool bIsDockIconEnabled = testStr.isEmpty() || testStr == "true";
+    if (machineView())
+    {
+        machineView()->setDockIconEnabled(bIsDockIconEnabled);
+        machineView()->updateDockOverlay();
+    }
+#endif
+}
+
+void UIMachineWindow::updateAppearanceOf(int iElement)
+{
+    CMachine machine = session().GetMachine();
+
+    if (iElement & UIVisualElement_WindowCaption)
+    {
+        QString strSnapshotName;
+        if (machine.GetSnapshotCount() > 0)
+        {
+            CSnapshot snapshot = machine.GetCurrentSnapshot();
+            strSnapshotName = " (" + snapshot.GetName() + ")";
+        }
+        QString strMachineName = machine.GetName() + strSnapshotName;
+        if (machineLogic()->machineState() != KMachineState_Null)
+            strMachineName += " [" + vboxGlobal().toString(machineLogic()->machineState()) + "] - ";
+        strMachineName += m_strWindowTitlePrefix;
+        machineWindow()->setWindowTitle(strMachineName);
+
+        // TODO: Move that to fullscreen/seamless update routine:
+        //mMiniToolBar->setDisplayText(machine.GetName() + strSnapshotName);
+    }
 }
 
@@ -435,2 +439,65 @@
 }
 
+void UIMachineWindow::sltPrepareMenuMachine()
+{
+    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Machine)->menu();
+
+    menu->clear();
+
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Seamless));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCAD));
+#ifdef Q_WS_X11
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCABS));
+#endif
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InformationDialog));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Pause));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Reset));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Shutdown));
+#ifndef Q_WS_MAC
+    menu->addSeparator();
+#endif /* Q_WS_MAC */
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Close));
+}
+
+void UIMachineWindow::sltPrepareMenuDevices()
+{
+    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Devices)->menu();
+
+    menu->clear();
+
+    /* Devices submenu */
+    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu());
+    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu());
+    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu());
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_VRDP));
+    menu->addSeparator();
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InstallGuestTools));
+}
+
+#ifdef VBOX_WITH_DEBUGGER_GUI
+void UIMachineWindow::sltPrepareMenuDebug()
+{
+    QMenu *menu = machineLogic()->actionsPool()->action(UIActionIndex_Menu_Debug)->menu();
+
+    menu->clear();
+
+    /* Debug submenu */
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Statistics));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_CommandLine));
+    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Logging));
+}
+#endif /* VBOX_WITH_DEBUGGER_GUI */
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h	(revision 26773)
@@ -54,13 +54,17 @@
 protected:
 
-    /* Common machine window constructor: */
+    /* Machine window constructor/destructor: */
     UIMachineWindow(UIMachineLogic *pMachineLogic);
     virtual ~UIMachineWindow();
+
+    /* Protected getters: */
+    CSession session();
+    const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
 
     /* Translate routine: */
     virtual void retranslateUi();
 
-    /* Update routines: */
-    virtual void updateAppearanceOf(int iElement);
+    /* Common machine window event handlers: */
+    void closeEvent(QCloseEvent *pEvent);
 
     /* Prepare helpers: */
@@ -70,17 +74,18 @@
 
     /* Cleanup helpers: */
-    //virtual void saveWindowSettings();
-    //virtual void cleanupConsoleConnections();
-    //virtual void cleanupWindowIcon();
+    virtual void saveWindowSettings() {}
+    virtual void cleanupConsoleConnections() {}
+    virtual void cleanupWindowIcon() {}
 
-    /* Common machine window event handlers: */
-    void closeEvent(QCloseEvent *pEvent);
+    /* Update routines: */
+    virtual void updateAppearanceOf(int iElement);
 
-    /* Protected getters: */
-    CSession session();
-    const QString& defaultWindowTitle() const { return m_strWindowTitlePrefix; }
-
-    /* Protected signals: */
+    /* Protected slots: */
     void sltMachineStateChanged(KMachineState machineState);
+    void sltPrepareMenuMachine();
+    void sltPrepareMenuDevices();
+#ifdef VBOX_WITH_DEBUGGER_GUI
+    void sltPrepareMenuDebug();
+#endif
 
     /* Protected variables: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp	(revision 26773)
@@ -55,18 +55,18 @@
     prepareRequiredFeatures();
 
+    /* Load common logic settings: */
+    loadLogicSettings();
+
     /* Prepare normal machine window: */
     prepareMachineWindow();
-
-    /* Load common logic settings: */
-    loadLogicSettings();
 }
 
 UIMachineLogicNormal::~UIMachineLogicNormal()
 {
+    /* Cleanup normal machine window: */
+    cleanupMachineWindow();
+
     /* Save common logic settings: */
     saveLogicSettings();
-
-    /* Cleanup normal machine window: */
-    cleanupMachineWindow();
 }
 
@@ -74,5 +74,5 @@
 {
     QMenu *menu = qobject_cast<QMenu*>(sender());
-    AssertMsg(menu, ("This slot should be called only on Network Adapters Menu show!\n"));
+    AssertMsg(menu, ("This slot should be called only on Network Adapters menu show!\n"));
     menu->clear();
     menu->addAction(actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
@@ -82,5 +82,5 @@
 {
     QMenu *menu = qobject_cast<QMenu*>(sender());
-    AssertMsg(menu, ("This slot should be called only on Shared Folders Menu show!\n"));
+    AssertMsg(menu, ("This slot should be called only on Shared Folders menu show!\n"));
     menu->clear();
     menu->addAction(actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
@@ -97,5 +97,5 @@
 void UIMachineLogicNormal::prepareActionConnections()
 {
-    /* Parent class connections: */
+    /* Base-class connections: */
     UIMachineLogic::prepareActionConnections();
 
@@ -122,8 +122,5 @@
 
     /* Create machine window: */
-    m_pMachineWindowContainer = UIMachineWindow::create(this, visualStateType());
-
-    /* Get the correct initial machineState() value */
-    setMachineState(session().GetConsole().GetState());
+    setMachineWindowWrapper(UIMachineWindow::create(this, visualStateType()));
 
     bool bIsSaved = machineState() == KMachineState_Saved;
@@ -222,14 +219,4 @@
 #endif
     }
-
-    /* Configure view connections: */
-    if (machineWindowWrapper()->machineView())
-    {
-        connect(machineWindowWrapper()->machineView(), SIGNAL(mouseStateChanged(int)),
-                this, SLOT(sltMouseStateChanged(int)));
-    }
-
-    /* Set what view opened: */
-    setOpenViewFinished(true);
 }
 
@@ -241,6 +228,6 @@
 
     /* Cleanup machine window: */
-    UIMachineWindow::destroy(m_pMachineWindowContainer);
-    m_pMachineWindowContainer = 0;
-}
-
+    UIMachineWindow::destroy(machineWindowWrapper());
+    setMachineWindowWrapper(0);
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.h	(revision 26773)
@@ -54,10 +54,8 @@
     void prepareActionConnections();
     void prepareMachineWindow();
-    //void loadLogicSettings();
 
     /* Cleanup helpers: */
-    //void saveLogicSettings();
     void cleanupMachineWindow();
-    //void cleanupActionConnections();
+    void cleanupActionConnections() {}
 
     /* Friend classes: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.cpp	(revision 26773)
@@ -73,68 +73,5 @@
 }
 
-void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */)
-{
-    /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized */
-    if (machineWindowWrapper()->machineWindow()->isMaximized())
-        return;
-
-    QWidget *pTopLevelWidget = window();
-
-    /* calculate client window offsets */
-    QRect fr = pTopLevelWidget->frameGeometry();
-    QRect r = pTopLevelWidget->geometry();
-    int dl = r.left() - fr.left();
-    int dt = r.top() - fr.top();
-    int dr = fr.right() - r.right();
-    int db = fr.bottom() - r.bottom();
-
-    /* get the best size w/o scroll bars */
-    QSize s = pTopLevelWidget->sizeHint();
-
-    /* resize the frame to fit the contents */
-    s -= pTopLevelWidget->size();
-    fr.setRight(fr.right() + s.width());
-    fr.setBottom(fr.bottom() + s.height());
-
-    if (bAdjustPosition)
-    {
-        QRegion ar;
-        QDesktopWidget *dwt = QApplication::desktop();
-        if (dwt->isVirtualDesktop())
-            /* Compose complex available region */
-            for (int i = 0; i < dwt->numScreens(); ++ i)
-                ar += dwt->availableGeometry(i);
-        else
-            /* Get just a simple available rectangle */
-            ar = dwt->availableGeometry(pTopLevelWidget->pos());
-
-        fr = VBoxGlobal::normalizeGeometry(fr, ar, mode() != VBoxDefs::SDLMode /* canResize */);
-    }
-
-#if 0
-    /* Center the frame on the desktop: */
-    fr.moveCenter(ar.center());
-#endif
-
-    /* Finally, set the frame geometry */
-    pTopLevelWidget->setGeometry(fr.left() + dl, fr.top() + dt, fr.width() - dl - dr, fr.height() - dt - db);
-}
-
-void UIMachineViewNormal::maybeRestrictMinimumSize()
-{
-    /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
-     * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
-     * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
-     * In all other modes, or when auto-resize is in force, this function does nothing. */
-    if (mode() == VBoxDefs::SDLMode)
-    {
-        if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
-            setMinimumSize(sizeHint());
-        else
-            setMinimumSize(0, 0);
-    }
-}
-
-void UIMachineViewNormal::doResizeHint(const QSize & /*toSize*/)
+void UIMachineViewNormal::sltPerformGuestResize(const QSize & /* toSize */)
 {
 #if 0 // TODO: fix that logic!
@@ -171,33 +108,16 @@
 }
 
-/* If the desktop geometry is set automatically, this will update it. */
-void UIMachineViewNormal::doResizeDesktop(int)
-{
-    calculateDesktopGeometry();
-}
-
-void UIMachineViewNormal::sltToggleGuestAutoresize(bool bOn)
-{
-    if (m_bIsGuestAutoresizeEnabled != bOn)
-    {
-        m_bIsGuestAutoresizeEnabled = bOn;
-
-        maybeRestrictMinimumSize();
-
-        if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
-            doResizeHint();
-    }
-}
-
-void UIMachineViewNormal::sltAdditionsStateChanged(const QString & /* strVersion */, bool /* bIsActive */,
-                                                   bool /* bIsSeamlessSupported */, bool bIsGraphicsSupported)
-{
+void UIMachineViewNormal::sltAdditionsStateChanged()
+{
+    /* Base-class additions state-change-handler: */
+    UIMachineView::sltAdditionsStateChanged();
+
     /* Enable/Disable guest auto-resizing depending on advanced graphics availablability: */
-    sltToggleGuestAutoresize(bIsGraphicsSupported && m_bIsGuestAutoresizeEnabled);
+    setGuestAutoresizeEnabled(isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled);
 }
 
 void UIMachineViewNormal::prepareFilters()
 {
-    /* Parent class filters: */
+    /* Prepare base-class filters: */
     UIMachineView::prepareFilters();
 
@@ -206,2 +126,78 @@
 }
 
+void UIMachineViewNormal::setGuestAutoresizeEnabled(bool fEnabled)
+{
+    if (m_bIsGuestAutoresizeEnabled != fEnabled)
+    {
+        m_bIsGuestAutoresizeEnabled = fEnabled;
+
+        maybeRestrictMinimumSize();
+
+        if (isGuestSupportsGraphics() && m_bIsGuestAutoresizeEnabled)
+            sltPerformGuestResize();
+    }
+}
+
+void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition /* = false */)
+{
+    QWidget *pTopLevelWidget = window();
+
+    /* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
+    if (pTopLevelWidget->isMaximized())
+        return;
+
+    /* Calculate client window offsets: */
+    QRect frameGeo = pTopLevelWidget->frameGeometry();
+    QRect geo = pTopLevelWidget->geometry();
+    int dl = geo.left() - frameGeo.left();
+    int dt = geo.top() - frameGeo.top();
+    int dr = frameGeo.right() - geo.right();
+    int db = frameGeo.bottom() - geo.bottom();
+
+    /* Get the best size w/o scroll bars: */
+    QSize s = pTopLevelWidget->sizeHint();
+
+    /* Resize the frame to fit the contents: */
+    s -= pTopLevelWidget->size();
+    frameGeo.setRight(frameGeo.right() + s.width());
+    frameGeo.setBottom(frameGeo.bottom() + s.height());
+
+    if (bAdjustPosition)
+    {
+        QRegion availableGeo;
+        QDesktopWidget *dwt = QApplication::desktop();
+        if (dwt->isVirtualDesktop())
+            /* Compose complex available region */
+            for (int i = 0; i < dwt->numScreens(); ++ i)
+                availableGeo += dwt->availableGeometry(i);
+        else
+            /* Get just a simple available rectangle */
+            availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());
+
+        frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, mode() != VBoxDefs::SDLMode /* canResize */);
+    }
+
+#if 0
+    /* Center the frame on the desktop: */
+    frameGeo.moveCenter(availableGeo.center());
+#endif
+
+    /* Finally, set the frame geometry */
+    pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);
+}
+
+void UIMachineViewNormal::maybeRestrictMinimumSize()
+{
+    /* Sets the minimum size restriction depending on the auto-resize feature state and the current rendering mode.
+     * Currently, the restriction is set only in SDL mode and only when the auto-resize feature is inactive.
+     * We need to do that because we cannot correctly draw in a scrolled window in SDL mode.
+     * In all other modes, or when auto-resize is in force, this function does nothing. */
+    if (mode() == VBoxDefs::SDLMode)
+    {
+        if (!isGuestSupportsGraphics() || !m_bIsGuestAutoresizeEnabled)
+            setMinimumSize(sizeHint());
+        else
+            setMinimumSize(0, 0);
+    }
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineViewNormal.h	(revision 26773)
@@ -33,4 +33,5 @@
 protected:
 
+    /* Normal machine view constructor/destructor: */
     UIMachineViewNormal(  UIMachineWindow *pMachineWindow
                         , VBoxDefs::RenderMode renderMode
@@ -41,18 +42,12 @@
     virtual ~UIMachineViewNormal();
 
-    void normalizeGeometry(bool bAdjustPosition = false);
-
-    void maybeRestrictMinimumSize();
-
 private slots:
 
-    void doResizeHint(const QSize &aSize = QSize());
+    /* Console callback handlers: */
+    void sltAdditionsStateChanged();
 
-    void doResizeDesktop(int);
+    /* Slot to perform guest resize: */
+    void sltPerformGuestResize(const QSize &aSize = QSize());
 
-    void sltToggleGuestAutoresize(bool bOn);
-
-    void sltAdditionsStateChanged(const QString &strVersion, bool bIsActive,
-                                  bool bIsSeamlessSupported, bool bIsGraphicsSupported);
 private:
 
@@ -60,6 +55,15 @@
     void prepareFilters();
 
+    /* Private setters: */
+    void setGuestAutoresizeEnabled(bool bEnabled);
+
+    /* Private helpers: */
+    void normalizeGeometry(bool bAdjustPosition = false);
+    void maybeRestrictMinimumSize();
+
+    /* Private members: */
     bool m_bIsGuestAutoresizeEnabled : 1;
 
+    /* Friend classes: */
     friend class UIMachineView;
 };
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp	(revision 26773)
@@ -68,13 +68,13 @@
     prepareConnections();
 
+    /* Load normal window settings: */
+    loadWindowSettings();
+
+    /* Retranslate normal window finally: */
+    retranslateUi();
+
     /* Prepare normal machine view: */
     prepareMachineView();
 
-    /* Load normal window settings: */
-    loadWindowSettings();
-
-    /* Retranslate normal window finally: */
-    retranslateUi();
-
     /* Update all the elements: */
     updateAppearanceOf(UIVisualElement_AllStuff);
@@ -93,9 +93,4 @@
 }
 
-void UIMachineWindowNormal::sltTryClose()
-{
-    UIMachineWindow::sltTryClose();
-}
-
 void UIMachineWindowNormal::sltMachineStateChanged(KMachineState machineState)
 {
@@ -106,8 +101,10 @@
 {
     KDeviceType type = attachment.GetType();
-    Assert(type == KDeviceType_DVD || type == KDeviceType_Floppy);
-    updateAppearanceOf(type == KDeviceType_DVD ? UIVisualElement_CDStuff :
-                       type == KDeviceType_Floppy ? UIVisualElement_FDStuff :
-                       UIVisualElement_AllStuff);
+    if (type == KDeviceType_HardDisk)
+        updateAppearanceOf(UIVisualElement_HDStuff);
+    if (type == KDeviceType_DVD)
+        updateAppearanceOf(UIVisualElement_CDStuff);
+    if (type == KDeviceType_Floppy)
+        updateAppearanceOf(UIVisualElement_FDStuff);
 }
 
@@ -134,53 +131,10 @@
 void UIMachineWindowNormal::sltPrepareMenuMachine()
 {
-    QMenu *menu = qobject_cast<QMenu*>(sender());
-    AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Machine)->menu(),
-              ("This slot should only be called on 'Machine' menu hovering!\n"));
-
-    menu->clear();
-
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Fullscreen));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Seamless));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_GuestAutoresize));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_AdjustWindow));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_MouseIntegration));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCAD));
-#ifdef Q_WS_X11
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TypeCABS));
-#endif
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_TakeSnapshot));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InformationDialog));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Pause));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Reset));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Shutdown));
-#ifndef Q_WS_MAC
-    menu->addSeparator();
-#endif /* Q_WS_MAC */
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Close));
+    UIMachineWindow::sltPrepareMenuMachine();
 }
 
 void UIMachineWindowNormal::sltPrepareMenuDevices()
 {
-    QMenu *menu = qobject_cast<QMenu*>(sender());
-    AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Devices)->menu(),
-              ("This slot should only be called on 'Devices' menu hovering!\n"));
-
-    menu->clear();
-
-    /* Devices submenu */
-    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices)->menu());
-    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_FloppyDevices)->menu());
-    menu->addMenu(machineLogic()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->menu());
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_SharedFoldersDialog));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_VRDP));
-    menu->addSeparator();
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_InstallGuestTools));
+    UIMachineWindow::sltPrepareMenuDevices();
 }
 
@@ -188,16 +142,12 @@
 void UIMachineWindowNormal::sltPrepareMenuDebug()
 {
-    QMenu *menu = qobject_cast<QMenu*>(sender());
-    AssertMsg(menu == machineLogic()->actionsPool()->action(UIActionIndex_Menu_Debug)->menu(),
-              ("This slot should only be called on 'Debug' menu hovering!\n"));
-
-    menu->clear();
-
-    /* Debug submenu */
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_Statistics));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Simple_CommandLine));
-    menu->addAction(machineLogic()->actionsPool()->action(UIActionIndex_Toggle_Logging));
-}
-#endif /* VBOX_WITH_DEBUGGER_GUI */
+    UIMachineWindow::sltPrepareMenuDebug();
+}
+#endif
+
+void UIMachineWindowNormal::sltTryClose()
+{
+    UIMachineWindow::sltTryClose();
+}
 
 void UIMachineWindowNormal::sltUpdateIndicators()
@@ -275,19 +225,4 @@
 {
     m_pNameHostkey->setText(QIHotKeyEdit::keyName(vboxGlobal().settings().hostKey()));
-}
-
-void UIMachineWindowNormal::sltUpdateMouseState(int iState)
-{
-    if ((iState & UIMouseStateType_MouseAbsoluteDisabled) &&
-        (iState & UIMouseStateType_MouseAbsolute) &&
-        !(iState & UIMouseStateType_MouseCaptured))
-    {
-        indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(4);
-    }
-    else
-    {
-        indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(
-            iState & (UIMouseStateType_MouseAbsolute | UIMouseStateType_MouseCaptured));
-    }
 }
 
@@ -322,19 +257,11 @@
     if (iElement & UIVisualElement_CDStuff)
         indicatorsPool()->indicator(UIIndicatorIndex_OpticalDisks)->updateAppearance();
-#if 0 /* TODO: Allow to setup status-bar! */
-    if (iElement & UIVisualElement_FDStuff)
-        indicatorsPool()->indicator(UIIndicatorIndex_FloppyDisks)->updateAppearance();
-#endif
-    if (    iElement & UIVisualElement_USBStuff
-        && !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
-            indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
+    if (iElement & UIVisualElement_USBStuff &&
+        !indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->isHidden())
+        indicatorsPool()->indicator(UIIndicatorIndex_USBDevices)->updateAppearance();
     if (iElement & UIVisualElement_NetworkStuff)
         indicatorsPool()->indicator(UIIndicatorIndex_NetworkAdapters)->updateAppearance();
     if (iElement & UIVisualElement_SharedFolderStuff)
         indicatorsPool()->indicator(UIIndicatorIndex_SharedFolders)->updateAppearance();
-#if 0 /* TODO: Allow to setup status-bar! */
-    if (iElement & UIVisualElement_VRDPStuff)
-        indicatorsPool()->indicator(UIIndicatorIndex_VRDP)->updateAppearance();
-#endif
     if (iElement & UIVisualElement_VirtualizationStuff)
         indicatorsPool()->indicator(UIIndicatorIndex_Virtualization)->updateAppearance();
@@ -347,6 +274,5 @@
         case QEvent::Resize:
         {
-            QResizeEvent *pResizeEvent = (QResizeEvent*)pEvent;
-
+            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
             if (!isMaximized())
             {
@@ -406,15 +332,24 @@
 void UIMachineWindowNormal::prepareConsoleConnections()
 {
-    /* Parent class connections: */
+    /* Base-class connections: */
     UIMachineWindow::prepareConsoleConnections();
-    /* Other console connections: */
+
+    /* Medium change updater: */
     connect(machineLogic()->uisession(), SIGNAL(sigMediumChange(const CMediumAttachment &)),
             this, SLOT(sltMediumChange(const CMediumAttachment &)));
+
+    /* USB controller change updater: */
     connect(machineLogic()->uisession(), SIGNAL(sigUSBControllerChange()),
             this, SLOT(sltUSBControllerChange()));
+
+    /* USB device state-change updater: */
     connect(machineLogic()->uisession(), SIGNAL(sigUSBDeviceStateChange(const CUSBDevice &, bool, const CVirtualBoxErrorInfo &)),
             this, SLOT(sltUSBDeviceStateChange()));
+
+    /* Network adapter change updater: */
     connect(machineLogic()->uisession(), SIGNAL(sigNetworkAdapterChange(const CNetworkAdapter &)),
             this, SLOT(sltNetworkAdapterChange()));
+
+    /* Shared folder change updater: */
     connect(machineLogic()->uisession(), SIGNAL(sigSharedFolderChange()),
             this, SLOT(sltSharedFolderChange()));
@@ -519,5 +454,5 @@
 void UIMachineWindowNormal::prepareConnections()
 {
-    /* Setup global settings <-> indicators connections: */
+    /* Setup global settings change updater: */
     connect(&vboxGlobal().settings(), SIGNAL(propertyChanged(const char *, const char *)),
             this, SLOT(sltProcessGlobalSettingChange(const char *, const char *)));
@@ -540,10 +475,19 @@
                                            , machineLogic()->visualStateType());
 
-    //qobject_cast<QGridLayout*>(centralWidget()->layout())->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
     setCentralWidget(m_pMachineView);
 
-    /* Setup machine view <-> indicators connections: */
-    connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
-    connect(machineView(), SIGNAL(mouseStateChanged(int)), this, SLOT(sltUpdateMouseState(int)));
+    /* Setup machine view connections: */
+    if (machineView())
+    {
+        /* Keyboard state-change updater: */
+        connect(machineView(), SIGNAL(keyboardStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Hostkey), SLOT(setState(int)));
+
+        /* Mouse state-change updater: */
+        connect(machineView(), SIGNAL(mouseStateChanged(int)), indicatorsPool()->indicator(UIIndicatorIndex_Mouse), SLOT(setState(int)));
+
+        /* Early initialize required connections: */
+        indicatorsPool()->indicator(UIIndicatorIndex_Hostkey)->setState(machineView()->keyboardState());
+        indicatorsPool()->indicator(UIIndicatorIndex_Mouse)->setState(machineView()->mouseState());
+    }
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h	(revision 26758)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.h	(revision 26773)
@@ -46,4 +46,5 @@
 protected:
 
+    /* Normal machine window constructor/destructor: */
     UIMachineWindowNormal(UIMachineLogic *pMachineLogic);
     virtual ~UIMachineWindowNormal();
@@ -51,6 +52,5 @@
 private slots:
 
-    void sltTryClose();
-
+    /* Console callback handlers: */
     void sltMachineStateChanged(KMachineState machineState);
     void sltMediumChange(const CMediumAttachment &attachment);
@@ -60,4 +60,5 @@
     void sltSharedFolderChange();
 
+    /* Runtime menus: */
     void sltPrepareMenuMachine();
     void sltPrepareMenuDevices();
@@ -66,10 +67,11 @@
 #endif
 
+    /* LED connections: */
     void sltUpdateIndicators();
     void sltShowIndicatorsContextMenu(QIStateIndicator *pIndicator, QContextMenuEvent *pEvent);
-
     void sltProcessGlobalSettingChange(const char *aPublicName, const char *aName);
 
-    void sltUpdateMouseState(int iState);
+    /* Close window reimplementation: */
+    void sltTryClose();
 
 private:
@@ -96,14 +98,14 @@
     void prepareStatusBar();
     void prepareConnections();
+    void loadWindowSettings();
     void prepareMachineView();
-    void loadWindowSettings();
 
     /* Cleanup helpers: */
+    void cleanupMachineView() {}
     void saveWindowSettings();
-    //void cleanupMachineView();
-    //void cleanupConnections();
+    void cleanupConnections() {}
     void cleanupStatusBar();
-    //void cleanupMenu();
-    void cleanupConsoleConnections();
+    void cleanupMenu() {}
+    void cleanupConsoleConnections() {}
 
     /* Indicators pool: */
