Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 50497)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp	(revision 50498)
@@ -506,5 +506,10 @@
     {
         case UIVisualStateType_Normal: return Qt::Window;
+#ifdef Q_WS_MAC
+        /* We want normal window for native fullscreen mode on ML and next: */
+        case UIVisualStateType_Fullscreen: return vboxGlobal().osRelease() > MacOSXRelease_Lion ? Qt::Window : Qt::FramelessWindowHint;
+#else /* !Q_WS_MAC */
         case UIVisualStateType_Fullscreen: return Qt::FramelessWindowHint;
+#endif /* !Q_WS_MAC */
         case UIVisualStateType_Seamless: return Qt::FramelessWindowHint;
         case UIVisualStateType_Scale: return Qt::Window;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 50497)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp	(revision 50498)
@@ -97,4 +97,96 @@
 }
 
+#ifdef RT_OS_DARWIN
+void UIMachineLogicFullscreen::sltHandleNativeFullscreenDidEnter()
+{
+    /* Make sure this method is only used for ML and next: */
+    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
+
+    /* Get sender machine-window: */
+    UIMachineWindow *pMachineWindow = qobject_cast<UIMachineWindow*>(sender());
+    AssertReturnVoid(pMachineWindow);
+
+    /* Add machine-window to corresponding set: */
+    m_fullscreenMachineWindows.insert(pMachineWindow);
+    AssertReturnVoid(m_fullscreenMachineWindows.contains(pMachineWindow));
+}
+
+void UIMachineLogicFullscreen::sltHandleNativeFullscreenDidExit()
+{
+    /* Make sure this method is only used for ML and next: */
+    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
+
+    /* Get sender machine-window: */
+    UIMachineWindow *pMachineWindow = qobject_cast<UIMachineWindow*>(sender());
+    AssertReturnVoid(pMachineWindow);
+
+    /* Remove machine-window from corresponding set: */
+    bool fResult = m_fullscreenMachineWindows.remove(pMachineWindow);
+    AssertReturnVoid(fResult && !m_fullscreenMachineWindows.contains(pMachineWindow));
+    Q_UNUSED(fResult);
+
+    /* Exit fullscreen mode if there is/are no fullscreen window(s) left: */
+    if (m_fullscreenMachineWindows.isEmpty())
+    {
+        /* Change visual-state to requested: */
+        LogRel(("UIMachineLogicFullscreen::sltHandleNativeFullscreenDidExit: "
+                "Machine-window(s) exited fullscreen, changing visual-state to requested...\n"));
+        UIVisualStateType type = uisession()->requestedVisualState();
+        if (type == UIVisualStateType_Invalid)
+            type = UIVisualStateType_Normal;
+        uisession()->setRequestedVisualState(UIVisualStateType_Invalid);
+        uisession()->changeVisualState(type);
+    }
+}
+
+void UIMachineLogicFullscreen::sltChangeVisualStateToNormal()
+{
+    /* Base-class handling for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+        UIMachineLogic::sltChangeVisualStateToNormal();
+    /* Special handling for ML and next: */
+    else
+    {
+        /* Request 'normal' (window) visual-state: */
+        uisession()->setRequestedVisualState(UIVisualStateType_Normal);
+        /* Toggle native fullscreen mode for each window: */
+        foreach (UIMachineWindow *pMachineWindow, machineWindows())
+            darwinToggleFullscreenMode(pMachineWindow);
+    }
+}
+
+void UIMachineLogicFullscreen::sltChangeVisualStateToSeamless()
+{
+    /* Base-class handling for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+        UIMachineLogic::sltChangeVisualStateToSeamless();
+    /* Special handling for ML and next: */
+    else
+    {
+        /* Request 'seamless' visual-state: */
+        uisession()->setRequestedVisualState(UIVisualStateType_Seamless);
+        /* Toggle native fullscreen mode for each window: */
+        foreach (UIMachineWindow *pMachineWindow, machineWindows())
+            darwinToggleFullscreenMode(pMachineWindow);
+    }
+}
+
+void UIMachineLogicFullscreen::sltChangeVisualStateToScale()
+{
+    /* Base-class handling for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+        UIMachineLogic::sltChangeVisualStateToScale();
+    /* Special handling for ML and next: */
+    else
+    {
+        /* Request 'scale' visual-state: */
+        uisession()->setRequestedVisualState(UIVisualStateType_Scale);
+        /* Toggle native fullscreen mode for each window: */
+        foreach (UIMachineWindow *pMachineWindow, machineWindows())
+            darwinToggleFullscreenMode(pMachineWindow);
+    }
+}
+#endif /* RT_OS_DARWIN */
+
 void UIMachineLogicFullscreen::sltMachineStateChanged()
 {
@@ -191,7 +283,8 @@
 void UIMachineLogicFullscreen::prepareOtherConnections()
 {
-    /* Presentation mode connection: */
-    connect(gEDataEvents, SIGNAL(sigPresentationModeChange(bool)),
-            this, SLOT(sltChangePresentationMode(bool)));
+    /* Make sure 'presentation mode' is updated for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+        connect(gEDataEvents, SIGNAL(sigPresentationModeChange(bool)),
+                this, SLOT(sltChangePresentationMode(bool)));
 }
 #endif /* Q_WS_MAC */
@@ -222,10 +315,25 @@
 
 #ifdef Q_WS_MAC
-    /* If the user change the screen, we have to decide again if the
-     * presentation mode should be changed. */
-    connect(m_pScreenLayout, SIGNAL(sigScreenLayoutChanged()),
-            this, SLOT(sltScreenLayoutChanged()));
-    /* Note: Presentation mode has to be set *after* the windows are created. */
-    setPresentationModeEnabled(true);
+    /* Make sure 'presentation mode' is enabled/updated for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+    {
+        connect(m_pScreenLayout, SIGNAL(sigScreenLayoutChanged()),
+                this, SLOT(sltScreenLayoutChanged()));
+        setPresentationModeEnabled(true);
+    }
+#endif /* Q_WS_MAC */
+
+#ifdef Q_WS_MAC
+    /* Keep sync for machine-logic/window(s) in ML and next: */
+    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
+    {
+        foreach (UIMachineWindow *pMachineWindow, machineWindows())
+        {
+            connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()),
+                    this, SLOT(sltHandleNativeFullscreenDidEnter()));
+            connect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidExit()),
+                    this, SLOT(sltHandleNativeFullscreenDidExit()));
+        }
+    }
 #endif /* Q_WS_MAC */
 
