Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/UICocoaDockIconPreview.mm
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/UICocoaDockIconPreview.mm	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/UICocoaDockIconPreview.mm	(revision 28279)
@@ -58,4 +58,5 @@
 }
 - (id)initWithParent:(UICocoaDockIconPreviewPrivate*)parent;
+- (void)destroy;
 - (NSView*)screenContent;
 - (void)cleanup;
@@ -82,4 +83,6 @@
     inline ~UICocoaDockIconPreviewPrivate()
     {
+
+        [mUIDockTile destroy];
         [mUIDockTile release];
     }
@@ -246,4 +249,16 @@
 }
 
+- (void)destroy
+{
+    /* Remove all content from the application dock tile. */
+    [mOverlay removeFromSuperview];
+    [mOverlay release];
+    mOverlay = nil;
+    NSDockTile *dock = [[NSApplication sharedApplication] dockTile];
+    [dock setContentView: nil];
+    /* Cleanup all other resources */
+    [self cleanup];
+}
+
 - (NSView*)screenContent
 {
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp	(revision 28279)
@@ -314,4 +314,15 @@
                 CGImageRelease(image);
             }
+}
+
+void UIMachineLogic::updateDockIconSize(int screenId, int width, int height)
+{
+    if (!isMachineWindowsCreated())
+        return;
+
+    if (   m_fIsDockIconEnabled
+        && m_pDockIconPreview
+        && m_DockIconPreviewMonitor == screenId)
+        m_pDockIconPreview->setOriginalSize(width, height);
 }
 #endif /* Q_WS_MAC */
@@ -344,9 +355,4 @@
     //dbgDestroy();
 #endif
-
-#ifdef Q_WS_MAC
-    if (m_pDockIconPreview)
-        delete m_pDockIconPreview;
-#endif /* Q_WS_MAC */
 }
 
@@ -608,4 +614,23 @@
 }
 
+void UIMachineLogic::cleanupMachineWindows()
+{
+#ifdef Q_WS_MAC
+    /* We need to clean up the dock stuff before the machine windows. */
+    cleanupDock();
+#endif /* Q_WS_MAC */
+}
+
+#ifdef Q_WS_MAC
+void UIMachineLogic::cleanupDock()
+{
+    if (m_pDockIconPreview)
+    {
+        delete m_pDockIconPreview;
+        m_pDockIconPreview = 0;
+    }
+}
+#endif /* Q_WS_MAC */
+
 void UIMachineLogic::sltMachineStateChanged()
 {
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h	(revision 28279)
@@ -80,4 +80,5 @@
 #ifdef Q_WS_MAC
     void updateDockIcon();
+    void updateDockIconSize(int screenId, int width, int height);
 #endif /* Q_WS_MAC */
 
@@ -120,6 +121,7 @@
     /* Cleanup helpers: */
     //virtual void cleanupRequiredFeatures() {}
-#ifdef Q_WS_MAC
-    //virtual void cleanupDock() {}
+    virtual void cleanupMachineWindows();
+#ifdef Q_WS_MAC
+    virtual void cleanupDock();
 #endif /* Q_WS_MAC */
     //virtual void cleanupActionGroups() {}
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp	(revision 28279)
@@ -828,6 +828,5 @@
 
 #ifdef Q_WS_MAC
-            // TODO_NEW_CORE
-//            mDockIconPreview->setOriginalSize(pResizeEvent->width(), pResizeEvent->height());
+            machineLogic()->updateDockIconSize(screenId(), pResizeEvent->width(), pResizeEvent->height());
 #endif /* Q_WS_MAC */
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 28279)
@@ -210,4 +210,7 @@
     if (!isMachineWindowsCreated())
         return;
+
+    /* Base class cleanup: */
+    UIMachineLogic::cleanupMachineWindows();
 
     /* Cleanup normal machine window: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp	(revision 28279)
@@ -133,4 +133,7 @@
         return;
 
+    /* Base class cleanup: */
+    UIMachineLogic::cleanupMachineWindows();
+
 #ifdef Q_WS_MAC // TODO: Is that really need here?
     /* We have to make sure that we are getting the front most process.
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp	(revision 28279)
@@ -199,4 +199,7 @@
         return;
 
+    /* Base class cleanup: */
+    UIMachineLogic::cleanupMachineWindows();
+
     /* Cleanup normal machine window: */
     foreach (UIMachineWindow *pMachineWindow, machineWindows())
