Index: trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 17126)
@@ -152,5 +152,7 @@
 VirtualBox_DEFS.debug     = VBOX_CHECK_STATE # QT_FATAL_ASSERT
 VirtualBox_DEFS.darwin    = VBOX_GUI_USE_QIMAGE VBOX_WITHOUT_QHTTP
+ifndef VBOX_WITH_COCOA_QT
 VirtualBox_DEFS.darwin.x86= VBOX_GUI_USE_QUARTZ2D USE_HID_FOR_MODIFIERS
+endif
 VirtualBox_DEFS.freebsd   = VBOX_GUI_USE_QIMAGE VBOX_GUI_USE_SDL
 VirtualBox_DEFS.linux     = VBOX_GUI_USE_QIMAGE VBOX_GUI_USE_SDL
@@ -403,5 +405,9 @@
 ifdef VBOX_WITH_COCOA_QT
  VirtualBox_SOURCES.darwin += \
-	src/darwin/VBoxCocoaApplication.m
+	src/darwin/VBoxCocoaApplication.m \
+	src/darwin/VBoxUtils-darwin-cocoa.m
+else
+ VirtualBox_SOURCES.darwin += \
+	src/darwin/VBoxUtils-darwin-carbon.cpp
 endif
 
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxToolBar.h	(revision 17126)
@@ -81,5 +81,5 @@
             /** @todo Carbon -> Cocoa */
 # else  /* !QT_MAC_USE_COCOA */
-            WindowRef window = ::darwinToWindowRef (this);
+            WindowRef window = ::darwinToNativeWindow (this);
             EventHandlerUPP eventHandler = ::NewEventHandlerUPP (VBoxToolBar::macEventFilter);
             EventTypeSpec eventTypes[2];
@@ -123,5 +123,5 @@
     {
 #ifdef Q_WS_MAC
-        ::darwinSetShowToolBarButton (this, aShow);
+        ::darwinSetShowsToolbarButton (this, aShow);
 #else  /* Q_WS_MAC */
         NOREF (aShow);
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 17126)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h	(revision 17126)
@@ -0,0 +1,200 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * Declarations of utility classes and functions for handling Darwin specific
+ * tasks
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#ifndef __VBoxUtils_darwin_h
+#define __VBoxUtils_darwin_h
+
+/*
+ * Here is some really magic in. The "OS System native" methods are implemented
+ * in the current OS specific way. This means either Carbon
+ * (VBoxUtils-darwin-carbon.cpp) or Cocoa (VBoxUtils-darwin-cocoa.m). The Qt
+ * wrapper methods handle the conversion from Q* data types to the native one
+ * (VBoxUtils-darwin.cpp).
+ */
+
+#ifdef __OBJC__
+#import <AppKit/NSWindow.h>
+
+typedef NSWindow *NativeWindowRef;
+typedef NSView *NativeViewRef;
+#else
+# include <iprt/cdefs.h> /* for __BEGIN_DECLS/__END_DECLS & stuff */
+# include <qglobal.h> /* for QT_MAC_USE_COCOA */
+class QWidget;
+class QToolBar;
+class QPixmap;
+
+# ifdef QT_MAC_USE_COCOA
+/* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
+typedef void *NativeWindowRef;
+typedef void *NativeViewRef;
+# else /* QT_MAC_USE_COCOA */
+#  include <Carbon/Carbon.h>
+typedef WindowRef NativeWindowRef;
+typedef HIViewRef NativeViewRef;
+# endif /* QT_MAC_USE_COCOA */
+#endif /* __OBJC__ */
+
+__BEGIN_DECLS
+
+/********************************************************************************
+ *
+ * Window/View management (OS System native)
+ *
+ ********************************************************************************/
+NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView);
+
+/********************************************************************************
+ *
+ * Simple setter methods (OS System native)
+ *
+ ********************************************************************************/
+void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled);
+void darwinSetMouseCoalescingEnabled (bool aEnabled);
+
+__END_DECLS
+
+#ifndef __OBJC__
+/********************************************************************************
+ *
+ * Window/View management (Qt Wrapper)
+ *
+ ********************************************************************************/
+
+/**
+ * Returns a reference to the native View of the QWidget.
+ *
+ * @returns either HIViewRef or NSView* of the QWidget.
+ * @param   aWidget   Pointer to the QWidget
+ */
+NativeViewRef darwinToNativeView (QWidget *aWidget);
+
+/**
+ * Returns a reference to the native Window of the QWidget.
+ *
+ * @returns either WindowRef or NSWindow* of the QWidget.
+ * @param   aWidget   Pointer to the QWidget
+ */
+NativeWindowRef darwinToNativeWindow (QWidget *aWidget);
+
+/* This is necessary because of the C calling convention. Its a simple wrapper
+   for darwinToNativeWindowImpl to allow operator overloading which isn't
+   allowed in C. */
+/**
+ * Returns a reference to the native Window of the View..
+ *
+ * @returns either WindowRef or NSWindow* of the View.
+ * @param   aWidget   Pointer to the native View
+ */
+NativeWindowRef darwinToNativeWindow (NativeViewRef aView);
+
+/********************************************************************************
+ *
+ * Simple setter methods (Qt Wrapper)
+ *
+ ********************************************************************************/
+void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled);
+void darwinDisableIconsInMenus (void);
+
+/********************************************************************************
+ *
+ * Simple helper methods (Qt Wrapper)
+ *
+ ********************************************************************************/
+QString darwinSystemLanguage (void);
+QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
+
+
+
+
+
+/********************************************************************************
+ *
+ * Old carbon stuff. Have to be converted soon!
+ *
+ ********************************************************************************/
+
+#include <QWidget>
+class QImage;
+
+# ifndef QT_MAC_USE_COCOA
+
+/* Asserts if a != noErr and prints the error code */
+#  define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
+
+/* Converting stuff */
+CGImageRef darwinToCGImageRef (const QImage *aImage);
+CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
+CGImageRef darwinToCGImageRef (const char *aSource);
+
+/**
+ * Returns a reference to the CGContext of the QWidget.
+ *
+ * @returns CGContextRef of the QWidget.
+ * @param   aWidget      Pointer to the QWidget
+ */
+DECLINLINE(CGContextRef) darwinToCGContextRef (QWidget *aWidget)
+{
+    return static_cast<CGContext *> (aWidget->macCGHandle());
+}
+
+/**
+ * Converts a QRect to a HIRect.
+ *
+ * @returns HIRect for the converted QRect.
+ * @param   aRect  the QRect to convert
+ */
+DECLINLINE(HIRect) darwinToHIRect (const QRect &aRect)
+{
+    return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height());
+}
+
+/* Experimental region handler for the seamless mode */
+OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
+
+/* Handler for the OpenGL overlay window stuff & the possible messages. */
+enum
+{
+    /* Event classes */
+    kEventClassVBox        = 'vbox',
+    /* Event kinds */
+    kEventVBoxShowWindow   = 'swin',
+    kEventVBoxMoveWindow   = 'mwin',
+    kEventVBoxResizeWindow = 'rwin',
+    kEventVBoxUpdateDock   = 'udck'
+};
+OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
+
+bool darwinIsMenuOpen (void);
+
+void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
+# endif /* !QT_MAC_USE_COCOA */
+
+# ifdef DEBUG
+void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
+# endif
+
+#endif /* !__OBJC__ */
+
+#endif /* __VBoxUtils_darwin_h */
+
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils.h	(revision 17126)
@@ -128,117 +128,5 @@
 
 #ifdef Q_WS_MAC
