Index: trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp	(revision 51454)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp	(revision 51455)
@@ -18,4 +18,5 @@
 /* Qt includes: */
 #include <QMutex>
+#include <QDesktopWidget>
 
 /* GUI includes: */
@@ -315,4 +316,71 @@
 }
 
+QRect UIExtraDataManager::selectorWindowGeometry(QWidget *pHintWidget /* = 0 */)
+{
+    /* Load corresponding extra-data: */
+    const QStringList data = extraDataStringList(GUI_LastSelectorWindowPosition);
+
+    /* Parse loaded data: */
+    int iX = 0, iY = 0, iW = 0, iH = 0;
+    bool fOk = data.size() >= 4;
+    do
+    {
+        if (!fOk) break;
+        iX = data[0].toInt(&fOk);
+        if (!fOk) break;
+        iY = data[1].toInt(&fOk);
+        if (!fOk) break;
+        iW = data[2].toInt(&fOk);
+        if (!fOk) break;
+        iH = data[3].toInt(&fOk);
+    }
+    while (0);
+
+    /* Use geometry (loaded or default): */
+    QRect geometry = fOk ? QRect(iX, iY, iW, iH) : QRect(0, 0, 770, 550);
+
+    /* Take hint-widget into account: */
+    if (pHintWidget)
+        geometry.setSize(geometry.size().expandedTo(pHintWidget->minimumSizeHint()));
+
+    /* Get screen-geometry [of screen with point (iX, iY) if possible]: */
+    const QRect screenGeometry = fOk ? QApplication::desktop()->availableGeometry(QPoint(iX, iY)) :
+                                       QApplication::desktop()->availableGeometry();
+
+    /* Make sure resulting geometry is within current bounds: */
+    geometry = geometry.intersected(screenGeometry);
+
+    /* Move default-geometry to screen-geometry' center: */
+    if (!fOk)
+        geometry.moveCenter(screenGeometry.center());
+
+    /* Return result: */
+    return geometry;
+}
+
+bool UIExtraDataManager::isSelectorWindowShouldBeMaximized()
+{
+    /* Load corresponding extra-data: */
+    const QStringList data = extraDataStringList(GUI_LastSelectorWindowPosition);
+
+    /* Make sure 5th item has required value: */
+    return data.size() == 5 && data[4] == GUI_LastWindowState_Max;
+}
+
+void UIExtraDataManager::setSelectorWindowGeometry(const QRect &geometry, bool fMaximized)
+{
+    /* Serialize passed values: */
+    QStringList data;
+    data << QString::number(geometry.x());
+    data << QString::number(geometry.y());
+    data << QString::number(geometry.width());
+    data << QString::number(geometry.height());
+    if (fMaximized)
+        data << GUI_LastWindowState_Max;
+
+    /* Re-cache corresponding extra-data: */
+    setExtraDataStringList(GUI_LastSelectorWindowPosition, data);
+}
+
 bool UIExtraDataManager::isFirstRun(const QString &strId) const
 {
Index: trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h	(revision 51454)
+++ trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h	(revision 51455)
@@ -130,4 +130,11 @@
     /** Defines @a mode (basic/expert) for wizard of @a type. */
     void setModeForWizard(WizardType type, WizardMode mode);
+
+    /** Returns selector-window geometry using @a pHintWidget as the hint. */
+    QRect selectorWindowGeometry(QWidget *pHintWidget = 0);
+    /** Returns whether selector-window should be maximized or not. */
+    bool isSelectorWindowShouldBeMaximized();
+    /** Defines selector-window geometry to passed @a geometry which is @a fMaximized. */
+    void setSelectorWindowGeometry(const QRect &geometry, bool fMaximized);
 
     /** Returns render-mode for machine with passed @a strId. */
Index: trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp	(revision 51454)
+++ trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp	(revision 51455)
@@ -23,5 +23,4 @@
 
 /* Qt includes: */
-#include <QDesktopWidget>
 #include <QDesktopServices>
 #include <QMenuBar>
@@ -1526,51 +1525,18 @@
     /* Restore window position: */
     {
-        /* Loading geometry: */
-        QString strWinPos = vbox.GetExtraData(GUI_LastSelectorWindowPosition);
-        LogRelFlow(("UISelectorWindow: Loading geometry settings: {%s}\n", strWinPos.toAscii().constData()));
-
-        bool ok = false, max = false;
-        int x = 0, y = 0, w = 0, h = 0;
-        x = strWinPos.section(',', 0, 0).toInt(&ok);
-        if (ok)
-            y = strWinPos.section(',', 1, 1).toInt(&ok);
-        if (ok)
-            w = strWinPos.section(',', 2, 2).toInt(&ok);
-        if (ok)
-            h = strWinPos.section(',', 3, 3).toInt(&ok);
-        if (ok)
-            max = strWinPos.section(',', 4, 4) == GUI_LastWindowState_Max;
-
-        QRect ar = ok ? QApplication::desktop()->availableGeometry(QPoint(x, y)) :
-                        QApplication::desktop()->availableGeometry(this);
-
-        if (ok /* previous parameters were read correctly */
-            && (y > 0) && (y < ar.bottom()) /* check vertical bounds */
-            && (x + w > ar.left()) && (x < ar.right()) /* & horizontal bounds */)
-        {
-            /* Apply loaded geometry: */
-            m_normalGeo.moveTo(x, y);
-            m_normalGeo.setSize(QSize(w, h).expandedTo(minimumSizeHint()).boundedTo(ar.size()));
+        /* Load geometry: */
+        m_normalGeo = gEDataManager->selectorWindowGeometry(this);
 #ifdef Q_WS_MAC
-            move(m_normalGeo.topLeft());
-            resize(m_normalGeo.size());
+        move(m_normalGeo.topLeft());
+        resize(m_normalGeo.size());
 #else /* Q_WS_MAC */
-            setGeometry(m_normalGeo);
+        setGeometry(m_normalGeo);
 #endif /* !Q_WS_MAC */
-            LogRelFlow(("UISelectorWindow: Geometry set to: %dx%d @ %dx%d.\n",
-                        m_normalGeo.x(), m_normalGeo.y(), m_normalGeo.width(), m_normalGeo.height()));
-            if (max) /* maximize if needed */
-                showMaximized();
-        }
-        else
-        {
-            /* Apply default geometry: */
-            m_normalGeo.setSize(QSize(770, 550).expandedTo(minimumSizeHint()).boundedTo(ar.size()));
-            m_normalGeo.moveCenter(ar.center());
-            setGeometry(m_normalGeo);
-            LogRelFlow(("UISelectorWindow: Geometry set to default because something was wrong: "
-                        "(loaded correctly = '%s', x = %d, y = %d, w = %d, h = %d)!\n",
-                        ok ? "true" : "false", x, y, w, h));
-        }
+        LogRel(("UISelectorWindow: Geometry loaded to: %dx%d @ %dx%d.\n",
+                m_normalGeo.x(), m_normalGeo.y(), m_normalGeo.width(), m_normalGeo.height()));
+
+        /* Maximize (if necessary): */
+        if (gEDataManager->isSelectorWindowShouldBeMaximized())
+            showMaximized();
     }
 
@@ -1609,16 +1575,11 @@
     /* Save window position: */
     {
-        QRect save(m_normalGeo);
-        LogRelFlow(("UISelectorWindow: Saving geometry as %dx%d @ %dx%d.\n",
-                    save.x(), save.y(), save.width(), save.height()));
-        QString strWinPos = QString("%1,%2,%3,%4").arg(save.x()).arg(save.y()).arg(save.width()).arg(save.height());
 #ifdef Q_WS_MAC
-        if (::darwinIsWindowMaximized(this))
+        gEDataManager->setSelectorWindowGeometry(m_normalGeo, ::darwinIsWindowMaximized(this));
 #else /* Q_WS_MAC */
-        if (isMaximized())
+        gEDataManager->setSelectorWindowGeometry(m_normalGeo, isMaximized());
 #endif /* !Q_WS_MAC */
-            strWinPos += QString(",%1").arg(GUI_LastWindowState_Max);
-
-        vbox.SetExtraData(GUI_LastSelectorWindowPosition, strWinPos);
+        LogRel(("UISelectorWindow: Geometry saved as: %dx%d @ %dx%d.\n",
+                m_normalGeo.x(), m_normalGeo.y(), m_normalGeo.width(), m_normalGeo.height()));
     }
 }