Index: trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsDisplay.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsDisplay.cpp	(revision 28278)
+++ trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsDisplay.cpp	(revision 28279)
@@ -304,18 +304,8 @@
 {
     int cVal = mSlMonitors->value();
-    if (cVal > 1)
-    {
-#ifdef Q_WS_MAC
-        mCb3D->setChecked(false);
-#endif
-    }
 #ifdef VBOX_WITH_VIDEOHWACCEL
     mCb2DVideo->setEnabled(VBoxGlobal::isAcceleration2DVideoAvailable());
 #endif /* VBOX_WITH_VIDEOHWACCEL */
-#ifdef Q_WS_MAC
-    mCb3D->setEnabled(cVal == 1 && vboxGlobal().virtualBox().GetHost().GetAcceleration3DAvailable());
-#else
     mCb3D->setEnabled(vboxGlobal().virtualBox().GetHost().GetAcceleration3DAvailable());
-#endif
 
     /* The memory requirements have changed too. */
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 28279)
@@ -347,5 +347,5 @@
     {
         renderspuMakeCurrent(0, 0, pCtx->id);
-    }    
+    }
 }
 
@@ -372,5 +372,5 @@
             if (pNewCtx!=pOldCtx)
             {
-                renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->id:0, 0, 
+                renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->id:0, 0,
                                      pOldCtx ? pOldCtx->id:0);
             }
@@ -1054,7 +1054,5 @@
     }
 
-#if defined(WINDOWS) || defined(GLX)
     renderspu_SystemReparentWindow(pWindow);
-#endif
 }
 
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 28279)
@@ -311,11 +311,8 @@
 
 extern GLint RENDER_APIENTRY renderspuWindowCreate( const char *dpyName, GLint visBits );
+extern void RENDER_APIENTRY renderspu_SystemReparentWindow(WindowInfo *window);
 extern GLint RENDER_APIENTRY renderspuCreateContext( const char *dpyname, GLint visBits, GLint shareCtx );
 extern void RENDER_APIENTRY renderspuMakeCurrent(GLint crWindow, GLint nativeWindow, GLint ctx);
 extern void RENDER_APIENTRY renderspuSwapBuffers( GLint window, GLint flags );
-
-#if defined(WINDOWS) || defined(GLX)
-extern void renderspu_SystemReparentWindow(WindowInfo *window);
-#endif
 
 #ifdef __cplusplus
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c	(revision 28279)
@@ -428,4 +428,9 @@
 }
 
+void renderspu_SystemReparentWindow(WindowInfo *)
+{
+    /* stub only */
+}
+
 void
 renderspu_SystemDestroyWindow(WindowInfo *window)
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa.c	(revision 28279)
@@ -96,15 +96,6 @@
 }
 