-class QImage;
-class QPixmap;
-class QToolBar;
-class VBoxFrameBuffer;
-
-# ifdef QT_MAC_USE_COCOA
-/** @todo Carbon -> Cocoa */
-# else /* !QT_MAC_USE_COCOA */
-#  undef PAGE_SIZE
-#  undef PAGE_SHIFT
-#  include <Carbon/Carbon.h>
-
-/* Asserts if a != noErr and prints the error code */
-#  define AssertCarbonOSStatus(a) AssertMsg ((a) == noErr, ("Carbon OSStatus: %d\n", static_cast<int> (a)))
-
-/* Converting stuff */
-CGImageRef darwinToCGImageRef (const QImage *aImage);
-CGImageRef darwinToCGImageRef (const QPixmap *aPixmap);
-CGImageRef darwinToCGImageRef (const char *aSource);
-
-/**
- * Returns a reference to the HIView of the QWidget.
- *
- * @returns HIViewRef of the QWidget.
- * @param   aWidget   Pointer to the QWidget
- */
-DECLINLINE(HIViewRef) darwinToHIViewRef (QWidget *aWidget)
-{
-    return HIViewRef(aWidget->winId());
-}
-
-/**
- * Returns a reference to the Window of the HIView.
- *
- * @returns WindowRef of the HIView.
- * @param   aViewRef  Reference to the HIView
- */
-DECLINLINE(WindowRef) darwinToWindowRef (HIViewRef aViewRef)
-{
-    return reinterpret_cast<WindowRef> (HIViewGetWindow(aViewRef));
-}
-
-/**
- * Returns a reference to the Window of the QWidget.
- *
- * @returns WindowRef of the QWidget.
- * @param   aWidget   Pointer to the QWidget
- */
-DECLINLINE(WindowRef) darwinToWindowRef (QWidget *aWidget)
-{
-    return ::darwinToWindowRef (::darwinToHIViewRef (aWidget));
-}
-
-/**
- * Returns a reference to the CGContext of the QWidget.
- *
- * @returns CGContextRef of the QWidget.
- * @param   aWidget      Pointer to the QWidget
- */
-DECLINLINE(CGContextRef) darwinToCGContextRef (QWidget *aWidget)
-{
-    return static_cast<CGContext *> (aWidget->macCGHandle());
-}
-
-/**
- * Converts a QRect to a HIRect.
- *
- * @returns HIRect for the converted QRect.
- * @param   aRect  the QRect to convert
- */
-DECLINLINE(HIRect) darwinToHIRect (const QRect &aRect)
-{
-    return CGRectMake (aRect.x(), aRect.y(), aRect.width(), aRect.height());
-}
-#endif /* !QT_MAC_USE_COCOA */
-
-QString darwinSystemLanguage (void);
-
-bool darwinIsMenuOpen (void);
-
-void darwinSetShowToolBarButton (QToolBar *aToolBar, bool aShow);
-
-void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget);
-
-/* Proxy icon creation */
-QPixmap darwinCreateDragPixmap (const QPixmap& aPixmap, const QString &aText);
-
-/* Icons in the menu of an mac application are unusual. */
-void darwinDisableIconsInMenus (void);
-
-# ifdef DEBUG
-void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
-# endif
-
-# ifdef QT_MAC_USE_COCOA
-/** @todo Carbon -> Cocoa  */
-# else  /* !QT_MAC_USE_COCOA */
-/* Experimental region handler for the seamless mode */
-OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
-
-/* Handler for the OpenGL overlay window stuff & the possible messages. */
-enum
-{
-    /* Event classes */
-    kEventClassVBox        = 'vbox',
-    /* Event kinds */
-    kEventVBoxShowWindow   = 'swin',
-    kEventVBoxMoveWindow   = 'mwin',
-    kEventVBoxResizeWindow = 'rwin',
-    kEventVBoxUpdateDock   = 'udck'
-};
-OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
-# endif /* !QT_MAC_USE_COCOA*/
+# include "VBoxUtils-darwin.h"
 #endif /* Q_WS_MAC */
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/QIDialog.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/QIDialog.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/QIDialog.cpp	(revision 17126)
@@ -50,5 +50,5 @@
         /** @todo Carbon -> Cocoa */
 # else
