Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.h	(revision 50490)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.h	(revision 50491)
@@ -18,7 +18,17 @@
 #define ___darwin_VBoxCocoaApplication_h
 
+/* Qt includes: */
+#include <QMap>
+
+/* GUI includes: */
 #include "VBoxCocoaHelper.h"
+
 ADD_COCOA_NATIVE_REF(UICocoaApplicationPrivate);
 ADD_COCOA_NATIVE_REF(NSAutoreleasePool);
+ADD_COCOA_NATIVE_REF(NSString);
+ADD_COCOA_NATIVE_REF(NSWindow);
+
+/* Forward declarations: */
+class QWidget;
 
 /** Event handler callback.
@@ -29,4 +39,7 @@
  */
 typedef bool (*PFNVBOXCACALLBACK)(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
+
+/** Native notification callback type for QWidget. */
+typedef void (*PfnNativeNotificationCallbackForQWidget)(const QString &strNativeNotificationName, QWidget *pWidget);
 
 /* C++ singleton for our private NSApplication object */
@@ -41,4 +54,11 @@
     void unregisterForNativeEvents(uint32_t fMask, PFNVBOXCACALLBACK pfnCallback, void *pvUser);
 
+    /** Register passed @a pWidget to native notification @a strNativeNotificationName, using @a pCallback as handler. */
+    void registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback);
+    /** Unregister passed @a pWidget from native notification @a strNativeNotificationName. */
+    void unregisterFromNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget);
+    /** Redirects native notification @a pstrNativeNotificationName for window @a pWindow to registered listener. */
+    void nativeNotificationProxy(NativeNSStringRef pstrNativeNotificationName, NativeNSWindowRef pWindow);
+
 private:
     UICocoaApplication();
@@ -46,4 +66,7 @@
     NativeUICocoaApplicationPrivateRef m_pNative;
     NativeNSAutoreleasePoolRef m_pPool;
+
+    /** Map of notification callbacks registered for corresponding QWidget(s). */
+    QMap<QWidget*, QMap<QString, PfnNativeNotificationCallbackForQWidget> > m_callbacks;
 };
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm	(revision 50490)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaApplication.mm	(revision 50491)
@@ -16,5 +16,5 @@
  */
 
-/* Local includes */
+/* GUI includes: */
 #include "UICocoaApplication.h"
 #include "VBoxUtils-darwin.h"
@@ -68,4 +68,8 @@
 - (void)setCallback:(uint32_t)fMask :(PFNVBOXCACALLBACK)pfnCallback :(void *)pvUser;
 - (void)unsetCallback:(uint32_t)fMask :(PFNVBOXCACALLBACK)pfnCallback :(void *)pvUser;
+
+- (void)registerToNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow;
+- (void)unregisterFromNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow;
+- (void)notificationCallback :(NSNotification*)notification;
 @end /* @interface UICocoaApplicationPrivate */
 
@@ -160,4 +164,43 @@
     m_fMask = fNewMask;
 }
+
+/** Register @a pWindow to cocoa notification @a pstrNotificationName. */
+- (void) registerToNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow
+{
+    /* Register notification observer: */
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(notificationCallback:)
+                                                 name:pstrNotificationName
+                                               object:pWindow];
+}
+
+/** Unregister @a pWindow from cocoa notification @a pstrNotificationName. */
+- (void) unregisterFromNotification :(NSString*)pstrNotificationName :(NSWindow*)pWindow
+{
+    /* Uninstall notification observer: */
+    [[NSNotificationCenter defaultCenter] removeObserver:self
+                                                    name:pstrNotificationName
+                                                  object:pWindow];
+}
+
+/** Redirects cocoa @a notification to UICocoaApplication instance. */
+- (void) notificationCallback :(NSNotification*)notification
+{
+    /* Get current notification name: */
+    NSString *pstrName = [notification name];
+
+    /* Define known notification names: */
+    NSString *spstrWillEnterFullscreenNotification = @"NSWindowWillEnterFullScreenNotification";
+    NSString *spstrDidEnterFullscreenNotification  = @"NSWindowDidEnterFullScreenNotification";
+    NSString *spstrWillExitFullscreenNotification  = @"NSWindowWillExitFullScreenNotification";
+    NSString *spstrDidExitFullscreenNotification   = @"NSWindowDidExitFullScreenNotification";
+
+    /* Redirect known notifications to UICocoaApplication instance: */
+    if (   [pstrName isEqualToString :spstrWillEnterFullscreenNotification]
+        || [pstrName isEqualToString :spstrDidEnterFullscreenNotification]
+        || [pstrName isEqualToString :spstrWillExitFullscreenNotification]
+        || [pstrName isEqualToString :spstrDidExitFullscreenNotification])
+        UICocoaApplication::instance()->nativeNotificationProxy(pstrName, [notification object]);
+}
 @end /* @implementation UICocoaApplicationPrivate */
 
@@ -206,2 +249,51 @@
 }
 
+void UICocoaApplication::registerToNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget, PfnNativeNotificationCallbackForQWidget pCallback)
+{
+    /* Make sure it is not registered yet: */
+    AssertReturnVoid(!m_callbacks.contains(pWidget) || !m_callbacks[pWidget].contains(strNativeNotificationName));
+
+    /* Remember callback: */
+    m_callbacks[pWidget][strNativeNotificationName] = pCallback;
+
+    /* Register observer: */
+    NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
+    NativeNSWindowRef pWindow = darwinToNativeWindow(pWidget);
+    [m_pNative registerToNotification :pstrNativeNotificationName :pWindow];
+}
+
+void UICocoaApplication::unregisterFromNativeNotification(const QString &strNativeNotificationName, QWidget *pWidget)
+{
+    /* Make sure it is registered yet: */
+    AssertReturnVoid(m_callbacks.contains(pWidget) && m_callbacks[pWidget].contains(strNativeNotificationName));
+
+    /* Forget callback: */
+    m_callbacks[pWidget].remove(strNativeNotificationName);
+    if (m_callbacks[pWidget].isEmpty())
+        m_callbacks.remove(pWidget);
+
+    /* Unregister observer: */
+    NativeNSStringRef pstrNativeNotificationName = darwinToNativeString(strNativeNotificationName.toLatin1().constData());
+    NativeNSWindowRef pWindow = darwinToNativeWindow(pWidget);
+    [m_pNative unregisterFromNotification :pstrNativeNotificationName :pWindow];
+}
+
+void UICocoaApplication::nativeNotificationProxy(NativeNSStringRef pstrNotificationName, NativeNSWindowRef pWindow)
+{
+    /* Get notification name: */
+    QString strNotificationName = darwinFromNativeString(pstrNotificationName);
+
+    /* Check if existing widget(s) have corresponding notification handler: */
+    const QList<QWidget*> &keys1 = m_callbacks.keys();
+    for (int i = 0; i < keys1.size(); ++i)
+    {
+        QWidget *pWidget = keys1[i];
+        if (darwinToNativeWindow(pWidget) == pWindow)
+        {
+            const QMap<QString, PfnNativeNotificationCallbackForQWidget> &callbacks = m_callbacks[pWidget];
+            if (callbacks.contains(strNotificationName))
+                callbacks[strNotificationName](strNotificationName, pWidget);
+        }
+    }
+}
+