-void renderspu_SystemDestroyWindow(WindowInfo *pWinInfo)
-{
-    CRASSERT(pWinInfo);
-
-    cocoaViewDestroy(pWinInfo->window);
-}
-
-void renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
-{
-    CRASSERT(pWinInfo);
-
+void renderspu_SystemReparentWindow(WindowInfo *pWinInfo)
+{
 #ifdef __LP64__
     NativeViewRef pParentWin = (NativeViewRef)render_spu_parent_window_id;
@@ -112,4 +103,23 @@
     NativeViewRef pParentWin = (NativeViewRef)(uint32_t)render_spu_parent_window_id;
 #endif /* __LP64__ */
+    cocoaViewReparent(pWinInfo->window, pParentWin);
+}
+
+void renderspu_SystemDestroyWindow(WindowInfo *pWinInfo)
+{
+    CRASSERT(pWinInfo);
+
+    cocoaViewDestroy(pWinInfo->window);
+}
+
+void renderspu_SystemWindowPosition(WindowInfo *pWinInfo, GLint x, GLint y)
+{
+    CRASSERT(pWinInfo);
+
+#ifdef __LP64__
+    NativeViewRef pParentWin = (NativeViewRef)render_spu_parent_window_id;
+#else /* __LP64__ */
+    NativeViewRef pParentWin = (NativeViewRef)(uint32_t)render_spu_parent_window_id;
+#endif /* __LP64__ */
 
     cocoaViewSetPosition(pWinInfo->window, pParentWin, x, y);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.h	(revision 28279)
@@ -43,4 +43,5 @@
 /* View management */
 void cocoaViewCreate(NativeViewRef *ppView, NativeViewRef pParentView, GLbitfield fVisParams);
+void cocoaViewReparent(NativeViewRef pView, NativeViewRef pParentView);
 void cocoaViewDestroy(NativeViewRef pView);
 void cocoaViewDisplay(NativeViewRef pView);
Index: trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
===================================================================
--- trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 28278)
+++ trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m	(revision 28279)
@@ -138,4 +138,5 @@
 @private
     NSView          *m_pParentView;
+    NSWindow        *m_pOverlayWin;
 
     NSOpenGLContext *m_pGLCtx;
@@ -172,4 +173,9 @@
 - (void)setGLCtx:(NSOpenGLContext*)pCtx;
 - (NSOpenGLContext*)glCtx;
+
+- (void)setParentView: (NSView*)view;
+- (NSView*)parentView;
+- (void)setOverlayWin: (NSWindow*)win;
+- (NSWindow*)overlayWin;
 
 - (void)setPos:(NSPoint)pos;
@@ -299,17 +305,21 @@
     [self cleanup];
 
-    /* Create a buffer for our thumbnail image. Its in the size of this view. */
-    m_ThumbBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-        pixelsWide:frame.size.width
-        pixelsHigh:frame.size.height
-        bitsPerSample:8
-        samplesPerPixel:4
-        hasAlpha:YES
-        isPlanar:NO
-        colorSpaceName:NSDeviceRGBColorSpace
-        bytesPerRow:frame.size.width * 4
-        bitsPerPixel:8 * 4];
-    m_ThumbImage = [[NSImage alloc] initWithSize:[m_ThumbBitmap size]];
-    [m_ThumbImage addRepresentation:m_ThumbBitmap];
+    if (   frame.size.width > 0
+        && frame.size.height > 0)
+    {
+        /* Create a buffer for our thumbnail image. Its in the size of this view. */
+        m_ThumbBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
+            pixelsWide:frame.size.width
+            pixelsHigh:frame.size.height
+            bitsPerSample:8
+            samplesPerPixel:4
+            hasAlpha:YES
+            isPlanar:NO
+            colorSpaceName:NSDeviceRGBColorSpace
+            bytesPerRow:frame.size.width * 4
+            bitsPerPixel:8 * 4];
+        m_ThumbImage = [[NSImage alloc] initWithSize:[m_ThumbBitmap size]];
+        [m_ThumbImage addRepresentation:m_ThumbBitmap];
+    }
     [self unlock];
 }
@@ -447,4 +457,6 @@
         m_pOverlayView = pOverlayView;
         m_Thread = [NSThread currentThread];
+
+        [m_pOverlayView setOverlayWin: self];
 
         m_pOverlayHelperView = [[OverlayHelperView alloc] initWithOverlayWindow:self];
@@ -606,4 +618,24 @@
 }
 
+- (NSView*)parentView
+{
+    return m_pParentView;
+}
+
+- (void)setParentView: (NSView*)view
+{
+    m_pParentView = view;
+}
+
+- (void)setOverlayWin: (NSWindow*)win
+{
+    m_pOverlayWin = win;
+}
+
+- (NSWindow*)overlayWin
+{
+    return m_pOverlayWin;
+}
+
 - (void)setPos:(NSPoint)pos
 {
@@ -1026,5 +1058,5 @@
                 [m_DockTileView thumbBitmap] != nil)
             {
-                /* Only update after atleast 200 ms, cause glReadPixels is
+                /* Only update after at least 200 ms, cause glReadPixels is
                  * heavy performance wise. */
                 uint64_t uiNewTime = RTTimeMilliTS();
@@ -1306,4 +1338,23 @@
 }
 
+void cocoaViewReparent(NativeViewRef pView, NativeViewRef pParentView)
+{
+    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
+
+    OverlayView* pOView = (OverlayView*)pView;
+
+    if (pOView)
+    {
+        /* Make sure the window is removed from any previous parent window. */
+        [[[pOView overlayWin] parentWindow] removeChildWindow:[pOView overlayWin]];
+        /* Set the new parent view */
+        [pOView setParentView: pParentView];
+        /* Add the overlay window as a child to the new parent window */
+        [[pParentView window] addChildWindow:[pOView overlayWin] ordered:NSWindowAbove];
+    }
+
+    [pPool release];
+}
+
 void cocoaViewDestroy(NativeViewRef pView)
 {