-        ChangeWindowAttributes (::darwinToWindowRef (this), kWindowNoAttributes, kWindowResizableAttribute);
+        ChangeWindowAttributes (::darwinToNativeWindow (this), kWindowNoAttributes, kWindowResizableAttribute);
 # endif
 #endif /* Q_WS_MAC */
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 17126)
@@ -4091,9 +4091,5 @@
        event handler). */
     if (aOn || mKeyboardGrabbed)
-# ifdef QT_MAC_USE_COCOA
-        ::VBoxCocoaApplication_setMouseCoalescingEnabled (aOn);
-# else
-        ::SetMouseCoalescingEnabled (aOn, NULL);
-# endif
+        ::darwinSetMouseCoalescingEnabled (aOn);
 }
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp	(revision 17126)
@@ -1270,5 +1270,5 @@
 # else
                 HIRect viewRect;
-                HIViewGetBounds (::darwinToHIViewRef (this), &viewRect);
+                HIViewGetBounds (::darwinToNativeView (this), &viewRect);
                 CGContextClearRect (::darwinToCGContextRef (this), viewRect);
 # endif
@@ -2385,5 +2385,5 @@
 # else  /* !QT_MAC_USE_COCOA */
             OSStatus status;
-            WindowRef windowRef = ::darwinToWindowRef (this);
+            WindowRef windowRef = ::darwinToNativeWindow (this);
             Assert (VALID_PTR (windowRef));
             /* See above.
@@ -2432,7 +2432,7 @@
 # else  /* !QT_MAC_USE_COCOA */
         OSStatus status;
-        HIViewRef viewRef = ::darwinToHIViewRef (console->viewport());
+        HIViewRef viewRef = ::darwinToNativeView (console->viewport());
         Assert (VALID_PTR (viewRef));
-        WindowRef windowRef = ::darwinToWindowRef (viewRef);
+        WindowRef windowRef = ::darwinToNativeWindow (viewRef);
         Assert (VALID_PTR (windowRef));
         /* @todo=poetzsch: Currently this isn't necessary. I should
@@ -2518,5 +2518,5 @@
     /* setWindowState removes the window group connection somehow. So save it
      * temporary. */
-    WindowGroupRef g = GetWindowGroup (::darwinToWindowRef (this));
+    WindowGroupRef g = GetWindowGroup (::darwinToNativeWindow (this));
     if (aSeamless)
         if (aOn)
@@ -2540,5 +2540,5 @@
         setWindowState (windowState() ^ Qt::WindowFullScreen);
     /* Reassign the correct window group. */
-    SetWindowGroup (::darwinToWindowRef (this), g);
+    SetWindowGroup (::darwinToNativeWindow (this), g);
 # endif /* !QT_MAC_USE_COCOA */
 #else
@@ -3031,5 +3031,5 @@
          * an repaint only. All the magic clipping stuff is done
          * in the paint engine. */
-        HIViewReshapeStructure (::darwinToHIViewRef (console->viewport()));
+        HIViewReshapeStructure (::darwinToNativeView (console->viewport()));
 //        HIWindowInvalidateShadow (::darwinToWindowRef (console->viewport()));
 //        ReshapeCustomWindow (::darwinToWindowRef (this));
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp	(revision 17126)
@@ -164,5 +164,5 @@
     Assert (VALID_PTR (viewport));
 
