Index: trunk/src/VBox/Frontends/VirtualBox/Makefile
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/Makefile	(revision 1338)
+++ trunk/src/VBox/Frontends/VirtualBox/Makefile	(revision 1339)
@@ -135,8 +135,9 @@
 VirtualBox_DEFS.debug     = VBOX_GUI_DEBUG VBOX_CHECK_STATE # QT_FATAL_ASSERT
 VirtualBox_DEFS.win       = UNICODE QT_DLL
+VirtualBox_DEFS.darwin    = VBOX_WITH_HACKED_QT
 ifeq ($(BUILD_TYPE),release)
  VirtualBox_DEFS.win     += VBOX_GUI_USE_QIMAGE
  VirtualBox_DEFS.linux   += VBOX_GUI_USE_SDL
- VirtualBox_DEFS.darwin  += VBOX_GUI_USE_SDL
+ VirtualBox_DEFS.darwin  += VBOX_GUI_USE_QIMAGE
 else
  VirtualBox_DEFS         += VBOX_WITH_DEBUGGER_GUI_MENU
Index: trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h	(revision 1338)
+++ trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h	(revision 1339)
@@ -239,6 +239,10 @@
                                                   WPARAM wParam, LPARAM lParam);
 #elif defined (Q_WS_MAC)
+# ifndef VBOX_WITH_HACKED_QT
     static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
                                                    EventRef inEvent, void *inUserData);
+# else  /* VBOX_WITH_HACKED_QT */
+    static bool macEventFilter (EventRef inEvent, void *inUserData);
+# endif /* VBOX_WITH_HACKED_QT */
 #endif
 
Index: trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 1338)
+++ trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 1339)
@@ -80,4 +80,7 @@
 #if defined (Q_WS_MAC)
 # include "DarwinKeyboard.h"
+# ifdef VBOX_WITH_HACKED_QT
+#  include "QIApplication.h"
+# endif
 #endif /* defined (Q_WS_MAC) */
 
@@ -106,10 +109,11 @@
 #if defined (Q_WS_MAC)
 
+# ifndef VBOX_WITH_HACKED_QT
 /**
  *  Event handler callback for Mac OS X.
  */
 /* static */
-pascal OSStatus VBoxConsoleView::darwinEventHandlerProc(EventHandlerCallRef inHandlerCallRef,
-                                                        EventRef inEvent, void *inUserData)
+pascal OSStatus VBoxConsoleView::darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
+                                                         EventRef inEvent, void *inUserData)
 {
     VBoxConsoleView *view = (VBoxConsoleView *)inUserData;
@@ -134,4 +138,23 @@
     return ::CallNextEventHandler (inHandlerCallRef, inEvent);
 }
+
+# else /* VBOX_WITH_HACKED_QT */
+
+/**
+ *  Event handler callback for Mac OS X.
+ */
+/* static */
+bool VBoxConsoleView::macEventFilter (EventRef inEvent, void *inUserData)
+{
+    VBoxConsoleView *view = (VBoxConsoleView *)inUserData;
+    UInt32 EventClass = ::GetEventClass (inEvent);
+    if (EventClass == kEventClassKeyboard)
+    {
+        if (view->darwinKeyboardEvent (inEvent))
+            return true;
+    }
+    return false;
+}
+# endif /* VBOX_WITH_HACKED_QT */
 
 #endif /* Q_WS_MAC */
@@ -1344,5 +1367,6 @@
 
 /**
- *  Invoked by VBoxConsoleView::darwinEventHandlerProc when it gets a raw keyboard event.
+ *  Invoked by VBoxConsoleView::darwinEventHandlerProc / VBoxConsoleView::macEventFilter when
+ *  it receives a raw keyboard event.
  *
  *  @param inEvent      The keyboard event.
@@ -1401,4 +1425,5 @@
         newMask = ::DarwinAdjustModifierMask (newMask);
         UInt32 changed = newMask ^ m_darwinKeyModifiers;
+        ret = kbd_captured;
         if (changed)
         {
@@ -1419,11 +1444,9 @@
                     scanCode &= ~0x80;
                 }
-                keyEvent (keyCode, scanCode, flags);
+                ret |= keyEvent (keyCode, scanCode, flags);
             }
         }
 
         m_darwinKeyModifiers = newMask;
-
-        ret = kbd_captured; //??
     }
 
@@ -1443,4 +1466,6 @@
         ::SetMouseCoalescingEnabled (false, NULL);      //??
         ::CGSetLocalEventsSuppressionInterval (0.0);    //??
+
+#ifndef VBOX_WITH_HACKED_QT
 
         EventTypeSpec eventTypes[6];
@@ -1454,5 +1479,5 @@
         eventTypes[3].eventKind  = kEventRawKeyModifiersChanged;
         /* For ignorning Command-H and Command-Q which aren't affected by the
-         * global hotkey stuff: */
+         * global hotkey stuff (doesn't work well): */
         eventTypes[4].eventClass = kEventClassCommand;
         eventTypes[4].eventKind  = kEventCommandProcess;
@@ -1467,4 +1492,8 @@
         ::DisposeEventHandlerUPP (eventHandler);
 
+#else /* VBOX_WITH_HACKED_QT */
+        ((QIApplication *)qApp)->setEventFilter (VBoxConsoleView::macEventFilter, this);
+#endif /* VBOX_WITH_HACKED_QT */
+
         ::DarwinGrabKeyboard (false);
     }
@@ -1477,4 +1506,7 @@
             m_darwinEventHandlerRef = NULL;
         }
+#ifdef VBOX_WITH_HACKED_QT
+        ((QIApplication *)qApp)->setEventFilter (NULL, NULL);
+#endif
     }
 }
Index: trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 1338)
+++ trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 1339)
@@ -24,4 +24,9 @@
 #include "VBoxSelectorWnd.h"
 #include "VBoxConsoleWnd.h"
+#ifdef Q_WS_MAC
+# include "QIApplication.h"
+#else
+# define QIApplication
+#endif
 
 #include <qmessagebox.h>
@@ -136,5 +141,7 @@
     /** @todo automatically start VBoxSVC. */
 }
-#endif
+
+#endif
+
 
 int main( int argc, char ** argv )
@@ -162,5 +169,5 @@
     qInstallMsgHandler (QtMessageOutput);
 
-    QApplication a (argc, argv);
+    QIApplication a (argc, argv);
 
 #ifdef Q_WS_X11