@@ -253,4 +361,18 @@
     setMachineWindowsCreated(false);
 
+#ifdef Q_WS_MAC
+    /* Leave sync for machine-logic/window(s) in ML and next: */
+    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
+    {
+        foreach (UIMachineWindow *pMachineWindow, machineWindows())
+        {
+            disconnect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidEnter()),
+                       this, SLOT(sltHandleNativeFullscreenDidEnter()));
+            disconnect(pMachineWindow, SIGNAL(sigNotifyAboutNativeFullscreenDidExit()),
+                       this, SLOT(sltHandleNativeFullscreenDidExit()));
+        }
+    }
+#endif/* Q_WS_MAC */
+
     /* Cleanup machine-window(s): */
     foreach (UIMachineWindow *pMachineWindow, machineWindows())
@@ -258,5 +380,7 @@
 
 #ifdef Q_WS_MAC
-    setPresentationModeEnabled(false);
+    /* Make sure 'presentation mode' is disabled for Lion and previous: */
+    if (vboxGlobal().osRelease() <= MacOSXRelease_Lion)
+        setPresentationModeEnabled(false);
 #endif/* Q_WS_MAC */
 }
@@ -298,4 +422,7 @@
 void UIMachineLogicFullscreen::setPresentationModeEnabled(bool fEnabled)
 {
+    /* Make sure this method is only used for Lion and previous: */
+    AssertReturnVoid(vboxGlobal().osRelease() <= MacOSXRelease_Lion);
+
     /* First check if we are on a screen which contains the Dock or the
      * Menubar (which hasn't to be the same), only than the
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h	(revision 50497)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.h	(revision 50498)
@@ -45,4 +45,19 @@
 private slots:
 
+#ifdef RT_OS_DARWIN
+    /** Mac OS X: Marks sender() machine-window as 'fullscreen' one. */
+    void sltHandleNativeFullscreenDidEnter();
+    /** Mac OS X: Marks sender() machine-window as 'non-fullscreen' one,
+      * changes visual-state to requested if there is/are no more fullscreen window(s). */
+    void sltHandleNativeFullscreenDidExit();
+
+    /** Mac OS X: Requests visual-state change from 'fullscreen' to 'normal' (window). */
+    void sltChangeVisualStateToNormal();
+    /** Mac OS X: Requests visual-state change from 'fullscreen' to 'seamless'. */
+    void sltChangeVisualStateToSeamless();
+    /** Mac OS X: Requests visual-state change from 'fullscreen' to 'scale'. */
+    void sltChangeVisualStateToScale();
+#endif /* RT_OS_DARWIN */
+
     /* Handler: Console callback stuff: */
     void sltMachineStateChanged();
@@ -82,4 +97,9 @@
     UIMultiScreenLayout *m_pScreenLayout;
 
+#ifdef Q_WS_MAC
+    /** Mac OS X: Contains machine-window(s) marked as 'fullscreen'. */
+    QSet<UIMachineWindow*> m_fullscreenMachineWindows;
+#endif /* Q_WS_MAC */
+
     /* Friend classes: */
     friend class UIMachineLogic;
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp	(revision 50497)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp	(revision 50498)
@@ -32,4 +32,8 @@
 #include "UIMachineDefs.h"
 #include "UIMiniToolBar.h"
+#ifdef Q_WS_MAC
+# include "VBoxUtils-darwin.h"
+# include "UICocoaApplication.h"
+#endif /* Q_WS_MAC */
 
 /* COM includes: */
@@ -42,4 +46,41 @@
 {
 }
+
+#ifdef Q_WS_MAC
+void UIMachineWindowFullscreen::handleNativeNotification(const QString &strNativeNotificationName)
+{
+    /* Make sure this method is only used for ML and next: */
+    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
+
+    /* Handle arrived notification: */
+    LogRel(("UIMachineWindowFullscreen::handleNativeNotification: Notification '%s' received.\n",
+            strNativeNotificationName.toAscii().constData()));
+    /* Handle 'NSWindowDidEnterFullScreenNotification' notification: */
+    if (strNativeNotificationName == "NSWindowDidEnterFullScreenNotification")
+    {
+        LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
+                "Native fullscreen mode entered, notifying listener...\n"));
+        emit sigNotifyAboutNativeFullscreenDidEnter();
+    }
+    /* Handle 'NSWindowDidExitFullScreenNotification' notification: */
+    else if (strNativeNotificationName == "NSWindowDidExitFullScreenNotification")
+    {
+        LogRel(("UIMachineWindowFullscreen::handleNativeNotification: "
+                "Native fullscreen mode exited, notifying listener...\n"));
+        emit sigNotifyAboutNativeFullscreenDidExit();
+    }
+}
+#endif /* Q_WS_MAC */
+
+#ifdef RT_OS_DARWIN
+void UIMachineWindowFullscreen::sltToggleNativeFullscreenMode()
+{
+    /* Make sure this method is only used for ML and next: */
+    AssertReturnVoid(vboxGlobal().osRelease() > MacOSXRelease_Lion);
+
+    /* Toggle native fullscreen mode: */
+    darwinToggleFullscreenMode(this);
+}
+#endif /* RT_OS_DARWIN */
 
 void UIMachineWindowFullscreen::sltMachineStateChanged()