-    HIViewRef viewRef = ::darwinToHIViewRef (viewport);
+    HIViewRef viewRef = ::darwinToNativeView (viewport);
     Assert (VALID_PTR (viewRef));
     /* Get the dimensions of this HIView */
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsDialog.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsDialog.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsDialog.cpp	(revision 17126)
@@ -20,5 +20,4 @@
  * additional information or have any questions.
  */
-
 #include "VBoxSettingsDialog.h"
 #include "VBoxSettingsUtils.h"
@@ -39,5 +38,4 @@
 #include <QStackedWidget>
 
-
 #if MAC_LEOPARD_STYLE
 # define VBOX_GUI_WITH_TOOLBAR_SETTINGS
@@ -56,4 +54,5 @@
     Ui::VBoxSettingsDialog::setupUi (this);
 
+//    setToolbar (new VBoxToolBar (this));
 #ifdef Q_WS_MAC
 //    VBoxGlobal::setLayoutMargin (centralWidget()->layout(), 0);
@@ -277,4 +276,5 @@
     mStack->setCurrentIndex (mStack->indexOf (rootPage));
 #else /* Q_WS_MAC */
+# ifndef QT_MAC_USE_COCOA
     QSize cs = size();
     /* First make all fully resizeable */
@@ -300,4 +300,9 @@
         setFixedSize (ss);
     }
+# else /* QT_MAC_USE_COCOA */
+    for (int i = 0; i < mStack->count(); ++i)
+        mStack->widget (i)->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
+    mStack->setCurrentIndex (mStack->indexOf (rootPage));
+# endif /* QT_MAC_USE_COCOA */
 #endif /* !Q_WS_MAC */
 # ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS
@@ -415,4 +420,5 @@
     int minWidth = mSelector->minWidth();
 #ifdef Q_WS_MAC
+# ifndef QT_MAC_USE_COCOA
     /* Set all size policies to ignored */
     for (int i = 0; i < mStack->count(); ++i)
@@ -432,4 +438,7 @@
 
     categoryChanged (mSelector->currentId());
+# else /* QT_MAC_USE_COCOA */
+    categoryChanged (mSelector->currentId());
+# endif /* QT_MAC_USE_COCOA */
 #else /* Q_WS_MAC */
     /* Resize to the minimum possible size */
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsSelector.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsSelector.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxSettingsSelector.cpp	(revision 17126)
@@ -368,4 +368,5 @@
     mTbSelector->setUsesTextLabel (true);
     mTbSelector->setIconSize (QSize (32, 32));
+    mTbSelector->setShowToolBarButton (false);
     /* Init the action group for house keeping */
     mActionGroup = new QActionGroup (this);
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m	(revision 17126)
@@ -27,4 +27,5 @@
 #include "DarwinKeyboard.h"
 #include <iprt/assert.h>
+#import <AppKit/NSWindow.h>
 #import <AppKit/NSEvent.h>
 
@@ -289,15 +290,4 @@
 
     return fCarbon;
-}
-
-
-/**
- * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
- *
- * @param   fEnabled    Whether to enable or disable coalescing.
- */
-void VBoxCocoaApplication_setMouseCoalescingEnabled(bool fEnabled)
-{
-    [NSEvent setMouseCoalescingEnabled:fEnabled];
 }
 
@@ -337,5 +327,5 @@
         EVT_CASE(NSOtherMouseUp);
         EVT_CASE(NSOtherMouseDragged);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
         EVT_CASE(NSEventTypeGesture);
         EVT_CASE(NSEventTypeMagnify);
@@ -467,5 +457,5 @@
         case NSOtherMouseUp:
         case NSOtherMouseDragged:
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
         case NSEventTypeGesture:
         case NSEventTypeMagnify:
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxDockIconPreview.cpp	(revision 17126)
@@ -252,5 +252,5 @@
 
     /* Process the content of any external OpenGL window. */
-    WindowRef w = darwinToWindowRef (mMainWnd);
+    WindowRef w = darwinToNativeWindow (mMainWnd);
     WindowGroupRef g = GetWindowGroup (w);
     WindowGroupContentOptions wgco = kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible;
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 17126)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 17126)
@@ -0,0 +1,256 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * Declarations of utility classes and functions for handling Darwin Carbon
+ * specific tasks
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#include "VBoxUtils-darwin.h"
+
+#include <iprt/assert.h>
+
+#include <Carbon/Carbon.h>
+
+NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
+{
+    return reinterpret_cast<WindowRef> (::HIViewGetWindow (aView));
+}
+
+void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
+{
+    int err = ::ChangeWindowAttributes (aWindow, aEnabled ? kWindowToolbarButtonAttribute:kWindowNoAttributes,
+                                                 aEnabled ? kWindowNoAttributes:kWindowToolbarButtonAttribute);
+    AssertCarbonOSStatus (err);
+}
+
+void darwinSetMouseCoalescingEnabled (bool aEnabled)
+{
+    ::SetMouseCoalescingEnabled (aEnabled, NULL);
+}
+
+
+
+
+
+/********************************************************************************
+ *
+ * Old carbon stuff. Have to converted soon!
+ *
+ ********************************************************************************/
+#include "VBoxConsoleView.h"
+
+/**
+ * Callback for deleting the QImage object when CGImageCreate is done
+ * with it (which is probably not until the returned CFGImageRef is released).
+ *
+ * @param   info        Pointer to the QImage.
+ */
+static void darwinDataProviderReleaseQImage (void *info, const void *, size_t)
+{
+    QImage *qimg = (QImage *)info;
+    delete qimg;
+}
+
+/**
+ * Converts a QPixmap to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aPixmap     Pointer to the QPixmap instance to convert.
+ */
+CGImageRef darwinToCGImageRef (const QImage *aImage)
+{
+    QImage *imageCopy = new QImage (*aImage);
+    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
+    if (imageCopy->format() != QImage::Format_ARGB32)
+        *imageCopy = imageCopy->convertToFormat (QImage::Format_ARGB32);
+    Assert (!imageCopy->isNull());
+
+    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
+    CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits(), aImage->numBytes(), darwinDataProviderReleaseQImage);
+
+    CGBitmapInfo bmpInfo = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
+    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
+                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
+                                   kCGRenderingIntentDefault);
+    CGColorSpaceRelease (cs);
+    CGDataProviderRelease (dp);
+
+    Assert (ir);
+    return ir;
+}
+
+/**
+ * Converts a QPixmap to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aPixmap     Pointer to the QPixmap instance to convert.
+ */
+CGImageRef darwinToCGImageRef (const QPixmap *aPixmap)
+{
+    return aPixmap->toMacCGImageRef();
+}
+
+/**
+ * Loads an image using Qt and converts it to a CGImage.
+ *
+ * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
+ * @param   aSource     The source name.
+ */
+CGImageRef darwinToCGImageRef (const char *aSource)
+{
+    QPixmap qpm (QString(":/") + aSource);
+    Assert (!qpm.isNull());
+    return ::darwinToCGImageRef (&qpm);
+}
+
+void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget)
+{
+    HIRect r = ::darwinToHIRect (aTarget);
+    TransitionWindowWithOptions (::darwinToNativeWindow (aWidget), kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &r, false, NULL);
+}
+
+bool darwinIsMenuOpen (void)
+{
+    MenuTrackingData outData;
+    return (GetMenuTrackingData (NULL, &outData) != menuNotFoundErr);
+}
+
+/* Currently not used! */
+OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
+{
+    NOREF (aInHandlerCallRef);
+
+    OSStatus status = eventNotHandledErr;
+
+    switch (GetEventKind (aInEvent))
+    {
+        case kEventWindowGetRegion:
+        {
+            WindowRegionCode code;
+            RgnHandle rgn;
+
+            /* which region code is being queried? */
+            GetEventParameter (aInEvent, kEventParamWindowRegionCode, typeWindowRegionCode, NULL, sizeof (code), NULL, &code);
+
+            /* if it is the opaque region code then set the region to Empty and return noErr to stop the propagation */
+            if (code == kWindowOpaqueRgn)
+            {
+                printf("test1\n");
+                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn);
+                SetEmptyRgn (rgn);
+                status = noErr;
+            }
+            /* if the content of the whole window is queried return a copy of our saved region. */
+            else if (code == (kWindowStructureRgn))// || kWindowGlobalPortRgn || kWindowUpdateRgn))
+            {
+                printf("test2\n");
+                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn);
+                QRegion *pRegion = static_cast <QRegion*> (aInUserData);
+                if (!pRegion->isEmpty() && pRegion)
+                {
+                    //CopyRgn (pRegion->handle(), rgn);
+                    status = noErr;
+                }
+            }
+            break;
+        }
+        case kEventControlDraw:
+        {
+            printf("test3\n");
+            CGContextRef ctx;
+            HIRect bounds;
+
+            GetEventParameter (aInEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof (ctx), NULL, &ctx);
+            HIViewGetBounds ((HIViewRef)aInUserData, &bounds);
+
+            CGContextClearRect (ctx, bounds);
+            status = noErr;
+            break;
+        }
+    }
+
+    return status;
+}
+
+OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
+{
+    if (!aInUserData)
+        return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
+
+    UInt32 eventClass = ::GetEventClass (aInEvent);
+    UInt32 eventKind = ::GetEventKind (aInEvent);
+    /* For debugging events */
+    /*
+    if (!(eventClass == 'cute'))
+        ::darwinDebugPrintEvent ("view: ", aInEvent);
+    */
+    VBoxConsoleView *view = static_cast<VBoxConsoleView *> (aInUserData);
+
+    if (eventClass == kEventClassVBox)
+    {
+        if (eventKind == kEventVBoxShowWindow)
+        {
+//            printf ("ShowWindow requested\n");
+            WindowRef w;
+            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
+                return noErr;
+            ShowWindow (w);
+            SelectWindow (w);
+            return noErr;
+        }
+        if (eventKind == kEventVBoxMoveWindow)
+        {
+//            printf ("MoveWindow requested\n");
+            WindowPtr w;
+            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
+                return noErr;
+            HIPoint p;
+            if (GetEventParameter (aInEvent, kEventParamOrigin, typeHIPoint, NULL, sizeof (p), NULL, &p) != noErr)
+                return noErr;
+            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
+            QPoint p1 = view->mapToGlobal (QPoint (p.x, p.y));
+            MoveWindow (w, p1.x(), p1.y(), true);
+            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
+            return noErr;
+        }
+        if (eventKind == kEventVBoxResizeWindow)
+        {
+//            printf ("ResizeWindow requested\n");
+            WindowPtr w;
+            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
+                return noErr;
+            HISize s;
+            if (GetEventParameter (aInEvent, kEventParamDimensions, typeHISize, NULL, sizeof (s), NULL, &s) != noErr)
+                return noErr;
+            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
+            SizeWindow (w, s.width, s.height, true);
+            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
+            return noErr;
+        }
+        if (eventKind == kEventVBoxUpdateDock)
+        {
+//            printf ("UpdateDock requested\n");
+            view->updateDockIcon();
+            return noErr;
+        }
+    }
+
+    return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m	(revision 17126)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-cocoa.m	(revision 17126)
@@ -0,0 +1,51 @@
+/** @file
+ *
+ * VBox frontends: Qt GUI ("VirtualBox"):
+ * Declarations of utility classes and functions for handling Darwin Cocoa
+ * specific tasks
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
+ * Clara, CA 95054 USA or visit http://www.sun.com if you need
+ * additional information or have any questions.
+ */
+
+#include "VBoxUtils-darwin.h"
+
+#import <AppKit/NSWindow.h>
+#import <AppKit/NSView.h>
+#import <AppKit/NSEvent.h>
+
+NativeWindowRef darwinToNativeWindowImpl (NativeViewRef aView)
+{
+    if (aView)
+        return [aView window];
+    return 0;
+}
+
+void darwinSetShowsToolbarButtonImpl (NativeWindowRef aWindow, bool aEnabled)
+{
+    [aWindow setShowsToolbarButton:aEnabled];
+}
+
+/**
+ * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
+ *
+ * @param   fEnabled    Whether to enable or disable coalescing.
+ */
+void darwinSetMouseCoalescingEnabled (bool aEnabled)
+{
+    [NSEvent setMouseCoalescingEnabled:aEnabled];
+}
+
Index: trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 17125)
+++ trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.cpp	(revision 17126)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Sun Microsystems, Inc.
+ * Copyright (C) 2006-2009 Sun Microsystems, Inc.
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -20,24 +20,13 @@
  */
 