@@ -88,4 +129,20 @@
     /* Prepare mini-toolbar: */
     prepareMiniToolbar();
+
+#ifdef Q_WS_MAC
+    /* Native fullscreen stuff on ML and next: */
+    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
+    {
+        /* Enable native fullscreen support: */
+        darwinEnableFullscreenSupport(this);
+        /* Register to native fullscreen notifications: */
+        UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidEnterFullScreenNotification", this,
+                                                                     UIMachineWindow::handleNativeNotification);
+        UICocoaApplication::instance()->registerToNativeNotification("NSWindowDidExitFullScreenNotification", this,
+                                                                     UIMachineWindow::handleNativeNotification);
+        /* Asynchronously toggle native fullscreen mode: */
+        QTimer::singleShot(0, this, SLOT(sltToggleNativeFullscreenMode()));
+    }
+#endif /* Q_WS_MAC */
 }
 
@@ -140,4 +197,14 @@
 void UIMachineWindowFullscreen::cleanupVisualState()
 {
+#ifdef Q_WS_MAC
+    /* Native fullscreen stuff on ML and next: */
+    if (vboxGlobal().osRelease() > MacOSXRelease_Lion)
+    {
+        /* Unregister from native fullscreen notifications: */
+        UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidEnterFullScreenNotification", this);
+        UICocoaApplication::instance()->unregisterFromNativeNotification("NSWindowDidExitFullScreenNotification", this);
+    }
+#endif /* Q_WS_MAC */
+
     /* Cleanup mini-toolbar: */
     cleanupMiniToolbar();
@@ -199,6 +266,13 @@
 #endif /* Q_WS_WIN */
 
+#ifdef Q_WS_MAC
+                /* ML and next using native stuff, so we can call for simple show(): */
+                if (vboxGlobal().osRelease() > MacOSXRelease_Lion) show();
+                /* Lion and previous still using Qt one, call for showFullScreen(): */
+                else showFullScreen();
+#else /* !Q_WS_MAC */
                 /* Show in fullscreen mode: */
                 showFullScreen();
+#endif /* !Q_WS_MAC */
 
                 /* Make sure the window is placed on valid screen again
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h	(revision 50497)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.h	(revision 50498)
@@ -31,4 +31,12 @@
     Q_OBJECT;
 
+#ifdef RT_OS_DARWIN
+signals:
+    /** Mac OS X: Notifies listener about native fullscreen entering. */
+    void sigNotifyAboutNativeFullscreenDidEnter();
+    /** Mac OS X: Notifies listener about native fullscreen exiting. */
+    void sigNotifyAboutNativeFullscreenDidExit();
+#endif /* RT_OS_DARWIN */
+
 protected:
 
@@ -36,5 +44,15 @@
     UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId);
 
+#ifdef Q_WS_MAC
+    /** Mac OS X: Handles native notifications @a strNativeNotificationName for fullscreen window. */
+    void handleNativeNotification(const QString &strNativeNotificationName);
+#endif /* Q_WS_MAC */
+
 private slots:
+
+#ifdef RT_OS_DARWIN
+    /** Mac OS X: Toggles native fullscreen mode. */
+    void sltToggleNativeFullscreenMode();
+#endif /* RT_OS_DARWIN */
 
     /* Session event-handlers: */