-
-
-#include "VBoxUtils.h"
-#include "VBoxFrameBuffer.h"
-#include "VBoxConsoleView.h"
-
-#include <iprt/assert.h>
-#include <iprt/mem.h>
-
-#include <CoreFoundation/CFBundle.h>
+#include "VBoxUtils-darwin.h"
+
+#include <QApplication>
+#include <QWidget>
+#include <QToolBar>
+#include <QPainter>
+#include <QPixmap>
+
 #include <Carbon/Carbon.h>
-
-/* Qt includes */
-#include <QImage>
-#include <QPixmap>
-#include <QPainter>
-#include <QApplication>
-#include <QToolBar>
-#include <QMainWindow>
-#include <QStatusBar>
 
 #if QT_VERSION < 0x040400
@@ -45,95 +34,57 @@
 #endif /* QT_VERSION < 0x040400 */
 
-#ifndef QT_MAC_USE_COCOA
-
-/**
- * Callback for deleting the QImage object when CGImageCreate is done
- * with it (which is probably not until the returned CFGImageRef is released).
- *
- * @param   info        Pointer to the QImage.
- */
-static void darwinDataProviderReleaseQImage (void *info, const void *, size_t)
-{
-    QImage *qimg = (QImage *)info;
-    delete qimg;
-}
-
-/**
- * Converts a QPixmap to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aPixmap     Pointer to the QPixmap instance to convert.
- */
-CGImageRef darwinToCGImageRef (const QImage *aImage)
-{
-    QImage *imageCopy = new QImage (*aImage);
-    /** @todo this code assumes 32-bit image input, the lazy bird convert image to 32-bit method is anything but optimal... */
-    if (imageCopy->format() != QImage::Format_ARGB32)
-        *imageCopy = imageCopy->convertToFormat (QImage::Format_ARGB32);
-    Assert (!imageCopy->isNull());
-
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    CGDataProviderRef dp = CGDataProviderCreateWithData (imageCopy, aImage->bits(), aImage->numBytes(), darwinDataProviderReleaseQImage);
-
-    CGBitmapInfo bmpInfo = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
-    CGImageRef ir = CGImageCreate (imageCopy->width(), imageCopy->height(), 8, 32, imageCopy->bytesPerLine(), cs,
-                                   bmpInfo, dp, 0 /*decode */, 0 /* shouldInterpolate */,
-                                   kCGRenderingIntentDefault);
-    CGColorSpaceRelease (cs);
-    CGDataProviderRelease (dp);
-
-    Assert (ir);
-    return ir;
-}
-
-/**
- * Converts a QPixmap to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aPixmap     Pointer to the QPixmap instance to convert.
- */
-CGImageRef darwinToCGImageRef (const QPixmap *aPixmap)
-{
-    return aPixmap->toMacCGImageRef();
-}
-
-/**
- * Loads an image using Qt and converts it to a CGImage.
- *
- * @returns CGImageRef for the new image. (Remember to release it when finished with it.)
- * @param   aSource     The source name.
- */
-CGImageRef darwinToCGImageRef (const char *aSource)
-{
-    QPixmap qpm (QString(":/") + aSource);
-    Assert (!qpm.isNull());
-    return ::darwinToCGImageRef (&qpm);
-}
-
-#endif /* !QT_MAC_USE_COCOA */
-
-void darwinSetShowToolBarButton (QToolBar *aToolBar, bool aShow)
+NativeViewRef darwinToNativeView (QWidget *aWidget)
+{
+    return reinterpret_cast<NativeViewRef>(aWidget->winId());
+}
+
+NativeWindowRef darwinToNativeWindow (QWidget *aWidget)
+{
+    return darwinToNativeWindowImpl (::darwinToNativeView (aWidget));
+}
+
+NativeWindowRef darwinToNativeWindow (NativeViewRef aView)
+{ 
+    return darwinToNativeWindowImpl (aView);
+}
+
+void darwinSetShowsToolbarButton (QToolBar *aToolBar, bool aEnabled)
 {
     QWidget *parent = aToolBar->parentWidget();
     if (parent)
-    {
-#ifdef QT_MAC_USE_COCOA
-        /** @todo Carbon -> Cocoa */
-#else
-        int err = ChangeWindowAttributes (::darwinToWindowRef (parent), aShow ? kWindowToolbarButtonAttribute:kWindowNoAttributes,
-                                                                        aShow ? kWindowNoAttributes:kWindowToolbarButtonAttribute);
-        AssertCarbonOSStatus (err);
-#endif
-    }
-}
-
-void darwinWindowAnimateResize (QWidget *aWidget, const QRect &aTarget)
-{
-#ifdef QT_MAC_USE_COCOA
-    /** @todo Carbon -> Cocoa */
-#else
-    HIRect r = ::darwinToHIRect (aTarget);
-    TransitionWindowWithOptions (::darwinToWindowRef (aWidget), kWindowSlideTransitionEffect, kWindowResizeTransitionAction, &r, false, NULL);
-#endif
+        darwinSetShowsToolbarButtonImpl (::darwinToNativeWindow (parent), aEnabled);
+}
+
+QString darwinSystemLanguage (void)
+{
+    /* Get the locales supported by our bundle */
+    CFArrayRef supportedLocales = ::CFBundleCopyBundleLocalizations (::CFBundleGetMainBundle());
+    /* Check them against the languages currently selected by the user */
+    CFArrayRef preferredLocales = ::CFBundleCopyPreferredLocalizationsFromArray (supportedLocales);
+    /* Get the one which is on top */
+    CFStringRef localeId = (CFStringRef)::CFArrayGetValueAtIndex (preferredLocales, 0);
+    /* Convert them to a C-string */
+    char localeName[20];
+    ::CFStringGetCString (localeId, localeName, sizeof (localeName), kCFStringEncodingUTF8);
+    /* Some cleanup */
+    ::CFRelease (supportedLocales);
+    ::CFRelease (preferredLocales);
+    QString id(localeName);
+    /* Check for some misbehavior */
+    if (id.isEmpty() ||
+        id.toLower() == "english")
+        id = "en";
+    return id;
+}
+
+void darwinDisableIconsInMenus (void)
+{
+    /* No icons in the menu of a mac application. */
+#if QT_VERSION < 0x040400
+    qt_mac_set_menubar_icons (false);
+#else /* QT_VERSION < 0x040400 */
+    /* Available since Qt 4.4 only */
+    QApplication::instance()->setAttribute (Qt::AA_DontShowIconsInMenus, true);
+#endif /* QT_VERSION >= 0x040400 */
 }
 
@@ -157,175 +108,10 @@
 }
 
-QString darwinSystemLanguage (void)
-{
-    /* Get the locales supported by our bundle */
-    CFArrayRef supportedLocales = CFBundleCopyBundleLocalizations (CFBundleGetMainBundle());
-    /* Check them against the languages currently selected by the user */
-    CFArrayRef preferredLocales = CFBundleCopyPreferredLocalizationsFromArray (supportedLocales);
-    /* Get the one which is on top */
-    CFStringRef localeId = (CFStringRef)CFArrayGetValueAtIndex (preferredLocales, 0);
-    /* Convert them to a C-string */
-    char localeName[20];
-    CFStringGetCString (localeId, localeName, sizeof (localeName), kCFStringEncodingUTF8);
-    /* Some cleanup */
-    CFRelease (supportedLocales);
-    CFRelease (preferredLocales);
-    QString id(localeName);
-    /* Check for some misbehavior */
-    if (id.isEmpty() ||
-        id.toLower() == "english")
-        id = "en";
-    return id;
-}
-
-bool darwinIsMenuOpen (void)
-{
-#ifdef QT_MAC_USE_COCOA
-    /** @todo Carbon -> Cocoa */
-    return false;
-#else
-    MenuTrackingData outData;
-    return (GetMenuTrackingData (NULL, &outData) != menuNotFoundErr);
-#endif
-}
-
-void darwinDisableIconsInMenus (void)
-{
-    /* No icons in the menu of a mac application. */
-#if QT_VERSION < 0x040400
-    qt_mac_set_menubar_icons (false);
-#else /* QT_VERSION < 0x040400 */
-    /* Available since Qt 4.4 only */
-    QApplication::instance()->setAttribute (Qt::AA_DontShowIconsInMenus, true);
-#endif /* QT_VERSION >= 0x040400 */
-}
-
-#ifndef QT_MAC_USE_COCOA
-
-/* Currently not used! */
-OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
-{
-    NOREF (aInHandlerCallRef);
-
-    OSStatus status = eventNotHandledErr;
-
-    switch (GetEventKind (aInEvent))
-    {
-        case kEventWindowGetRegion:
-        {
-            WindowRegionCode code;
-            RgnHandle rgn;
-
-            /* which region code is being queried? */
-            GetEventParameter (aInEvent, kEventParamWindowRegionCode, typeWindowRegionCode, NULL, sizeof (code), NULL, &code);
-
-            /* if it is the opaque region code then set the region to Empty and return noErr to stop the propagation */
-            if (code == kWindowOpaqueRgn)
-            {
-                printf("test1\n");
-                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn);
-                SetEmptyRgn (rgn);
-                status = noErr;
-            }
-            /* if the content of the whole window is queried return a copy of our saved region. */
-            else if (code == (kWindowStructureRgn))// || kWindowGlobalPortRgn || kWindowUpdateRgn))
-            {
-                printf("test2\n");
-                GetEventParameter (aInEvent, kEventParamRgnHandle, typeQDRgnHandle, NULL, sizeof (rgn), NULL, &rgn);
-                QRegion *pRegion = static_cast <QRegion*> (aInUserData);
-                if (!pRegion->isEmpty() && pRegion)
-                {
-                    CopyRgn (pRegion->handle(), rgn);
-                    status = noErr;
-                }
-            }
-            break;
-        }
-        case kEventControlDraw:
-        {
-            printf("test3\n");
-            CGContextRef ctx;
-            HIRect bounds;
-
-            GetEventParameter (aInEvent, kEventParamCGContextRef, typeCGContextRef, NULL, sizeof (ctx), NULL, &ctx);
-            HIViewGetBounds ((HIViewRef)aInUserData, &bounds);
-
-            CGContextClearRect (ctx, bounds);
-            status = noErr;
-            break;
-        }
-    }
-
-    return status;
-}
-
-OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
-{
-    if (!aInUserData)
-        return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
-
-    UInt32 eventClass = ::GetEventClass (aInEvent);
-    UInt32 eventKind = ::GetEventKind (aInEvent);
-    /* For debugging events */
-    /*
-    if (!(eventClass == 'cute'))
-        ::darwinDebugPrintEvent ("view: ", aInEvent);
-    */
-    VBoxConsoleView *view = static_cast<VBoxConsoleView *> (aInUserData);
-
-    if (eventClass == kEventClassVBox)
-    {
-        if (eventKind == kEventVBoxShowWindow)
-        {
-//            printf ("ShowWindow requested\n");
-            WindowRef w;
-            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
-                return noErr;
-            ShowWindow (w);
-            SelectWindow (w);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxMoveWindow)
-        {
-//            printf ("MoveWindow requested\n");
-            WindowPtr w;
-            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
-                return noErr;
-            HIPoint p;
-            if (GetEventParameter (aInEvent, kEventParamOrigin, typeHIPoint, NULL, sizeof (p), NULL, &p) != noErr)
-                return noErr;
-            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
-            QPoint p1 = view->mapToGlobal (QPoint (p.x, p.y));
-            MoveWindow (w, p1.x(), p1.y(), true);
-            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxResizeWindow)
-        {
-//            printf ("ResizeWindow requested\n");
-            WindowPtr w;
-            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
-                return noErr;
-            HISize s;
-            if (GetEventParameter (aInEvent, kEventParamDimensions, typeHISize, NULL, sizeof (s), NULL, &s) != noErr)
-                return noErr;
-            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
-            SizeWindow (w, s.width, s.height, true);
-            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxUpdateDock)
-        {
-//            printf ("UpdateDock requested\n");
-            view->updateDockIcon();
-            return noErr;
-        }
-    }
-
-    return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
-}
-
-#endif /* !QT_MAC_USE_COCOA */
-
+
+/********************************************************************************
+ *
+ * Old carbon stuff. Have to converted soon!
+ *
+ ********************************************************************************/
 
 /* Event debugging stuff. Borrowed from Knuts Qt patch. */
@@ -534,2 +320,3 @@
 
 #endif /* DEBUG */
+
