Index: /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 29794)
@@ -44,10 +44,4 @@
 VBOX_WITH_UPDATE_REQUEST := 1
 endif
-
-# Build new VirtualBox FE/Qt4 GUI runtime core.
-# Currently its not used, you can build it for developing purposes.
-VBOX_WITH_NEW_RUNTIME_CORE := 1
-# Force the usage of the new runtime core for the single monitor case also.
-VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS := 1
 
 #
@@ -121,10 +115,4 @@
 ifdef VBOX_WITH_ICHAT_THEATER
  VirtualBox_DEFS.darwin += VBOX_WITH_ICHAT_THEATER
-endif
-ifdef VBOX_WITH_NEW_RUNTIME_CORE
- VirtualBox_DEFS += VBOX_WITH_NEW_RUNTIME_CORE
- ifdef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
-  VirtualBox_DEFS += VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
- endif
 endif
 ifneq ($(KBUILD_TYPE),release)
@@ -159,7 +147,7 @@
 
 ifdef VBOX_BLEEDING_EDGE
-VirtualBox_src/VBoxConsoleWnd.cpp_DEFS += \
+VirtualBox_src/VBoxSelectorWnd.cpp_DEFS += \
     VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\"
-VirtualBox_src/VBoxSelectorWnd.cpp_DEFS += \
+VirtualBox_src/runtime/UIMachineWindow.cpp_DEFS += \
     VBOX_BLEEDING_EDGE=\"$(VBOX_BLEEDING_EDGE)\"
 VirtualBox_src/VBoxAboutDlg.cpp_DEFS += \
@@ -184,12 +172,9 @@
 	./src/widgets \
 	./src/X11 \
-	./src/darwin
-ifdef VBOX_WITH_NEW_RUNTIME_CORE
-VBOX_GUI_INC_DIRS += \
+	./src/darwin \
     ./src/runtime \
 	./src/runtime/normal \
 	./src/runtime/fullscreen \
 	./src/runtime/seamless
-endif
 
 ifdef VBOX_WITH_REGISTRATION
@@ -258,6 +243,4 @@
 	src/VBoxAboutDlg.h \
 	src/VBoxCloseVMDlg.h \
-	src/VBoxConsoleView.h \
-	src/VBoxConsoleWnd.h \
 	src/VBoxGlobalSettings.h \
 	src/VBoxMediaManagerDlg.h \
@@ -337,7 +320,5 @@
 	src/widgets/VBoxProgressDialog.h \
 	src/widgets/VBoxSpecialControls.h \
-	src/widgets/VBoxWarningPane.h
-ifdef VBOX_WITH_NEW_RUNTIME_CORE
-VirtualBox_QT_MOCHDRS += \
+	src/widgets/VBoxWarningPane.h \
 	src/runtime/UISession.h \
 	src/runtime/UIActionsPool.h \
@@ -356,5 +337,4 @@
 	src/runtime/seamless/UIMachineWindowSeamless.h \
 	src/runtime/seamless/UIMachineViewSeamless.h
-endif
 
 ifdef VBOX_WITH_REGISTRATION
@@ -366,7 +346,5 @@
 VirtualBox_QT_MOCSRCS = \
 	src/VBoxSelectorWnd.cpp \
-	src/VBoxMediaManagerDlg.cpp
-ifdef VBOX_WITH_NEW_RUNTIME_CORE
-VirtualBox_QT_MOCSRCS += \
+	src/VBoxMediaManagerDlg.cpp \
 	src/runtime/UIActionsPool.cpp \
 	src/runtime/UIMachineMenuBar.cpp \
@@ -374,5 +352,4 @@
 	src/runtime/UIMachine.cpp \
 	src/runtime/UIMachineLogic.cpp
-endif
 ifdef VBOX_WITH_XPCOM
  VirtualBox_QT_MOCSRCS += \
@@ -393,7 +370,4 @@
 	src/VBoxAboutDlg.cpp \
 	src/VBoxCloseVMDlg.cpp \
-	src/VBoxConsoleView.cpp \
-	src/VBoxConsoleWnd.cpp \
-	src/VBoxFrameBuffer.cpp \
 	src/VBoxGlobalSettings.cpp \
 	src/VBoxHelpActions.cpp \
@@ -476,7 +450,5 @@
 	src/widgets/VBoxProgressDialog.cpp \
 	src/widgets/VBoxSpecialControls.cpp \
-	src/widgets/VBoxWarningPane.cpp
-ifdef VBOX_WITH_NEW_RUNTIME_CORE
-VirtualBox_SOURCES += \
+	src/widgets/VBoxWarningPane.cpp \
 	src/runtime/UISession.cpp \
 	src/runtime/UIActionsPool.cpp \
@@ -507,5 +479,4 @@
 	src/darwin/UIAbstractDockIconPreview.cpp \
 	src/darwin/UICocoaDockIconPreview.mm
-endif
 
 ifeq ($(filter-out freebsd linux netbsd openbsd solaris,$(KBUILD_TARGET)),) # X11
@@ -540,7 +511,5 @@
 VirtualBox_SOURCES.darwin += \
 	src/darwin/DarwinKeyboard.cpp \
-	src/darwin/VBoxUtils-darwin.cpp \
-	src/darwin/AbstractDockIconPreview.cpp \
-	src/VBoxFBQuartz2D.cpp
+	src/darwin/VBoxUtils-darwin.cpp
 
 ifdef VBOX_WITH_ICHAT_THEATER
@@ -554,12 +523,10 @@
  	src/darwin/VBoxCocoaApplication.m \
  	src/darwin/VBoxUtils-darwin-cocoa.mm \
- 	src/darwin/VBoxCocoaSpecialControls.mm \
- 	src/darwin/CocoaDockIconPreview.mm
+ 	src/darwin/VBoxCocoaSpecialControls.mm
  VirtualBox_QT_MOCHDRS.darwin = \
  	src/darwin/VBoxCocoaSpecialControls.h
 else
  VirtualBox_SOURCES.darwin += \
- 	src/darwin/VBoxUtils-darwin-carbon.cpp \
- 	src/darwin/CarbonDockIconPreview.cpp
+ 	src/darwin/VBoxUtils-darwin-carbon.cpp
 endif
 
@@ -916,4 +883,5 @@
 # lupdate call
 #
+#VirtualBox_QT_TRANSLATIONS = nls/VirtualBox_de.ts
 updatenls:: makeallnls nls/VirtualBox_en.ts
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxCloseVMDlg.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxCloseVMDlg.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxCloseVMDlg.cpp	(revision 29794)
@@ -23,7 +23,5 @@
 #include "VBoxCloseVMDlg.h"
 #include "VBoxProblemReporter.h"
-#ifdef Q_WS_MAC
-# include "VBoxConsoleWnd.h"
-#endif /* Q_WS_MAC */
+#include "UIMachineWindowNormal.h"
 
 /* Qt includes */
@@ -31,13 +29,8 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
-# include "UIMachineWindowNormal.h"
-#endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
-
 VBoxCloseVMDlg::VBoxCloseVMDlg (QWidget *aParent)
     : QIWithRetranslateUI<QIDialog> (aParent)
 {
 #ifdef Q_WS_MAC
-# ifdef VBOX_WITH_NEW_RUNTIME_CORE
     /* No sheets in another mode than normal for now. Firstly it looks ugly and
      * secondly in some cases it is broken. */
@@ -45,14 +38,4 @@
     if (pWnd)
         setWindowFlags (Qt::Sheet);
-# endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
-# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
-    /* Sheets are broken if the window is in fullscreen mode. So make it a
-     * normal window in that case. */
-    VBoxConsoleWnd *cwnd = qobject_cast<VBoxConsoleWnd*> (aParent);
-    if (cwnd == NULL ||
-        (!cwnd->isTrueFullscreen() &&
-         !cwnd->isTrueSeamless()))
-        setWindowFlags (Qt::Sheet);
-# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
 #endif /* Q_WS_MAC */
 
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp	(revision 29793)
+++ 	(revision )
@@ -1,4313 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxConsoleView class implementation
- */
-
-/*
- * Copyright (C) 22006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include <VBox/VBoxVideo.h>
-
-#include "VBoxConsoleView.h"
-#include "VBoxConsoleWnd.h"
-#include "VBoxUtils.h"
-
-#include "VBoxFrameBuffer.h"
-#include "VBoxGlobal.h"
-#include "VBoxProblemReporter.h"
-#include "VBox/com/array.h"
-
-#ifdef Q_WS_PM
-#include "QIHotKeyEdit.h"
-#endif
-
-/* Qt includes */
-#include <QMenuBar>
-#include <QDesktopWidget>
-#include <QTimer>
-#include <QStatusBar>
-#include <QPainter>
-#include <QBitmap>
-
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ /** @todo Move this further down! Requires some cleanup below though, so later. */
-
-#ifdef Q_WS_WIN
-// VBox/cdefs.h defines these:
-#undef LOWORD
-#undef HIWORD
-#undef LOBYTE
-#undef HIBYTE
-#include <windows.h>
-#endif
-
-#ifdef Q_WS_X11
-#include <QX11Info>
-// We need to capture some X11 events directly which
-// requires the XEvent structure to be defined. However,
-// including the Xlib header file will cause some nasty
-// conflicts with Qt. Therefore we use the following hack
-// to redefine those conflicting identifiers.
-#define XK_XKB_KEYS
-#define XK_MISCELLANY
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/XKBlib.h>
-#include <X11/keysym.h>
-#ifdef KeyPress
-const int XFocusOut = FocusOut;
-const int XFocusIn = FocusIn;
-const int XKeyPress = KeyPress;
-const int XKeyRelease = KeyRelease;
-#undef KeyRelease
-#undef KeyPress
-#undef FocusOut
-#undef FocusIn
-#endif
-#include "XKeyboard.h"
-#ifndef VBOX_WITHOUT_XCURSOR
-# include <X11/Xcursor/Xcursor.h>
-#endif
-#endif // Q_WS_X11
-
-#if defined (Q_WS_MAC)
-# include "DockIconPreview.h"
-# include "DarwinKeyboard.h"
-# ifdef QT_MAC_USE_COCOA
-#  include "darwin/VBoxCocoaApplication.h"
-# else /* QT_MAC_USE_COCOA */
-#  include <Carbon/Carbon.h>
-# endif /* !QT_MAC_USE_COCOA */
-# include <VBox/err.h>
-#endif /* defined (Q_WS_MAC) */
-
-#if defined (Q_WS_WIN32)
-
-static HHOOK gKbdHook = NULL;
-static VBoxConsoleView *gView = 0;
-
-LRESULT CALLBACK VBoxConsoleView::lowLevelKeyboardProc (int nCode,
-                                                        WPARAM wParam, LPARAM lParam)
-{
-    Assert (gView);
-    if (gView && nCode == HC_ACTION &&
-            gView->winLowKeyboardEvent (wParam, *(KBDLLHOOKSTRUCT *) lParam))
-        return 1;
-
-    return CallNextHookEx (NULL, nCode, wParam, lParam);
-}
-
-#endif
-
-#if defined (Q_WS_MAC)
-# if defined (QT_MAC_USE_COCOA)
-/**
- * Event handler callback for Mac OS X, Cocoa variant.
- *
- * (Registered with and called from VBoxCocoaApplication.)
- *
- * @returns true if the event should be dropped, false if it should be passed
- *          along.
- * @param   pvCocoaEvent    The Cocoa event object.
- * @param   pvCarbonEvent   The Carbon event object reference.
- * @param   pvUser          The user argument.
- */
-/* static */
-bool VBoxConsoleView::darwinEventHandlerProc (const void *pvCocoaEvent,
-                                              const void *pvCarbonEvent,
-                                              void *pvUser)
-{
-    VBoxConsoleView    *view       = (VBoxConsoleView *)pvUser;
-    EventRef            inEvent    = (EventRef)pvCarbonEvent;
-    UInt32              eventClass = ::GetEventClass (inEvent);
-
-#if 0
-    /* For debugging events. */
-    if (eventClass != 'cute')
-        ::VBoxCocoaApplication_printEvent ("view: ", pvCocoaEvent);
-#endif
-    /* Check if this is an application key combo. In that case we will not pass
-       the event to the guest, but let the host process it. */
-    if (VBoxCocoaApplication_isApplicationCommand(pvCocoaEvent))
-        return false;
-
-    /*
-     * All keyboard class events needs to be handled.
-     */
-    if (eventClass == kEventClassKeyboard)
-    {
-        if (view->darwinKeyboardEvent (pvCocoaEvent, inEvent))
-            return true;
-    }
-    /* Pass the event along. */
-    return false;
-}
-
-# else /* QT_MAC_USE_COCOA */
-/**
- *  Event handler callback for Mac OS X.
- */
-/* static */
-pascal OSStatus VBoxConsoleView::darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
-                                                         EventRef inEvent, void *inUserData)
-{
-    VBoxConsoleView *view = static_cast<VBoxConsoleView *> (inUserData);
-    UInt32 eventClass = ::GetEventClass (inEvent);
-
-    /* For debugging events */
-    /*
-    if (eventClass != 'cute')
-        ::darwinDebugPrintEvent ("view: ", inEvent);
-    */
-
-    /* Not sure but this seems an triggered event if the spotlight searchbar is
-     * displayed. So flag that the host key isn't pressed alone. */
-    if (   eventClass == 'cgs '
-        && view->mIsHostkeyPressed
-        && ::GetEventKind (inEvent) == 0x15)
-        view->mIsHostkeyAlone = false;
-
-    if (eventClass == kEventClassKeyboard)
-    {
-        if (view->darwinKeyboardEvent (NULL, inEvent))
-            return 0;
-    }
-    /*
-     * Command-H and Command-Q aren't properly disabled yet, and it's still
-     * possible to use the left command key to invoke them when the keyboard
-     * is captured. We discard the events these if the keyboard is captured
-     * as a half measure to prevent unexpected behavior. However, we don't
-     * get any key down/up events, so these combinations are dead to the guest...
-     */
-    else if (eventClass == kEventClassCommand)
-    {
-        if (view->mKbdCaptured)
-            return 0;
-    }
-    return ::CallNextEventHandler (inHandlerCallRef, inEvent);
-}
-# endif /* !QT_MAC_USE_COCOA */
-
-#endif /* Q_WS_MAC */
-
-/** Guest mouse pointer shape change event. */
-class MousePointerChangeEvent : public QEvent
-{
-public:
-    MousePointerChangeEvent (bool visible, bool alpha, uint xhot, uint yhot,
-                             uint width, uint height,
-                             ComSafeArrayIn(BYTE,pShape)) :
-        QEvent ((QEvent::Type) VBoxDefs::MousePointerChangeEventType),
-        vis (visible), alph (alpha), xh (xhot), yh (yhot), w (width), h (height)
-    {
-        com::SafeArray <BYTE> aShape(ComSafeArrayInArg (pShape));
-        size_t cbShapeSize = aShape.size();
-        if (cbShapeSize > 0)
-        {
-            shape.resize(cbShapeSize);
-            ::memcpy(shape.raw(), aShape.raw(), cbShapeSize);
-        }
-    }
-    ~MousePointerChangeEvent()
-    {
-    }
-    bool isVisible() const { return vis; }
-    bool hasAlpha() const { return alph; }
-    uint xHot() const { return xh; }
-    uint yHot() const { return yh; }
-    uint width() const { return w; }
-    uint height() const { return h; }
-    const uchar *shapeData() const { return shape.size() > 0 ? shape.raw() : NULL; }
-private:
-    bool vis, alph;
-    uint xh, yh, w, h;
-    com::SafeArray <uint8_t> shape;
-};
-
-/** Guest mouse absolute positioning capability change event. */
-class MouseCapabilityEvent : public QEvent
-{
-public:
-    MouseCapabilityEvent (bool supportsAbsolute, bool supportsRelative, bool needsHostCursor) :
-        QEvent ((QEvent::Type) VBoxDefs::MouseCapabilityEventType),
-        can_abs (supportsAbsolute),
-        can_rel (supportsRelative),
-        needs_host_cursor (needsHostCursor) {}
-    bool supportsAbsolute() const { return can_abs; }
-    bool supportsRelative() const { return can_rel; }
-    bool needsHostCursor() const { return needs_host_cursor; }
-private:
-    bool can_abs;
-    bool can_rel;
-    bool needs_host_cursor;
-};
-
-/** Machine state change. */
-class StateChangeEvent : public QEvent
-{
-public:
-    StateChangeEvent (KMachineState state) :
-        QEvent ((QEvent::Type) VBoxDefs::MachineStateChangeEventType),
-        s (state) {}
-    KMachineState machineState() const { return s; }
-private:
-    KMachineState s;
-};
-
-/** Guest Additions property changes. */
-class GuestAdditionsEvent : public QEvent
-{
-public:
-    GuestAdditionsEvent (const QString &aOsTypeId,
-                         const QString &aAddVersion,
-                         bool aAddActive,
-                         bool aSupportsSeamless,
-                         bool aSupportsGraphics) :
-        QEvent ((QEvent::Type) VBoxDefs::AdditionsStateChangeEventType),
-        mOsTypeId (aOsTypeId), mAddVersion (aAddVersion),
-        mAddActive (aAddActive), mSupportsSeamless (aSupportsSeamless),
-        mSupportsGraphics (aSupportsGraphics) {}
-    const QString &osTypeId() const { return mOsTypeId; }
-    const QString &additionVersion() const { return mAddVersion; }
-    bool additionActive() const { return mAddActive; }
-    bool supportsSeamless() const { return mSupportsSeamless; }
-    bool supportsGraphics() const { return mSupportsGraphics; }
-private:
-    QString mOsTypeId;
-    QString mAddVersion;
-    bool mAddActive;
-    bool mSupportsSeamless;
-    bool mSupportsGraphics;
-};
-
-/** DVD/Floppy drive change event */
-class MediaDriveChangeEvent : public QEvent
-{
-public:
-    MediaDriveChangeEvent (VBoxDefs::MediumType aType)
-        : QEvent ((QEvent::Type) VBoxDefs::MediaDriveChangeEventType)
-        , mType (aType) {}
-    VBoxDefs::MediumType type() const { return mType; }
-private:
-    VBoxDefs::MediumType mType;
-};
-
-/** Menu activation event */
-class ActivateMenuEvent : public QEvent
-{
-public:
-    ActivateMenuEvent (QAction *aData) :
-        QEvent ((QEvent::Type) VBoxDefs::ActivateMenuEventType),
-        mAction (aData) {}
-    QAction *action() const { return mAction; }
-private:
-    QAction *mAction;
-};
-
-/** VM Runtime error event */
-class RuntimeErrorEvent : public QEvent
-{
-public:
-    RuntimeErrorEvent (bool aFatal, const QString &aErrorID,
-                       const QString &aMessage) :
-        QEvent ((QEvent::Type) VBoxDefs::RuntimeErrorEventType),
-        mFatal (aFatal), mErrorID (aErrorID), mMessage (aMessage) {}
-    bool fatal() const { return mFatal; }
-    QString errorID() const { return mErrorID; }
-    QString message() const { return mMessage; }
-private:
-    bool mFatal;
-    QString mErrorID;
-    QString mMessage;
-};
-
-/** Modifier key change event */
-class ModifierKeyChangeEvent : public QEvent
-{
-public:
-    ModifierKeyChangeEvent (bool fNumLock, bool fCapsLock, bool fScrollLock) :
-        QEvent ((QEvent::Type) VBoxDefs::ModifierKeyChangeEventType),
-        mNumLock (fNumLock), mCapsLock (fCapsLock), mScrollLock (fScrollLock) {}
-    bool numLock()    const { return mNumLock; }
-    bool capsLock()   const { return mCapsLock; }
-    bool scrollLock() const { return mScrollLock; }
-private:
-    bool mNumLock, mCapsLock, mScrollLock;
-};
-
-/** Network adapter change event */
-class NetworkAdapterChangeEvent : public QEvent
-{
-public:
-    NetworkAdapterChangeEvent (INetworkAdapter *aAdapter) :
-        QEvent ((QEvent::Type) VBoxDefs::NetworkAdapterChangeEventType),
-        mAdapter (aAdapter) {}
-    INetworkAdapter* networkAdapter() { return mAdapter; }
-private:
-    INetworkAdapter *mAdapter;
-};
-
-/** USB controller state change event */
-class USBControllerStateChangeEvent : public QEvent
-{
-public:
-    USBControllerStateChangeEvent()
-        : QEvent ((QEvent::Type) VBoxDefs::USBCtlStateChangeEventType) {}
-};
-
-/** USB device state change event */
-class USBDeviceStateChangeEvent : public QEvent
-{
-public:
-    USBDeviceStateChangeEvent (const CUSBDevice &aDevice, bool aAttached,
-                               const CVirtualBoxErrorInfo &aError) :
-        QEvent ((QEvent::Type) VBoxDefs::USBDeviceStateChangeEventType),
-        mDevice (aDevice), mAttached (aAttached), mError (aError) {}
-    CUSBDevice device() const { return mDevice; }
-    bool attached() const { return mAttached; }
-    CVirtualBoxErrorInfo error() const { return mError; }
-private:
-    CUSBDevice mDevice;
-    bool mAttached;
-    CVirtualBoxErrorInfo mError;
-};
-
-//
-// VBoxConsoleCallback class
-/////////////////////////////////////////////////////////////////////////////
-
-class VBoxConsoleCallback : VBOX_SCRIPTABLE_IMPL(IConsoleCallback)
-{
-public:
-
-    VBoxConsoleCallback (VBoxConsoleView *v) {
-#if defined (Q_WS_WIN)
-        mRefCnt = 0;
-#endif
-        mView = v;
-    }
-
-    virtual ~VBoxConsoleCallback() {}
-
-    NS_DECL_ISUPPORTS
-
-#if defined (Q_WS_WIN)
-    STDMETHOD_(ULONG, AddRef)() {
-        return ::InterlockedIncrement (&mRefCnt);
-    }
-    STDMETHOD_(ULONG, Release)()
-    {
-        long cnt = ::InterlockedDecrement (&mRefCnt);
-        if (cnt == 0)
-            delete this;
-        return cnt;
-    }
-#endif
-    VBOX_SCRIPTABLE_DISPATCH_IMPL(IConsoleCallback)
-
-    STDMETHOD(OnMousePointerShapeChange) (BOOL visible, BOOL alpha,
-                                          ULONG xhot, ULONG yhot,
-                                          ULONG width, ULONG height,
-                                          ComSafeArrayIn(BYTE,shape))
-    {
-        QApplication::postEvent (mView,
-                                 new MousePointerChangeEvent (visible, alpha,
-                                                              xhot, yhot,
-                                                              width, height, ComSafeArrayInArg(shape)));
-        return S_OK;
-    }
-
-    STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
-    {
-        QApplication::postEvent (mView,
-                                 new MouseCapabilityEvent (supportsAbsolute,
-                                                           supportsRelative,
-                                                           needsHostCursor));
-        return S_OK;
-    }
-
-    STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
-    {
-        QApplication::postEvent (mView,
-                                 new ModifierKeyChangeEvent (fNumLock, fCapsLock,
-                                                             fScrollLock));
-        return S_OK;
-    }
-
-    STDMETHOD(OnStateChange)(MachineState_T machineState)
-    {
-        LogFlowFunc (("machineState=%d\n", machineState));
-        QApplication::postEvent (mView,
-                                 new StateChangeEvent ((KMachineState) machineState));
-        return S_OK;
-    }
-
-    STDMETHOD(OnAdditionsStateChange)()
-    {
-        CGuest guest = mView->console().GetGuest();
-        LogFlowFunc (("ver=%s, active=%d\n",
-                      guest.GetAdditionsVersion().toLatin1().constData(),
-                      guest.GetAdditionsActive()));
-        QApplication::postEvent (mView,
-                                 new GuestAdditionsEvent (
-                                     guest.GetOSTypeId(),
-                                     guest.GetAdditionsVersion(),
-                                     guest.GetAdditionsActive(),
-                                     guest.GetSupportsSeamless(),
-                                     guest.GetSupportsGraphics()));
-        return S_OK;
-    }
-
-    STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
-    {
-        QApplication::postEvent (mView,
-            new NetworkAdapterChangeEvent (aNetworkAdapter));
-        return S_OK;
-    }
-
-    STDMETHOD(OnStorageControllerChange) ()
-    {
-        /* @todo */
-        //QApplication::postEvent (mView,
-        //    new StorageControllerChangeEvent ());
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnMediumChange)(IMediumAttachment *aMediumAttachment)
-    {
-        CMediumAttachment att(aMediumAttachment);
-        switch (att.GetType())
-        {
-            case KDeviceType_Floppy:
-                QApplication::postEvent(mView,
-                    new MediaDriveChangeEvent(VBoxDefs::MediumType_Floppy));
-                break;
-            case KDeviceType_DVD:
-                QApplication::postEvent(mView,
-                    new MediaDriveChangeEvent(VBoxDefs::MediumType_DVD));
-                break;
-            default:
-                /* @todo later add hard disk change as well */
-                break;
-        }
-        return S_OK;
-    }
-
-    STDMETHOD(OnCPUChange)(ULONG aCPU, BOOL aRemove)
-    {
-        NOREF(aCPU);
-        NOREF(aRemove);
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
-    {
-        NOREF(aSerialPort);
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
-    {
-        NOREF(aParallelPort);
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnVRDPServerChange)()
-    {
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnRemoteDisplayInfoChange)()
-    {
-        return VBOX_E_DONT_CALL_AGAIN;
-    }
-
-    STDMETHOD(OnUSBControllerChange)()
-    {
-        QApplication::postEvent (mView,
-                                 new USBControllerStateChangeEvent());
-        return S_OK;
-    }
-
-    STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *aDevice, BOOL aAttached,
-                                      IVirtualBoxErrorInfo *aError)
-    {
-        QApplication::postEvent (mView,
-                                 new USBDeviceStateChangeEvent (
-                                     CUSBDevice (aDevice),
-                                     bool (aAttached),
-                                     CVirtualBoxErrorInfo (aError)));
-        return S_OK;
-    }
-
-    STDMETHOD(OnSharedFolderChange) (Scope_T aScope)
-    {
-        NOREF(aScope);
-        QApplication::postEvent (mView,
-                                 new QEvent ((QEvent::Type)
-                                             VBoxDefs::SharedFolderChangeEventType));
-        return S_OK;
-    }
-
-    STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTR id, IN_BSTR message)
-    {
-        QApplication::postEvent (mView,
-                                 new RuntimeErrorEvent (!!fatal,
-                                                        QString::fromUtf16 (id),
-                                                        QString::fromUtf16 (message)));
-        return S_OK;
-    }
-
-    STDMETHOD(OnCanShowWindow) (BOOL *canShow)
-    {
-        if (!canShow)
-            return E_POINTER;
-
-        /* as long as there is VBoxConsoleView (which creates/destroys us), it
-         * can be shown */
-        *canShow = TRUE;
-        return S_OK;
-    }
-
-    STDMETHOD(OnShowWindow) (ULONG64 *winId)
-    {
-        if (!winId)
-            return E_POINTER;
-
-#if defined (Q_WS_MAC)
-        /*
-         * Let's try the simple approach first - grab the focus.
-         * Getting a window out of the dock (minimized or whatever it's called)
-         * needs to be done on the GUI thread, so post it a note.
-         */
-        *winId = 0;
-        if (!mView)
-            return S_OK;
-
-        ProcessSerialNumber psn = { 0, kCurrentProcess };
-        OSErr rc = ::SetFrontProcess (&psn);
-        if (!rc)
-            QApplication::postEvent (mView, new QEvent ((QEvent::Type)VBoxDefs::ShowWindowEventType));
-        else
-        {
-            /*
-             * It failed for some reason, send the other process our PSN so it can try.
-             * (This is just a precaution should Mac OS X start imposing the same sensible
-             * focus stealing restrictions that other window managers implement.)
-             */
-            AssertMsgFailed(("SetFrontProcess -> %#x\n", rc));
-            if (::GetCurrentProcess (&psn))
-                *winId = RT_MAKE_U64 (psn.lowLongOfPSN, psn.highLongOfPSN);
-        }
-
-#else
-        /* Return the ID of the top-level console window. */
-        *winId = (ULONG64) mView->window()->winId();
-#endif
-
-        return S_OK;
-    }
-
-protected:
-
-    VBoxConsoleView *mView;
-
-#if defined (Q_WS_WIN)
-private:
-    long mRefCnt;
-#endif
-};
-
-#if !defined (Q_WS_WIN)
-NS_DECL_CLASSINFO (VBoxConsoleCallback)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI (VBoxConsoleCallback, IConsoleCallback)
-#endif
-
-class VBoxViewport: public QWidget
-{
-public:
-    VBoxViewport (QWidget *aParent)
-        : QWidget (aParent)
-    {
-        /* No need for background drawing */
-        setAttribute (Qt::WA_OpaquePaintEvent);
-    }
-    virtual QPaintEngine * paintEngine() const
-    {
-        if (testAttribute (Qt::WA_PaintOnScreen))
-            return NULL;
-        else
-            return QWidget::paintEngine();
-    }
-};
-
-//
-// VBoxConsoleView class
-/////////////////////////////////////////////////////////////////////////////
-
-/** @class VBoxConsoleView
- *
- *  The VBoxConsoleView class is a widget that implements a console
- *  for the running virtual machine.
- */
-
-VBoxConsoleView::VBoxConsoleView (VBoxConsoleWnd *mainWnd,
-                                  const CConsole &console,
-                                  VBoxDefs::RenderMode rm,
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                                  bool accelerate2DVideo,
-#endif
-                                  QWidget *parent)
-    : QAbstractScrollArea (parent)
-    , mMainWnd (mainWnd)
-    , mConsole (console)
-    , gs (vboxGlobal().settings())
-    , mAttached (false)
-    , mKbdCaptured (false)
-    , mMouseCaptured (false)
-    , mMouseCanAbsolute (false)
-    , mMouseCanRelative (true)
-    , mMouseNeedsHostCursor (false)
-    , mMouseIntegration (true)
-    , m_iLastMouseWheelDelta(0)
-    , mDisableAutoCapture (false)
-    , mIsHostkeyPressed (false)
-    , mIsHostkeyAlone (false)
-    , mIgnoreMainwndResize (true)
-    , mAutoresizeGuest (false)
-    , mIgnoreFrameBufferResize (false)
-    , mIgnoreGuestResize (false)
-    , mDoResize (false)
-    , mGuestSupportsGraphics (false)
-    , mNumLock (false)
-    , mScrollLock (false)
-    , mCapsLock (false)
-    , muNumLockAdaptionCnt (2)
-    , muCapsLockAdaptionCnt (2)
-    , mode (rm)
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    , mAccelerate2DVideo(accelerate2DVideo)
-#endif
-#if defined(Q_WS_WIN)
-    , mAlphaCursor (NULL)
-#endif
-#if defined(Q_WS_MAC)
-# ifndef QT_MAC_USE_COCOA
-    , mDarwinEventHandlerRef (NULL)
-# endif
-    , mDarwinKeyModifiers (0)
-    , mKeyboardGrabbed (false)
-    , mDockIconEnabled (true)
-#endif
-    , mDesktopGeo (DesktopGeo_Invalid)
-    , mPassCAD (false)
-      /* Don't show a hardware pointer until we have one to show */
-    , mHideHostPointer (true)
-{
-    Assert (!mConsole.isNull() &&
-            !mConsole.GetDisplay().isNull() &&
-            !mConsole.GetKeyboard().isNull() &&
-            !mConsole.GetMouse().isNull());
-
-#ifdef Q_WS_MAC
-    /* Overlay logo for the dock icon */
-    QString osTypeId = mConsole.GetGuest().GetOSTypeId();
-    mDockIconPreview = new VBoxDockIconPreview (mMainWnd, vboxGlobal().vmGuestOSTypeIcon (osTypeId));
-
-# ifndef QT_MAC_USE_COCOA
-    /* Install the event handler which will proceed external window handling */
-    EventHandlerUPP eventHandler = ::NewEventHandlerUPP (::darwinOverlayWindowHandler);
-    EventTypeSpec eventTypes[] =
-    {
-        { kEventClassVBox, kEventVBoxShowWindow },
-        { kEventClassVBox, kEventVBoxHideWindow },
-        { kEventClassVBox, kEventVBoxMoveWindow },
-        { kEventClassVBox, kEventVBoxResizeWindow },
-        { kEventClassVBox, kEventVBoxDisposeWindow },
-        { kEventClassVBox, kEventVBoxUpdateDock }
-    };
-
-    mDarwinWindowOverlayHandlerRef = NULL;
-    ::InstallApplicationEventHandler (eventHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],
-                                      this, &mDarwinWindowOverlayHandlerRef);
-    ::DisposeEventHandlerUPP (eventHandler);
-# endif /* !QT_MAC_USE_COCOA */
-#endif /* QT_WS_MAC */
-
-    /* No frame around the view */
-    setFrameStyle (QFrame::NoFrame);
-
-#ifdef VBOX_GUI_USE_QGLFB
-    QWidget *pViewport;
-    switch (mode)
-    {
-        case VBoxDefs::QGLMode:
-            pViewport = new VBoxGLWidget (mConsole, this, NULL);
-            break;
-        default:
-            pViewport = new VBoxViewport (this);
-    }
-#else
-    VBoxViewport *pViewport = new VBoxViewport (this);
-#endif
-    setViewport (pViewport);
-//    pViewport->vboxDoInit();
-
-    /* enable MouseMove events */
-    viewport()->setMouseTracking (true);
-
-    /*
-     *  QScrollView does the below on its own, but let's do it anyway
-     *  for the case it will not do it in the future.
-     */
-    viewport()->installEventFilter (this);
-
-    /* to fix some focus issues */
-    mMainWnd->menuBar()->installEventFilter (this);
-
-    /* we want to be notified on some parent's events */
-    mMainWnd->installEventFilter (this);
-
-#ifdef Q_WS_X11
-    /* initialize the X keyboard subsystem */
-    initMappedX11Keyboard(QX11Info::display(),
-            vboxGlobal().settings().publicProperty ("GUI/RemapScancodes"));
-#endif
-
-    ::memset (mPressedKeys, 0, sizeof (mPressedKeys));
-
-    /* setup rendering */
-
-    CDisplay display = mConsole.GetDisplay();
-    Assert (!display.isNull());
-
-    mFrameBuf = NULL;
-
-    LogFlowFunc (("Rendering mode: %d\n", mode));
-
-    switch (mode)
-    {
-#if defined (VBOX_GUI_USE_QGLFB)
-        case VBoxDefs::QGLMode:
-            mFrameBuf = new VBoxQGLFrameBuffer (this);
-            break;
-//        case VBoxDefs::QGLOverlayMode:
-//            mFrameBuf = new VBoxQGLOverlayFrameBuffer (this);
-//            break;
-#endif
-#if defined (VBOX_GUI_USE_QIMAGE)
-        case VBoxDefs::QImageMode:
-            mFrameBuf =
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                    /* these two additional template args is a workaround to this [VBox|UI] duplication
-                     * @todo: they are to be removed once VBox stuff is gone */
-                    mAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxQImageFrameBuffer, VBoxConsoleView, VBoxResizeEvent> (this, &mainWnd->session(), 0) :
-#endif
-                    new VBoxQImageFrameBuffer (this);
-            break;
-#endif
-#if defined (VBOX_GUI_USE_SDL)
-        case VBoxDefs::SDLMode:
-            /* Indicate that we are doing all
-             * drawing stuff ourself */
-            pViewport->setAttribute (Qt::WA_PaintOnScreen);
-# ifdef Q_WS_X11
-            /* This is somehow necessary to prevent strange X11 warnings on
-             * i386 and segfaults on x86_64. */
-            XFlush(QX11Info::display());
-# endif
-            mFrameBuf =
-#if defined(VBOX_WITH_VIDEOHWACCEL) && defined(DEBUG_misha) /* not tested yet */
-                    /* these two additional template args is a workaround to this [VBox|UI] duplication
-                     * @todo: they are to be removed once VBox stuff is gone */
-                    mAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxSDLFrameBuffer, VBoxConsoleView, VBoxResizeEvent> (this, &mainWnd->session(), 0) :
-#endif
-                    new VBoxSDLFrameBuffer (this);
-            /*
-             *  disable scrollbars because we cannot correctly draw in a
-             *  scrolled window using SDL
-             */
-            horizontalScrollBar()->setEnabled (false);
-            verticalScrollBar()->setEnabled (false);
-            break;
-#endif
-#if defined (VBOX_GUI_USE_DDRAW)
-        case VBoxDefs::DDRAWMode:
-            mFrameBuf = new VBoxDDRAWFrameBuffer (this);
-            break;
-#endif
-#if defined (VBOX_GUI_USE_QUARTZ2D)
-        case VBoxDefs::Quartz2DMode:
-            /* Indicate that we are doing all
-             * drawing stuff ourself */
-            pViewport->setAttribute (Qt::WA_PaintOnScreen);
-            mFrameBuf =
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                    /* these two additional template args is a workaround to this [VBox|UI] duplication
-                     * @todo: they are to be removed once VBox stuff is gone */
-                    mAccelerate2DVideo ? new VBoxOverlayFrameBuffer<VBoxQuartz2DFrameBuffer, VBoxConsoleView, VBoxResizeEvent> (this, &mainWnd->session(), 0) :
-#endif
-                    new VBoxQuartz2DFrameBuffer (this);
-            break;
-#endif
-        default:
-            AssertReleaseMsgFailed (("Render mode must be valid: %d\n", mode));
-            LogRel (("Invalid render mode: %d\n", mode));
-            qApp->exit (1);
-            break;
-    }
-
-#if defined (VBOX_GUI_USE_DDRAW)
-    if (!mFrameBuf || mFrameBuf->address() == NULL)
-    {
-        if (mFrameBuf)
-            delete mFrameBuf;
-        mode = VBoxDefs::QImageMode;
-        mFrameBuf = new VBoxQImageFrameBuffer (this);
-    }
-#endif
-
-    if (mFrameBuf)
-    {
-        mFrameBuf->AddRef();
-        display.SetFramebuffer (VBOX_VIDEO_PRIMARY_SCREEN, CFramebuffer (mFrameBuf));
-    }
-
-    /* setup the callback */
-    mCallback = CConsoleCallback (new VBoxConsoleCallback (this));
-    mConsole.RegisterCallback (mCallback);
-    AssertWrapperOk (mConsole);
-
-    QPalette palette (viewport()->palette());
-    palette.setColor (viewport()->backgroundRole(), Qt::black);
-    viewport()->setPalette (palette);
-
-    setSizePolicy (QSizePolicy (QSizePolicy::Maximum, QSizePolicy::Maximum));
-    setMaximumSize (sizeHint());
-
-    setFocusPolicy (Qt::WheelFocus);
-
-    /* Remember the desktop geometry and register for geometry change
-       events for telling the guest about video modes we like. */
-
-    QString desktopGeometry = vboxGlobal().settings()
-                                  .publicProperty ("GUI/MaxGuestResolution");
-    if ((desktopGeometry == QString::null) ||
-        (desktopGeometry == "auto"))
-        setDesktopGeometry (DesktopGeo_Automatic, 0, 0);
-    else if (desktopGeometry == "any")
-        setDesktopGeometry (DesktopGeo_Any, 0, 0);
-    else
-    {
-        int width = desktopGeometry.section (',', 0, 0).toInt();
-        int height = desktopGeometry.section (',', 1, 1).toInt();
-        setDesktopGeometry (DesktopGeo_Fixed, width, height);
-    }
-    connect (QApplication::desktop(), SIGNAL (resized (int)),
-             this, SLOT (doResizeDesktop (int)));
-
-    QString passCAD = mConsole.GetMachine().GetExtraData (VBoxDefs::GUI_PassCAD);
-    if (!passCAD.isEmpty() &&
-        ((passCAD != "false") || (passCAD != "no"))
-       )
-        mPassCAD = true;
-
-#if defined (Q_WS_WIN)
-    gView = this;
-#endif
-
-#if defined (Q_WS_PM)
-    bool ok = VBoxHlpInstallKbdHook (0, winId(), UM_PREACCEL_CHAR);
-    Assert (ok);
-    NOREF (ok);
-#endif
-}
-
-VBoxConsoleView::~VBoxConsoleView()
-{
-#if defined (Q_WS_PM)
-    bool ok = VBoxHlpUninstallKbdHook (0, winId(), UM_PREACCEL_CHAR);
-    Assert (ok);
-    NOREF (ok);
-#endif
-
-#if defined (Q_WS_WIN)
-    if (gKbdHook)
-        UnhookWindowsHookEx (gKbdHook);
-    gView = 0;
-    if (mAlphaCursor)
-        DestroyIcon (mAlphaCursor);
-#endif
-
-    if (mFrameBuf)
-    {
-        /* detach our framebuffer from Display */
-        CDisplay display = mConsole.GetDisplay();
-        Assert (!display.isNull());
-        display.SetFramebuffer (VBOX_VIDEO_PRIMARY_SCREEN, CFramebuffer(NULL));
-        /* release the reference */
-        mFrameBuf->Release();
-        mFrameBuf = NULL;
-    }
-
-    mConsole.UnregisterCallback (mCallback);
-
-#if defined (Q_WS_MAC)
-# if !defined (QT_MAC_USE_COCOA)
-    if (mDarwinWindowOverlayHandlerRef)
-    {
-        ::RemoveEventHandler (mDarwinWindowOverlayHandlerRef);
-        mDarwinWindowOverlayHandlerRef = NULL;
-    }
-# endif
-    delete mDockIconPreview;
-    mDockIconPreview = NULL;
-#endif
-}
-
-//
-// Public members
-/////////////////////////////////////////////////////////////////////////////
-
-QSize VBoxConsoleView::sizeHint() const
-{
-#ifdef VBOX_WITH_DEBUGGER /** @todo figure out a more proper fix. */
-    /* HACK ALERT! Really ugly workaround for the resizing to 9x1 done
-     *             by DevVGA if provoked before power on.  */
-    QSize fb(mFrameBuf->width(), mFrameBuf->height());
-    if (    (   fb.width()  < 16
-             || fb.height() < 16)
-        &&  (   vboxGlobal().isStartPausedEnabled()
-             || vboxGlobal().isDebuggerAutoShowEnabled()) )
-        fb = QSize(640, 480);
-    return QSize (fb.width() + frameWidth() * 2,
-                  fb.height() + frameWidth() * 2);
-#else
-    return QSize (mFrameBuf->width() + frameWidth() * 2,
-                  mFrameBuf->height() + frameWidth() * 2);
-#endif
-}
-
-/**
- *  Attaches this console view to the managed virtual machine.
- *
- *  @note This method is not really necessary these days -- the only place where
- *        it gets called is VBoxConsole::openView(), right after powering the
- *        VM up. We leave it as is just in case attaching/detaching will become
- *        necessary some day (there are useful attached checks everywhere in the
- *        code).
- */
-void VBoxConsoleView::attach()
-{
-    if (!mAttached)
-    {
-        mAttached = true;
-    }
-}
-
-/**
- *  Detaches this console view from the VM. Must be called to indicate
- *  that the virtual machine managed by this instance will be no more valid
- *  after this call.
- *
- *  @note This method is not really necessary these days -- the only place where
- *        it gets called is VBoxConsole::closeView(), when the VM is powered
- *        down, before deleting VBoxConsoleView. We leave it as is just in case
- *        attaching/detaching will become necessary some day (there are useful
- *        attached checks everywhere in the code).
- */
-void VBoxConsoleView::detach()
-{
-    if (mAttached)
-    {
-        /* reuse the focus event handler to uncapture everything */
-        focusEvent (false);
-        mAttached = false;
-    }
-}
-
-/**
- *  Resizes the toplevel widget to fit the console view w/o scrollbars.
- *  If adjustPosition is true and such resize is not possible (because the
- *  console view size is lagrer then the available screen space) the toplevel
- *  widget is resized and moved to become as large as possible while staying
- *  fully visible.
- */
-void VBoxConsoleView::normalizeGeometry (bool adjustPosition /* = false */)
-{
-    /* Make no normalizeGeometry in case we are in manual resize
-     * mode or main window is maximized */
-    if (mMainWnd->isWindowMaximized() || mMainWnd->isWindowFullScreen())
-        return;
-
-    QWidget *tlw = window();
-
-    /* calculate client window offsets */
-    QRect fr = tlw->frameGeometry();
-    QRect r = tlw->geometry();
-    int dl = r.left() - fr.left();
-    int dt = r.top() - fr.top();
-    int dr = fr.right() - r.right();
-    int db = fr.bottom() - r.bottom();
-
-    /* get the best size w/o scroll bars */
-    QSize s = tlw->sizeHint();
-
-    /* resize the frame to fit the contents */
-    s -= tlw->size();
-    fr.setRight (fr.right() + s.width());
-    fr.setBottom (fr.bottom() + s.height());
-
-    if (adjustPosition)
-    {
-        QRegion ar;
-        QDesktopWidget *dwt = QApplication::desktop();
-        if (dwt->isVirtualDesktop())
-            /* Compose complex available region */
-            for (int i = 0; i < dwt->numScreens(); ++ i)
-                ar += dwt->availableGeometry (i);
-        else
-            /* Get just a simple available rectangle */
-            ar = dwt->availableGeometry (tlw->pos());
-
-        fr = VBoxGlobal::normalizeGeometry (
-            fr, ar, mode != VBoxDefs::SDLMode /* canResize */);
-    }
-
-#if 0
-    /* center the frame on the desktop */
-    fr.moveCenter (ar.center());
-#endif
-
-    /* finally, set the frame geometry */
-    tlw->setGeometry (fr.left() + dl, fr.top() + dt,
-                      fr.width() - dl - dr, fr.height() - dt - db);
-}
-
-/**
- *  Pauses or resumes the VM execution.
- */
-bool VBoxConsoleView::pause (bool on)
-{
-    /* QAction::setOn() emits the toggled() signal, so avoid recursion when
-     * QAction::setOn() is called from VBoxConsoleWnd::updateMachineState() */
-    if (isPaused() == on)
-        return true;
-
-    if (on)
-        mConsole.Pause();
-    else
-        mConsole.Resume();
-
-    bool ok = mConsole.isOk();
-    if (!ok)
-    {
-        if (on)
-            vboxProblem().cannotPauseMachine (mConsole);
-        else
-            vboxProblem().cannotResumeMachine (mConsole);
-    }
-
-    return ok;
-}
-
-/**
- *  Temporarily disables the mouse integration (or enables it back).
- */
-void VBoxConsoleView::setMouseIntegrationEnabled (bool enabled)
-{
-    if (mMouseIntegration == enabled)
-        return;
-
-    if (mMouseCanAbsolute)
-        captureMouse (!enabled, false);
-
-    /* Hiding host cursor in case we are entering mouse integration
-     * mode until it's shape is set to the guest cursor shape in
-     * OnMousePointerShapeChange event handler.
-     *
-     * This is necessary to avoid double-cursor issues where both the
-     * guest and the host cursors are displayed in one place, one above the
-     * other.
-     *
-     * This is a workaround because the correct decision would be to notify
-     * the Guest Additions about we are entering the mouse integration
-     * mode. The GuestOS should hide it's cursor to allow using of
-     * host cursor for the guest's manipulation.
-     *
-     * This notification is not always possible though, as not all guests
-     * support switching to a hardware pointer on demand. */
-    if (enabled)
-    {
-        mHideHostPointer = true;
-        updateHostCursor();
-    }
-
-    mMouseIntegration = enabled;
-
-    emitMouseStateChanged();
-}
-
-void VBoxConsoleView::updateHostCursor()
-{
-    if (!mMouseIntegration && !mMouseCaptured)
-        viewport()->unsetCursor();
-    else if (mMouseCaptured || (mMouseCanAbsolute && mHideHostPointer))
-        viewport()->setCursor(Qt::BlankCursor);
-    else
-        viewport()->setCursor(mLastCursor);
-}
-
-void VBoxConsoleView::setAutoresizeGuest (bool on, bool doHint)
-{
-    if (mAutoresizeGuest != on)
-    {
-        mAutoresizeGuest = on;
-
-        maybeRestrictMinimumSize();
-
-        if (mGuestSupportsGraphics && mAutoresizeGuest && doHint)
-            doResizeHint();
-    }
-}
-
-/**
- *  This method is called by VBoxConsoleWnd after it does everything necessary
- *  on its side to go to or from fullscreen, but before it is shown.
- */
-void VBoxConsoleView::onFullscreenChange (bool /* on */)
-{
-    /* Nothing to do here so far */
-}
-
-/**
- *  Notify the console scroll-view about the console-window is opened.
- */
-void VBoxConsoleView::onViewOpened()
-{
-    /* Variable mIgnoreMainwndResize was initially "true" to ignore QT
-     * initial resize event in case of auto-resize feature is on.
-     * Currently, initial resize event is already processed, so we set
-     * mIgnoreMainwndResize to "false" to process all further resize
-     * events as user-initiated window resize events. */
-    mIgnoreMainwndResize = false;
-}
-
-//
-// Protected Events
-/////////////////////////////////////////////////////////////////////////////
-
-bool VBoxConsoleView::event (QEvent *e)
-{
-    if (mAttached)
-    {
-        switch (e->type())
-        {
-            case QEvent::FocusIn:
-            {
-                if (isRunning())
-                    focusEvent (true);
-                break;
-            }
-            case QEvent::FocusOut:
-            {
-                if (isRunning())
-                    focusEvent (false);
-                else
-                {
-                    /* release the host key and all other pressed keys too even
-                     * when paused (otherwise, we will get stuck keys in the
-                     * guest when doing sendChangedKeyStates() on resume because
-                     * key presses were already recorded in mPressedKeys but key
-                     * releases will most likely not reach us but the new focus
-                     * window instead). */
-                    releaseAllPressedKeys (true /* aReleaseHostKey */);
-                }
-                break;
-            }
-
-            case VBoxDefs::ResizeEventType:
-            {
-                /* Some situations require initial VGA Resize Request
-                 * to be ignored at all, leaving previous framebuffer,
-                 * console widget and vm window size preserved. */
-                if (mIgnoreGuestResize)
-                    return true;
-
-                bool oldIgnoreMainwndResize = mIgnoreMainwndResize;
-                mIgnoreMainwndResize = true;
-
-                VBoxResizeEvent *re = (VBoxResizeEvent *) e;
-                LogRelFlowFunc (("VBoxDefs::ResizeEventType: %d x %d x %d bpp\n",
-                                 re->width(), re->height(),
-                                 re->bitsPerPixel()));
-
-                bool notifyMainWnd = mFrameBuf->width() != re->width()
-                        || mFrameBuf->height() != re->height();
-
-                /* Store the new size to prevent unwanted resize hints being
-                 * sent back. */
-                storeConsoleSize(re->width(), re->height());
-                /* do frame buffer dependent resize */
-
-                /* restoreOverrideCursor() is broken in Qt 4.4.0 if WA_PaintOnScreen
-                 * widgets are present. This is the case on linux with SDL. As
-                 * workaround we restore the arrow cursor manually after the resize. See
-                 * http://trolltech.com/developer/task-tracker/index_html?id=206165&method=entry
-                 * for details.
-                 */
-                QCursor cursor;
-                mFrameBuf->resizeEvent (re);
-                updateHostCursor();
-
-#ifdef Q_WS_MAC
-                mDockIconPreview->setOriginalSize (re->width(), re->height());
-#endif /* Q_WS_MAC */
-
-                /* This event appears in case of guest video was changed
-                 * for somehow even without video resolution change.
-                 * In this last case the host VM window will not be resized
-                 * according this event and the host mouse cursor which was
-                 * unset to default here will not be hidden in capture state.
-                 * So it is necessary to perform updateMouseClipping() for
-                 * the guest resize event if the mouse cursor was captured. */
-                if (mMouseCaptured)
-                    updateMouseClipping();
-
-                /* apply maximum size restriction */
-                setMaximumSize (sizeHint());
-
-                maybeRestrictMinimumSize();
-
-                /* resize the guest canvas */
-                if (!mIgnoreFrameBufferResize)
-                    resize (re->width(), re->height());
-                updateSliders();
-                /* Let our toplevel widget calculate its sizeHint properly. */
-#ifdef Q_WS_X11
-                /* We use processEvents rather than sendPostedEvents & set the
-                 * time out value to max cause on X11 otherwise the layout
-                 * isn't calculated correctly. Dosn't find the bug in Qt, but
-                 * this could be triggered through the async nature of the X11
-                 * window event system. */
-                QCoreApplication::processEvents (QEventLoop::AllEvents, INT_MAX);
-#else /* Q_WS_X11 */
-                QCoreApplication::sendPostedEvents (0, QEvent::LayoutRequest);
-#endif /* Q_WS_X11 */
-
-                if (!mIgnoreFrameBufferResize)
-                    normalizeGeometry (true /* adjustPosition */);
-
-                /* report to the VM thread that we finished resizing */
-                mConsole.GetDisplay().ResizeCompleted (0);
-
-                mIgnoreMainwndResize = oldIgnoreMainwndResize;
-
-                /* update geometry after entering fullscreen | seamless */
-                if (mMainWnd->isTrueFullscreen() || mMainWnd->isTrueSeamless())
-                    updateGeometry();
-
-                /* make sure that all posted signals are processed */
-                qApp->processEvents();
-
-                /* emit a signal about guest was resized */
-                emit resizeHintDone();
-
-                /* We also recalculate the desktop geometry if this is determined
-                 * automatically.  In fact, we only need this on the first resize,
-                 * but it is done every time to keep the code simpler. */
-                calculateDesktopGeometry();
-
-                /* Enable frame-buffer resize watching. */
-                if (mIgnoreFrameBufferResize)
-                {
-                    mIgnoreFrameBufferResize = false;
-                }
-
-                if (notifyMainWnd)
-                    mMainWnd->onDisplayResize (re->width(), re->height());
-
-                return true;
-            }
-
-            /* See VBox[QImage|SDL]FrameBuffer::NotifyUpdate(). */
-            case VBoxDefs::RepaintEventType:
-            {
-                VBoxRepaintEvent *re = (VBoxRepaintEvent *) e;
-                viewport()->repaint (re->x() - contentsX(),
-                                     re->y() - contentsY(),
-                                     re->width(), re->height());
-                /* mConsole.GetDisplay().UpdateCompleted(); - the event was acked already */
-                return true;
-            }
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-            case VBoxDefs::VHWACommandProcessType:
-            {
-                mFrameBuf->doProcessVHWACommand(e);
-                return true;
-            }
-#endif
-
-            case VBoxDefs::SetRegionEventType:
-            {
-                VBoxSetRegionEvent *sre = (VBoxSetRegionEvent*) e;
-                if (mMainWnd->isTrueSeamless() &&
-                    sre->region() != mLastVisibleRegion)
-                {
-                    mLastVisibleRegion = sre->region();
-                    mMainWnd->setMask (sre->region());
-                }
-                else if (!mLastVisibleRegion.isEmpty() &&
-                         !mMainWnd->isTrueSeamless())
-                    mLastVisibleRegion = QRegion();
-                return true;
-            }
-
-            case VBoxDefs::MousePointerChangeEventType:
-            {
-                MousePointerChangeEvent *me = (MousePointerChangeEvent *) e;
-                /* change cursor shape only when mouse integration is
-                 * supported (change mouse shape type event may arrive after
-                 * mouse capability change that disables integration */
-                if (mMouseCanAbsolute)
-                    setPointerShape (me);
-                else
-                    /* Note: actually we should still remember the requested
-                     * cursor shape.  If we can't do that, at least remember
-                     * the requested visiblilty. */
-                    mHideHostPointer = !me->isVisible();
-                return true;
-            }
-            case VBoxDefs::MouseCapabilityEventType:
-            {
-                MouseCapabilityEvent *me = (MouseCapabilityEvent *) e;
-                if (mMouseCanAbsolute != me->supportsAbsolute())
-                {
-                    mMouseCanAbsolute = me->supportsAbsolute();
-                    /* correct the mouse capture state and reset the cursor
-                     * to the default shape if necessary */
-                    if (mMouseCanAbsolute)
-                    {
-                        CMouse mouse = mConsole.GetMouse();
-                        mouse.PutMouseEventAbsolute (-1, -1, 0,
-                                                     0 /* Horizontal wheel */,
-                                                     0);
-                        captureMouse (false, false);
-                    }
-                    updateHostCursor();
-                    emitMouseStateChanged();
-                    vboxProblem().remindAboutMouseIntegration (mMouseCanAbsolute);
-                }
-                mMouseCanRelative = me->supportsRelative();
-                mMouseNeedsHostCursor = me->needsHostCursor();
-                if (!me->supportsRelative() || me->needsHostCursor())
-                    mMainWnd->setMouseIntegrationLocked (false);
-                else
-                    mMainWnd->setMouseIntegrationLocked (true);
-                return true;
-            }
-
-            case VBoxDefs::ModifierKeyChangeEventType:
-            {
-                ModifierKeyChangeEvent *me = (ModifierKeyChangeEvent* )e;
-                if (me->numLock() != mNumLock)
-                    muNumLockAdaptionCnt = 2;
-                if (me->capsLock() != mCapsLock)
-                    muCapsLockAdaptionCnt = 2;
-                mNumLock    = me->numLock();
-                mCapsLock   = me->capsLock();
-                mScrollLock = me->scrollLock();
-                return true;
-            }
-
-            case VBoxDefs::MachineStateChangeEventType:
-            {
-                StateChangeEvent *me = (StateChangeEvent *) e;
-                LogFlowFunc (("MachineStateChangeEventType: state=%d\n",
-                               me->machineState()));
-                onStateChange (me->machineState());
-                emit machineStateChanged (me->machineState());
-                return true;
-            }
-
-            case VBoxDefs::AdditionsStateChangeEventType:
-            {
-                GuestAdditionsEvent *ge = (GuestAdditionsEvent *) e;
-                LogFlowFunc (("AdditionsStateChangeEventType\n"));
-
-                /* Always send a size hint if we are in fullscreen or seamless
-                 * when the graphics capability is enabled, in case the host
-                 * resolution has changed since the VM was last run. */
-#if 0
-                if (!mDoResize && !mGuestSupportsGraphics &&
-                    ge->supportsGraphics() &&
-                    (mMainWnd->isTrueSeamless() || mMainWnd->isTrueFullscreen()))
-                    mDoResize = true;
-#endif
-
-                mGuestSupportsGraphics = ge->supportsGraphics();
-
-                maybeRestrictMinimumSize();
-
-#if 0
-                /* This will only be acted upon if mDoResize is true. */
-                doResizeHint();
-#endif
-
-                emit additionsStateChanged (ge->additionVersion(),
-                                            ge->additionActive(),
-                                            ge->supportsSeamless(),
-                                            ge->supportsGraphics());
-                return true;
-            }
-
-            case VBoxDefs::MediaDriveChangeEventType:
-            {
-                MediaDriveChangeEvent *mce = (MediaDriveChangeEvent *) e;
-                LogFlowFunc (("MediaChangeEvent\n"));
-
-                emit mediaDriveChanged (mce->type());
-                return true;
-            }
-
-            case VBoxDefs::ActivateMenuEventType:
-            {
-                ActivateMenuEvent *ame = (ActivateMenuEvent *) e;
-                ame->action()->trigger();
-
-                /*
-                 *  The main window and its children can be destroyed at this
-                 *  point (if, for example, the activated menu item closes the
-                 *  main window). Detect this situation to prevent calls to
-                 *  destroyed widgets.
-                 */
-                QWidgetList list = QApplication::topLevelWidgets();
-                bool destroyed = list.indexOf (mMainWnd) < 0;
-                if (!destroyed && mMainWnd->statusBar())
-                    mMainWnd->statusBar()->clearMessage();
-
-                return true;
-            }
-
-            case VBoxDefs::NetworkAdapterChangeEventType:
-            {
-                /* no specific adapter information stored in this
-                 * event is currently used */
-                emit networkStateChange();
-                return true;
-            }
-
-            case VBoxDefs::USBCtlStateChangeEventType:
-            {
-                emit usbStateChange();
-                return true;
-            }
-
-            case VBoxDefs::USBDeviceStateChangeEventType:
-            {
-                USBDeviceStateChangeEvent *ue = (USBDeviceStateChangeEvent *)e;
-
-                bool success = ue->error().isNull();
-
-                if (!success)
-                {
-                    if (ue->attached())
-                        vboxProblem().cannotAttachUSBDevice (
-                            mConsole,
-                            vboxGlobal().details (ue->device()), ue->error());
-                    else
-                        vboxProblem().cannotDetachUSBDevice (
-                            mConsole,
-                            vboxGlobal().details (ue->device()), ue->error());
-                }
-
-                emit usbStateChange();
-
-                return true;
-            }
-
-            case VBoxDefs::SharedFolderChangeEventType:
-            {
-                emit sharedFoldersChanged();
-                return true;
-            }
-
-            case VBoxDefs::RuntimeErrorEventType:
-            {
-                RuntimeErrorEvent *ee = (RuntimeErrorEvent *) e;
-                vboxProblem().showRuntimeError (mConsole, ee->fatal(),
-                                                ee->errorID(), ee->message());
-                return true;
-            }
-
-            case QEvent::KeyPress:
-            case QEvent::KeyRelease:
-            {
-                QKeyEvent *ke = (QKeyEvent *) e;
-
-#ifdef Q_WS_PM
-                /// @todo temporary solution to send Alt+Tab and friends to
-                //  the guest. The proper solution is to write a keyboard
-                //  driver that will steal these combos from the host (it's
-                //  impossible to do so using hooks on OS/2).
-
-                if (mIsHostkeyPressed)
-                {
-                    bool pressed = e->type() == QEvent::KeyPress;
-                    CKeyboard keyboard = mConsole.GetKeyboard();
-
-                    /* whether the host key is Shift so that it will modify
-                     * the hot key values? Note that we don't distinguish
-                     * between left and right shift here (too much hassle) */
-                    const bool kShift = (gs.hostKey() == VK_SHIFT ||
-                                        gs.hostKey() == VK_LSHIFT) &&
-                                        (ke->state() & Qt::ShiftModifier);
-                    /* define hot keys according to the Shift state */
-                    const int kAltTab      = kShift ? Qt::Key_Exclam     : Qt::Key_1;
-                    const int kAltShiftTab = kShift ? Qt::Key_At         : Qt::Key_2;
-                    const int kCtrlEsc     = kShift ? Qt::Key_AsciiTilde : Qt::Key_QuoteLeft;
-
-                    /* Simulate Alt+Tab on Host+1 and Alt+Shift+Tab on Host+2 */
-                    if (ke->key() == kAltTab || ke->key() == kAltShiftTab)
-                    {
-                        if (pressed)
-                        {
-                            /* Send the Alt press to the guest */
-                            if (!(mPressedKeysCopy [0x38] & IsKeyPressed))
-                            {
-                                /* store the press in *Copy to have it automatically
-                                 * released when the Host key is released */
-                                mPressedKeysCopy [0x38] |= IsKeyPressed;
-                                keyboard.PutScancode (0x38);
-                            }
-
-                            /* Make sure Shift is pressed if it's Key_2 and released
-                             * if it's Key_1 */
-                            if (ke->key() == kAltTab &&
-                                (mPressedKeysCopy [0x2A] & IsKeyPressed))
-                            {
-                                mPressedKeysCopy [0x2A] &= ~IsKeyPressed;
-                                keyboard.PutScancode (0xAA);
-                            }
-                            else
-                            if (ke->key() == kAltShiftTab &&
-                                !(mPressedKeysCopy [0x2A] & IsKeyPressed))
-                            {
-                                mPressedKeysCopy [0x2A] |= IsKeyPressed;
-                                keyboard.PutScancode (0x2A);
-                            }
-                        }
-
-                        keyboard.PutScancode (pressed ? 0x0F : 0x8F);
-
-                        ke->accept();
-                        return true;
-                    }
-
-                    /* Simulate Ctrl+Esc on Host+Tilde */
-                    if (ke->key() == kCtrlEsc)
-                    {
-                        /* Send the Ctrl press to the guest */
-                        if (pressed && !(mPressedKeysCopy [0x1d] & IsKeyPressed))
-                        {
-                            /* store the press in *Copy to have it automatically
-                             * released when the Host key is released */
-                            mPressedKeysCopy [0x1d] |= IsKeyPressed;
-                            keyboard.PutScancode (0x1d);
-                        }
-
-                        keyboard.PutScancode (pressed ? 0x01 : 0x81);
-
-                        ke->accept();
-                        return true;
-                    }
-                }
-
-                /* fall through to normal processing */
-
-#endif /* Q_WS_PM */
-
-                if (mIsHostkeyPressed && e->type() == QEvent::KeyPress)
-                {
-                    if (ke->key() >= Qt::Key_F1 && ke->key() <= Qt::Key_F12)
-                    {
-                        QVector <LONG> combo (6);
-                        combo [0] = 0x1d; /* Ctrl down */
-                        combo [1] = 0x38; /* Alt  down */
-                        combo [4] = 0xb8; /* Alt  up   */
-                        combo [5] = 0x9d; /* Ctrl up   */
-                        if (ke->key() >= Qt::Key_F1 && ke->key() <= Qt::Key_F10)
-                        {
-                            combo [2] = 0x3b + (ke->key() - Qt::Key_F1); /* F1-F10 down */
-                            combo [3] = 0xbb + (ke->key() - Qt::Key_F1); /* F1-F10 up   */
-                        }
-                        /* some scan slice */
-                        else if (ke->key() >= Qt::Key_F11 && ke->key() <= Qt::Key_F12)
-                        {
-                            combo [2] = 0x57 + (ke->key() - Qt::Key_F11); /* F11-F12 down */
-                            combo [3] = 0xd7 + (ke->key() - Qt::Key_F11); /* F11-F12 up   */
-                        }
-                        else
-                            Assert (0);
-
-                        CKeyboard keyboard = mConsole.GetKeyboard();
-                        keyboard.PutScancodes (combo);
-                    }
-                    else if (ke->key() == Qt::Key_Home)
-                    {
-                        /* Activate the main menu */
-                        if (mMainWnd->isTrueSeamless() || mMainWnd->isTrueFullscreen())
-                            mMainWnd->popupMainMenu (mMouseCaptured);
-                        else
-                        {
-                            /* In Qt4 it is not enough to just set the focus to
-                             * menu-bar. So to get the menu-bar we have to send
-                             * Qt::Key_Alt press/release events directly. */
-                            QKeyEvent e1 (QEvent::KeyPress, Qt::Key_Alt,
-                                          Qt::NoModifier);
-                            QKeyEvent e2 (QEvent::KeyRelease, Qt::Key_Alt,
-                                          Qt::NoModifier);
-                            QApplication::sendEvent (mMainWnd->menuBar(), &e1);
-                            QApplication::sendEvent (mMainWnd->menuBar(), &e2);
-                        }
-                    }
-                    else
-                    {
-                        /* process hot keys not processed in keyEvent()
-                         * (as in case of non-alphanumeric keys) */
-                        processHotKey (QKeySequence (ke->key()),
-                                       mMainWnd->menuBar()->actions());
-                    }
-                }
-                else if (!mIsHostkeyPressed && e->type() == QEvent::KeyRelease)
-                {
-                    /* Show a possible warning on key release which seems to
-                     * be more expected by the end user */
-
-                    if (isPaused())
-                    {
-                        /* if the reminder is disabled we pass the event to
-                         * Qt to enable normal keyboard functionality
-                         * (for example, menu access with Alt+Letter) */
-                        if (!vboxProblem().remindAboutPausedVMInput())
-                            break;
-                    }
-                }
-
-                ke->accept();
-                return true;
-            }
-
-#ifdef Q_WS_MAC
-            /* posted OnShowWindow */
-            case VBoxDefs::ShowWindowEventType:
-            {
-                /*
-                 *  Dunno what Qt3 thinks a window that has minimized to the dock
-                 *  should be - it is not hidden, neither is it minimized. OTOH it is
-                 *  marked shown and visible, but not activated. This latter isn't of
-                 *  much help though, since at this point nothing is marked activated.
-                 *  I might have overlooked something, but I'm buggered what if I know
-                 *  what. So, I'll just always show & activate the stupid window to
-                 *  make it get out of the dock when the user wishes to show a VM.
-                 */
-                window()->show();
-                window()->activateWindow();
-                return true;
-            }
-#endif
-            default:
-                break;
-        }
-    }
-
-    return QAbstractScrollArea::event (e);
-}
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-void VBoxConsoleView::scrollContentsBy (int dx, int dy)
-{
-    if (mAttached && mFrameBuf)
-    {
-        mFrameBuf->viewportScrolled(dx, dy);
-    }
-    QAbstractScrollArea::scrollContentsBy (dx, dy);
-}
-#endif
-
-
-bool VBoxConsoleView::eventFilter (QObject *watched, QEvent *e)
-{
-    if (mAttached && watched == viewport())
-    {
-        switch (e->type())
-        {
-            case QEvent::MouseMove:
-            case QEvent::MouseButtonPress:
-            case QEvent::MouseButtonDblClick:
-            case QEvent::MouseButtonRelease:
-            {
-                QMouseEvent *me = (QMouseEvent *) e;
-                m_iLastMouseWheelDelta = 0;
-                if (mouseEvent (me->type(), me->pos(), me->globalPos(),
-                                me->buttons(), me->modifiers(),
-                                0, Qt::Horizontal))
-                    return true; /* stop further event handling */
-                break;
-            }
-            case QEvent::Wheel:
-            {
-                QWheelEvent *we = (QWheelEvent *) e;
-                /* There are pointing devices which send smaller values for the
-                 * delta than 120. Here we sum them up until we are greater
-                 * than 120. This allows to have finer control over the speed
-                 * acceleration & enables such devices to send a valid wheel
-                 * event to our guest mouse device at all. */
-                int iDelta = 0;
-                m_iLastMouseWheelDelta += we->delta();
-                if (qAbs(m_iLastMouseWheelDelta) >= 120)
-                {
-                    iDelta = m_iLastMouseWheelDelta;
-                    m_iLastMouseWheelDelta = m_iLastMouseWheelDelta % 120;
-                }
-                if (mouseEvent (we->type(), we->pos(), we->globalPos(),
-#ifdef QT_MAC_USE_COCOA
-                                /* Qt Cocoa is buggy. It always reports a left
-                                 * button pressed when the mouse wheel event
-                                 * occurs. A workaround is to ask the
-                                 * application which buttons are pressed
-                                 * currently. */
-                                QApplication::mouseButtons(),
-#else /* QT_MAC_USE_COCOA */
-                                we->buttons(),
-#endif /* QT_MAC_USE_COCOA */
-                                we->modifiers(),
-                                iDelta, we->orientation()))
-                    return true; /* stop further event handling */
-                break;
-            }
-#ifdef Q_WS_MAC
-            case QEvent::Leave:
-            {
-                /* Enable mouse event compression if we leave the VM view. This
-                   is necessary for having smooth resizing of the VM/other
-                   windows. */
-                setMouseCoalescingEnabled (true);
-                break;
-            }
-            case QEvent::Enter:
-            {
-                /* Disable mouse event compression if we enter the VM view. So
-                   all mouse events are registered in the VM. Only do this if
-                   the keyboard/mouse is grabbed (this is when we have a valid
-                   event handler). */
-                setMouseCoalescingEnabled (false);
-                break;
-            }
-#endif /* Q_WS_MAC */
-            case QEvent::Resize:
-            {
-                if (mMouseCaptured)
-                    updateMouseClipping();
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                if (mFrameBuf)
-                {
-                    mFrameBuf->viewportResized((QResizeEvent*)e);
-                }
-#endif
-                break;
-            }
-            default:
-                break;
-        }
-    }
-    else if (watched == mMainWnd)
-    {
-        switch (e->type())
-        {
-#if defined (Q_WS_WIN32)
-#if defined (VBOX_GUI_USE_DDRAW)
-            case QEvent::Move:
-            {
-                /*
-                 *  notification from our parent that it has moved. We need this
-                 *  in order to possibly adjust the direct screen blitting.
-                 */
-                if (mFrameBuf)
-                    mFrameBuf->moveEvent ((QMoveEvent *) e);
-                break;
-            }
-#endif
-            /*
-             *  install/uninstall low-level kbd hook on every
-             *  activation/deactivation to:
-             *  a) avoid excess hook calls when we're not active and
-             *  b) be always in front of any other possible hooks
-             */
-            case QEvent::WindowActivate:
-            {
-                gKbdHook = SetWindowsHookEx (WH_KEYBOARD_LL, lowLevelKeyboardProc,
-                                              GetModuleHandle (NULL), 0);
-                AssertMsg (gKbdHook, ("SetWindowsHookEx(): err=%d", GetLastError()));
-                break;
-            }
-            case QEvent::WindowDeactivate:
-            {
-                if (gKbdHook)
-                {
-                    UnhookWindowsHookEx (gKbdHook);
-                    gKbdHook = NULL;
-                }
-                break;
-            }
-#endif /* defined (Q_WS_WIN32) */
-#if defined (Q_WS_MAC)
-            /*
-             *  Install/remove the keyboard event handler.
-             */
-            case QEvent::WindowActivate:
-                darwinGrabKeyboardEvents (true);
-                break;
-            case QEvent::WindowDeactivate:
-                darwinGrabKeyboardEvents (false);
-                break;
-#endif /* defined (Q_WS_MAC) */
-            case QEvent::Resize:
-            {
-                /* Set the "guest needs to resize" hint.  This hint is acted upon
-                 * when (and only when) the autoresize property is "true". */
-                mDoResize = mGuestSupportsGraphics || mMainWnd->isTrueFullscreen();
-                if (!mIgnoreMainwndResize &&
-                    mGuestSupportsGraphics && mAutoresizeGuest)
-                    QTimer::singleShot (300, this, SLOT (doResizeHint()));
-                break;
-            }
-            case QEvent::WindowStateChange:
-            {
-                /* During minimizing and state restoring mMainWnd gets the focus
-                 * which belongs to console view window, so returning it properly. */
-                QWindowStateChangeEvent *ev = static_cast <QWindowStateChangeEvent*> (e);
-                if (ev->oldState() & Qt::WindowMinimized)
-                {
-                    if (QApplication::focusWidget())
-                    {
-                        QApplication::focusWidget()->clearFocus();
-                        qApp->processEvents();
-                    }
-                    QTimer::singleShot (0, this, SLOT (setFocus()));
-                }
-                break;
-            }
-
-            default:
-                break;
-        }
-    }
-    else if (watched == mMainWnd->menuBar())
-    {
-        /*
-         *  sometimes when we press ESC in the menu it brings the
-         *  focus away (Qt bug?) causing no widget to have a focus,
-         *  or holds the focus itself, instead of returning the focus
-         *  to the console window. here we fix this.
-         */
-        switch (e->type())
-        {
-            case QEvent::FocusOut:
-            {
-                if (qApp->focusWidget() == 0)
-                    setFocus();
-                break;
-            }
-            case QEvent::KeyPress:
-            {
-                QKeyEvent *ke = (QKeyEvent *) e;
-                if (ke->key() == Qt::Key_Escape && (ke->modifiers() == Qt::NoModifier))
-                    if (mMainWnd->menuBar()->hasFocus())
-                        setFocus();
-                break;
-            }
-            default:
-                break;
-        }
-    }
-
-    return QAbstractScrollArea::eventFilter (watched, e);
-}
-
-#if defined(Q_WS_WIN32)
-
-/**
- *  Low-level keyboard event handler,
- *  @return
- *      true to indicate that the message is processed and false otherwise
- */
-bool VBoxConsoleView::winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event)
-{
-#if 0
-    LogFlow (("### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X (mKbdCaptured=%d)\n",
-              event.vkCode, event.scanCode, event.flags, event.dwExtraInfo, mKbdCaptured));
-    char buf [256];
-    sprintf (buf, "### vkCode=%08X, scanCode=%08X, flags=%08X, dwExtraInfo=%08X",
-             event.vkCode, event.scanCode, event.flags, event.dwExtraInfo);
-    mMainWnd->statusBar()->message (buf);
-#endif
-
-    /* Sometimes it happens that Win inserts additional events on some key
-     * press/release. For example, it prepends ALT_GR in German layout with
-     * the VK_LCONTROL vkey with curious 0x21D scan code (seems to be necessary
-     * to specially treat ALT_GR to enter additional chars to regular apps).
-     * These events are definitely unwanted in VM, so filter them out. */
-    /* Note (michael): it also sometimes sends the VK_CAPITAL vkey with scan
-     * code 0x23a. If this is not passed through then it is impossible to
-     * cancel CapsLock on a French keyboard.  I didn't find any other examples
-     * of these strange events.  Let's hope we are not missing anything else
-     * of importance! */
-    if (hasFocus() && (event.scanCode & ~0xFF))
-    {
-        if (event.vkCode == VK_CAPITAL)
-            return false;
-        else
-            return true;
-    }
-
-    if (!mKbdCaptured)
-        return false;
-
-    /* it's possible that a key has been pressed while the keyboard was not
-     * captured, but is being released under the capture. Detect this situation
-     * and return false to let Windows process the message normally and update
-     * its key state table (to avoid the stuck key effect). */
-    uint8_t what_pressed = (event.flags & 0x01) && (event.vkCode != VK_RSHIFT)
-                           ? IsExtKeyPressed
-                           : IsKeyPressed;
-    if ((event.flags & 0x80) /* released */ &&
-        ((event.vkCode == gs.hostKey() && !hostkey_in_capture) ||
-         (mPressedKeys [event.scanCode] & (IsKbdCaptured | what_pressed)) == what_pressed))
-        return false;
-
-    MSG message;
-    message.hwnd = winId();
-    message.message = msg;
-    message.wParam = event.vkCode;
-    message.lParam =
-        1 |
-        (event.scanCode & 0xFF) << 16 |
-        (event.flags & 0xFF) << 24;
-
-    /* Windows sets here the extended bit when the Right Shift key is pressed,
-     * which is totally wrong. Undo it. */
-    if (event.vkCode == VK_RSHIFT)
-        message.lParam &= ~0x1000000;
-
-    /* we suppose here that this hook is always called on the main GUI thread */
-    long dummyResult;
-    return winEvent (&message, &dummyResult);
-}
-
-/**
- * Get Win32 messages before they are passed to Qt. This allows us to get
- * the keyboard events directly and bypass the harmful Qt translation. A
- * return value of @c true indicates to Qt that the event has been handled.
- */
-bool VBoxConsoleView::winEvent (MSG *aMsg, long* /* aResult */)
-{
-    if (!mAttached || ! (
-        aMsg->message == WM_KEYDOWN || aMsg->message == WM_SYSKEYDOWN ||
-        aMsg->message == WM_KEYUP || aMsg->message == WM_SYSKEYUP
-    ))
-        return false;
-
-    /* check for the special flag possibly set at the end of this function */
-    if (aMsg->lParam & (0x1 << 25))
-    {
-        aMsg->lParam &= ~(0x1 << 25);
-        return false;
-    }
-
-#if 0
-    char buf [256];
-    sprintf (buf, "WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d rzv=%01X ctx=%01d prev=%01d tran=%01d",
-             aMsg->message, aMsg->wParam,
-             (aMsg->lParam & 0xFFFF),
-             ((aMsg->lParam >> 16) & 0xFF),
-             ((aMsg->lParam >> 24) & 0x1),
-             ((aMsg->lParam >> 25) & 0xF),
-             ((aMsg->lParam >> 29) & 0x1),
-             ((aMsg->lParam >> 30) & 0x1),
-             ((aMsg->lParam >> 31) & 0x1));
-    mMainWnd->statusBar()->message (buf);
-    LogFlow (("%s\n", buf));
-#endif
-
-    int scan = (aMsg->lParam >> 16) & 0x7F;
-    /* scancodes 0x80 and 0x00 are ignored */
-    if (!scan)
-        return true;
-
-    int vkey = aMsg->wParam;
-
-    /* When one of the SHIFT keys is held and one of the cursor movement
-     * keys is pressed, Windows duplicates SHIFT press/release messages,
-     * but with the virtual key code set to 0xFF. These virtual keys are also
-     * sent in some other situations (Pause, PrtScn, etc.). Ignore such
-     * messages. */
-    if (vkey == 0xFF)
-        return true;
-
-    int flags = 0;
-    if (aMsg->lParam & 0x1000000)
-        flags |= KeyExtended;
-    if (!(aMsg->lParam & 0x80000000))
-        flags |= KeyPressed;
-
-    switch (vkey)
-    {
-        case VK_SHIFT:
-        case VK_CONTROL:
-        case VK_MENU:
-        {
-            /* overcome stupid Win32 modifier key generalization */
-            int keyscan = scan;
-            if (flags & KeyExtended)
-                keyscan |= 0xE000;
-            switch (keyscan)
-            {
-                case 0x002A: vkey = VK_LSHIFT; break;
-                case 0x0036: vkey = VK_RSHIFT; break;
-                case 0x001D: vkey = VK_LCONTROL; break;
-                case 0xE01D: vkey = VK_RCONTROL; break;
-                case 0x0038: vkey = VK_LMENU; break;
-                case 0xE038: vkey = VK_RMENU; break;
-            }
-            break;
-        }
-        case VK_NUMLOCK:
-            /* Win32 sets the extended bit for the NumLock key. Reset it. */
-            flags &= ~KeyExtended;
-            break;
-        case VK_SNAPSHOT:
-            flags |= KeyPrint;
-            break;
-        case VK_PAUSE:
-            flags |= KeyPause;
-            break;
-    }
-
-    bool result = keyEvent (vkey, scan, flags);
-    if (!result && mKbdCaptured)
-    {
-        /* keyEvent() returned that it didn't process the message, but since the
-         * keyboard is captured, we don't want to pass it to Windows. We just want
-         * to let Qt process the message (to handle non-alphanumeric <HOST>+key
-         * shortcuts for example). So send it direcltly to the window with the
-         * special flag in the reserved area of lParam (to avoid recursion). */
-        ::SendMessage (aMsg->hwnd, aMsg->message,
-                       aMsg->wParam, aMsg->lParam | (0x1 << 25));
-        return true;
-    }
-
-    /* These special keys have to be handled by Windows as well to update the
-     * internal modifier state and to enable/disable the keyboard LED */
-    if (vkey == VK_NUMLOCK || vkey == VK_CAPITAL || vkey == VK_LSHIFT || vkey == VK_RSHIFT)
-        return false;
-
-    return result;
-}
-
-#elif defined (Q_WS_PM)
-
-/**
- *  Get PM messages before they are passed to Qt. This allows us to get
- *  the keyboard events directly and bypass the harmful Qt translation. A
- *  return value of @c true indicates to Qt that the event has been handled.
- */
-bool VBoxConsoleView::pmEvent (QMSG *aMsg)
-{
-    if (!mAttached)
-        return false;
-
-    if (aMsg->msg == UM_PREACCEL_CHAR)
-    {
-        /* we are inside the input hook */
-
-        /* let the message go through the normal system pipeline */
-        if (!mKbdCaptured)
-            return false;
-    }
-
-    if (aMsg->msg != WM_CHAR &&
-        aMsg->msg != UM_PREACCEL_CHAR)
-        return false;
-
-    /* check for the special flag possibly set at the end of this function */
-    if (SHORT2FROMMP (aMsg->mp2) & 0x8000)
-    {
-        aMsg->mp2 = MPFROM2SHORT (SHORT1FROMMP (aMsg->mp2),
-                                  SHORT2FROMMP (aMsg->mp2) & ~0x8000);
-        return false;
-    }
-
-#if 0
-    {
-        char buf [256];
-        sprintf (buf, "*** %s: f=%04X rep=%03d scan=%02X ch=%04X vk=%04X",
-                 (aMsg->msg == WM_CHAR ? "WM_CHAR" : "UM_PREACCEL_CHAR"),
-                 SHORT1FROMMP (aMsg->mp1), CHAR3FROMMP (aMsg->mp1),
-                 CHAR4FROMMP (aMsg->mp1), SHORT1FROMMP (aMsg->mp2),
-                 SHORT2FROMMP (aMsg->mp2));
-        mMainWnd->statusBar()->message (buf);
-        LogFlow (("%s\n", buf));
-    }
-#endif
-
-    USHORT ch = SHORT1FROMMP (aMsg->mp2);
-    USHORT f = SHORT1FROMMP (aMsg->mp1);
-
-    int scan = (unsigned int) CHAR4FROMMP (aMsg->mp1);
-    if (!scan || scan > 0x7F)
-        return true;
-
-    int vkey = QIHotKeyEdit::virtualKey (aMsg);
-
-    int flags = 0;
-
-    if ((ch & 0xFF) == 0xE0)
-    {
-        flags |= KeyExtended;
-        scan = ch >> 8;
-    }
-    else if (scan == 0x5C && (ch & 0xFF) == '/')
-    {
-        /* this is the '/' key on the keypad */
-        scan = 0x35;
-        flags |= KeyExtended;
-    }
-    else
-    {
-        /* For some keys, the scan code passed in QMSG is a pseudo scan
-         * code. We replace it with a real hardware scan code, according to
-         * http://www.computer-engineering.org/ps2keyboard/scancodes1.html.
-         * Also detect Pause and PrtScn and set flags. */
-        switch (vkey)
-        {
-            case VK_ENTER:     scan = 0x1C; flags |= KeyExtended; break;
-            case VK_CTRL:      scan = 0x1D; flags |= KeyExtended; break;
-            case VK_ALTGRAF:   scan = 0x38; flags |= KeyExtended; break;
-            case VK_LWIN:      scan = 0x5B; flags |= KeyExtended; break;
-            case VK_RWIN:      scan = 0x5C; flags |= KeyExtended; break;
-            case VK_WINMENU:   scan = 0x5D; flags |= KeyExtended; break;
-            case VK_FORWARD:   scan = 0x69; flags |= KeyExtended; break;
-            case VK_BACKWARD:  scan = 0x6A; flags |= KeyExtended; break;
-#if 0
-            /// @todo this would send 0xE0 0x46 0xE0 0xC6. It's not fully
-            // clear what is more correct
-            case VK_BREAK:     scan = 0x46; flags |= KeyExtended; break;
-#else
-            case VK_BREAK:     scan = 0;    flags |= KeyPause; break;
-#endif
-            case VK_PAUSE:     scan = 0;    flags |= KeyPause;    break;
-            case VK_PRINTSCRN: scan = 0;    flags |= KeyPrint;    break;
-            default:;
-        }
-    }
-
-    if (!(f & KC_KEYUP))
-        flags |= KeyPressed;
-
-    bool result = keyEvent (vkey, scan, flags);
-    if (!result && mKbdCaptured)
-    {
-        /* keyEvent() returned that it didn't process the message, but since the
-         * keyboard is captured, we don't want to pass it to PM. We just want
-         * to let Qt process the message (to handle non-alphanumeric <HOST>+key
-         * shortcuts for example). So send it direcltly to the window with the
-         * special flag in the reserved area of lParam (to avoid recursion). */
-        ::WinSendMsg (aMsg->hwnd, WM_CHAR,
-                      aMsg->mp1,
-                      MPFROM2SHORT (SHORT1FROMMP (aMsg->mp2),
-                                    SHORT2FROMMP (aMsg->mp2) | 0x8000));
-        return true;
-    }
-    return result;
-}
-
-#elif defined(Q_WS_X11)
-
-/**
- * This function is a "predicate" for XCheckIfEvent().  It will check
- * the XEvent passed to it to see if it is a keypress event matching
- * the keyrelease event in @a pvArg.
- * @returns True if the event matches, False otherwise
- * @param   pEvent    the event to compare, taken from the event queue
- * @param   pvArg     the keyrelease event we would like to compare against
- */
-static Bool VBoxConsoleViewCompEvent(Display *, XEvent *pEvent,
-                                     XPointer pvArg)
-{
-    XEvent *pKeyEvent = (XEvent *) pvArg;
-    if ((pEvent->type == XKeyPress) &&
-        (pEvent->xkey.keycode == pKeyEvent->xkey.keycode))
-        return True;
-    else
-        return False;
-}
-
-/**
- *  This routine gets X11 events before they are processed by Qt. This is
- *  used for our platform specific keyboard implementation. A return value
- *  of TRUE indicates that the event has been processed by us.
- */
-bool VBoxConsoleView::x11Event (XEvent *event)
-{
-    switch (event->type)
-    {
-        /* We have to handle XFocusOut right here as this event is not passed
-         * to VBoxConsoleView::event(). Handling this event is important for
-         * releasing the keyboard before the screen saver gets active.
-         *
-         * See public ticket #3894: Apparently this makes problems with newer
-         * versions of Qt and this hack is probably not necessary anymore.
-         * So disable it for Qt >= 4.5.0. */
-        case XFocusOut:
-        case XFocusIn:
-            if (isRunning())
-            {
-                if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
-                    focusEvent (event->type == XFocusIn);
-            }
-            return false;
-        case XKeyPress:
-        case XKeyRelease:
-            if (mAttached)
-                break;
-            /*  else fall through */
-        default:
-            return false; /* pass the event to Qt */
-    }
-
-    /* Translate the keycode to a PC scan code. */
-    unsigned scan = handleXKeyEvent (event);
-
-#if 0
-    char buf [256];
-    sprintf (buf, "pr=%d kc=%08X st=%08X extended=%s scan=%04X",
-             event->type == XKeyPress ? 1 : 0, event->xkey.keycode,
-             event->xkey.state, scan >> 8 ? "true" : "false", scan & 0x7F);
-    mMainWnd->statusBar()->message (buf);
-    LogFlow (("### %s\n", buf));
-#endif
-
-    // scancodes 0x00 (no valid translation) and 0x80 are ignored
-    if (!scan & 0x7F)
-        return true;
-
-    /* Fix for http://www.virtualbox.org/ticket/1296:
-     * when X11 sends events for repeated keys, it always inserts an
-     * XKeyRelease before the XKeyPress. */
-    XEvent returnEvent;
-    if ((event->type == XKeyRelease) &&
-        (XCheckIfEvent(event->xkey.display, &returnEvent,
-                       VBoxConsoleViewCompEvent, (XPointer) event) == True)) {
-        XPutBackEvent(event->xkey.display, &returnEvent);
-        /* Discard it, don't pass it to Qt. */
-        return true;
-    }
-
-    KeySym ks = ::XKeycodeToKeysym (event->xkey.display, event->xkey.keycode, 0);
-
-    int flags = 0;
-    if (scan >> 8)
-        flags |= KeyExtended;
-    if (event->type == XKeyPress)
-        flags |= KeyPressed;
-
-    /* Remove the extended flag */
-    scan &= 0x7F;
-
-    switch (ks)
-    {
-        case XK_Print:
-            flags |= KeyPrint;
-            break;
-        case XK_Pause:
-            if (event->xkey.state & ControlMask) /* Break */
-            {
-                ks = XK_Break;
-                flags |= KeyExtended;
-                scan = 0x46;
-            }
-            else
-                flags |= KeyPause;
-            break;
-    }
-
-    return keyEvent (ks, scan, flags);
-}
-
-#elif defined (Q_WS_MAC)
-
-/**
- *  Invoked by VBoxConsoleView::darwinEventHandlerProc / VBoxConsoleView::macEventFilter when
- *  it receives a raw keyboard event.
- *
- *  @param pvCocoaEvent The Cocoa keyboard event. Can be NULL in some configs.
- *  @param inEvent      The keyboard event.
- *
- *  @return true if the key was processed, false if it wasn't processed and should be passed on.
- */
-bool VBoxConsoleView::darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent)
-{
-    bool ret = false;
-    UInt32 EventKind = ::GetEventKind (inEvent);
-    if (EventKind != kEventRawKeyModifiersChanged)
-    {
-        /* convert keycode to set 1 scan code. */
-        UInt32 keyCode = ~0U;
-        ::GetEventParameter (inEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof (keyCode), NULL, &keyCode);
-        /* The usb keyboard driver translates these codes to different virtual
-         * key codes depending of the keyboard type. There are ANSI, ISO, JIS
-         * and unknown. For European keyboards (ISO) the key 0xa and 0x32 have
-         * to be switched. Here we are doing this at runtime, cause the user
-         * can have more than one keyboard (of different type), where he may
-         * switch at will all the time. Default is the ANSI standard as defined
-         * in g_aDarwinToSet1. */
-//        if (   (keyCode == 0xa || keyCode == 0x32)
-//            && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO)
-//            keyCode = 0x3c - keyCode;
-        unsigned scanCode = ::DarwinKeycodeToSet1Scancode (keyCode);
-        if (scanCode)
-        {
-            /* calc flags. */
-            int flags = 0;
-            if (EventKind != kEventRawKeyUp)
-                flags |= KeyPressed;
-            if (scanCode & VBOXKEY_EXTENDED)
-                flags |= KeyExtended;
-            /** @todo KeyPause, KeyPrint. */
-            scanCode &= VBOXKEY_SCANCODE_MASK;
-
-            /* get the unicode string (if present). */
-            AssertCompileSize (wchar_t, 2);
-            AssertCompileSize (UniChar, 2);
-            ByteCount cbWritten = 0;
-            wchar_t ucs[8];
-            if (::GetEventParameter (inEvent, kEventParamKeyUnicodes, typeUnicodeText, NULL,
-                                     sizeof (ucs), &cbWritten, &ucs[0]) != 0)
-                cbWritten = 0;
-            ucs[cbWritten / sizeof(wchar_t)] = 0; /* The api doesn't terminate it. */
-
-            ret = keyEvent (keyCode, scanCode, flags, ucs[0] ? ucs : NULL);
-        }
-    }
-    else
-    {
-        /* May contain multiple modifier changes, kind of annoying. */
-        UInt32 newMask = 0;
-        ::GetEventParameter (inEvent, kEventParamKeyModifiers, typeUInt32, NULL,
-                             sizeof (newMask), NULL, &newMask);
-        newMask = ::DarwinAdjustModifierMask (newMask, pvCocoaEvent);
-        UInt32 changed = newMask ^ mDarwinKeyModifiers;
-        if (changed)
-        {
-            for (UInt32 bit = 0; bit < 32; bit++)
-            {
-                if (!(changed & (1 << bit)))
-                    continue;
-                unsigned scanCode = ::DarwinModifierMaskToSet1Scancode (1 << bit);
-                if (!scanCode)
-                    continue;
-                unsigned keyCode = ::DarwinModifierMaskToDarwinKeycode (1 << bit);
-                Assert (keyCode);
-
-                if (!(scanCode & VBOXKEY_LOCK))
-                {
-                    unsigned flags = (newMask & (1 << bit)) ? KeyPressed : 0;
-                    if (scanCode & VBOXKEY_EXTENDED)
-                        flags |= KeyExtended;
-                    scanCode &= VBOXKEY_SCANCODE_MASK;
-                    ret |= keyEvent (keyCode, scanCode & 0xff, flags);
-                }
-                else
-                {
-                    unsigned flags = 0;
-                    if (scanCode & VBOXKEY_EXTENDED)
-                        flags |= KeyExtended;
-                    scanCode &= VBOXKEY_SCANCODE_MASK;
-                    keyEvent (keyCode, scanCode, flags | KeyPressed);
-                    keyEvent (keyCode, scanCode, flags);
-                }
-            }
-        }
-
-        mDarwinKeyModifiers = newMask;
-
-        /* Always return true here because we'll otherwise getting a Qt event
-           we don't want and that will only cause the Pause warning to pop up. */
-        ret = true;
-    }
-
-    return ret;
-}
-
-
-/**
- * Installs or removes the keyboard event handler.
- *
- * @param   fGrab    True if we're to grab the events, false if we're not to.
- */
-void VBoxConsoleView::darwinGrabKeyboardEvents (bool fGrab)
-{
-    mKeyboardGrabbed = fGrab;
-    if (fGrab)
-    {
-        /* Disable mouse and keyboard event compression/delaying to make sure
-           we *really* get all of the events. */
-        ::CGSetLocalEventsSuppressionInterval (0.0);
-        setMouseCoalescingEnabled (false);
-
-        /* Register the event callback/hook and grab the keyboard. */
-# ifdef QT_MAC_USE_COCOA
-        ::VBoxCocoaApplication_setCallback (UINT32_MAX, /** @todo fix mask */
-                                            VBoxConsoleView::darwinEventHandlerProc, this);
-
-# else /* QT_MAC_USE_COCOA */
-        EventTypeSpec eventTypes[6];
-        eventTypes[0].eventClass = kEventClassKeyboard;
-        eventTypes[0].eventKind  = kEventRawKeyDown;
-        eventTypes[1].eventClass = kEventClassKeyboard;
-        eventTypes[1].eventKind  = kEventRawKeyUp;
-        eventTypes[2].eventClass = kEventClassKeyboard;
-        eventTypes[2].eventKind  = kEventRawKeyRepeat;
-        eventTypes[3].eventClass = kEventClassKeyboard;
-        eventTypes[3].eventKind  = kEventRawKeyModifiersChanged;
-        /* For ignorning Command-H and Command-Q which aren't affected by the
-         * global hotkey stuff (doesn't work well): */
-        eventTypes[4].eventClass = kEventClassCommand;
-        eventTypes[4].eventKind  = kEventCommandProcess;
-        eventTypes[5].eventClass = kEventClassCommand;
-        eventTypes[5].eventKind  = kEventCommandUpdateStatus;
-
-        EventHandlerUPP eventHandler = ::NewEventHandlerUPP (VBoxConsoleView::darwinEventHandlerProc);
-
-        mDarwinEventHandlerRef = NULL;
-        ::InstallApplicationEventHandler (eventHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],
-                                          this, &mDarwinEventHandlerRef);
-        ::DisposeEventHandlerUPP (eventHandler);
-# endif /* !QT_MAC_USE_COCOA */
-
-        ::DarwinGrabKeyboard (false);
-    }
-    else
-    {
-        ::DarwinReleaseKeyboard();
-# ifdef QT_MAC_USE_COCOA
-        ::VBoxCocoaApplication_unsetCallback (UINT32_MAX, /** @todo fix mask */
-                                              VBoxConsoleView::darwinEventHandlerProc, this);
-# else /* !QT_MAC_USE_COCOA */
-        if (mDarwinEventHandlerRef)
-        {
-            ::RemoveEventHandler (mDarwinEventHandlerRef);
-            mDarwinEventHandlerRef = NULL;
-        }
-# endif /* !QT_MAC_USE_COCOA */
-    }
-}
-
-#endif // defined (Q_WS_MAC)
-
-//
-// Private members
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Called on every focus change and also to forcibly capture/uncapture the
- *  input in situations similar to gaining or losing focus.
- *
- *  @param aHasFocus        true if the window got focus and false otherwise.
- *  @param aReleaseHostKey  true to release the host key (used only when
- *                          @a aHasFocus is false.
- */
-void VBoxConsoleView::focusEvent (bool aHasFocus,
-                                  bool aReleaseHostKey /* = true */)
-{
-    if (aHasFocus)
-    {
-#ifdef RT_OS_WINDOWS
-        if (   !mDisableAutoCapture && gs.autoCapture()
-            && GetAncestor (winId(), GA_ROOT) == GetForegroundWindow())
-#else
-        if (!mDisableAutoCapture && gs.autoCapture())
-#endif /* RT_OS_WINDOWS */
-        {
-            captureKbd (true);
-/// @todo (dmik)
-//      the below is for the mouse auto-capture. disabled for now. in order to
-//      properly support it, we need to know when *all* mouse buttons are
-//      released after we got focus, and grab the mouse only after then.
-//      btw, the similar would be good the for keyboard auto-capture, too.
-//            if (!(mMouseCanAbsolute && mMouseIntegration))
-//                captureMouse (true);
-        }
-
-        /* reset the single-time disable capture flag */
-        if (mDisableAutoCapture)
-            mDisableAutoCapture = false;
-    }
-    else
-    {
-        captureMouse (false);
-        captureKbd (false, false);
-        releaseAllPressedKeys (aReleaseHostKey);
-    }
-}
-
-/**
- *  Synchronize the views of the host and the guest to the modifier keys.
- *  This function will add up to 6 additional keycodes to codes.
- *
- *  @param  codes  pointer to keycodes which are sent to the keyboard
- *  @param  count  pointer to the keycodes counter
- */
-void VBoxConsoleView::fixModifierState (LONG *codes, uint *count)
-{
-#if defined(Q_WS_X11)
-
-    Window   wDummy1, wDummy2;
-    int      iDummy3, iDummy4, iDummy5, iDummy6;
-    unsigned uMask;
-    unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0, uKeyMaskScroll = 0;
-
-    uKeyMaskCaps          = LockMask;
-    XModifierKeymap* map  = XGetModifierMapping(QX11Info::display());
-    KeyCode keyCodeNum    = XKeysymToKeycode(QX11Info::display(), XK_Num_Lock);
-    KeyCode keyCodeScroll = XKeysymToKeycode(QX11Info::display(), XK_Scroll_Lock);
-
-    for (int i = 0; i < 8; i++)
-    {
-        if (   keyCodeNum != NoSymbol
-            && map->modifiermap[map->max_keypermod * i] == keyCodeNum)
-            uKeyMaskNum    = 1 << i;
-        else if (   keyCodeScroll != NoSymbol
-                 && map->modifiermap[map->max_keypermod * i] == keyCodeScroll)
-            uKeyMaskScroll = 1 << i;
-    }
-    XQueryPointer(QX11Info::display(), DefaultRootWindow(QX11Info::display()), &wDummy1, &wDummy2,
-                  &iDummy3, &iDummy4, &iDummy5, &iDummy6, &uMask);
-    XFreeModifiermap(map);
-
-    if (muNumLockAdaptionCnt && (mNumLock ^ !!(uMask & uKeyMaskNum)))
-    {
-        muNumLockAdaptionCnt--;
-        codes[(*count)++] = 0x45;
-        codes[(*count)++] = 0x45 | 0x80;
-    }
-    if (muCapsLockAdaptionCnt && (mCapsLock ^ !!(uMask & uKeyMaskCaps)))
-    {
-        muCapsLockAdaptionCnt--;
-        codes[(*count)++] = 0x3a;
-        codes[(*count)++] = 0x3a | 0x80;
-        /* Some keyboard layouts require shift to be pressed to break
-         * capslock.  For simplicity, only do this if shift is not
-         * already held down. */
-        if (mCapsLock && !(mPressedKeys [0x2a] & IsKeyPressed))
-        {
-            codes[(*count)++] = 0x2a;
-            codes[(*count)++] = 0x2a | 0x80;
-        }
-    }
-
-#elif defined(Q_WS_WIN32)
-
-    if (muNumLockAdaptionCnt && (mNumLock ^ !!(GetKeyState(VK_NUMLOCK))))
-    {
-        muNumLockAdaptionCnt--;
-        codes[(*count)++] = 0x45;
-        codes[(*count)++] = 0x45 | 0x80;
-    }
-    if (muCapsLockAdaptionCnt && (mCapsLock ^ !!(GetKeyState(VK_CAPITAL))))
-    {
-        muCapsLockAdaptionCnt--;
-        codes[(*count)++] = 0x3a;
-        codes[(*count)++] = 0x3a | 0x80;
-        /* Some keyboard layouts require shift to be pressed to break
-         * capslock.  For simplicity, only do this if shift is not
-         * already held down. */
-        if (mCapsLock && !(mPressedKeys [0x2a] & IsKeyPressed))
-        {
-            codes[(*count)++] = 0x2a;
-            codes[(*count)++] = 0x2a | 0x80;
-        }
-    }
-
-#elif defined (Q_WS_MAC)
-
-    /* if (muNumLockAdaptionCnt) ... - NumLock isn't implemented by Mac OS X so ignore it. */
-    if (muCapsLockAdaptionCnt && (mCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock)))
-    {
-        muCapsLockAdaptionCnt--;
-        codes[(*count)++] = 0x3a;
-        codes[(*count)++] = 0x3a | 0x80;
-        /* Some keyboard layouts require shift to be pressed to break
-         * capslock.  For simplicity, only do this if shift is not
-         * already held down. */
-        if (mCapsLock && !(mPressedKeys [0x2a] & IsKeyPressed))
-        {
-            codes[(*count)++] = 0x2a;
-            codes[(*count)++] = 0x2a | 0x80;
-        }
-    }
-
-#else
-
-//#warning Adapt VBoxConsoleView::fixModifierState
-
-#endif
-
-
-}
-
-/**
- *  Called on enter/exit seamless/fullscreen mode.
- */
-void VBoxConsoleView::toggleFSMode (const QSize &aSize)
-{
-    if (mAutoresizeGuest ||
-        mMainWnd->isTrueSeamless() ||
-        mMainWnd->isTrueFullscreen())
-    {
-        QSize newSize;
-        if (aSize.isValid())
-        {
-            mNormalSize = aSize;
-            newSize = maximumSize();
-        }
-        else
-            newSize = mNormalSize;
-        doResizeHint (newSize);
-    }
-
-    /* Reactivate the console window to preserve the focus position.
-     * Else focus will move to the mini-tool-bar. */
-    activateWindow();
-}
-
-/**
- * Get the current available desktop geometry for the console/framebuffer
- *
- * @returns the geometry.  An empty rectangle means unrestricted.
- */
-QRect VBoxConsoleView::desktopGeometry()
-{
-    QRect rc;
-    switch (mDesktopGeo)
-    {
-        case DesktopGeo_Fixed:
-        case DesktopGeo_Automatic:
-            rc = QRect (0, 0,
-                        RT_MAX (mDesktopGeometry.width(), mStoredConsoleSize.width()),
-                        RT_MAX (mDesktopGeometry.height(), mStoredConsoleSize.height()));
-            break;
-        case DesktopGeo_Any:
-            rc = QRect (0, 0, 0, 0);
-            break;
-        default:
-            AssertMsgFailed (("Bad geometry type %d\n", mDesktopGeo));
-    }
-    return rc;
-}
-
-QRegion VBoxConsoleView::lastVisibleRegion() const
-{
-    return mLastVisibleRegion;
-}
-
-bool VBoxConsoleView::isAutoresizeGuestActive()
-{
-    return mGuestSupportsGraphics && mAutoresizeGuest;
-}
-
-/**
- *  Called on every key press and release (while in focus).
- *
- *  @param aKey        virtual scan code (virtual key on Win32 and KeySym on X11)
- *  @param aScan       hardware scan code
- *  @param aFlags      flags, a combination of Key* constants
- *  @param aUniKey     Unicode translation of the key. Optional.
- *
- *  @return     true to consume the event and false to pass it to Qt
- */
-bool VBoxConsoleView::keyEvent (int aKey, uint8_t aScan, int aFlags,
-                                wchar_t *aUniKey/* = NULL*/)
-{
-#if 0
-    {
-        char buf [256];
-        sprintf (buf, "aKey=%08X aScan=%02X aFlags=%08X",
-                 aKey, aScan, aFlags);
-        mMainWnd->statusBar()->message (buf);
-    }
-#endif
-
-    const bool isHostKey = aKey == gs.hostKey();
-
-    LONG buf [16];
-    LONG *codes = buf;
-    uint count = 0;
-    uint8_t whatPressed = 0;
-
-    if (!isHostKey && !mIsHostkeyPressed)
-    {
-        if (aFlags & KeyPrint)
-        {
-            static LONG PrintMake[] = { 0xE0, 0x2A, 0xE0, 0x37 };
-            static LONG PrintBreak[] = { 0xE0, 0xB7, 0xE0, 0xAA };
-            if (aFlags & KeyPressed)
-            {
-                codes = PrintMake;
-                count = SIZEOF_ARRAY (PrintMake);
-            }
-            else
-            {
-                codes = PrintBreak;
-                count = SIZEOF_ARRAY (PrintBreak);
-            }
-        }
-        else if (aFlags & KeyPause)
-        {
-            if (aFlags & KeyPressed)
-            {
-                static LONG Pause[] = { 0xE1, 0x1D, 0x45, 0xE1, 0x9D, 0xC5 };
-                codes = Pause;
-                count = SIZEOF_ARRAY (Pause);
-            }
-            else
-            {
-                /* Pause shall not produce a break code */
-                return true;
-            }
-        }
-        else
-        {
-            if (aFlags & KeyPressed)
-            {
-                /* Check if the guest has the same view on the modifier keys (NumLock,
-                 * CapsLock, ScrollLock) as the X server. If not, send KeyPress events
-                 * to synchronize the state. */
-                fixModifierState (codes, &count);
-            }
-
-            /* Check if it's C-A-D and GUI/PassCAD is not true */
-            if (!mPassCAD &&
-                aScan == 0x53 /* Del */ &&
-                ((mPressedKeys [0x38] & IsKeyPressed) /* Alt */ ||
-                 (mPressedKeys [0x38] & IsExtKeyPressed)) &&
-                ((mPressedKeys [0x1d] & IsKeyPressed) /* Ctrl */ ||
-                 (mPressedKeys [0x1d] & IsExtKeyPressed)))
-            {
-                /* Use the C-A-D combination as a last resort to get the
-                 * keyboard and mouse back to the host when the user forgets
-                 * the Host Key. Note that it's always possible to send C-A-D
-                 * to the guest using the Host+Del combination. BTW, it would
-                 * be preferrable to completely ignore C-A-D in guests, but
-                 * that's not possible because we cannot predict what other
-                 * keys will be pressed next when one of C, A, D is held. */
-
-                if (isRunning() && mKbdCaptured)
-                {
-                    captureKbd (false);
-                    if (!(mMouseCanAbsolute && mMouseIntegration))
-                        captureMouse (false);
-                }
-
-                return true;
-            }
-
-            /* process the scancode and update the table of pressed keys */
-            whatPressed = IsKeyPressed;
-
-            if (aFlags & KeyExtended)
-            {
-                codes [count++] = 0xE0;
-                whatPressed = IsExtKeyPressed;
-            }
-
-            if (aFlags & KeyPressed)
-            {
-                codes [count++] = aScan;
-                mPressedKeys [aScan] |= whatPressed;
-            }
-            else
-            {
-                /* if we haven't got this key's press message, we ignore its
-                 * release */
-                if (!(mPressedKeys [aScan] & whatPressed))
-                    return true;
-                codes [count++] = aScan | 0x80;
-                mPressedKeys [aScan] &= ~whatPressed;
-            }
-
-            if (mKbdCaptured)
-                mPressedKeys [aScan] |= IsKbdCaptured;
-            else
-                mPressedKeys [aScan] &= ~IsKbdCaptured;
-        }
-    }
-    else
-    {
-        /* currently this is used in winLowKeyboardEvent() only */
-        hostkey_in_capture = mKbdCaptured;
-    }
-
-    bool emitSignal = false;
-    int hotkey = 0;
-
-    /* process the host key */
-    if (aFlags & KeyPressed)
-    {
-        if (isHostKey)
-        {
-            if (!mIsHostkeyPressed)
-            {
-                mIsHostkeyPressed = mIsHostkeyAlone = true;
-                if (isRunning())
-                    saveKeyStates();
-                emitSignal = true;
-            }
-        }
-        else
-        {
-            if (mIsHostkeyPressed)
-            {
-                if (mIsHostkeyAlone)
-                {
-                    hotkey = aKey;
-                    mIsHostkeyAlone = false;
-                }
-            }
-        }
-    }
-    else
-    {
-        if (isHostKey)
-        {
-            if (mIsHostkeyPressed)
-            {
-                mIsHostkeyPressed = false;
-
-                if (mIsHostkeyAlone)
-                {
-                    if (isPaused())
-                    {
-                        vboxProblem().remindAboutPausedVMInput();
-                    }
-                    else
-                    if (isRunning())
-                    {
-                        bool captured = mKbdCaptured;
-                        bool ok = true;
-                        if (!captured)
-                        {
-                            /* temporarily disable auto capture that will take
-                             * place after this dialog is dismissed because
-                             * the capture state is to be defined by the
-                             * dialog result itself */
-                            mDisableAutoCapture = true;
-                            bool autoConfirmed = false;
-                            ok = vboxProblem().confirmInputCapture (&autoConfirmed);
-                            if (autoConfirmed)
-                                mDisableAutoCapture = false;
-                            /* otherwise, the disable flag will be reset in
-                             * the next console view's foucs in event (since
-                             * may happen asynchronously on some platforms,
-                             * after we return from this code) */
-                        }
-
-                        if (ok)
-                        {
-                            captureKbd (!captured, false);
-                            if (!(mMouseCanAbsolute && mMouseIntegration))
-                            {
-#ifdef Q_WS_X11
-                                /* make sure that pending FocusOut events from the
-                                 * previous message box are handled, otherwise the
-                                 * mouse is immediately ungrabbed. */
-                                qApp->processEvents();
-#endif
-                                captureMouse (mKbdCaptured);
-                            }
-                        }
-                    }
-                }
-
-                if (isRunning())
-                    sendChangedKeyStates();
-
-                emitSignal = true;
-            }
-        }
-        else
-        {
-            if (mIsHostkeyPressed)
-                mIsHostkeyAlone = false;
-        }
-    }
-
-    /* emit the keyboard state change signal */
-    if (emitSignal)
-        emitKeyboardStateChanged();
-
-    /* Process Host+<key> shortcuts. currently, <key> is limited to
-     * alphanumeric chars. Other Host+<key> combinations are handled in
-     * event(). */
-    if (hotkey)
-    {
-        bool processed = false;
-#if defined (Q_WS_WIN32)
-        NOREF(aUniKey);
-        int n = GetKeyboardLayoutList (0, NULL);
-        Assert (n);
-        HKL *list = new HKL [n];
-        GetKeyboardLayoutList (n, list);
-        for (int i = 0; i < n && !processed; i++)
-        {
-            wchar_t ch;
-            static BYTE keys [256] = {0};
-            if (!ToUnicodeEx (hotkey, 0, keys, &ch, 1, 0, list [i]) == 1)
-                ch = 0;
-            if (ch)
-                processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL +
-                                                QChar (ch).toUpper().unicode()),
-                                           mMainWnd->menuBar()->actions());
-        }
-        delete[] list;
-#elif defined (Q_WS_X11)
-        NOREF(aUniKey);
-        Display *display = QX11Info::display();
-        int keysyms_per_keycode = getKeysymsPerKeycode();
-        KeyCode kc = XKeysymToKeycode (display, aKey);
-        // iterate over the first level (not shifted) keysyms in every group
-        for (int i = 0; i < keysyms_per_keycode && !processed; i += 2)
-        {
-            KeySym ks = XKeycodeToKeysym (display, kc, i);
-            char ch = 0;
-            if (!XkbTranslateKeySym (display, &ks, 0, &ch, 1, NULL) == 1)
-                ch = 0;
-            if (ch)
-            {
-                QChar c = QString::fromLocal8Bit (&ch, 1) [0];
-                processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL +
-                                                         c.toUpper().unicode()),
-                                           mMainWnd->menuBar()->actions());
-            }
-        }
-#elif defined (Q_WS_MAC)
-        if (aUniKey && aUniKey [0] && !aUniKey [1])
-            processed = processHotKey (QKeySequence (Qt::UNICODE_ACCEL +
-                                                     QChar (aUniKey [0]).toUpper().unicode()),
-                                       mMainWnd->menuBar()->actions());
-
-        /* Don't consider the hot key as pressed since the guest never saw
-         * it. (probably a generic thing) */
-        mPressedKeys [aScan] &= ~whatPressed;
-#endif
-
-        /* grab the key from Qt if processed, or pass it to Qt otherwise
-         * in order to process non-alphanumeric keys in event(), after they are
-         * converted to Qt virtual keys. */
-        return processed;
-    }
-
-    /* no more to do, if the host key is in action or the VM is paused */
-    if (mIsHostkeyPressed || isHostKey || isPaused())
-    {
-        /* grab the key from Qt and from VM if it's a host key,
-         * otherwise just pass it to Qt */
-        return isHostKey;
-    }
-
-    CKeyboard keyboard = mConsole.GetKeyboard();
-    Assert (!keyboard.isNull());
-
-#if defined (Q_WS_WIN32)
-    /* send pending WM_PAINT events */
-    ::UpdateWindow (viewport()->winId());
-#endif
-
-#if 0
-    {
-        char buf [256];
-        sprintf (buf, "*** SCANS: ");
-        for (uint i = 0; i < count; ++ i)
-            sprintf (buf + strlen (buf), "%02X ", codes [i]);
-        mMainWnd->statusBar()->message (buf);
-        LogFlow (("%s\n", buf));
-    }
-#endif
-
-    std::vector <LONG> scancodes(codes, &codes[count]);
-    keyboard.PutScancodes (QVector<LONG>::fromStdVector(scancodes));
-
-    /* grab the key from Qt */
-    return true;
-}
-
-/**
- *  Called on every mouse/wheel move and button press/release.
- *
- *  @return     true to consume the event and false to pass it to Qt
- */
-bool VBoxConsoleView::mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
-                                  Qt::MouseButtons aButtons, Qt::KeyboardModifiers aModifiers,
-                                  int aWheelDelta, Qt::Orientation aWheelDir)
-{
-#if 1
-
-    LogRel3(("%s: type=%03d x=%03d y=%03d btns=%08X wdelta=%03d wdir=%s\n",
-             __PRETTY_FUNCTION__ , aType, aPos.x(), aPos.y(),
-               (aButtons & Qt::LeftButton ? 1 : 0)
-             | (aButtons & Qt::RightButton ? 2 : 0)
-             | (aButtons & Qt::MidButton ? 4 : 0)
-             | (aButtons & Qt::XButton1 ? 8 : 0)
-             | (aButtons & Qt::XButton2 ? 16 : 0),
-             aWheelDelta,
-               aWheelDir == Qt::Horizontal ? "Horizontal"
-             : aWheelDir == Qt::Vertical ? "Vertical" : "Unknown"));
-    Q_UNUSED (aModifiers);
-#else
-    Q_UNUSED (aModifiers);
-#endif
-
-    int state = 0;
-    if (aButtons & Qt::LeftButton)
-        state |= KMouseButtonState_LeftButton;
-    if (aButtons & Qt::RightButton)
-        state |= KMouseButtonState_RightButton;
-    if (aButtons & Qt::MidButton)
-        state |= KMouseButtonState_MiddleButton;
-    if (aButtons & Qt::XButton1)
-        state |= KMouseButtonState_XButton1;
-    if (aButtons & Qt::XButton2)
-        state |= KMouseButtonState_XButton2;
-
-#ifdef Q_WS_MAC
-    /* Simulate the right click on
-     * Host+Left Mouse */
-    if (mIsHostkeyPressed &&
-        mIsHostkeyAlone &&
-        state == KMouseButtonState_LeftButton)
-        state = KMouseButtonState_RightButton;
-#endif /* Q_WS_MAC */
-
-    int wheelVertical = 0;
-    int wheelHorizontal = 0;
-    if (aWheelDir == Qt::Vertical)
-    {
-        /* the absolute value of wheel delta is 120 units per every wheel
-         * move; positive deltas correspond to counterclockwize rotations
-         * (usually up), negative -- to clockwize (usually down). */
-        wheelVertical = - (aWheelDelta / 120);
-    }
-    else if (aWheelDir == Qt::Horizontal)
-        wheelHorizontal = aWheelDelta / 120;
-
-    if (mMouseCaptured)
-    {
-#ifdef Q_WS_WIN32
-        /* send pending WM_PAINT events */
-        ::UpdateWindow (viewport()->winId());
-#endif
-
-        CMouse mouse = mConsole.GetMouse();
-        mouse.PutMouseEvent (aGlobalPos.x() - mLastPos.x(),
-                             aGlobalPos.y() - mLastPos.y(),
-                             wheelVertical, wheelHorizontal, state);
-
-#if defined (Q_WS_MAC)
-        /*
-         * Keep the mouse from leaving the widget.
-         *
-         * This is a bit tricky to get right because if it escapes we won't necessarily
-         * get mouse events any longer and can warp it back. So, we keep safety zone
-         * of up to 300 pixels around the borders of the widget to prevent this from
-         * happening. Also, the mouse is warped back to the center of the widget.
-         *
-         * (Note, aPos seems to be unreliable, it caused endless recursion here at one points...)
-         * (Note, synergy and other remote clients might not like this cursor warping.)
-         */
-        QRect rect = viewport()->visibleRegion().boundingRect();
-        QPoint pw = viewport()->mapToGlobal (viewport()->pos());
-        rect.translate (pw.x(), pw.y());
-
-        QRect dpRect = QApplication::desktop()->screenGeometry (viewport());
-        if (rect.intersects (dpRect))
-            rect = rect.intersect (dpRect);
-
-        int wsafe = rect.width() / 6;
-        rect.setWidth (rect.width() - wsafe * 2);
-        rect.setLeft (rect.left() + wsafe);
-
-        int hsafe = rect.height() / 6;
-        rect.setWidth (rect.height() - hsafe * 2);
-        rect.setTop (rect.top() + hsafe);
-
-        if (rect.contains (aGlobalPos, true))
-            mLastPos = aGlobalPos;
-        else
-        {
-            mLastPos = rect.center();
-            QCursor::setPos (mLastPos);
-        }
-
-#else /* !Q_WS_MAC */
-
-        /* "jerk" the mouse by bringing it to the opposite side
-         * to simulate the endless moving */
-
-#ifdef Q_WS_WIN32
-        int we = viewport()->width() - 1;
-        int he = viewport()->height() - 1;
-        QPoint p = aPos;
-        if (aPos.x() == 0)
-            p.setX (we - 1);
-        else if (aPos.x() == we)
-            p.setX (1);
-        if (aPos.y() == 0 )
-            p.setY (he - 1);
-        else if (aPos.y() == he)
-            p.setY (1);
-
-        if (p != aPos)
-        {
-            mLastPos = viewport()->mapToGlobal (p);
-            QCursor::setPos (mLastPos);
-        }
-        else
-        {
-            mLastPos = aGlobalPos;
-        }
-#else
-        int we = QApplication::desktop()->width() - 1;
-        int he = QApplication::desktop()->height() - 1;
-        QPoint p = aGlobalPos;
-        if (aGlobalPos.x() == 0)
-            p.setX (we - 1);
-        else if (aGlobalPos.x() == we)
-            p.setX( 1 );
-        if (aGlobalPos.y() == 0)
-            p.setY (he - 1);
-        else if (aGlobalPos.y() == he)
-            p.setY (1);
-
-        if (p != aGlobalPos)
-        {
-            mLastPos =  p;
-            QCursor::setPos (mLastPos);
-        }
-        else
-        {
-            mLastPos = aGlobalPos;
-        }
-#endif
-#endif /* !Q_WS_MAC */
-        return true; /* stop further event handling */
-    }
-    else /* !mMouseCaptured */
-    {
-        if (mMainWnd->isTrueFullscreen())
-        {
-            if (mode != VBoxDefs::SDLMode)
-            {
-                /* try to automatically scroll the guest canvas if the
-                 * mouse is on the screen border */
-                /// @todo (r=dmik) better use a timer for autoscroll
-                QRect scrGeo = QApplication::desktop()->screenGeometry (this);
-                int dx = 0, dy = 0;
-                if (scrGeo.width() < contentsWidth())
-                {
-                    if (scrGeo.left() == aGlobalPos.x()) dx = -1;
-                    if (scrGeo.right() == aGlobalPos.x()) dx = +1;
-                }
-                if (scrGeo.height() < contentsHeight())
-                {
-                    if (scrGeo.top() == aGlobalPos.y()) dy = -1;
-                    if (scrGeo.bottom() == aGlobalPos.y()) dy = +1;
-                }
-                if (dx || dy)
-                    scrollBy (dx, dy);
-            }
-        }
-
-        if (mMouseCanAbsolute && mMouseIntegration)
-        {
-            int cw = contentsWidth(), ch = contentsHeight();
-            int vw = visibleWidth(), vh = visibleHeight();
-
-            if (mode != VBoxDefs::SDLMode)
-            {
-                /* try to automatically scroll the guest canvas if the
-                 * mouse goes outside its visible part */
-
-                int dx = 0;
-                if (aPos.x() > vw) dx = aPos.x() - vw;
-                else if (aPos.x() < 0) dx = aPos.x();
-                int dy = 0;
-                if (aPos.y() > vh) dy = aPos.y() - vh;
-                else if (aPos.y() < 0) dy = aPos.y();
-                if (dx != 0 || dy != 0) scrollBy (dx, dy);
-            }
-
-            QPoint cpnt = viewportToContents (aPos);
-            if (cpnt.x() < 0) cpnt.setX (0);
-            else if (cpnt.x() > cw - 1) cpnt.setX (cw - 1);
-            if (cpnt.y() < 0) cpnt.setY (0);
-            else if (cpnt.y() > ch - 1) cpnt.setY (ch - 1);
-
-            CMouse mouse = mConsole.GetMouse();
-            mouse.PutMouseEventAbsolute (cpnt.x() + 1, cpnt.y() + 1,
-                                         wheelVertical, wheelHorizontal,
-                                         state);
-            return true; /* stop further event handling */
-        }
-        else
-        {
-            if (hasFocus() &&
-                (aType == QEvent::MouseButtonRelease &&
-                 aButtons == Qt::NoButton))
-            {
-                if (isPaused())
-                {
-                    vboxProblem().remindAboutPausedVMInput();
-                }
-                else if (isRunning())
-                {
-                    /* temporarily disable auto capture that will take
-                     * place after this dialog is dismissed because
-                     * the capture state is to be defined by the
-                     * dialog result itself */
-                    mDisableAutoCapture = true;
-                    bool autoConfirmed = false;
-                    bool ok = vboxProblem().confirmInputCapture (&autoConfirmed);
-                    if (autoConfirmed)
-                        mDisableAutoCapture = false;
-                    /* otherwise, the disable flag will be reset in
-                     * the next console view's foucs in event (since
-                     * may happen asynchronously on some platforms,
-                     * after we return from this code) */
-
-                    if (ok)
-                    {
-#ifdef Q_WS_X11
-                        /* make sure that pending FocusOut events from the
-                         * previous message box are handled, otherwise the
-                         * mouse is immediately ungrabbed again */
-                        qApp->processEvents();
-#endif
-                        captureKbd (true);
-                        captureMouse (true);
-                    }
-                }
-            }
-        }
-    }
-
-    return false;
-}
-
-void VBoxConsoleView::onStateChange (KMachineState state)
-{
-    switch (state)
-    {
-        case KMachineState_Paused:
-        case KMachineState_TeleportingPausedVM:
-        {
-            if (    mode != VBoxDefs::TimerMode
-                &&  mFrameBuf
-                &&  (   state      != KMachineState_TeleportingPausedVM
-                     || mLastState != KMachineState_Teleporting)
-               )
-            {
-                /*
-                 *  Take a screen snapshot. Note that TakeScreenShot() always
-                 *  needs a 32bpp image
-                 */
-                QImage shot = QImage (mFrameBuf->width(), mFrameBuf->height(), QImage::Format_RGB32);
-                CDisplay dsp = mConsole.GetDisplay();
-                dsp.TakeScreenShot (0, shot.bits(), shot.width(), shot.height());
-                /*
-                 *  TakeScreenShot() may fail if, e.g. the Paused notification
-                 *  was delivered after the machine execution was resumed. It's
-                 *  not fatal.
-                 */
-                if (dsp.isOk())
-                {
-                    dimImage (shot);
-                    mPausedShot = QPixmap::fromImage (shot);
-                    /* fully repaint to pick up mPausedShot */
-                    repaint();
-                }
-            }
-            /* fall through */
-        }
-        case KMachineState_Stuck:
-        {
-            /* reuse the focus event handler to uncapture everything */
-            if (hasFocus())
-                focusEvent (false /* aHasFocus*/, false /* aReleaseHostKey */);
-            break;
-        }
-        case KMachineState_Running:
-        {
-            if (   mLastState == KMachineState_Paused
-                || mLastState == KMachineState_TeleportingPausedVM
-               )
-            {
-                if (mode != VBoxDefs::TimerMode && mFrameBuf)
-                {
-                    /* reset the pixmap to free memory */
-                    mPausedShot = QPixmap ();
-                    /*
-                     *  ask for full guest display update (it will also update
-                     *  the viewport through IFramebuffer::NotifyUpdate)
-                     */
-                    CDisplay dsp = mConsole.GetDisplay();
-                    dsp.InvalidateAndUpdate();
-                }
-            }
-            /* reuse the focus event handler to capture input */
-            if (hasFocus())
-                focusEvent (true /* aHasFocus */);
-            break;
-        }
-        default:
-            break;
-    }
-
-    mLastState = state;
-}
-
-void VBoxConsoleView::doRefresh()
-{
-    viewport()->repaint();
-}
-
-void VBoxConsoleView::resizeEvent (QResizeEvent *)
-{
-    updateSliders();
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    QRect r = viewport()->geometry();
-//    printf ("qt resize: %d %d %d %d\n", r.x(), r.y(), r.width(), r.height());
-    PostBoundsChanged (r);
-#endif /* Q_WS_MAC */
-}
-
-void VBoxConsoleView::moveEvent (QMoveEvent *)
-{
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
-    QRect r = viewport()->geometry();
-//    printf ("qt resize: %d %d %d %d\n", r.x(), r.y(), r.width(), r.height());
-    PostBoundsChanged (r);
-#endif /* Q_WS_MAC */
-}
-
-void VBoxConsoleView::paintEvent (QPaintEvent *pe)
-{
-    if (mPausedShot.isNull())
-    {
-        /* delegate the paint function to the VBoxFrameBuffer interface */
-        if (mFrameBuf)
-            mFrameBuf->paintEvent (pe);
-#ifdef Q_WS_MAC
-        /* Update the dock icon if we are in the running state */
-        if (isRunning())
-            updateDockIcon();
-#endif
-        return;
-    }
-
-#ifdef VBOX_GUI_USE_QUARTZ2D
-    if (mode == VBoxDefs::Quartz2DMode && mFrameBuf)
-    {
-        mFrameBuf->paintEvent (pe);
-        updateDockIcon();
-    }
-    else
-#endif
-    {
-        /* we have a snapshot for the paused state */
-        QRect r = pe->rect().intersect (viewport()->rect());
-        /* We have to disable paint on screen if we are using the regular painter */
-        bool paintOnScreen = viewport()->testAttribute (Qt::WA_PaintOnScreen);
-        viewport()->setAttribute (Qt::WA_PaintOnScreen, false);
-        QPainter pnt (viewport());
-        pnt.drawPixmap (r.x(), r.y(), mPausedShot,
-                        r.x() + contentsX(), r.y() + contentsY(),
-                        r.width(), r.height());
-        /* Restore the attribute to its previous state */
-        viewport()->setAttribute (Qt::WA_PaintOnScreen, paintOnScreen);
-#ifdef Q_WS_MAC
-        updateDockIcon();
-#endif
-    }
-
-}
-
-/**
- *  Captures the keyboard. When captured, no keyboard input reaches the host
- *  system (including most system combinations like Alt-Tab).
- *
- *  @param aCapture     true to capture, false to uncapture.
- *  @param aEmitSignal  Whether to emit keyboardStateChanged() or not.
- */
-void VBoxConsoleView::captureKbd (bool aCapture, bool aEmitSignal /* = true */)
-{
-    AssertMsg (mAttached, ("Console must be attached"));
-
-    if (mKbdCaptured == aCapture)
-        return;
-
-    /* On Win32, keyboard grabbing is ineffective, a low-level keyboard hook is
-     * used instead. On X11, we use XGrabKey instead of XGrabKeyboard (called
-     * by QWidget::grabKeyboard()) because the latter causes problems under
-     * metacity 2.16 (in particular, due to a bug, a window cannot be moved
-     * using the mouse if it is currently grabing the keyboard). On Mac OS X,
-     * we use the Qt methods + disabling global hot keys + watching modifiers
-     * (for right/left separation). */
-#if defined (Q_WS_WIN32)
-    /**/
-#elif defined (Q_WS_X11)
-    if (aCapture)
-        XGrabKey (QX11Info::display(), AnyKey, AnyModifier,
-                  window()->winId(), False,
-                  GrabModeAsync, GrabModeAsync);
-    else
-        XUngrabKey (QX11Info::display(),  AnyKey, AnyModifier,
-                    window()->winId());
-#elif defined (Q_WS_MAC)
-    if (aCapture)
-    {
-        ::DarwinDisableGlobalHotKeys (true);
-        grabKeyboard();
-    }
-    else
-    {
-        ::DarwinDisableGlobalHotKeys (false);
-        releaseKeyboard();
-    }
-#else
-    if (aCapture)
-        grabKeyboard();
-    else
-        releaseKeyboard();
-#endif
-
-    mKbdCaptured = aCapture;
-
-    if (aEmitSignal)
-        emitKeyboardStateChanged();
-}
-
-/**
- *  Captures the host mouse pointer. When captured, the mouse pointer is
- *  unavailable to the host applications.
- *
- *  @param aCapture     true to capture, false to uncapture.
- *  @param aEmitSignal  Whether to emit mouseStateChanged() or not.
- */
-void VBoxConsoleView::captureMouse (bool aCapture, bool aEmitSignal /* = true */)
-{
-    AssertMsg (mAttached, ("Console must be attached"));
-
-    if (mMouseCaptured == aCapture)
-        return;
-
-    if (aCapture)
-    {
-        /* memorize the host position where the cursor was captured */
-        mCapturedPos = QCursor::pos();
-#ifdef Q_WS_WIN32
-        viewport()->setCursor (QCursor (Qt::BlankCursor));
-        /* move the mouse to the center of the visible area */
-        QCursor::setPos (mapToGlobal (visibleRegion().boundingRect().center()));
-        mLastPos = QCursor::pos();
-#elif defined (Q_WS_MAC)
-        /* move the mouse to the center of the visible area */
-        mLastPos = mapToGlobal (visibleRegion().boundingRect().center());
-        QCursor::setPos (mLastPos);
-        /* grab all mouse events. */
-        viewport()->grabMouse();
-#else
-        viewport()->grabMouse();
-        mLastPos = QCursor::pos();
-#endif
-    }
-    else
-    {
-#ifndef Q_WS_WIN32
-        viewport()->releaseMouse();
-#endif
-        /* release mouse buttons */
-        CMouse mouse = mConsole.GetMouse();
-        mouse.PutMouseEvent (0, 0, 0, 0 /* Horizontal wheel */, 0);
-    }
-
-    mMouseCaptured = aCapture;
-
-    updateMouseClipping();
-
-    if (aEmitSignal)
-        emitMouseStateChanged();
-}
-
-/**
- *  Searches for a menu item with a given hot key (shortcut). If the item
- *  is found, activates it and returns true. Otherwise returns false.
- */
-bool VBoxConsoleView::processHotKey (const QKeySequence &aKey,
-                                     const QList <QAction*> &aData)
-{
-    foreach (QAction *pAction, aData)
-    {
-        if (QMenu *menu = pAction->menu())
-        {
-            /* Process recursively for each sub-menu */
-            if (processHotKey (aKey, menu->actions()))
-                return true;
-        }
-        else
-        {
-            QString hotkey = VBoxGlobal::extractKeyFromActionText (pAction->text());
-            if (pAction->isEnabled() && !hotkey.isEmpty())
-            {
-                if (aKey.matches (QKeySequence (hotkey)) == QKeySequence::ExactMatch)
-                {
-                    /* We asynchronously post a special event instead of calling
-                     * pAction->trigger() directly, to let key presses and
-                     * releases be processed correctly by Qt first.
-                     * Note: we assume that nobody will delete the menu item
-                     * corresponding to the key sequence, so that the pointer to
-                     * menu data posted along with the event will remain valid in
-                     * the event handler, at least until the main window is closed. */
-                    QApplication::postEvent (this, new ActivateMenuEvent (pAction));
-                    return true;
-                }
-            }
-        }
-    }
-
-    return false;
-}
-
-/**
- * Send the KEY BREAK code to the VM for all currently pressed keys.
- *
- * @param aReleaseHostKey @c true to set the host key state to unpressed.
- */
-void VBoxConsoleView::releaseAllPressedKeys (bool aReleaseHostKey /* = true*/)
-{
-    AssertMsg (mAttached, ("Console must be attached"));
-
-    CKeyboard keyboard = mConsole.GetKeyboard();
-    bool fSentRESEND = false;
-
-    /* send a dummy scan code (RESEND) to prevent the guest OS from recognizing
-     * a single key click (for ex., Alt) and performing an unwanted action
-     * (for ex., activating the menu) when we release all pressed keys below.
-     * Note, that it's just a guess that sending RESEND will give the desired
-     * effect :), but at least it works with NT and W2k guests. */
-
-    /// @todo Sending 0xFE is responsible for the warning
-    //
-    //         ``atkbd.c: Spurious NAK on isa0060/serio0. Some program might
-    //           be trying access hardware directly''
-    //
-    //       on Linux guests (#1944). It might also be responsible for #1949. Don't
-    //       send this command unless we really have to release any key modifier.
-    //                                                                    --frank
-
-    for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); i++)
-    {
-        if (mPressedKeys [i] & IsKeyPressed)
-        {
-            if (!fSentRESEND)
-            {
-                keyboard.PutScancode (0xFE);
-                fSentRESEND = true;
-            }
-            keyboard.PutScancode (i | 0x80);
-        }
-        else if (mPressedKeys [i] & IsExtKeyPressed)
-        {
-            if (!fSentRESEND)
-            {
-                keyboard.PutScancode (0xFE);
-                fSentRESEND = true;
-            }
-            QVector <LONG> codes (2);
-            codes[0] = 0xE0;
-            codes[1] = i | 0x80;
-            keyboard.PutScancodes (codes);
-        }
-        mPressedKeys [i] = 0;
-    }
-
-    if (aReleaseHostKey)
-        mIsHostkeyPressed = false;
-
-#ifdef Q_WS_MAC
-    /* clear most of the modifiers. */
-    mDarwinKeyModifiers &=
-        alphaLock | kEventKeyModifierNumLockMask |
-        (aReleaseHostKey ? 0 : ::DarwinKeyCodeToDarwinModifierMask (gs.hostKey()));
-#endif
-
-    emitKeyboardStateChanged();
-}
-
-void VBoxConsoleView::saveKeyStates()
-{
-    ::memcpy (mPressedKeysCopy, mPressedKeys, sizeof (mPressedKeys));
-}
-
-void VBoxConsoleView::sendChangedKeyStates()
-{
-    AssertMsg (mAttached, ("Console must be attached"));
-
-    QVector <LONG> codes (2);
-    CKeyboard keyboard = mConsole.GetKeyboard();
-    for (uint i = 0; i < SIZEOF_ARRAY (mPressedKeys); ++ i)
-    {
-        uint8_t os = mPressedKeysCopy [i];
-        uint8_t ns = mPressedKeys [i];
-        if ((os & IsKeyPressed) != (ns & IsKeyPressed))
-        {
-            codes [0] = i;
-            if (!(ns & IsKeyPressed))
-                codes[0] |= 0x80;
-            keyboard.PutScancode (codes[0]);
-        }
-        else if ((os & IsExtKeyPressed) != (ns & IsExtKeyPressed))
-        {
-            codes [0] = 0xE0;
-            codes [1] = i;
-            if (!(ns & IsExtKeyPressed))
-                codes [1] |= 0x80;
-            keyboard.PutScancodes (codes);
-        }
-    }
-}
-
-void VBoxConsoleView::updateMouseClipping()
-{
-    AssertMsg (mAttached, ("Console must be attached"));
-
-    if (mMouseCaptured)
-    {
-        updateHostCursor();
-#ifdef Q_WS_WIN32
-        QRect r = viewport()->rect();
-        r.moveTopLeft (viewport()->mapToGlobal (QPoint (0, 0)));
-        RECT rect = { r.left(), r.top(), r.right() + 1, r.bottom() + 1 };
-        ::ClipCursor (&rect);
-#endif
-    }
-    else
-    {
-#ifdef Q_WS_WIN32
-        ::ClipCursor (NULL);
-#endif
-        /* return the cursor to where it was when we captured it and show it */
-        QCursor::setPos (mCapturedPos);
-        updateHostCursor();
-    }
-}
-
-void VBoxConsoleView::setPointerShape (MousePointerChangeEvent *me)
-{
-    if (me->shapeData() != NULL)
-    {
-        bool ok = false;
-
-        const uchar *srcAndMaskPtr = me->shapeData();
-        uint andMaskSize = (me->width() + 7) / 8 * me->height();
-        const uchar *srcShapePtr = me->shapeData() + ((andMaskSize + 3) & ~3);
-        uint srcShapePtrScan = me->width() * 4;
-
-#if defined (Q_WS_WIN)
-
-        BITMAPV5HEADER bi;
-        HBITMAP hBitmap;
-        void *lpBits;
-
-        ::ZeroMemory (&bi, sizeof (BITMAPV5HEADER));
-        bi.bV5Size = sizeof (BITMAPV5HEADER);
-        bi.bV5Width = me->width();
-        bi.bV5Height = - (LONG) me->height();
-        bi.bV5Planes = 1;
-        bi.bV5BitCount = 32;
-        bi.bV5Compression = BI_BITFIELDS;
-        // specifiy a supported 32 BPP alpha format for Windows XP
-        bi.bV5RedMask   = 0x00FF0000;
-        bi.bV5GreenMask = 0x0000FF00;
-        bi.bV5BlueMask  = 0x000000FF;
-        if (me->hasAlpha())
-            bi.bV5AlphaMask = 0xFF000000;
-        else
-            bi.bV5AlphaMask = 0;
-
-        HDC hdc = GetDC (NULL);
-
-        // create the DIB section with an alpha channel
-        hBitmap = CreateDIBSection (hdc, (BITMAPINFO *) &bi, DIB_RGB_COLORS,
-                                    (void **) &lpBits, NULL, (DWORD) 0);
-
-        ReleaseDC (NULL, hdc);
-
-        HBITMAP hMonoBitmap = NULL;
-        if (me->hasAlpha())
-        {
-            // create an empty mask bitmap
-            hMonoBitmap = CreateBitmap (me->width(), me->height(), 1, 1, NULL);
-        }
-        else
-        {
-            /* Word aligned AND mask. Will be allocated and created if necessary. */
-            uint8_t *pu8AndMaskWordAligned = NULL;
-
-            /* Width in bytes of the original AND mask scan line. */
-            uint32_t cbAndMaskScan = (me->width() + 7) / 8;
-
-            if (cbAndMaskScan & 1)
-            {
-                /* Original AND mask is not word aligned. */
-
-                /* Allocate memory for aligned AND mask. */
-                pu8AndMaskWordAligned = (uint8_t *)RTMemTmpAllocZ ((cbAndMaskScan + 1) * me->height());
-
-                Assert(pu8AndMaskWordAligned);
-
-                if (pu8AndMaskWordAligned)
-                {
-                    /* According to MSDN the padding bits must be 0.
-                     * Compute the bit mask to set padding bits to 0 in the last byte of original AND mask.
-                     */
-                    uint32_t u32PaddingBits = cbAndMaskScan * 8  - me->width();
-                    Assert(u32PaddingBits < 8);
-                    uint8_t u8LastBytesPaddingMask = (uint8_t)(0xFF << u32PaddingBits);
-
-                    Log(("u8LastBytesPaddingMask = %02X, aligned w = %d, width = %d, cbAndMaskScan = %d\n",
-                          u8LastBytesPaddingMask, (cbAndMaskScan + 1) * 8, me->width(), cbAndMaskScan));
-
-                    uint8_t *src = (uint8_t *)srcAndMaskPtr;
-                    uint8_t *dst = pu8AndMaskWordAligned;
-
-                    unsigned i;
-                    for (i = 0; i < me->height(); i++)
-                    {
-                        memcpy (dst, src, cbAndMaskScan);
-
-                        dst[cbAndMaskScan - 1] &= u8LastBytesPaddingMask;
-
-                        src += cbAndMaskScan;
-                        dst += cbAndMaskScan + 1;
-                    }
-                }
-            }
-
-            /* create the AND mask bitmap */
-            hMonoBitmap = ::CreateBitmap (me->width(), me->height(), 1, 1,
-                                          pu8AndMaskWordAligned? pu8AndMaskWordAligned: srcAndMaskPtr);
-
-            if (pu8AndMaskWordAligned)
-            {
-                RTMemTmpFree (pu8AndMaskWordAligned);
-            }
-        }
-
-        Assert (hBitmap);
-        Assert (hMonoBitmap);
-        if (hBitmap && hMonoBitmap)
-        {
-            DWORD *dstShapePtr = (DWORD *) lpBits;
-
-            for (uint y = 0; y < me->height(); y ++)
-            {
-                memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan);
-                srcShapePtr += srcShapePtrScan;
-                dstShapePtr += me->width();
-            }
-
-            ICONINFO ii;
-            ii.fIcon = FALSE;
-            ii.xHotspot = me->xHot();
-            ii.yHotspot = me->yHot();
-            ii.hbmMask = hMonoBitmap;
-            ii.hbmColor = hBitmap;
-
-            HCURSOR hAlphaCursor = CreateIconIndirect (&ii);
-            Assert (hAlphaCursor);
-            if (hAlphaCursor)
-            {
-                mLastCursor = QCursor (hAlphaCursor);
-                ok = true;
-                if (mAlphaCursor)
-                    DestroyIcon (mAlphaCursor);
-                mAlphaCursor = hAlphaCursor;
-            }
-        }
-
-        if (hMonoBitmap)
-            DeleteObject (hMonoBitmap);
-        if (hBitmap)
-            DeleteObject (hBitmap);
-
-#elif defined (Q_WS_X11) && !defined (VBOX_WITHOUT_XCURSOR)
-
-        XcursorImage *img = XcursorImageCreate (me->width(), me->height());
-        Assert (img);
-        if (img)
-        {
-            img->xhot = me->xHot();
-            img->yhot = me->yHot();
-
-            XcursorPixel *dstShapePtr = img->pixels;
-
-            for (uint y = 0; y < me->height(); y ++)
-            {
-                memcpy (dstShapePtr, srcShapePtr, srcShapePtrScan);
-
-                if (!me->hasAlpha())
-                {
-                    /* convert AND mask to the alpha channel */
-                    uchar byte = 0;
-                    for (uint x = 0; x < me->width(); x ++)
-                    {
-                        if (!(x % 8))
-                            byte = *(srcAndMaskPtr ++);
-                        else
-                            byte <<= 1;
-
-                        if (byte & 0x80)
-                        {
-                            /* Linux doesn't support inverted pixels (XOR ops,
-                             * to be exact) in cursor shapes, so we detect such
-                             * pixels and always replace them with black ones to
-                             * make them visible at least over light colors */
-                            if (dstShapePtr [x] & 0x00FFFFFF)
-                                dstShapePtr [x] = 0xFF000000;
-                            else
-                                dstShapePtr [x] = 0x00000000;
-                        }
-                        else
-                            dstShapePtr [x] |= 0xFF000000;
-                    }
-                }
-
-                srcShapePtr += srcShapePtrScan;
-                dstShapePtr += me->width();
-            }
-
-            Cursor cur = XcursorImageLoadCursor (QX11Info::display(), img);
-            Assert (cur);
-            if (cur)
-            {
-                mLastCursor = QCursor (cur);
-                ok = true;
-            }
-
-            XcursorImageDestroy (img);
-        }
-
-#elif defined(Q_WS_MAC)
-
-        /* Create a ARGB image out of the shape data. */
-        QImage image  (me->width(), me->height(), QImage::Format_ARGB32);
-        const uint8_t* pbSrcMask = static_cast<const uint8_t*> (srcAndMaskPtr);
-        unsigned cbSrcMaskLine = RT_ALIGN (me->width(), 8) / 8;
-        for (unsigned int y = 0; y < me->height(); ++y)
-        {
-            for (unsigned int x = 0; x < me->width(); ++x)
-            {
-               unsigned int color = ((unsigned int*)srcShapePtr)[y*me->width()+x];
-               /* If the alpha channel isn't in the shape data, we have to
-                * create them from the and-mask. This is a bit field where 1
-                * represent transparency & 0 opaque respectively. */
-               if (!me->hasAlpha())
-               {
-                   if (!(pbSrcMask[x / 8] & (1 << (7 - (x % 8)))))
-                       color  |= 0xff000000;
-                   else
-                   {
-                       /* This isn't quite right, but it's the best we can do I
-                        * think... */
-                       if (color & 0x00ffffff)
-                           color = 0xff000000;
-                       else
-                           color = 0x00000000;
-                   }
-               }
-               image.setPixel (x, y, color);
-            }
-            /* Move one scanline forward. */
-            pbSrcMask += cbSrcMaskLine;
-        }
-        /* Set the new cursor */
-        QCursor cursor (QPixmap::fromImage (image),
-                        me->xHot(), me->yHot());
-        mLastCursor = cursor;
-        ok = true;
-        NOREF (srcShapePtrScan);
-
-#else
-
-# warning "port me"
-
-#endif
-        if (!ok)
-            mLastCursor = QCursor();  /* in practice this is equivalent to
-                                       * unsetCursor() */
-        mHideHostPointer = false;
-    }
-    else
-        /* The visiblity flag is only interpreted if there is no shape */
-        mHideHostPointer = !me->isVisible();
-    updateHostCursor();
-}
-
-inline QRgb qRgbIntensity (QRgb rgb, int mul, int div)
-{
-    int r = qRed (rgb);
-    int g = qGreen (rgb);
-    int b = qBlue (rgb);
-    return qRgb (mul * r / div, mul * g / div, mul * b / div);
-}
-
-/* static */
-void VBoxConsoleView::dimImage (QImage &img)
-{
-    for (int y = 0; y < img.height(); y ++) {
-        if (y % 2) {
-            if (img.depth() == 32) {
-                for (int x = 0; x < img.width(); x ++) {
-                    int gray = qGray (img.pixel (x, y)) / 2;
-                    img.setPixel (x, y, qRgb (gray, gray, gray));
-//                    img.setPixel (x, y, qRgbIntensity (img.pixel (x, y), 1, 2));
-                }
-            } else {
-                ::memset (img.scanLine (y), 0, img.bytesPerLine());
-            }
-        } else {
-            if (img.depth() == 32) {
-                for (int x = 0; x < img.width(); x ++) {
-                    int gray = (2 * qGray (img.pixel (x, y))) / 3;
-                    img.setPixel (x, y, qRgb (gray, gray, gray));
-//                    img.setPixel (x, y, qRgbIntensity (img.pixel(x, y), 2, 3));
-                }
-            }
-        }
-    }
-}
-
-void VBoxConsoleView::doResizeHint (const QSize &aToSize)
-{
-    if (mAutoresizeGuest)
-    {
-        /* If this slot is invoked directly then use the passed size
-         * otherwise get the available size for the guest display.
-         * We assume here that the centralWidget() contains this view only
-         * and gives it all available space. */
-        QSize sz (aToSize.isValid() ? aToSize : mMainWnd->centralWidget()->size());
-        if (!aToSize.isValid())
-            sz -= QSize (frameWidth() * 2, frameWidth() * 2);
-        /* Do not send out useless hints. */
-        if ((sz.width() == mStoredConsoleSize.width()) &&
-            (sz.height() == mStoredConsoleSize.height()))
-            return;
-        /* We only actually send the hint if
-         * 1) the autoresize property is set to true and
-         * 2) either an explicit new size was given (e.g. if the request
-         *    was triggered directly by a console resize event) or if no
-         *    explicit size was specified but a resize is flagged as being
-         *    needed (e.g. the autoresize was just enabled and the console
-         *    was resized while it was disabled). */
-        if (mAutoresizeGuest &&
-            (aToSize.isValid() || mDoResize))
-        {
-            LogFlowFunc (("Will suggest %d x %d\n", sz.width(), sz.height()));
-
-            /* Remember the new size. */
-            storeConsoleSize (sz.width(), sz.height());
-
-            mConsole.GetDisplay().SetVideoModeHint (sz.width(), sz.height(), 0, 0);
-        }
-        /* we have resized now... */
-        mDoResize = false;
-    }
-}
-
-
-/* If the desktop geometry is set automatically, this will update it. */
-void VBoxConsoleView::doResizeDesktop (int)
-{
-    calculateDesktopGeometry();
-}
-
-/**
- * Store the current size of the console (i.e. the viewport to the guest).
- * This has two purposes.  One is to suppress unwanted resize events for
- * which the new size is the same as the stored size.  The other is to expand
- * the maximum size to which we will let the guest resize itself.  It makes
- * no sense to forbid guest resizes which are less than the current resolution
- * anyway.
- *
- * @param aWidth  width of the resolution hint
- * @param aHeight height of the resolution hint
- */
-void VBoxConsoleView::storeConsoleSize (int aWidth, int aHeight)
-{
-    LogFlowThisFunc (("aWidth=%d, aHeight=%d\n", aWidth, aHeight));
-    mStoredConsoleSize = QRect (0, 0, aWidth, aHeight);
-}
-
-/**
- * Do initial setup of desktop geometry restrictions on the guest framebuffer.
- * These determine the maximum size the guest framebuffer can take on.
- *
- * @note a hint from the host will always override these restrictions.
- *
- * @param aGeo    Fixed -     the guest has a fixed maximum framebuffer size
- *                Automatic - we calculate the maximum size ourselves.  The
- *                            calculations will not actually be done until
- *                            @a calculateDesktopGeometry is called, since
- *                            we don't initially have the information needed.
- *                Any -       any size is allowed
- * @param aWidth  The maximum width for the guest screen or zero for no change
- *                (only used for fixed geometry)
- * @param aHeight The maximum height for the guest screen or zero for no change
- *                (only used for fixed geometry)
- */
-void VBoxConsoleView::setDesktopGeometry (DesktopGeo aGeo, int aWidth, int aHeight)
-{
-    LogFlowThisFunc (("aGeo=%s, aWidth=%d, aHeight=%d\n",
-                      (aGeo == DesktopGeo_Fixed ? "Fixed" :
-                       aGeo == DesktopGeo_Automatic ? "Automatic" :
-                       aGeo == DesktopGeo_Any ? "Any" : "Invalid"),
-                      aWidth, aHeight));
-    switch (aGeo)
-    {
-        case DesktopGeo_Fixed:
-            mDesktopGeo = DesktopGeo_Fixed;
-            if (aWidth != 0 && aHeight != 0)
-                mDesktopGeometry = QRect (0, 0, aWidth, aHeight);
-            else
-                mDesktopGeometry = QRect (0, 0, 0, 0);
-            storeConsoleSize (0, 0);
-            break;
-        case DesktopGeo_Automatic:
-            mDesktopGeo = DesktopGeo_Automatic;
-            mDesktopGeometry = QRect (0, 0, 0, 0);
-            storeConsoleSize (0, 0);
-            break;
-        case DesktopGeo_Any:
-            mDesktopGeo = DesktopGeo_Any;
-            mDesktopGeometry = QRect (0, 0, 0, 0);
-            break;
-        default:
-            AssertMsgFailed(("Invalid desktop geometry type %d\n", aGeo));
-            mDesktopGeo = DesktopGeo_Invalid;
-    }
-}
-
-
-/**
- * If we are in automatic mode, the geometry restrictions will be recalculated.
- * This is needed in particular on the first widget resize, as we can't
- * calculate them correctly before that.
- *
- * @note a hint from the host will always override these restrictions.
- * @note we can't do calculations on the fly when they are needed, because
- *       they require querying the X server on X11 hosts and this must be done
- *       from within the GUI thread, due to the single threadedness of Xlib.
- */
-void VBoxConsoleView::calculateDesktopGeometry()
-{
-    LogFlowThisFunc (("Entering\n"));
-    /* This method should not get called until we have initially set up the */
-    Assert ((mDesktopGeo != DesktopGeo_Invalid));
-    /* If we are not doing automatic geometry calculation then there is
-     * nothing to do. */
-    if (DesktopGeo_Automatic == mDesktopGeo)
-    {
-        /* Available geometry of the desktop.  If the desktop is a single
-         * screen, this will exclude space taken up by desktop taskbars
-         * and things, but this is unfortunately not true for the more
-         * complex case of a desktop spanning multiple screens. */
-        QRect desktop = availableGeometry();
-        /* The area taken up by the console window on the desktop,
-         * including window frame, title and menu bar and whatnot. */
-        QRect frame = mMainWnd->frameGeometry();
-        /* The area taken up by the console window, minus all
-         * decorations. */
-        QRect window = mMainWnd->centralWidget()->geometry();
-        /* To work out how big we can make the console window while still
-         * fitting on the desktop, we calculate desktop - frame + window.
-         * This works because the difference between frame and window
-         * (or at least its width and height) is a constant. */
-        mDesktopGeometry =
-            QRect (0, 0, desktop.width() - frame.width() + window.width(),
-                   desktop.height() - frame.height() + window.height());
-        LogFlowThisFunc (("Setting %d, %d\n", mDesktopGeometry.width(),
-                           mDesktopGeometry.height()));
-    }
-}
-
-/**
- *  Sets the minimum size restriction depending on the auto-resize feature
- *  state and the current rendering mode.
- *
- *  Currently, the restriction is set only in SDL mode and only when the
- *  auto-resize feature is inactive. We need to do that because we cannot
- *  correctly draw in a scrolled window in SDL mode.
- *
- *  In all other modes, or when auto-resize is in force, this function does
- *  nothing.
- */
-void VBoxConsoleView::maybeRestrictMinimumSize()
-{
-    if (mode == VBoxDefs::SDLMode)
-    {
-        if (!mGuestSupportsGraphics || !mAutoresizeGuest)
-            setMinimumSize (sizeHint());
-        else
-            setMinimumSize (0, 0);
-    }
-}
-
-QRect VBoxConsoleView::availableGeometry() const
-{
-    return mMainWnd->isWindowFullScreen() ?
-           QApplication::desktop()->screenGeometry(this) :
-           QApplication::desktop()->availableGeometry(this);
-}
-
-int VBoxConsoleView::contentsWidth() const
-{
-    return mFrameBuf->width();
-}
-
-int VBoxConsoleView::contentsHeight() const
-{
-    return mFrameBuf->height();
-}
-
-void VBoxConsoleView::updateSliders()
-{
-    QSize p = viewport()->size();
-    QSize m = maximumViewportSize();
-
-    QSize v = QSize (mFrameBuf->width(), mFrameBuf->height());
-    /* no scroll bars needed */
-    if (m.expandedTo(v) == m)
-        p = m;
-
-    horizontalScrollBar()->setRange(0, v.width() - p.width());
-    verticalScrollBar()->setRange(0, v.height() - p.height());
-    horizontalScrollBar()->setPageStep(p.width());
-    verticalScrollBar()->setPageStep(p.height());
-}
-
-void VBoxConsoleView::requestToResize (const QSize &aSize)
-{
-    mIgnoreFrameBufferResize = true;
-    mNormalSize = aSize;
-}
-
-#if defined(Q_WS_MAC)
-
-void VBoxConsoleView::updateDockIcon()
-{
-    if (mDockIconEnabled)
-    {
-        if (!mPausedShot.isNull())
-        {
-            CGImageRef pauseImg = ::darwinToCGImageRef (&mPausedShot);
-            /* Use the pause image as background */
-            mDockIconPreview->updateDockPreview (pauseImg);
-            CGImageRelease (pauseImg);
-        }
-        else
-        {
-# if defined (VBOX_GUI_USE_QUARTZ2D)
-            if (mode == VBoxDefs::Quartz2DMode)
-            {
-                /* If the render mode is Quartz2D we could use the CGImageRef
-                 * of the framebuffer for the dock icon creation. This saves
-                 * some conversion time. */
-                mDockIconPreview->updateDockPreview (static_cast <VBoxQuartz2DFrameBuffer *> (mFrameBuf)->imageRef());
-            }
-            else
-# endif
-                /* In image mode we have to create the image ref out of the
-                 * framebuffer */
-                mDockIconPreview->updateDockPreview (mFrameBuf);
-        }
-    }
-}
-
-void VBoxConsoleView::updateDockOverlay()
-{
-    /* Only to an update to the realtime preview if this is enabled by the user
-     * & we are in an state where the framebuffer is likely valid. Otherwise to
-     * the overlay stuff only. */
-    if (mDockIconEnabled &&
-        (mLastState == KMachineState_Running ||
-         mLastState == KMachineState_Paused ||
-         mLastState == KMachineState_Teleporting ||
-         mLastState == KMachineState_LiveSnapshotting ||
-         mLastState == KMachineState_Restoring ||
-         mLastState == KMachineState_TeleportingPausedVM ||
-         mLastState == KMachineState_TeleportingIn ||
-         mLastState == KMachineState_Saving ||
-         mLastState == KMachineState_DeletingSnapshotOnline ||
-         mLastState == KMachineState_DeletingSnapshotPaused))
-        updateDockIcon();
-    else
-        mDockIconPreview->updateDockOverlay();
-}
-
-/**
- * Wrapper for SetMouseCoalescingEnabled().
- *
- * Called by eventFilter() and darwinGrabKeyboardEvents().
- *
- * @param   aOn     Switch it on (true) or off (false).
- */
-void VBoxConsoleView::setMouseCoalescingEnabled (bool aOn)
-{
-    /* Enable mouse event compression if we leave the VM view. This
-       is necessary for having smooth resizing of the VM/other
-       windows.
-       Disable mouse event compression if we enter the VM view. So
-       all mouse events are registered in the VM. Only do this if
-       the keyboard/mouse is grabbed (this is when we have a valid
-       event handler). */
-    if (aOn || mKeyboardGrabbed)
-        ::darwinSetMouseCoalescingEnabled (aOn);
-}
-
-#endif /* Q_WS_MAC */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.h	(revision 29793)
+++ 	(revision )
@@ -1,373 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxConsoleView class declaration
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef ___VBoxConsoleView_h___
-#define ___VBoxConsoleView_h___
-
-#include "COMDefs.h"
-
-#include "VBoxDefs.h"
-#include "VBoxGlobalSettings.h"
-
-/* Qt includes */
-#include <QAbstractScrollArea>
-#include <QScrollBar>
-
-#if defined (Q_WS_PM)
-#include "src/os2/VBoxHlp.h"
-#define UM_PREACCEL_CHAR WM_USER
-#endif
-
-#if defined (Q_WS_MAC)
-# include <ApplicationServices/ApplicationServices.h>
-# ifndef QT_MAC_USE_COCOA
-#  include <Carbon/Carbon.h>
-# endif /* !QT_MAC_USE_COCOA */
-#endif
-
-class VBoxConsoleWnd;
-class MousePointerChangeEvent;
-class VBoxFrameBuffer;
-class VBoxDockIconPreview;
-
-class QPainter;
-class QLabel;
-class QMenuData;
-
-class VBoxConsoleView : public QAbstractScrollArea
-{
-    Q_OBJECT
-
-public:
-
-    enum {
-        MouseCaptured = 0x01,
-        MouseAbsolute = 0x02,
-        MouseAbsoluteDisabled = 0x04,
-        MouseNeedsHostCursor = 0x08,
-        KeyboardCaptured = 0x01,
-        HostKeyPressed = 0x02,
-    };
-
-    VBoxConsoleView (VBoxConsoleWnd *mainWnd,
-                     const CConsole &console,
-                     VBoxDefs::RenderMode rm,
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                     bool accelerate2DVideo,
-#endif
-                     QWidget *parent = 0);
-    ~VBoxConsoleView();
-
-    QSize sizeHint() const;
-
-    void attach();
-    void detach();
-    void refresh() { doRefresh(); }
-    void normalizeGeometry (bool adjustPosition = false);
-
-    CConsole &console() { return mConsole; }
-
-    bool pause (bool on);
-    bool isPaused()
-    {
-        return mLastState == KMachineState_Paused
-            || mLastState == KMachineState_TeleportingPausedVM;
-    }
-    const QPixmap& pauseShot() const { return mPausedShot; }
-
-    void setMouseIntegrationEnabled (bool enabled);
-
-    bool mouseCanAbsolute() const { return mMouseCanAbsolute; }
-    bool mouseCanRelative() const { return mMouseCanRelative; }
-    bool mouseNeedsHostCursor() const { return mMouseNeedsHostCursor; }
-
-    void updateHostCursor();
-
-    void setAutoresizeGuest (bool on, bool doHint);
-
-    void onFullscreenChange (bool on);
-
-    void onViewOpened();
-
-    void fixModifierState (LONG *codes, uint *count);
-
-    void toggleFSMode (const QSize &aSize = QSize());
-
-    void setIgnoreMainwndResize (bool aYes) { mIgnoreMainwndResize = aYes; }
-    void setIgnoreGuestResize (bool aYes) { mIgnoreGuestResize = aYes; }
-
-    QRect desktopGeometry();
-
-    QRegion lastVisibleRegion() const;
-
-    bool isAutoresizeGuestActive();
-
-    /* todo: This are some support functions for the qt4 port. Maybe we get rid
-     * of them some day. */
-    int contentsX() const { return horizontalScrollBar()->value(); }
-    int contentsY() const { return verticalScrollBar()->value(); }
-    int contentsWidth() const;
-    int contentsHeight() const;
-    int visibleWidth() const { return horizontalScrollBar()->pageStep(); }
-    int visibleHeight() const { return verticalScrollBar()->pageStep(); }
-    void scrollBy (int dx, int dy)
-    {
-        horizontalScrollBar()->setValue (horizontalScrollBar()->value() + dx);
-        verticalScrollBar()->setValue (verticalScrollBar()->value() + dy);
-    }
-    QPoint viewportToContents ( const QPoint & vp ) const
-    {
-        return QPoint (vp.x() + contentsX(),
-                       vp.y() + contentsY());
-    }
-    void updateSliders();
-
-    void requestToResize (const QSize &aSize);
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    void scrollContentsBy (int dx, int dy);
-#endif
-
-#if defined(Q_WS_MAC)
-    void updateDockIcon();
-    void updateDockOverlay();
-    void setDockIconEnabled (bool aOn) { mDockIconEnabled = aOn; };
-    void setMouseCoalescingEnabled (bool aOn);
-#endif
-
-signals:
-
-    void keyboardStateChanged (int state);
-    void mouseStateChanged (int state);
-    void machineStateChanged (KMachineState state);
-    void additionsStateChanged (const QString &, bool, bool, bool);
-    void mediaDriveChanged (VBoxDefs::MediumType aType);
-    void networkStateChange();
-    void usbStateChange();
-    void sharedFoldersChanged();
-    void resizeHintDone();
-
-protected:
-
-    // events
-    bool event (QEvent *e);
-    bool eventFilter (QObject *watched, QEvent *e);
-
-#if defined(Q_WS_WIN32)
-    bool winLowKeyboardEvent (UINT msg, const KBDLLHOOKSTRUCT &event);
-    bool winEvent (MSG *aMsg, long *aResult);
-#elif defined(Q_WS_PM)
-    bool pmEvent (QMSG *aMsg);
-#elif defined(Q_WS_X11)
-    bool x11Event (XEvent *event);
-#elif defined(Q_WS_MAC)
-    bool darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent);
-    void darwinGrabKeyboardEvents (bool fGrab);
-#endif
-
-private:
-
-    /** Flags for keyEvent(). */
-    enum {
-        KeyExtended = 0x01,
-        KeyPressed = 0x02,
-        KeyPause = 0x04,
-        KeyPrint = 0x08,
-    };
-
-    void focusEvent (bool aHasFocus, bool aReleaseHostKey = true);
-    bool keyEvent (int aKey, uint8_t aScan, int aFlags,
-                   wchar_t *aUniKey = NULL);
-    bool mouseEvent (int aType, const QPoint &aPos, const QPoint &aGlobalPos,
-                     Qt::MouseButtons aButtons, Qt::KeyboardModifiers aModifiers,
-                     int aWheelDelta, Qt::Orientation aWheelDir);
-
-    void emitKeyboardStateChanged()
-    {
-        emit keyboardStateChanged (
-            (mKbdCaptured ? KeyboardCaptured : 0) |
-            (mIsHostkeyPressed ? HostKeyPressed : 0));
-    }
-
-    void emitMouseStateChanged() {
-        emit mouseStateChanged ((mMouseCaptured ? MouseCaptured : 0) |
-                                (mMouseCanAbsolute ? MouseAbsolute : 0) |
-                                (!mMouseIntegration ? MouseAbsoluteDisabled : 0));
-    }
-
-    // IConsoleCallback event handlers
-    void onStateChange (KMachineState state);
-
-    void doRefresh();
-
-    void resizeEvent (QResizeEvent *);
-    void moveEvent (QMoveEvent *);
-    void paintEvent (QPaintEvent *);
-
-    void captureKbd (bool aCapture, bool aEmitSignal = true);
-    void captureMouse (bool aCapture, bool aEmitSignal = true);
-
-    bool processHotKey (const QKeySequence &key, const QList<QAction*>& data);
-    void updateModifiers (bool fNumLock, bool fCapsLock, bool fScrollLock);
-
-    void releaseAllPressedKeys (bool aReleaseHostKey = true);
-    void saveKeyStates();
-    void sendChangedKeyStates();
-    void updateMouseClipping();
-
-    void setPointerShape (MousePointerChangeEvent *me);
-
-    bool isRunning()
-    {
-        return mLastState == KMachineState_Running
-            || mLastState == KMachineState_Teleporting
-            || mLastState == KMachineState_LiveSnapshotting;
-    }
-
-    static void dimImage (QImage &img);
-
-private slots:
-
-    void doResizeHint (const QSize &aSize = QSize());
-    void doResizeDesktop (int);
-
-private:
-
-    enum DesktopGeo
-    {
-        DesktopGeo_Invalid = 0, DesktopGeo_Fixed,
-        DesktopGeo_Automatic, DesktopGeo_Any
-    };
-
-    void setDesktopGeometry (DesktopGeo aGeo, int aWidth, int aHeight);
-    void storeConsoleSize (int aWidth, int aHeight);
-    void calculateDesktopGeometry();
-    void maybeRestrictMinimumSize();
-    QRect availableGeometry() const;
-
-    VBoxConsoleWnd *mMainWnd;
-
-    CConsole mConsole;
-
-    const VBoxGlobalSettings &gs;
-
-    KMachineState mLastState;
-
-    bool mAttached : 1;
-    bool mKbdCaptured : 1;
-    bool mMouseCaptured : 1;
-    bool mMouseCanAbsolute : 1;
-    bool mMouseCanRelative : 1;
-    bool mMouseNeedsHostCursor : 1;
-    bool mMouseIntegration : 1;
-    QPoint mLastPos;
-    QPoint mCapturedPos;
-    int m_iLastMouseWheelDelta;
-
-    bool mDisableAutoCapture : 1;
-
-    enum { IsKeyPressed = 0x01, IsExtKeyPressed = 0x02, IsKbdCaptured = 0x80 };
-    uint8_t mPressedKeys [128];
-    uint8_t mPressedKeysCopy [128];
-
-    bool mIsHostkeyPressed : 1;
-    bool mIsHostkeyAlone : 1;
-
-    /** mKbdCaptured value during the the last host key press or release */
-    bool hostkey_in_capture : 1;
-
-    bool mIgnoreMainwndResize : 1;
-    bool mAutoresizeGuest : 1;
-    bool mIgnoreFrameBufferResize : 1;
-    bool mIgnoreGuestResize : 1;
-
-    /**
-     * This flag indicates whether the last console resize should trigger
-     * a size hint to the guest.  This is important particularly when
-     * enabling the autoresize feature to know whether to send a hint.
-     */
-    bool mDoResize : 1;
-
-    bool mGuestSupportsGraphics : 1;
-
-    bool mNumLock : 1;
-    bool mScrollLock : 1;
-    bool mCapsLock : 1;
-    long muNumLockAdaptionCnt;
-    long muCapsLockAdaptionCnt;
-
-
-    VBoxDefs::RenderMode mode;
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    bool mAccelerate2DVideo;
-#endif
-
-    QRegion mLastVisibleRegion;
-    QSize mNormalSize;
-
-#if defined(Q_WS_WIN)
-    HCURSOR mAlphaCursor;
-#endif
-
-#if defined(Q_WS_MAC)
-# ifndef QT_MAC_USE_COCOA
-    /** Event handler reference. NULL if the handler isn't installed. */
-    EventHandlerRef mDarwinEventHandlerRef;
-# endif /* !QT_MAC_USE_COCOA */
-    /** The current modifier key mask. Used to figure out which modifier
-     *  key was pressed when we get a kEventRawKeyModifiersChanged event. */
-    UInt32 mDarwinKeyModifiers;
-    bool mKeyboardGrabbed;
-#endif
-
-    VBoxFrameBuffer *mFrameBuf;
-    CConsoleCallback mCallback;
-
-    friend class VBoxConsoleCallback;
-
-#if defined (Q_WS_WIN32)
-    static LRESULT CALLBACK lowLevelKeyboardProc (int nCode,
-                                                  WPARAM wParam, LPARAM lParam);
-#elif defined (Q_WS_MAC)
-# ifdef QT_MAC_USE_COCOA
-    static bool darwinEventHandlerProc (const void *pvCocoaEvent, const
-                                        void *pvCarbonEvent, void *pvUser);
-# else /* QT_MAC_USE_COCOA */
-    static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
-                                                   EventRef inEvent, void *inUserData);
-# endif /* !QT_MAC_USE_COCOA */
-#endif
-
-    QPixmap mPausedShot;
-#if defined(Q_WS_MAC)
-# if !defined (QT_MAC_USE_COCOA)
-    EventHandlerRef mDarwinWindowOverlayHandlerRef;
-# endif
-    VBoxDockIconPreview *mDockIconPreview;
-    bool mDockIconEnabled;
-#endif
-    DesktopGeo mDesktopGeo;
-    QRect mDesktopGeometry;
-    QRect mStoredConsoleSize;
-    bool mPassCAD;
-    bool mHideHostPointer;
-    QCursor mLastCursor;
-};
-
-#endif // !___VBoxConsoleView_h___
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp	(revision 29793)
+++ 	(revision )
@@ -1,3934 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxConsoleWnd class implementation
- */
-
-/*
- * Copyright (C) 2006-2010 Oracle Corporation
- *
- * 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.
- */
-
-/* Global includes */
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include <QActionGroup>
-#include <QDesktopWidget>
-#include <QDir>
-#include <QFileInfo>
-#include <QMenuBar>
-#include <QProgressBar>
-#include <QTimer>
-
-#ifdef Q_WS_X11
-# include <QX11Info>
-#endif
-#ifdef Q_WS_MAC
-# include <QPainter>
-#endif
-
-/* Local includes */
-#include "QIFileDialog.h"
-#include "QIHotKeyEdit.h"
-#include "QIHttp.h"
-#include "QIStateIndicator.h"
-#include "QIStatusBar.h"
-#include "QIWidgetValidator.h"
-#include "QIHotKeyEdit.h"
-#include "VBoxConsoleWnd.h"
-#include "VBoxConsoleView.h"
-#include "VBoxCloseVMDlg.h"
-#include "UIDownloaderAdditions.h"
-#include "UIDownloaderUserManual.h"
-#include "VBoxGlobal.h"
-#include "VBoxMediaManagerDlg.h"
-#include "VBoxMiniToolBar.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxTakeSnapshotDlg.h"
-#include "UIFirstRunWzd.h"
-#include "VBoxVMSettingsNetwork.h"
-#include "VBoxVMSettingsSF.h"
-#include "VBoxVMInformationDlg.h"
-
-#ifdef Q_WS_X11
-# include <X11/Xlib.h>
-# include <XKeyboard.h>
-#endif
-#ifdef Q_WS_MAC
-# include "VBoxUtils.h"
-# include "VBoxIChatTheaterWrapper.h"
-# include <ApplicationServices/ApplicationServices.h>
-#endif
-#ifdef VBOX_WITH_DEBUGGER_GUI
-# include <VBox/err.h>
-# include <iprt/ldr.h>
-#endif
-
-#include <VBox/VMMDev.h> /** @todo @bugref{4084} */
-#include <VBox/version.h>
-#include <iprt/buildconfig.h>
-#include <iprt/param.h>
-#include <iprt/path.h>
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-/* Global forwards */
-extern void qt_set_sequence_auto_mnemonic (bool on);
-
-/** class StatusTipEvent
- *
- *  The StatusTipEvent class is an auxiliary QEvent class
- *  for carrying statusTip text of non-QAction menu item's.
- *  This event is posted then the menu item is highlighted but
- *  processed later in VBoxConsoleWnd::event() handler to
- *  avoid statusBar messaging collisions.
- */
-class StatusTipEvent : public QEvent
-{
-public:
-    enum { Type = QEvent::User + 10 };
-    StatusTipEvent (const QString &aTip)
-        : QEvent ((QEvent::Type) Type), mTip (aTip) {}
-
-    QString mTip;
-};
-
-struct MountTarget
-{
-    MountTarget() : name (QString ("")), port (0), device (0), id (QString()), type (VBoxDefs::MediumType_Invalid) {}
-    MountTarget (const QString &aName, LONG aPort, LONG aDevice)
-        : name (aName), port (aPort), device (aDevice), id (QString()), type (VBoxDefs::MediumType_Invalid) {}
-    MountTarget (const QString &aName, LONG aPort, LONG aDevice, const QString &aId)
-        : name (aName), port (aPort), device (aDevice), id (aId), type (VBoxDefs::MediumType_Invalid) {}
-    MountTarget (const QString &aName, LONG aPort, LONG aDevice, VBoxDefs::MediumType aType)
-        : name (aName), port (aPort), device (aDevice), id (QString()), type (aType) {}
-    QString name;
-    LONG port;
-    LONG device;
-    QString id;
-    VBoxDefs::MediumType type;
-};
-Q_DECLARE_METATYPE (MountTarget);
-
-int searchMaxSnapshotIndex (const CMachine &aMachine, const CSnapshot &aSnapshot, const QString &aNameTemplate)
-{
-    int maxIndex = 0;
-    QRegExp regExp (QString ("^") + aNameTemplate.arg ("([0-9]+)") + QString ("$"));
-    if (!aSnapshot.isNull())
-    {
-        /* Check the current snapshot name */
-        QString name = aSnapshot.GetName();
-        int pos = regExp.indexIn (name);
-        if (pos != -1)
-            maxIndex = regExp.cap (1).toInt() > maxIndex ? regExp.cap (1).toInt() : maxIndex;
-        /* Traversing all the snapshot children */
-        foreach (const CSnapshot &child, aSnapshot.GetChildren())
-        {
-            int maxIndexOfChildren = searchMaxSnapshotIndex (aMachine, child, aNameTemplate);
-            maxIndex = maxIndexOfChildren > maxIndex ? maxIndexOfChildren : maxIndex;
-        }
-    }
-    return maxIndex;
-}
-
-/** \class VBoxConsoleWnd
- *
- *  The VBoxConsoleWnd class is a VM console window, one of two main VBox
- *  GUI windows.
- *
- *  This window appears when the user starts the virtual machine. It
- *  contains the VBoxConsoleView widget that acts as a console of the
- *  running virtual machine.
- */
-
-/**
- *  Constructs the VM console window.
- *
- *  @param aSelf pointer to a variable where to store |this| right after
- *               this object's constructor is called (necessary to avoid
- *               recursion in VBoxGlobal::consoleWnd())
- */
-VBoxConsoleWnd::VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent, Qt::WindowFlags aFlags /* = Qt::Window */)
-    : QIWithRetranslateUI2 <QMainWindow> (aParent, aFlags)
-    /* Machine State */
-    , mMachineState (KMachineState_Null)
-    /* Window Variables */
-    , mConsoleStyle (0)
-    /* Menu Items */
-    , mMainMenu (0)
-    , mVMMenu (0)
-    , mVMMenuMini (0)
-    , mDevicesMenu (0)
-    , mDevicesCDMenu (0)
-    , mDevicesFDMenu (0)
-    , mDevicesNetworkMenu (0)
-    , mDevicesSFMenu (0)
-    , mDevicesUSBMenu (0)
-    , mVmDisMouseIntegrMenu (0)
-#if 0 /* TODO: Allow to setup status-bar! */
-    , mDevicesVRDPMenu (0)
-    , mVmAutoresizeMenu (0)
-#endif
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    , mDbgMenu (0)
-#endif
-    , mHelpMenu (0)
-    /* Action Groups */
-    , mRunningActions (0)
-    , mRunningOrPausedActions (0)
-    /* Machine Menu Actions */
-    , mVmFullscreenAction (0)
-    , mVmSeamlessAction (0)
-    , mVmAutoresizeGuestAction (0)
-    , mVmAdjustWindowAction (0)
-    , mVmDisableMouseIntegrAction (0)
-    , mVmTypeCADAction (0)
-#ifdef Q_WS_X11
-    , mVmTypeCABSAction (0)
-#endif
-    , mVmTakeSnapshotAction (0)
-    , mVmShowInformationDlgAction (0)
-    , mVmResetAction (0)
-    , mVmPauseAction (0)
-    , mVmACPIShutdownAction (0)
-    , mVmCloseAction (0)
-    /* Device Menu Actions */
-    , mDevicesNetworkDialogAction (0)
-    , mDevicesSFDialogAction (0)
-    , mDevicesSwitchVrdpSeparator (0)
-    , mDevicesSwitchVrdpAction (0)
-    , mDevicesInstallGuestToolsAction (0)
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Debug Menu Actions */
-    , mDbgStatisticsAction (0)
-    , mDbgCommandLineAction (0)
-    , mDbgLoggingAction (0)
-#endif
-    /* Widgets */
-    , mConsole (0)
-    , mMiniToolBar (0)
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    , mDbgGui (0)
-    , mDbgGuiVT (0)
-#endif
-    /* LED Update Timer */
-    , mIdleTimer (new QTimer (this))
-    , mNetworkTimer (new QTimer (this))
-    /* LEDs */
-    , mHDLed (0)
-    , mCDLed (0)
-#if 0 /* TODO: Allow to setup status-bar! */
-    , mFDLed (0)
-#endif
-    , mNetLed (0)
-    , mUSBLed (0)
-    , mSFLed (0)
-    , mVirtLed (0)
-    , mMouseLed (0)
-    , mHostkeyLed (0)
-    , mHostkeyLedContainer (0)
-    , mHostkeyName (0)
-#if 0 /* TODO: Allow to setup status-bar! */
-    , mVrdpLed (0)
-    , mAutoresizeLed (0)
-#endif
-    , mIsOpenViewFinished (false)
-    , mIsFirstTimeStarted (false)
-    , mIsAutoSaveMedia (true)
-    , mNoAutoClose (false)
-    , mIsFullscreen (false)
-    , mIsSeamless (false)
-    , mIsSeamlessSupported (false)
-    , mIsGraphicsSupported (false)
-    , mIsWaitingModeResize (false)
-    , mWasMax (false)
-{
-#ifdef DEBUG_poetzsch
-    printf("Old code path\n");
-#endif /* DEBUG_poetzsch */
-    if (aSelf)
-        *aSelf = this;
-
-    vboxGlobal().setMainWindow (this);
-
-    /* Cache IMedium data! */
-    vboxGlobal().startEnumeratingMedia();
-
-#if !(defined (Q_WS_WIN) || defined (Q_WS_MAC))
-    /* The default application icon (will change to the VM-specific icon in
-     * openView()). On Win32, it's built-in to the executable. On Mac OS X the
-     * icon referenced in info.plist is used. */
-    setWindowIcon (QIcon (":/VirtualBox_48px.png"));
-#endif
-
-    /* Ensure status bar is created */
-    setStatusBar (new QIStatusBar (this));
-
-    /* A group for all actions that are enabled only when the VM is running.
-     * Note that only actions whose enabled state depends exclusively on the
-     * execution state of the VM are added to this group. */
-    mRunningActions = new QActionGroup (this);
-    mRunningActions->setExclusive (false);
-
-    /* A group for all actions that are enabled when the VM is running or
-     * paused. Note that only actions whose enabled state depends exclusively
-     * on the execution state of the VM are added to this group. */
-    mRunningOrPausedActions = new QActionGroup (this);
-    mRunningOrPausedActions->setExclusive (false);
-
-    /* VM menu actions */
-    mVmFullscreenAction = new QAction (this);
-    mVmFullscreenAction->setIcon (VBoxGlobal::iconSetOnOff (
-        ":/fullscreen_on_16px.png", ":/fullscreen_16px.png",
-        ":/fullscreen_on_disabled_16px.png", ":/fullscreen_disabled_16px.png"));
-    mVmFullscreenAction->setCheckable (true);
-
-    mVmSeamlessAction = new QAction (this);
-    mVmSeamlessAction->setIcon (VBoxGlobal::iconSetOnOff (
-        ":/seamless_on_16px.png", ":/seamless_16px.png",
-        ":/seamless_on_disabled_16px.png", ":/seamless_disabled_16px.png"));
-    mVmSeamlessAction->setCheckable (true);
-
-    mVmAutoresizeGuestAction = new QAction (mRunningActions);
-    mVmAutoresizeGuestAction->setIcon (VBoxGlobal::iconSetOnOff (
-        ":/auto_resize_on_on_16px.png", ":/auto_resize_on_16px.png",
-        ":/auto_resize_on_on_disabled_16px.png", ":/auto_resize_on_disabled_16px.png"));
-    mVmAutoresizeGuestAction->setCheckable (true);
-    mVmAutoresizeGuestAction->setEnabled (false);
-
-    mVmAdjustWindowAction = new QAction (this);
-    mVmAdjustWindowAction->setIcon (VBoxGlobal::iconSet (
-        ":/adjust_win_size_16px.png", ":/adjust_win_size_disabled_16px.png"));
-
-    mVmDisableMouseIntegrAction = new QAction (this);
-    mVmDisableMouseIntegrAction->setIcon (VBoxGlobal::iconSetOnOff (
-        ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png",
-        ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png"));
-    mVmDisableMouseIntegrAction->setCheckable (true);
-
-    mVmTypeCADAction = new QAction (mRunningActions);
-    mVmTypeCADAction->setIcon (VBoxGlobal::iconSet (
-        ":/hostkey_16px.png", ":/hostkey_disabled_16px.png"));
-
-#if defined(Q_WS_X11)
-    mVmTypeCABSAction = new QAction (mRunningActions);
-    mVmTypeCABSAction->setIcon (VBoxGlobal::iconSet (
-        ":/hostkey_16px.png", ":/hostkey_disabled_16px.png"));
-#endif
-
-    mVmTakeSnapshotAction = new QAction (mRunningOrPausedActions);
-    mVmTakeSnapshotAction->setIcon (VBoxGlobal::iconSet (
-        ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png"));
-
-    mVmShowInformationDlgAction = new QAction (this);
-    mVmShowInformationDlgAction->setIcon (VBoxGlobal::iconSet (
-        ":/session_info_16px.png", ":/session_info_disabled_16px.png"));
-
-    mVmResetAction = new QAction (mRunningActions);
-    mVmResetAction->setIcon (VBoxGlobal::iconSet (
-        ":/reset_16px.png", ":/reset_disabled_16px.png"));
-
-    mVmPauseAction = new QAction (this);
-    mVmPauseAction->setIcon (VBoxGlobal::iconSet (
-        ":/pause_16px.png", ":/pause_disabled_16px.png"));
-    mVmPauseAction->setCheckable (true);
-
-    mVmACPIShutdownAction = new QAction (mRunningActions);
-    mVmACPIShutdownAction->setIcon (VBoxGlobal::iconSet (
-        ":/acpi_16px.png", ":/acpi_disabled_16px.png"));
-
-    mVmCloseAction = new QAction (this);
-    mVmCloseAction->setMenuRole (QAction::QuitRole);
-    mVmCloseAction->setIcon (VBoxGlobal::iconSet (":/exit_16px.png"));
-
-    /* Devices menu actions */
-    mDevicesNetworkDialogAction = new QAction (mRunningOrPausedActions);
-    mDevicesNetworkDialogAction->setIcon (VBoxGlobal::iconSet (
-        ":/nw_16px.png", ":/nw_disabled_16px.png"));
-
-    mDevicesSFDialogAction = new QAction (mRunningOrPausedActions);
-    mDevicesSFDialogAction->setIcon (VBoxGlobal::iconSet (
-        ":/shared_folder_16px.png", ":/shared_folder_disabled_16px.png"));
-
-    mDevicesSwitchVrdpAction = new QAction (mRunningOrPausedActions);
-    mDevicesSwitchVrdpAction->setIcon (VBoxGlobal::iconSetOnOff (
-        ":/vrdp_on_16px.png", ":/vrdp_16px.png",
-        ":/vrdp_on_disabled_16px.png", ":/vrdp_disabled_16px.png"));
-    mDevicesSwitchVrdpAction->setCheckable (true);
-
-    mDevicesInstallGuestToolsAction = new QAction (mRunningActions);
-    mDevicesInstallGuestToolsAction->setIcon (VBoxGlobal::iconSet (
-        ":/guesttools_16px.png", ":/guesttools_disabled_16px.png"));
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Debug menu actions */
-    if (vboxGlobal().isDebuggerEnabled())
-    {
-        mDbgStatisticsAction = new QAction (this);
-        mDbgCommandLineAction = new QAction (this);
-        if (vboxGlobal().getDebuggerModule()== NIL_RTLDRMOD)
-        {
-            mDbgStatisticsAction->setEnabled (false);
-            mDbgCommandLineAction->setEnabled (false);
-        }
-        mDbgLoggingAction = new QAction (this);
-        mDbgLoggingAction->setCheckable (true);
-    }
-    else
-    {
-        mDbgStatisticsAction = 0;
-        mDbgCommandLineAction = 0;
-        mDbgLoggingAction = 0;
-    }
-#endif
-
-    /* Help menu actions */
-    mHelpActions.setup (this);
-
-    /* Menu Items */
-    mMainMenu = new QIMenu (this);
-    mDevicesCDMenu = new QMenu (this);
-    mDevicesFDMenu = new QMenu (this);
-    mDevicesNetworkMenu = new QMenu (this);
-    mDevicesSFMenu = new QMenu (this);
-    mDevicesUSBMenu = new VBoxUSBMenu (this);
-
-    /* Machine submenu */
-    mVMMenu = menuBar()->addMenu (QString::null);
-    mMainMenu->addMenu (mVMMenu);
-    mVmDisMouseIntegrMenu = new VBoxSwitchMenu (mVMMenu, mVmDisableMouseIntegrAction, true);
-#if 0 /* TODO: Allow to setup status-bar! */
-    mVmAutoresizeMenu = new VBoxSwitchMenu (mVMMenu, mVmAutoresizeGuestAction);
-#endif
-
-    mVMMenu->addAction (mVmFullscreenAction);
-    mVMMenu->addAction (mVmSeamlessAction);
-    mVMMenu->addAction (mVmAutoresizeGuestAction);
-    mVMMenu->addAction (mVmAdjustWindowAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmDisableMouseIntegrAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmTypeCADAction);
-#ifdef Q_WS_X11
-    mVMMenu->addAction (mVmTypeCABSAction);
-#endif
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmTakeSnapshotAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmShowInformationDlgAction);
-    mVMMenu->addSeparator();
-    mVMMenu->addAction (mVmResetAction);
-    mVMMenu->addAction (mVmPauseAction);
-    mVMMenu->addAction (mVmACPIShutdownAction);
-#ifndef Q_WS_MAC
-    mVMMenu->addSeparator();
-#endif /* Q_WS_MAC */
-    mVMMenu->addAction (mVmCloseAction);
-
-    /* Devices submenu */
-    mDevicesMenu = menuBar()->addMenu (QString::null);
-    mMainMenu->addMenu (mDevicesMenu);
-
-    mDevicesCDMenu->setIcon (VBoxGlobal::iconSet (":/cd_16px.png", ":/cd_disabled_16px.png"));
-    mDevicesFDMenu->setIcon (VBoxGlobal::iconSet (":/fd_16px.png", ":/fd_disabled_16px.png"));
-    mDevicesUSBMenu->setIcon (VBoxGlobal::iconSet (":/usb_16px.png", ":/usb_disabled_16px.png"));
-
-    mDevicesMenu->addMenu (mDevicesCDMenu);
-    mDevicesMenu->addMenu (mDevicesFDMenu);
-    mDevicesMenu->addAction (mDevicesNetworkDialogAction);
-    mDevicesMenu->addAction (mDevicesSFDialogAction);
-    mDevicesMenu->addMenu (mDevicesUSBMenu);
-
-#if 0 /* TODO: Allow to setup status-bar! */
-    mDevicesVRDPMenu = new VBoxSwitchMenu (mDevicesMenu, mDevicesSwitchVrdpAction);
-#endif
-    mDevicesSwitchVrdpSeparator = mDevicesMenu->addSeparator();
-    mDevicesMenu->addAction (mDevicesSwitchVrdpAction);
-
-    mDevicesMenu->addSeparator();
-    mDevicesMenu->addAction (mDevicesInstallGuestToolsAction);
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Debug submenu */
-    if (vboxGlobal().isDebuggerEnabled())
-    {
-        mDbgMenu = menuBar()->addMenu (QString::null);
-        mMainMenu->addMenu (mDbgMenu);
-        mDbgMenu->addAction (mDbgStatisticsAction);
-        mDbgMenu->addAction (mDbgCommandLineAction);
-        mDbgMenu->addAction (mDbgLoggingAction);
-    }
-    else
-        mDbgMenu = 0;
-#endif
-
-    /* Help submenu */
-    mHelpMenu = menuBar()->addMenu (QString::null);
-    mMainMenu->addMenu (mHelpMenu);
-    mHelpActions.addTo (mHelpMenu);
-
-    /* Machine submenu for mini-toolbar */
-    mVMMenuMini = new QMenu (this);
-    mVMMenuMini->addAction (mVmTypeCADAction);
-#ifdef Q_WS_X11
-    mVMMenuMini->addAction (mVmTypeCABSAction);
-#endif
-    mVMMenuMini->addSeparator();
-    mVMMenuMini->addAction (mVmTakeSnapshotAction);
-    mVMMenuMini->addSeparator();
-    mVMMenuMini->addAction (mVmShowInformationDlgAction);
-    mVMMenuMini->addSeparator();
-    mVMMenuMini->addAction (mVmResetAction);
-    mVMMenuMini->addAction (mVmPauseAction);
-    mVMMenuMini->addAction (mVmACPIShutdownAction);
-
-    /* Status bar */
-    QWidget *indicatorBox = new QWidget;
-    QHBoxLayout *indicatorBoxHLayout = new QHBoxLayout (indicatorBox);
-    VBoxGlobal::setLayoutMargin (indicatorBoxHLayout, 0);
-    indicatorBoxHLayout->setSpacing (5);
-
-    /* i/o devices */
-    mHDLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mHDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/hd_16px.png"));
-    mHDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/hd_read_16px.png"));
-    mHDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/hd_write_16px.png"));
-    mHDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/hd_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mHDLed);
-    mCDLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mCDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/cd_16px.png"));
-    mCDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/cd_read_16px.png"));
-    mCDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/cd_write_16px.png"));
-    mCDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/cd_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mCDLed);
-#if 0 /* TODO: Allow to setup status-bar! */
-    mFDLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mFDLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/fd_16px.png"));
-    mFDLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/fd_read_16px.png"));
-    mFDLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/fd_write_16px.png"));
-    mFDLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/fd_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mFDLed);
-#endif
-    mNetLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mNetLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/nw_16px.png"));
-    mNetLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/nw_read_16px.png"));
-    mNetLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/nw_write_16px.png"));
-    mNetLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/nw_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mNetLed);
-    mUSBLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mUSBLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/usb_16px.png"));
-    mUSBLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/usb_read_16px.png"));
-    mUSBLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/usb_write_16px.png"));
-    mUSBLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/usb_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mUSBLed);
-    mSFLed = new QIStateIndicator (KDeviceActivity_Idle);
-    mSFLed->setStateIcon (KDeviceActivity_Idle, QPixmap (":/shared_folder_16px.png"));
-    mSFLed->setStateIcon (KDeviceActivity_Reading, QPixmap (":/shared_folder_read_16px.png"));
-    mSFLed->setStateIcon (KDeviceActivity_Writing, QPixmap (":/shared_folder_write_16px.png"));
-    mSFLed->setStateIcon (KDeviceActivity_Null, QPixmap (":/shared_folder_disabled_16px.png"));
-    indicatorBoxHLayout->addWidget (mSFLed);
-
-    /* virtualization */
-    mVirtLed = new QIStateIndicator (0);
-    mVirtLed->setStateIcon (0, QPixmap (":/vtx_amdv_disabled_16px.png"));
-    mVirtLed->setStateIcon (1, QPixmap (":/vtx_amdv_16px.png"));
-    indicatorBoxHLayout->addWidget (mVirtLed);
-
-    QFrame *separator = new QFrame();
-    separator->setFrameStyle (QFrame::VLine | QFrame::Sunken);
-    indicatorBoxHLayout->addWidget (separator);
-
-    /* mouse */
-    mMouseLed = new QIStateIndicator (0);
-    mMouseLed->setStateIcon (0, QPixmap (":/mouse_disabled_16px.png"));
-    mMouseLed->setStateIcon (1, QPixmap (":/mouse_16px.png"));
-    mMouseLed->setStateIcon (2, QPixmap (":/mouse_seamless_16px.png"));
-    mMouseLed->setStateIcon (3, QPixmap (":/mouse_can_seamless_16px.png"));
-    mMouseLed->setStateIcon (4, QPixmap (":/mouse_can_seamless_uncaptured_16px.png"));
-    indicatorBoxHLayout->addWidget (mMouseLed);
-
-    /* host key */
-    mHostkeyLedContainer = new QWidget;
-    QHBoxLayout *hostkeyLEDContainerLayout = new QHBoxLayout (mHostkeyLedContainer);
-    VBoxGlobal::setLayoutMargin (hostkeyLEDContainerLayout, 0);
-    hostkeyLEDContainerLayout->setSpacing (3);
-    indicatorBoxHLayout->addWidget (mHostkeyLedContainer);
-
-    mHostkeyLed = new QIStateIndicator (0);
-    mHostkeyLed->setStateIcon (0, QPixmap (":/hostkey_16px.png"));
-    mHostkeyLed->setStateIcon (1, QPixmap (":/hostkey_captured_16px.png"));
-    mHostkeyLed->setStateIcon (2, QPixmap (":/hostkey_pressed_16px.png"));
-    mHostkeyLed->setStateIcon (3, QPixmap (":/hostkey_captured_pressed_16px.png"));
-    hostkeyLEDContainerLayout->addWidget (mHostkeyLed);
-    mHostkeyName = new QLabel (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey()));
-    hostkeyLEDContainerLayout->addWidget (mHostkeyName);
-
-#if 0 /* TODO: Allow to setup status-bar! */
-    /* VRDP Led */
-    mVrdpLed = new QIStateIndicator (0, indicatorBox, "mVrdpLed", Qt::WNoAutoErase);
-    mVrdpLed->setStateIcon (0, QPixmap (":/vrdp_disabled_16px.png"));
-    mVrdpLed->setStateIcon (1, QPixmap (":/vrdp_16px.png"));
-    /* Auto-Resize LED */
-    mAutoresizeLed = new QIStateIndicator (1, indicatorBox, "mAutoresizeLed", Qt::WNoAutoErase);
-    mAutoresizeLed->setStateIcon (0, QPixmap (":/auto_resize_off_disabled_16px.png"));
-    mAutoresizeLed->setStateIcon (1, QPixmap (":/auto_resize_off_16px.png"));
-    mAutoresizeLed->setStateIcon (2, QPixmap (":/auto_resize_on_disabled_16px.png"));
-    mAutoresizeLed->setStateIcon (3, QPixmap (":/auto_resize_on_16px.png"));
-#endif
-
-#ifdef Q_WS_MAC
-    m_pDockMenu = new QMenu(this);
-    /* Add all VM menu entries to the dock menu. Leave out close and stuff like
-     * this. */
-    QList<QAction*> actions = mVMMenu->actions();
-    for (int i=0; i < actions.size(); ++i)
-        if (actions.at(i)->menuRole() == QAction::TextHeuristicRole)
-            m_pDockMenu->addAction(actions.at(i));
-    m_pDockMenu->addSeparator();
-
-    m_pDockSettingsMenu = new QMenu(this);
-    QActionGroup *pDockPreviewModeGroup = new QActionGroup(this);
-    m_pDockEnablePreviewMonitor = new QAction(pDockPreviewModeGroup);
-    m_pDockEnablePreviewMonitor->setCheckable(true);
-    m_pDockDisablePreview = new QAction(pDockPreviewModeGroup);
-    m_pDockDisablePreview->setCheckable(true);
-    m_pDockSettingsMenu->addActions(pDockPreviewModeGroup->actions());
-
-    m_pDockMenu->addMenu(m_pDockSettingsMenu);
-
-    /* Add it to the dock. */
-    extern void qt_mac_set_dock_menu(QMenu *);
-    qt_mac_set_dock_menu(m_pDockMenu);
-#endif /* Q_WS_MAC */
-
-    /* add to statusbar */
-    statusBar()->addPermanentWidget (indicatorBox, 0);
-
-    /* Retranslate UI */
-    retranslateUi();
-
-    setWindowTitle (mCaptionPrefix);
-
-    /* Connections */
-    connect (mVmFullscreenAction, SIGNAL (toggled (bool)), this, SLOT (vmFullscreen (bool)));
-    connect (mVmSeamlessAction, SIGNAL (toggled (bool)), this, SLOT (vmSeamless (bool)));
-    connect (mVmAutoresizeGuestAction, SIGNAL (toggled (bool)), this, SLOT (vmAutoresizeGuest (bool)));
-    connect (mVmAdjustWindowAction, SIGNAL (triggered()), this, SLOT (vmAdjustWindow()));
-    connect (mVmDisableMouseIntegrAction, SIGNAL (toggled (bool)), this, SLOT (vmDisableMouseIntegration (bool)));
-    connect (mVmTypeCADAction, SIGNAL (triggered()), this, SLOT (vmTypeCAD()));
-#ifdef Q_WS_X11
-    connect (mVmTypeCABSAction, SIGNAL (triggered()), this, SLOT (vmTypeCABS()));
-#endif
-    connect (mVmTakeSnapshotAction, SIGNAL (triggered()), this, SLOT (vmTakeSnapshot()));
-    connect (mVmShowInformationDlgAction, SIGNAL (triggered()), this, SLOT (vmShowInfoDialog()));
-    connect (mVmResetAction, SIGNAL (triggered()), this, SLOT (vmReset()));
-    connect (mVmPauseAction, SIGNAL (toggled (bool)), this, SLOT (vmPause (bool)));
-    connect (mVmACPIShutdownAction, SIGNAL (triggered()), this, SLOT (vmACPIShutdown()));
-    connect (mVmCloseAction, SIGNAL (triggered()), this, SLOT (vmClose()));
-
-    connect (mDevicesCDMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu()));
-    connect (mDevicesFDMenu, SIGNAL (aboutToShow()), this, SLOT (prepareStorageMenu()));
-    connect (mDevicesNetworkMenu, SIGNAL (aboutToShow()), this, SLOT (prepareNetworkMenu()));
-    connect (mDevicesSFMenu, SIGNAL (aboutToShow()), this, SLOT (prepareSFMenu()));
-    connect (mDevicesUSBMenu, SIGNAL(triggered (QAction *)), this, SLOT(switchUSB (QAction *)));
-
-    connect (mDevicesNetworkDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenNetworkDialog()));
-    connect (mDevicesSFDialogAction, SIGNAL (triggered()), this, SLOT (devicesOpenSFDialog()));
-    connect (mDevicesSwitchVrdpAction, SIGNAL (toggled (bool)), this, SLOT (devicesSwitchVrdp (bool)));
-    connect (mDevicesInstallGuestToolsAction, SIGNAL (triggered()), this, SLOT (devicesInstallGuestAdditions()));
-
-    connect (mCDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-#if 0 /* TODO: Allow to setup status-bar! */
-    connect (mFDLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-#endif
-    connect (mNetLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-    connect (mUSBLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-    connect (mSFLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-    connect (mMouseLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-#if 0 /* TODO: Allow to setup status-bar! */
-    connect (mVrdpLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-    connect (mAutoresizeLed, SIGNAL (contextMenuRequested (QIStateIndicator *, QContextMenuEvent *)),
-             this, SLOT (showIndicatorContextMenu (QIStateIndicator *, QContextMenuEvent *)));
-#endif
-
-    /* Watch global settings changes */
-    connect (&vboxGlobal().settings(), SIGNAL (propertyChanged (const char *, const char *)),
-             this, SLOT (processGlobalSettingChange (const char *, const char *)));
-    connect(&vboxProblem(), SIGNAL(sigDownloaderUserManualCreated()), this, SLOT(sltDownloaderUserManualEmbed()));
-#ifdef Q_WS_MAC
-    connect(pDockPreviewModeGroup, SIGNAL(triggered(QAction*)),
-            this, SLOT(sltDockPreviewModeChanged(QAction*)));
-    connect (&vboxGlobal(), SIGNAL (dockIconUpdateChanged (const VBoxChangeDockIconUpdateEvent &)),
-             this, SLOT (changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &)));
-    connect (&vboxGlobal(), SIGNAL (presentationModeChanged (const VBoxChangePresentationModeEvent &)),
-             this, SLOT (changePresentationMode (const VBoxChangePresentationModeEvent &)));
-#endif
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    if (mDbgMenu)
-        connect (mDbgMenu, SIGNAL (aboutToShow()), this, SLOT (dbgPrepareDebugMenu()));
-    if (mDbgStatisticsAction)
-        connect (mDbgStatisticsAction, SIGNAL (triggered()), this, SLOT (dbgShowStatistics()));
-    if (mDbgCommandLineAction)
-        connect (mDbgCommandLineAction, SIGNAL (triggered()), this, SLOT (dbgShowCommandLine()));
-    if (mDbgLoggingAction)
-        connect (mDbgLoggingAction, SIGNAL (toggled (bool)), this, SLOT (dbgLoggingToggled (bool)));
-#endif
-
-#ifdef Q_WS_MAC
-    /* For the status bar on Cocoa */
-    setUnifiedTitleAndToolBarOnMac (true);
-# ifdef VBOX_WITH_ICHAT_THEATER
-    // int setAttr[] = { kHIWindowBitDoesNotShowBadgeInDock, 0 };
-    // HIWindowChangeAttributes (window, setAttr, 0);
-    initSharedAVManager();
-# endif
-#endif
-
-    mMaskShift.scale (0, 0, Qt::IgnoreAspectRatio);
-}
-
-VBoxConsoleWnd::~VBoxConsoleWnd()
-{
-    closeView();
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    dbgDestroy();
-#endif
-}
-
-#ifdef Q_WS_MAC
-void VBoxConsoleWnd::sltDockPreviewModeChanged(QAction *pAction)
-{
-    if (mConsole)
-    {
-        CMachine machine = mSession.GetMachine();
-        if (!machine.isNull())
-        {
-            if (pAction == m_pDockDisablePreview)
-                machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "false");
-            else if (pAction == m_pDockEnablePreviewMonitor)
-                machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "true");
-            mConsole->updateDockOverlay();
-        }
-    }
-}
-#endif /* Q_WS_MAC */
-
-/**
- *  Opens a new console view to interact with a given VM.
- *  Does nothing if the console view is already opened.
- *  Used by VBoxGlobal::startMachine(), should not be called directly.
- */
-bool VBoxConsoleWnd::openView (const CSession &aSession)
-{
-    LogFlowFuncEnter();
-
-    if (mConsole)
-    {
-        LogFlowFunc (("Already opened\n"));
-        LogFlowFuncLeave();
-        return false;
-    }
-
-#ifdef Q_WS_MAC
-    /* We have to make sure that we are getting the front most process. This is
-     * necessary for Qt versions > 4.3.3 */
-    ProcessSerialNumber psn = { 0, kCurrentProcess };
-    ::SetFrontProcess (&psn);
-#endif /* Q_WS_MAC */
-
-    mSession = aSession;
-
-    if (!centralWidget())
-    {
-        setCentralWidget (new QWidget (this));
-        QGridLayout *pMainLayout = new QGridLayout (centralWidget());
-        VBoxGlobal::setLayoutMargin (pMainLayout, 0);
-        pMainLayout->setSpacing (0);
-
-        mShiftingSpacerLeft = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerTop = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerRight = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerBottom = new QSpacerItem (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        pMainLayout->addItem (mShiftingSpacerTop, 0, 0, 1, -1);
-        pMainLayout->addItem (mShiftingSpacerLeft, 1, 0);
-        pMainLayout->addItem (mShiftingSpacerRight, 1, 2);
-        pMainLayout->addItem (mShiftingSpacerBottom, 2, 0, 1, -1);
-    }
-
-    mVmPauseAction->setChecked (false);
-
-    CConsole console = mSession.GetConsole();
-    AssertWrapperOk (mSession);
-
-    CMachine machine = mSession.GetMachine();
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled */
-    bool bAccelerate2DVideo = machine.GetAccelerate2DVideoEnabled()
-            && VBoxGlobal::isAcceleration2DVideoAvailable()
-    ;
-#endif
-
-    mConsole = new VBoxConsoleView (this, console, vboxGlobal().vmRenderMode(),
-#ifdef VBOX_WITH_VIDEOHWACCEL
-                                    bAccelerate2DVideo,
-#endif
-                                    centralWidget());
-    qobject_cast <QGridLayout*> (centralWidget()->layout())->addWidget (mConsole, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
-
-    /* Mini toolbar */
-    bool isActive = !(machine.GetExtraData (VBoxDefs::GUI_ShowMiniToolBar) == "no");
-    bool isAtTop = (machine.GetExtraData (VBoxDefs::GUI_MiniToolBarAlignment) == "top");
-    bool isAutoHide = !(machine.GetExtraData (VBoxDefs::GUI_MiniToolBarAutoHide) == "off");
-    QList <QMenu*> menus (QList <QMenu*>() << mVMMenuMini << mDevicesMenu);
-    mMiniToolBar = new VBoxMiniToolBar (centralWidget(), isAtTop ? VBoxMiniToolBar::AlignTop : VBoxMiniToolBar::AlignBottom,
-                                        isActive, isAutoHide);
-    *mMiniToolBar << menus;
-    connect (mMiniToolBar, SIGNAL (exitAction()), this, SLOT (mtExitMode()));
-    connect (mMiniToolBar, SIGNAL (closeAction()), this, SLOT (mtCloseVM()));
-    connect (mMiniToolBar, SIGNAL (geometryUpdated()), this, SLOT (mtMaskUpdate()));
-    connect (this, SIGNAL (closing()), mMiniToolBar, SLOT (close()));
-
-    activateUICustomizations();
-
-    /* Set the VM-specific application icon */
-    /* Not on Mac OS X. The dock icon is handled below. */
-#ifndef Q_WS_MAC
-    setWindowIcon (vboxGlobal().vmGuestOSTypeIcon (machine.GetOSTypeId()));
-#endif
-
-    /* Restore the position of the window and some options */
-    {
-        QString str = machine.GetExtraData (VBoxDefs::GUI_LastWindowPosition);
-
-        bool ok = false, max = false;
-        int x = 0, y = 0, w = 0, h = 0;
-        x = str.section (',', 0, 0).toInt (&ok);
-        if (ok)
-            y = str.section (',', 1, 1).toInt (&ok);
-        if (ok)
-            w = str.section (',', 2, 2).toInt (&ok);
-        if (ok)
-            h = str.section (',', 3, 3).toInt (&ok);
-        if (ok)
-            max = str.section (',', 4, 4) == VBoxDefs::GUI_LastWindowPosition_Max;
-
-        QRect ar = ok ? QApplication::desktop()->availableGeometry (QPoint (x, y)) :
-                        QApplication::desktop()->availableGeometry (this);
-
-        if (ok /* previous parameters were read correctly */)
-        {
-            mNormalGeo = QRect (x, y, w, h);
-            setGeometry (mNormalGeo);
-
-            /* Normalize to the optimal size */
-            mConsole->normalizeGeometry (true /* adjustPosition */);
-
-            if (max)
-            {
-                /* Maximize if needed */
-                setWindowState (windowState() | Qt::WindowMaximized);
-                mWasMax = max;
-            }
-        }
-        else
-        {
-            /* Normalize to the optimal size */
-            mConsole->normalizeGeometry (true /* adjustPosition */);
-
-            /* Move newly created window to the screen center. */
-            mNormalGeo = geometry();
-            mNormalGeo.moveCenter (ar.center());
-            setGeometry (mNormalGeo);
-        }
-
-        show();
-
-        /* Process show & possible maximize events */
-        qApp->processEvents();
-
-        mVmSeamlessAction->setEnabled (false);
-        str = machine.GetExtraData (VBoxDefs::GUI_Seamless);
-        if (str == "on")
-            mVmSeamlessAction->setChecked (true);
-
-        str = machine.GetExtraData (VBoxDefs::GUI_AutoresizeGuest);
-        if (str != "off")
-            mVmAutoresizeGuestAction->setChecked (true);
-
-        str = machine.GetExtraData (VBoxDefs::GUI_FirstRun);
-        if (str == "yes")
-            mIsFirstTimeStarted = true;
-        else if (!str.isEmpty())
-            machine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);
-
-        str = machine.GetExtraData (VBoxDefs::GUI_SaveMountedAtRuntime);
-        if (str == "no")
-            mIsAutoSaveMedia = false;
-
-        /* Check if one of extended modes to be activated on loading */
-        QString fsMode = machine.GetExtraData (VBoxDefs::GUI_Fullscreen);
-        QString slMode = machine.GetExtraData (VBoxDefs::GUI_Seamless);
-        bool extendedMode = fsMode == "on" || slMode == "on";
-
-        /* If one of extended modes to be loaded we have to ignore default
-         * console resize event which will come from VGA Device on loading. */
-        if (extendedMode)
-            mConsole->requestToResize (QSize (w, h - menuBar()->height() - statusBar()->height()));
-    }
-
-    /* initialize storage stuff */
-    int cdDevicesCount = 0;
-    int fdDevicesCount = 0;
-    const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
-    foreach (const CMediumAttachment &attachment, attachments)
-    {
-        if (attachment.GetType() == KDeviceType_DVD)
-            ++ cdDevicesCount;
-        if (attachment.GetType() == KDeviceType_Floppy)
-            ++ fdDevicesCount;
-    }
-    mDevicesCDMenu->menuAction()->setData (cdDevicesCount);
-    mDevicesFDMenu->menuAction()->setData (fdDevicesCount);
-    mDevicesCDMenu->menuAction()->setVisible (cdDevicesCount);
-    mDevicesFDMenu->menuAction()->setVisible (fdDevicesCount);
-
-    /* initialize usb stuff */
-    CUSBController usbctl = machine.GetUSBController();
-    if (   usbctl.isNull()
-        || !usbctl.GetEnabled()
-        || !usbctl.GetProxyAvailable())
-    {
-        /* hide usb_menu & usb_separator & usb_status_led */
-        mDevicesUSBMenu->menuAction()->setVisible (false);
-        mUSBLed->setHidden (true);
-    }
-    else
-    {
-        mDevicesUSBMenu->setEnabled (true);
-        mDevicesUSBMenu->setConsole (console);
-        mUSBLed->setState (true);
-    }
-
-    /* initialize vrdp stuff */
-    CVRDPServer vrdpsrv = machine.GetVRDPServer();
-    if (vrdpsrv.isNull())
-    {
-        /* hide vrdp_menu_action & vrdp_separator & vrdp_status_icon */
-        mDevicesSwitchVrdpAction->setVisible (false);
-        mDevicesSwitchVrdpSeparator->setVisible (false);
-#if 0 /* TODO: Allow to setup status-bar! */
-        mVrdpLed->setHidden (true);
-#endif
-    }
-
-    /* start an idle timer that will update device lighths */
-    connect (mIdleTimer, SIGNAL (timeout()), SLOT (updateDeviceLights()));
-    mIdleTimer->start (50);
-    connect (mNetworkTimer, SIGNAL (timeout()), SLOT (updateNetworkIPs()));
-    mNetworkTimer->start (5000);
-
-    connect (mConsole, SIGNAL (mouseStateChanged (int)), this, SLOT (updateMouseState (int)));
-    connect (mConsole, SIGNAL (keyboardStateChanged (int)), mHostkeyLed, SLOT (setState (int)));
-    connect (mConsole, SIGNAL (machineStateChanged (KMachineState)), this, SLOT (updateMachineState (KMachineState)));
-    connect (mConsole, SIGNAL (additionsStateChanged (const QString&, bool, bool, bool)),
-             this, SLOT (updateAdditionsState (const QString &, bool, bool, bool)));
-    connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)),
-             this, SLOT (updateMediaDriveState (VBoxDefs::MediumType)));
-    connect (mConsole, SIGNAL (usbStateChange()), this, SLOT (updateUsbState()));
-    connect (mConsole, SIGNAL (networkStateChange()), this, SLOT (updateNetworkAdaptersState()));
-    connect (mConsole, SIGNAL (sharedFoldersChanged()), this, SLOT (updateSharedFoldersState()));
-
-#ifdef Q_WS_MAC
-    QString strTest = machine.GetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled).toLower();
-    /* Default to true if it is an empty value */
-    bool f = (strTest.isEmpty() || strTest == "true");
-    if (f)
-        m_pDockEnablePreviewMonitor->setChecked(true);
-    else
-        m_pDockDisablePreview->setChecked(true);
-    mConsole->setDockIconEnabled (f);
-    mConsole->updateDockOverlay();
-#endif
-
-    /* set the correct initial mMachineState value */
-    mMachineState = console.GetState();
-
-    mConsole->normalizeGeometry (false /* adjustPosition */);
-
-    updateAppearanceOf (AllStuff);
-
-    if (vboxGlobal().settings().autoCapture())
-        vboxProblem().remindAboutAutoCapture();
-
-    /*
-     *  The further startup procedure should be done after we leave this method
-     *  and enter the main event loop in main(), because it may result into
-     *  showing various modal dialogs that will process events from within
-     *  this method that in turn can lead to various side effects like this
-     *  window is closed before this method returns, etc.
-     */
-
-    QTimer::singleShot (0, this, SLOT (finalizeOpenView()));
-
-    LogFlowFuncLeave();
-    return true;
-}
-
-void VBoxConsoleWnd::setMouseIntegrationLocked (bool aDisabled)
-{
-    mVmDisableMouseIntegrAction->setChecked (false);
-    mVmDisableMouseIntegrAction->setEnabled (aDisabled);
-}
-
-/**
- *  Shows up and activates the popup version of the main menu.
- *
- *  @param aCenter If @a true, center the popup menu on the screen, otherwise
- *                 show it at the current mouse pointer location.
- */
-void VBoxConsoleWnd::popupMainMenu (bool aCenter)
-{
-    QPoint pos = QCursor::pos();
-    if (aCenter)
-    {
-        QRect deskGeo = QApplication::desktop()->screenGeometry (this);
-        QRect popGeo = mMainMenu->frameGeometry();
-        popGeo.moveCenter (QPoint (deskGeo.width() / 2, deskGeo.height() / 2));
-        pos = popGeo.topLeft();
-    }
-    else
-    {
-        /* put the menu's bottom right corner to the pointer's hotspot point */
-        pos.setX (pos.x() - mMainMenu->frameGeometry().width());
-        pos.setY (pos.y() - mMainMenu->frameGeometry().height());
-    }
-
-    mMainMenu->popup (pos);
-    mMainMenu->selectFirstAction();
-#ifdef Q_WS_WIN
-    mMainMenu->activateWindow();
-#endif
-}
-
-void VBoxConsoleWnd::setMask (const QRegion &aRegion)
-{
-    QRegion region = aRegion;
-
-    /* The global mask shift cause of toolbars and such things. */
-    region.translate (mMaskShift.width(), mMaskShift.height());
-
-    /* Including mini toolbar area */
-    QRegion toolBarRegion (mMiniToolBar->mask());
-    toolBarRegion.translate (mMiniToolBar->mapToGlobal (toolBarRegion.boundingRect().topLeft()) - QPoint (1, 0));
-    region += toolBarRegion;
-
-    /* Restrict the drawing to the available space on the screen.
-     * (The &operator is better than the previous used -operator,
-     * because this excludes space around the real screen also.
-     * This is necessary for the mac.) */
-    region &= mStrictedRegion;
-
-#ifdef Q_WS_WIN
-    QRegion difference = mPrevRegion.subtract (region);
-
-    /* Region offset calculation */
-    int fleft = 0, ftop = 0;
-
-    /* Visible region calculation */
-    HRGN newReg = CreateRectRgn (0, 0, 0, 0);
-    CombineRgn (newReg, region.handle(), 0, RGN_COPY);
-    OffsetRgn (newReg, fleft, ftop);
-
-    /* Invisible region calculation */
-    HRGN diffReg = CreateRectRgn (0, 0, 0, 0);
-    CombineRgn (diffReg, difference.handle(), 0, RGN_COPY);
-    OffsetRgn (diffReg, fleft, ftop);
-
-    /* Set the current visible region and clean the previous */
-    SetWindowRgn (winId(), newReg, FALSE);
-    RedrawWindow (0, 0, diffReg, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN);
-    RedrawWindow (mConsole->viewport()->winId(), 0, 0, RDW_INVALIDATE);
-
-    mPrevRegion = region;
-#elif defined (Q_WS_MAC)
-# if defined (VBOX_GUI_USE_QUARTZ2D)
-    if (vboxGlobal().vmRenderMode() == VBoxDefs::Quartz2DMode)
-    {
-        /* If we are using the Quartz2D backend we have to trigger
-         * an repaint only. All the magic clipping stuff is done
-         * in the paint engine. */
-        ::darwinWindowInvalidateShape (mConsole->viewport());
-    }
-    else
-# endif
-    {
-        /* This is necessary to avoid the flicker by an mask update.
-         * See http://lists.apple.com/archives/Carbon-development/2001/Apr/msg01651.html
-         * for the hint.
-         * There *must* be a better solution. */
-        if (!region.isEmpty())
-            region |= QRect (0, 0, 1, 1);
-        // /* Save the current region for later processing in the darwin event handler. */
-        // mCurrRegion = region;
-        // /* We repaint the screen before the ReshapeCustomWindow command. Unfortunately
-        //  * this command flushes a copy of the backbuffer to the screen after the new
-        //  * mask is set. This leads into a missplaced drawing of the content. Currently
-        //  * no alternative to this and also this is not 100% perfect. */
-        // repaint();
-        // qApp->processEvents();
-        // /* Now force the reshaping of the window. This is definitly necessary. */
-        // ReshapeCustomWindow (reinterpret_cast <WindowPtr> (winId()));
-        QMainWindow::setMask (region);
-        // HIWindowInvalidateShadow (::darwinToWindowRef (mConsole->viewport()));
-    }
-#else
-    QMainWindow::setMask (region);
-#endif
-}
-
-void VBoxConsoleWnd::clearMask()
-{
-#ifdef Q_WS_WIN
-    SetWindowRgn (winId(), 0, TRUE);
-#else
-    QMainWindow::clearMask();
-#endif
-}
-
-void VBoxConsoleWnd::onDisplayResize (ulong aWidth, ulong aHeight)
-{
-    if (mIsSeamless)
-    {
-        const QRect & geo = QApplication::desktop()->availableGeometry (this);
-        int dW = geo.width() - (int)aWidth;
-        int dH = geo.height() - (int)aHeight;
-        if (RT_ABS (dW) > 16 || RT_ABS (dH) > 16)
-        {
-            mVmSeamlessAction->setChecked (false);
-            /* should be cleared already, but just in case */
-            if (mIsSeamless)
-                toggleFullscreenMode (false, true);
-        }
-    }
-}
-
-
-bool VBoxConsoleWnd::event (QEvent *aEvent)
-{
-    switch (aEvent->type())
-    {
-        /* By handling every Resize and Move we keep track of the normal
-         * (non-minimized and non-maximized) window geometry. Shame on Qt
-         * that it doesn't provide this geometry in its public APIs. */
-
-        case QEvent::Resize:
-        {
-            QResizeEvent *re = (QResizeEvent *) aEvent;
-
-            if (!mIsWaitingModeResize && !isWindowMaximized() &&
-                !isTrueFullscreen() && !isTrueSeamless())
-            {
-                mNormalGeo.setSize (re->size());
-#ifdef VBOX_WITH_DEBUGGER_GUI
-                dbgAdjustRelativePos();
-#endif
-            }
-
-            if (mIsWaitingModeResize)
-            {
-                if (!mIsFullscreen && !mIsSeamless)
-                {
-                    mIsWaitingModeResize = false;
-                    QTimer::singleShot (0, this, SLOT (onExitFullscreen()));
-                }
-            }
-            break;
-        }
-        case QEvent::Move:
-        {
-            if (!isWindowMaximized() && !isTrueFullscreen() && !isTrueSeamless())
-            {
-                mNormalGeo.moveTo (geometry().x(), geometry().y());
-#ifdef VBOX_WITH_DEBUGGER_GUI
-                dbgAdjustRelativePos();
-#endif
-            }
-            break;
-        }
-#ifdef Q_WS_MAC
-        case QEvent::Paint:
-        {
-            if (mIsSeamless)
-            {
-                /* Clear the background */
-                CGContextClearRect (::darwinToCGContextRef (this), ::darwinToCGRect (frameGeometry()));
-            }
-            break;
-        }
-#endif
-        case StatusTipEvent::Type:
-        {
-            StatusTipEvent *ev = (StatusTipEvent*) aEvent;
-            statusBar()->showMessage (ev->mTip);
-            break;
-        }
-        default:
-            break;
-    }
-
-    return QMainWindow::event (aEvent);
-}
-
-void VBoxConsoleWnd::closeEvent (QCloseEvent *aEvent)
-{
-    LogFlowFuncEnter();
-
-    static const char *kSave = "save";
-    static const char *kShutdown = "shutdown";
-    static const char *kPowerOff = "powerOff";
-    static const char *kDiscardCurState = "discardCurState";
-
-    if (!mConsole)
-    {
-        aEvent->accept();
-        LogFlowFunc (("Console already destroyed!"));
-        LogFlowFuncLeave();
-        return;
-    }
-
-    switch (mMachineState)
-    {
-        case KMachineState_PoweredOff:
-        case KMachineState_Saved:
-        case KMachineState_Teleported:
-        case KMachineState_Aborted:
-            /* The machine has been already powered off or saved or aborted -- close the window immediately. */
-            aEvent->accept();
-            break;
-
-        default:
-            /* The machine is in some temporary state like Saving or Stopping.
-             * Ignore the close event. When it is Stopping, it will be soon closed anyway from updateMachineState().
-             * In all other cases, an appropriate progress dialog will be shown within a few seconds. */
-            aEvent->ignore();
-            break;
-
-        case KMachineState_Teleporting:      /** @todo Live Migration: Test closing a VM that's being teleported or snapshotted. */
-        case KMachineState_LiveSnapshotting:
-        case KMachineState_Running:
-        case KMachineState_Paused:
-        case KMachineState_TeleportingPausedVM: /** @todo Live Migration: Check out this. */
-        case KMachineState_Stuck:
-            /* Start with ignoring the close event: */
-            aEvent->ignore();
-
-            /* Get the machine: */
-            CMachine machine = session().GetMachine();
-
-            /* Prepare close dialog: */
-            VBoxCloseVMDlg dlg (this);
-
-            /* Assign close-dialog pixmap: */
-            dlg.pmIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (machine.GetOSTypeId()));
-
-            /* Check which close actions are disallowed: */
-            QStringList restictedActionsList = machine.GetExtraData(VBoxDefs::GUI_RestrictedCloseActions).split(',');
-            bool fIsStateSavingAllowed = !restictedActionsList.contains("SaveState", Qt::CaseInsensitive);
-            bool fIsACPIShutdownAllowed = !restictedActionsList.contains("Shutdown", Qt::CaseInsensitive);
-            bool fIsPowerOffAllowed = !restictedActionsList.contains("PowerOff", Qt::CaseInsensitive);
-            bool fIsPowerOffAndRestoreAllowed = fIsPowerOffAllowed && !restictedActionsList.contains("Restore", Qt::CaseInsensitive);
-
-            /* Make Save State button visible/hidden depending on restriction: */
-            dlg.mRbSave->setVisible(fIsStateSavingAllowed);
-            dlg.mTxSave->setVisible(fIsStateSavingAllowed);
-            /* Make Save State button enabled/disabled depending on machine state: */
-            dlg.mRbSave->setEnabled(mMachineState != KMachineState_Stuck);
-
-            /* Make ACPI shutdown button visible/hidden depending on restriction: */
-            dlg.mRbShutdown->setVisible(fIsACPIShutdownAllowed);
-            dlg.mTxShutdown->setVisible(fIsACPIShutdownAllowed);
-            /* Make ACPI shutdown button enabled/disabled depending on ACPI state & machine state: */
-            bool isACPIEnabled = session().GetConsole().GetGuestEnteredACPIMode();
-            dlg.mRbShutdown->setEnabled(isACPIEnabled && mMachineState != KMachineState_Stuck);
-
-            /* Make Power Off button visible/hidden depending on restriction: */
-            dlg.mRbPowerOff->setVisible(fIsPowerOffAllowed);
-            dlg.mTxPowerOff->setVisible(fIsPowerOffAllowed);
-
-            /* Make the Restore Snapshot checkbox visible/hidden depending on snapshots count & restrictions: */
-            dlg.mCbDiscardCurState->setVisible(fIsPowerOffAndRestoreAllowed && machine.GetSnapshotCount() > 0);
-            if (!machine.GetCurrentSnapshot().isNull())
-                dlg.mCbDiscardCurState->setText(dlg.mCbDiscardCurState->text().arg(machine.GetCurrentSnapshot().GetName()));
-
-            /* Read the last user's choice for the given VM */
-            QStringList lastAction = machine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (',');
-
-            /* Check which button should be initially chosen: */
-            QRadioButton *pRadioButton = 0;
-
-            /* If chosing 'last choice' is possible: */
-            if (lastAction[0] == kSave && fIsStateSavingAllowed)
-            {
-                pRadioButton = dlg.mRbSave;
-            }
-            else if (lastAction[0] == kShutdown && fIsACPIShutdownAllowed && isACPIEnabled)
-            {
-                pRadioButton = dlg.mRbShutdown;
-            }
-            else if (lastAction[0] == kPowerOff && fIsPowerOffAllowed)
-            {
-                pRadioButton = dlg.mRbPowerOff;
-                if (fIsPowerOffAndRestoreAllowed)
-                    dlg.mCbDiscardCurState->setChecked(lastAction.count() > 1 && lastAction[1] == kDiscardCurState);
-            }
-            /* Else 'default choice' will be used: */
-            else
-            {
-                if (fIsACPIShutdownAllowed && isACPIEnabled)
-                    pRadioButton = dlg.mRbShutdown;
-                else if (fIsPowerOffAllowed)
-                    pRadioButton = dlg.mRbPowerOff;
-                else if (fIsStateSavingAllowed)
-                    pRadioButton = dlg.mRbSave;
-            }
-
-            /* If some radio button was chosen: */
-            if (pRadioButton)
-            {
-                /* Check and focus it: */
-                pRadioButton->setChecked(true);
-                pRadioButton->setFocus();
-            }
-            /* If no one of radio buttons was chosen: */
-            else
-            {
-                /* Just leave: */
-                return;
-            }
-
-            /* This flag will keep the status of every further logical operation: */
-            bool success = true;
-
-            /* This flag will remember if we are going to close VM: */
-            bool fCloseVM = false;
-
-            /* Pause before showing dialog if necessary: */
-            bool fWasPaused = mMachineState == KMachineState_Paused ||
-                              mMachineState == KMachineState_TeleportingPausedVM ||
-                              mMachineState == KMachineState_Stuck;
-            if (!fWasPaused)
-                success = mConsole->pause (true);
-
-            if (success)
-            {
-                if (dlg.exec() == QDialog::Accepted)
-                {
-                    /* Disable auto closure because we want to have a chance to show
-                     * the error dialog on save state / power off failure. */
-                    mNoAutoClose = true;
-
-                    /* Get current console: */
-                    CConsole console = session().GetConsole();
-
-                    success = false;
-
-                    if (dlg.mRbSave->isChecked())
-                    {
-                        CProgress progress = console.SaveState();
-
-                        if (!console.isOk())
-                            vboxProblem().cannotSaveMachineState (console);
-                        else
-                        {
-                            /* Show the "VM saving" progress dialog: */
-                            vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0);
-                            if (progress.GetResultCode() != 0)
-                                vboxProblem().cannotSaveMachineState (progress);
-                            else
-                                success = true;
-                        }
-
-                        if (success)
-                            fCloseVM = true;
-                    }
-                    else if (dlg.mRbShutdown->isChecked())
-                    {
-                        /* Unpause the VM to let it grab the ACPI shutdown event: */
-                        mConsole->pause (false);
-                        /* Prevent the subsequent unpause request: */
-                        fWasPaused = true;
-                        /* Signal ACPI shutdown (if there is no ACPI device, the operation will fail): */
-                        console.PowerButton();
-                        if (!console.isOk())
-                            vboxProblem().cannotACPIShutdownMachine (console);
-                        else
-                            success = true;
-                    }
-                    else if (dlg.mRbPowerOff->isChecked())
-                    {
-                        CProgress progress = console.PowerDown();
-
-                        if (!console.isOk())
-                            vboxProblem().cannotStopMachine (console);
-                        else
-                        {
-                            /* Show the power down progress dialog: */
-                            vboxProblem().showModalProgressDialog (progress, machine.GetName(), this);
-                            if (progress.GetResultCode() != 0)
-                                vboxProblem().cannotStopMachine (progress);
-                            else
-                                success = true;
-                        }
-
-                        if (success)
-                        {
-                            /* Discard the current state if requested: */
-                            if (dlg.mCbDiscardCurState->isChecked() && dlg.mCbDiscardCurState->isVisibleTo (&dlg))
-                            {
-                                CSnapshot snapshot = machine.GetCurrentSnapshot();
-                                CProgress progress = console.RestoreSnapshot (snapshot);
-                                if (!console.isOk())
-                                    vboxProblem().cannotRestoreSnapshot (console, snapshot.GetName());
-                                else
-                                {
-                                    /* Show the progress dialog: */
-                                    vboxProblem().showModalProgressDialog (progress, machine.GetName(), this);
-                                    if (progress.GetResultCode() != 0)
-                                        vboxProblem().cannotRestoreSnapshot (progress, snapshot.GetName());
-                                }
-                            }
-                        }
-
-                        if (success)
-                            fCloseVM = true;
-                    }
-
-                    if (success)
-                    {
-                        /* Read the last user's choice for the given VM: */
-                        QStringList prevAction = machine.GetExtraData (VBoxDefs::GUI_LastCloseAction).split (',');
-                        /* Memorize the last user's choice for the given VM: */
-                        QString lastAction = kPowerOff;
-                        if (dlg.mRbSave->isChecked())
-                            lastAction = kSave;
-                        else if ((dlg.mRbShutdown->isChecked()) ||
-                                 (dlg.mRbPowerOff->isChecked() && prevAction [0] == kShutdown && !isACPIEnabled))
-                            lastAction = kShutdown;
-                        else if (dlg.mRbPowerOff->isChecked())
-                            lastAction = kPowerOff;
-                        else
-                            AssertFailed();
-                        if (dlg.mCbDiscardCurState->isChecked())
-                            (lastAction += ",") += kDiscardCurState;
-                        machine.SetExtraData (VBoxDefs::GUI_LastCloseAction, lastAction);
-                    }
-
-                    if (fCloseVM)
-                    {
-                        /* Accept the close action if necessary: */
-                        aEvent->accept();
-                    }
-
-                    /* Enable auto closure again: */
-                    mNoAutoClose = false;
-                }
-            }
-
-            if (mMachineState == KMachineState_PoweredOff ||
-                mMachineState == KMachineState_Saved ||
-                mMachineState == KMachineState_Teleported ||
-                mMachineState == KMachineState_Aborted)
-            {
-                /* The machine has been stopped while showing the Close or the Pause
-                 * failure dialog -- accept the close event immediately. */
-                aEvent->accept();
-            }
-            else
-            {
-                /* Restore the running state if needed: */
-                if (success && !fCloseVM && !fWasPaused && mMachineState == KMachineState_Paused)
-                    mConsole->pause (false);
-            }
-
-            break;
-    }
-
-    if (aEvent->isAccepted())
-    {
-#ifndef VBOX_GUI_SEPARATE_VM_PROCESS
-        vboxGlobal().selectorWnd().show();
-#endif
-
-        /* Stop LED update timer: */
-        mIdleTimer->stop();
-        mIdleTimer->disconnect (SIGNAL (timeout()), this, SLOT (updateDeviceLights()));
-        /* Stop Network timer: */
-        mNetworkTimer->stop();
-        mNetworkTimer->disconnect (SIGNAL (timeout()), this, SLOT (updateNetworkIPs()));
-
-        /* Hide console window: */
-        hide();
-
-        /* Save the position of the window and some options: */
-        CMachine machine = mSession.GetMachine();
-        QString winPos = QString ("%1,%2,%3,%4")
-            .arg (mNormalGeo.x()).arg (mNormalGeo.y())
-            .arg (mNormalGeo.width()).arg (mNormalGeo.height());
-        if (isWindowMaximized() || (mIsFullscreen && mWasMax) || (mIsSeamless && mWasMax))
-            winPos += QString (",%1").arg (VBoxDefs::GUI_LastWindowPosition_Max);
-
-        machine.SetExtraData (VBoxDefs::GUI_LastWindowPosition, winPos);
-
-        machine.SetExtraData (VBoxDefs::GUI_Fullscreen,
-                              mVmFullscreenAction->isChecked() ? "on" : "off");
-        machine.SetExtraData (VBoxDefs::GUI_Seamless,
-                              mVmSeamlessAction->isChecked() ? "on" : "off");
-        machine.SetExtraData (VBoxDefs::GUI_AutoresizeGuest,
-                              mVmAutoresizeGuestAction->isChecked() ? "on" : "off");
-        machine.SetExtraData (VBoxDefs::GUI_MiniToolBarAutoHide,
-                              mMiniToolBar->isAutoHide() ? "on" : "off");
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-        /* Close & destroy the debugger GUI: */
-        dbgDestroy();
-#endif
-
-        /* Make sure all events are delivered: */
-        qApp->processEvents();
-
-        /* Notify all the top-level dialogs about closing: */
-        emit closing();
-    }
-
-    LogFlowFunc (("accepted=%d\n", aEvent->isAccepted()));
-    LogFlowFuncLeave();
-}
-
-#ifdef Q_WS_X11
-bool VBoxConsoleWnd::x11Event (XEvent *aEvent)
-{
-    /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
-     * WindowActivate and WindowDeactivate Qt events are not properly sent
-     * on top level window (i.e. this) deactivation. The fix is to substiute
-     * the mode in FocusOut X11 event structure to NotifyNormal to cause
-     * Qt to process it as desired. */
-    if (mConsole && aEvent->type == FocusOut)
-    {
-        if (aEvent->xfocus.mode == NotifyWhileGrabbed  &&
-            (aEvent->xfocus.detail == NotifyAncestor ||
-             aEvent->xfocus.detail == NotifyInferior ||
-             aEvent->xfocus.detail == NotifyNonlinear))
-        {
-             aEvent->xfocus.mode = NotifyNormal;
-        }
-    }
-    return false;
-}
-#endif
-
-/**
- *  Sets the strings of the subwidgets using the current
- *  language.
- */
-void VBoxConsoleWnd::retranslateUi()
-{
-#ifdef VBOX_OSE
-    mCaptionPrefix = tr ("VirtualBox OSE");
-#else
-    mCaptionPrefix = VBOX_PRODUCT;
-#endif
-
-#ifdef VBOX_BLEEDING_EDGE
-    mCaptionPrefix += tr (" EXPERIMENTAL build %1r%2 - %3").arg (RTBldCfgVersion()).arg (RTBldCfgRevisionStr()).arg (VBOX_BLEEDING_EDGE);
-#endif
-    /*
-     *  Note: All action shortcuts should be added to the menu text in the
-     *  form of "\tHost+<Key>" where <Key> is the shortcut key according
-     *  to regular QKeySequence rules. No translation of the "Host" word is
-     *  allowed (VBoxConsoleView relies on its spelling). setAccel() must not
-     *  be used. Unfortunately on the Mac the "host" string is silently removed
-     *  & the key is created as an global shortcut. So every e.g. F key stroke
-     *  in the vm leads to a menu call of the F entry. Mysteriously the
-     *  associated action isn't started. As a workaround the Host+<key> is
-     *  written in braces after the menu text.
-     */
-
-    /* VM actions */
-#ifdef Q_WS_MAC
-    qt_set_sequence_auto_mnemonic (false);
-#endif
-
-    mVmDisMouseIntegrMenu->setToolTip (tr ("Mouse Integration", "enable/disable..."));
-#if 0 /* TODO: Allow to setup status-bar! */
-    mVmAutoresizeMenu->setToolTip (tr ("Auto-resize Guest Display", "enable/disable..."));
-#endif
-
-    mVmFullscreenAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Fullscreen Mode"), "F"));
-    mVmFullscreenAction->setStatusTip (tr ("Switch to fullscreen mode" ));
-
-    mVmSeamlessAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Seam&less Mode"), "L"));
-    mVmSeamlessAction->setStatusTip (tr ("Switch to seamless desktop integration mode"));
-
-    mVmAutoresizeGuestAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Auto-resize &Guest Display"), "G"));
-    mVmAutoresizeGuestAction->setStatusTip (tr ("Automatically resize the guest display when the "
-                                                "window is resized (requires Guest Additions)"));
-
-    mVmAdjustWindowAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Adjust Window Size"), "A"));
-    mVmAdjustWindowAction->setStatusTip (tr ("Adjust window size and position to best fit the guest display"));
-
-    /* mVmDisableMouseIntegrAction is set up in updateAppearanceOf() */
-
-    mVmTypeCADAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Insert Ctrl-Alt-Del"), "Del"));
-    mVmTypeCADAction->setStatusTip (tr ("Send the Ctrl-Alt-Del sequence to the virtual machine"));
-
-#if defined(Q_WS_X11)
-    mVmTypeCABSAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Insert Ctrl-Alt-Backspace"), "Backspace"));
-    mVmTypeCABSAction->setStatusTip (tr ("Send the Ctrl-Alt-Backspace sequence to the virtual machine"));
-#endif
-
-    mVmTakeSnapshotAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Take &Snapshot..."), "S"));
-    mVmTakeSnapshotAction->setStatusTip (tr ("Take a snapshot of the virtual machine"));
-
-    mVmShowInformationDlgAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Session I&nformation Dialog"), "N"));
-    mVmShowInformationDlgAction->setStatusTip (tr ("Show Session Information Dialog"));
-
-    mVmResetAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Reset"), "R"));
-    mVmResetAction->setStatusTip (tr ("Reset the virtual machine"));
-
-    /* mVmPauseAction is set up in updateAppearanceOf() */
-
-#ifdef Q_WS_MAC
-    /* Host+H is Hide on the mac */
-    mVmACPIShutdownAction->setText (VBoxGlobal::insertKeyToActionText (tr ("ACPI S&hutdown"), "U"));
-#else /* Q_WS_MAC */
-    mVmACPIShutdownAction->setText (VBoxGlobal::insertKeyToActionText (tr ("ACPI S&hutdown"), "H"));
-#endif /* !Q_WS_MAC */
-    mVmACPIShutdownAction->setStatusTip (tr ("Send the ACPI Power Button press event to the virtual machine"));
-
-    mVmCloseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Close..." ), "Q"));
-    mVmCloseAction->setStatusTip (tr ("Close the virtual machine"));
-    mVmCloseAction->setMenuRole (QAction::QuitRole);
-
-    /* Devices actions */
-    mDevicesCDMenu->setTitle (tr ("&CD/DVD Devices"));
-    mDevicesFDMenu->setTitle (tr ("&Floppy Devices"));
-
-    mDevicesNetworkDialogAction->setText (tr ("&Network Adapters..."));
-    mDevicesNetworkDialogAction->setStatusTip (tr ("Change the settings of network adapters"));
-
-    mDevicesSFDialogAction->setText (tr ("&Shared Folders..."));
-    mDevicesSFDialogAction->setStatusTip (tr ("Create or modify shared folders"));
-
-    mDevicesSwitchVrdpAction->setText (tr ("&Remote Display"));
-    mDevicesSwitchVrdpAction->setStatusTip (tr ("Enable or disable remote desktop (RDP) connections to this machine"));
-#if 0 /* TODO: Allow to setup status-bar! */
-    mDevicesVRDPMenu->setToolTip (tr ("Remote Desktop (RDP) Server", "enable/disable..."));
-#endif
-
-    mDevicesInstallGuestToolsAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Install Guest Additions..."), "D"));
-    mDevicesInstallGuestToolsAction->setStatusTip (tr ("Mount the Guest Additions installation image"));
-
-    mDevicesUSBMenu->setTitle (tr ("&USB Devices"));
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Debug actions */
-    if (mDbgStatisticsAction)
-        mDbgStatisticsAction->setText (tr ("&Statistics...", "debug action"));
-    if (mDbgCommandLineAction)
-        mDbgCommandLineAction->setText (tr ("&Command Line...", "debug action"));
-    if (mDbgLoggingAction)
-        mDbgLoggingAction->setText (tr ("&Logging...", "debug action"));
-#endif
-
-    /* Help actions */
-    mHelpActions.retranslateUi();
-
-    /* Main menu & seamless popup menu */
-    mVMMenu->setTitle (tr ("&Machine"));
-    // mVMMenu->setIcon (VBoxGlobal::iconSet (":/machine_16px.png"));
-
-    mVMMenuMini->setTitle (tr ("&Machine"));
-
-    mDevicesMenu->setTitle (tr ("&Devices"));
-    // mDevicesMenu->setIcon (VBoxGlobal::iconSet (":/settings_16px.png"));
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    if (vboxGlobal().isDebuggerEnabled())
-        mDbgMenu->setTitle (tr ("De&bug"));
-#endif
-    mHelpMenu->setTitle (tr ("&Help"));
-    // mHelpMenu->setIcon (VBoxGlobal::iconSet (":/help_16px.png"));
-
-#ifdef Q_WS_MAC
-    m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
-    m_pDockDisablePreview->setText(tr("Show Application Icon"));
-    m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
-#endif /* Q_WS_MAC */
-
-    /* Status bar widgets */
-    mMouseLed->setToolTip (
-        tr ("Indicates whether the host mouse pointer is captured by the guest OS:<br>"
-            "<nobr><img src=:/mouse_disabled_16px.png/>&nbsp;&nbsp;pointer is not captured</nobr><br>"
-            "<nobr><img src=:/mouse_16px.png/>&nbsp;&nbsp;pointer is captured</nobr><br>"
-            "<nobr><img src=:/mouse_seamless_16px.png/>&nbsp;&nbsp;mouse integration (MI) is On</nobr><br>"
-            "<nobr><img src=:/mouse_can_seamless_16px.png/>&nbsp;&nbsp;MI is Off, pointer is captured</nobr><br>"
-            "<nobr><img src=:/mouse_can_seamless_uncaptured_16px.png/>&nbsp;&nbsp;MI is Off, pointer is not captured</nobr><br>"
-            "Note that the mouse integration feature requires Guest Additions to be installed in the guest OS."));
-    mHostkeyLed->setToolTip (
-        tr ("Indicates whether the keyboard is captured by the guest OS "
-            "(<img src=:/hostkey_captured_16px.png/>) or not (<img src=:/hostkey_16px.png/>)."));
-    mHostkeyName->setToolTip (
-        tr ("Shows the currently assigned Host key.<br>"
-            "This key, when pressed alone, toggles the keyboard and mouse "
-            "capture state. It can also be used in combination with other keys "
-            "to quickly perform actions from the main menu."));
-    mHostkeyName->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey()));
-
-#if 0 /* TODO: Allow to setup status-bar! */
-    mAutoresizeLed->setToolTip (
-        tr ("Indicates whether the guest display auto-resize function is On "
-            "(<img src=:/auto_resize_on_16px.png/>) or Off (<img src=:/auto_resize_off_16px.png/>). "
-            "Note that this function requires Guest Additions to be installed in the guest OS."));
-#endif
-
-    updateAppearanceOf (AllStuff);
-}
-
-void VBoxConsoleWnd::finalizeOpenView()
-{
-    LogFlowFuncEnter();
-
-    /* Notify the console scroll-view about the console-window is opened. */
-    mConsole->onViewOpened();
-
-    bool saved = mMachineState == KMachineState_Saved;
-
-    CMachine machine = mSession.GetMachine();
-    CConsole console = mConsole->console();
-
-    if (mIsFirstTimeStarted)
-    {
-        UIFirstRunWzd wzd (this, machine);
-        wzd.exec();
-
-        /* Remove GUI_FirstRun extra data key from the machine settings
-         * file after showing the wizard once. */
-        machine.SetExtraData (VBoxDefs::GUI_FirstRun, QString::null);
-    }
-
-    bool fFullscreenActivated = false;
-    QString str = machine.GetExtraData (VBoxDefs::GUI_Fullscreen);
-    if (str == "on")
-    {
-        mVmFullscreenAction->setChecked (true);
-        fFullscreenActivated = true;
-    }
-
-    /* Start the VM */
-    CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
-                         console.PowerUpPaused() : console.PowerUp();
-
-    /* Check for an immediate failure */
-    if (!console.isOk())
-    {
-        if (vboxGlobal().showStartVMErrors())
-            vboxProblem().cannotStartMachine (console);
-        /* close this window (this will call closeView()) */
-        close();
-
-        LogFlowFunc (("Error starting VM\n"));
-        LogFlowFuncLeave();
-        return;
-    }
-
-    mConsole->attach();
-
-    /* Disable auto closure because we want to have a chance to show the
-     * error dialog on startup failure */
-    if (vboxGlobal().showStartVMErrors())
-        mNoAutoClose = true;
-
-    /* show the "VM starting / restoring" progress dialog */
-
-    if (saved)
-        vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0);
-    else
-        vboxProblem().showModalProgressDialog (progress, machine.GetName(), this);
-
-    if (progress.GetResultCode() != 0)
-    {
-        if (vboxGlobal().showStartVMErrors())
-            vboxProblem().cannotStartMachine (progress);
-        /* close this window (this will call closeView()) */
-        close();
-
-        LogFlowFunc (("Error starting VM\n"));
-        LogFlowFuncLeave();
-        return;
-    }
-
-    if (vboxGlobal().showStartVMErrors())
-        mNoAutoClose = false;
-
-    /* Check if we missed a really quick termination after successful
-     * startup, and process it if we did. */
-    if (   mMachineState == KMachineState_PoweredOff
-        || mMachineState == KMachineState_Saved
-        || mMachineState == KMachineState_Teleported
-        || mMachineState == KMachineState_Aborted
-       )
-    {
-        close();
-        LogFlowFuncLeave();
-        return;
-    }
-
-    /* Currently the machine is started and the guest API could be used...
-     * Checking if the fullscreen mode should be activated */
-    if (fFullscreenActivated)
-        mConsole->toggleFSMode (mConsole->size());
-
-    /* If seamless mode should be enabled then check if it is enabled
-     * currently and re-enable it if seamless is supported */
-    if (mVmSeamlessAction->isChecked() && mIsSeamlessSupported && mIsGraphicsSupported)
-        toggleFullscreenMode (true, true);
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Open the debugger in "full screen" mode requested by the user. */
-    else if (vboxGlobal().isDebuggerAutoShowEnabled())
-    {
-        /* console in upper left corner of the desktop. */
-        QRect rct (0, 0, 0, 0);
-        QDesktopWidget *desktop = QApplication::desktop();
-        if (desktop)
-            rct = desktop->availableGeometry(pos());
-        move (QPoint (rct.x(), rct.y()));
-
-        if (vboxGlobal().isDebuggerAutoShowStatisticsEnabled())
-            dbgShowStatistics();
-        if (vboxGlobal().isDebuggerAutoShowCommandLineEnabled())
-            dbgShowCommandLine();
-
-        if (!vboxGlobal().isStartPausedEnabled())
-            mConsole->pause (false);
-    }
-#endif
-
-    mIsOpenViewFinished = true;
-    LogFlowFuncLeave();
-
-#ifdef VBOX_WITH_UPDATE_REQUEST
-    vboxGlobal().showUpdateDialog (false /* aForce */);
-#endif
-
-    /* Finally check the status of required features. */
-    checkRequiredFeatures();
-
-    /* Re-request all the static values finally after
-     * view is really opened and attached. */
-    updateAppearanceOf (VirtualizationStuff);
-}
-
-/**
- *  Helper to safely close the main console window.
- *
- *  This method ensures that close() will not be called if there is some
- *  modal widget currently being executed, as it can cause uninitialization
- *  at the point of code where it is not expected at all (example:
- *  VBoxConsoleView::mouseEvent() calling
- *  VBoxProblemReporter::confirmInputCapture()). Instead, an attempt to
- *  close the current modal widget is done and tryClose() is rescheduled for
- *  later execution using a single-shot zero timer.
- *
- *  In particular, this method is used by updateMachineState() when the VM
- *  goes offline, which can even happen if we are inside the modal event loop,
- *  (for example, the VM has been externally powered off or the guest OS
- *  has initiated a shutdown procedure).
- */
-void VBoxConsoleWnd::tryClose()
-{
-    /* First close any open modal & popup widgets. Use a single shot with
-     * timeout 0 to allow the widgets to cleany close and test then again. If
-     * all open widgets are closed destroy ourself. */
-    QWidget *widget = QApplication::activeModalWidget() ?
-                      QApplication::activeModalWidget() :
-                      QApplication::activePopupWidget() ?
-                      QApplication::activePopupWidget() : 0;
-    if (widget)
-    {
-        widget->close();
-        QTimer::singleShot (0, this, SLOT (tryClose()));
-    }
-    else
-        close();
-}
-
-void VBoxConsoleWnd::vmFullscreen (bool aOn)
-{
-    bool ok = toggleFullscreenMode (aOn, false /* aSeamless */);
-    if (!ok)
-    {
-        /* On failure, restore the previous button state */
-        mVmFullscreenAction->blockSignals (true);
-        mVmFullscreenAction->setChecked (!aOn);
-        mVmFullscreenAction->blockSignals (false);
-    }
-}
-
-void VBoxConsoleWnd::vmSeamless (bool aOn)
-{
-    /* Check if it is possible to enter/leave seamless mode */
-    if ((mIsSeamlessSupported && mIsGraphicsSupported) || !aOn)
-    {
-        bool ok = toggleFullscreenMode (aOn, true /* aSeamless */);
-        if (!ok)
-        {
-            /* On failure, restore the previous button state */
-            mVmSeamlessAction->blockSignals (true);
-            mVmSeamlessAction->setChecked (!aOn);
-            mVmSeamlessAction->blockSignals (false);
-        }
-    }
-}
-
-void VBoxConsoleWnd::vmAutoresizeGuest (bool on)
-{
-    if (!mConsole)
-        return;
-
-#if 0 /* TODO: Allow to setup status-bar! */
-    mAutoresizeLed->setState (on ? 3 : 1);
-#endif
-
-    mConsole->setAutoresizeGuest (on, true);
-}
-
-void VBoxConsoleWnd::vmAdjustWindow()
-{
-    if (mConsole)
-    {
-        if (isWindowMaximized())
-            showNormal();
-        mConsole->normalizeGeometry (true /* adjustPosition */);
-    }
-}
-
-void VBoxConsoleWnd::vmDisableMouseIntegration (bool aOff)
-{
-    if (mConsole)
-    {
-        mConsole->setMouseIntegrationEnabled (!aOff);
-        updateAppearanceOf (DisableMouseIntegrAction);
-    }
-}
-
-void VBoxConsoleWnd::vmTypeCAD()
-{
-    if (mConsole)
-    {
-        CKeyboard keyboard  = mConsole->console().GetKeyboard();
-        Assert (!keyboard.isNull());
-        keyboard.PutCAD();
-        AssertWrapperOk (keyboard);
-    }
-}
-
-#ifdef Q_WS_X11
-void VBoxConsoleWnd::vmTypeCABS()
-{
-    if (mConsole)
-    {
-        CKeyboard keyboard  = mConsole->console().GetKeyboard();
-        Assert (!keyboard.isNull());
-        static QVector <LONG> sSequence (6);
-        sSequence[0] = 0x1d; // Ctrl down
-        sSequence[1] = 0x38; // Alt down
-        sSequence[2] = 0x0E; // Backspace down
-        sSequence[3] = 0x8E; // Backspace up
-        sSequence[4] = 0xb8; // Alt up
-        sSequence[5] = 0x9d; // Ctrl up
-        keyboard.PutScancodes (sSequence);
-        AssertWrapperOk (keyboard);
-    }
-}
-#endif
-
-void VBoxConsoleWnd::vmTakeSnapshot()
-{
-    AssertReturn (mConsole, (void) 0);
-
-    /* remember the paused state */
-    bool wasPaused = mMachineState == KMachineState_Paused;
-    if (!wasPaused)
-    {
-        /* Suspend the VM and ignore the close event if failed to do so.
-         * pause() will show the error message to the user. */
-        if (!mConsole->pause (true))
-            return;
-    }
-
-    CMachine machine = mSession.GetMachine();
-
-    VBoxTakeSnapshotDlg dlg (this, machine);
-
-    QString typeId = machine.GetOSTypeId();
-    dlg.mLbIcon->setPixmap (vboxGlobal().vmGuestOSTypeIcon (typeId));
-
-    /* search for the max available filter index */
-    QString nameTemplate = tr ("Snapshot %1");
-    int maxSnapshotIndex = searchMaxSnapshotIndex (machine, machine.GetSnapshot (QString()), nameTemplate);
-    dlg.mLeName->setText (nameTemplate.arg (++ maxSnapshotIndex));
-
-    if (dlg.exec() == QDialog::Accepted)
-    {
-        CConsole console = mSession.GetConsole();
-
-        CProgress progress = console.TakeSnapshot (dlg.mLeName->text().trimmed(), dlg.mTeDescription->toPlainText());
-
-        if (console.isOk())
-        {
-            /* Show the "Taking Snapshot" progress dialog */
-            vboxProblem().showModalProgressDialog (progress, machine.GetName(), this, 0);
-
-            if (progress.GetResultCode() != 0)
-                vboxProblem().cannotTakeSnapshot (progress);
-        }
-        else
-            vboxProblem().cannotTakeSnapshot (console);
-    }
-
-    /* Restore the running state if needed */
-    if (!wasPaused)
-        mConsole->pause (false);
-}
-
-void VBoxConsoleWnd::vmShowInfoDialog()
-{
-    VBoxVMInformationDlg::createInformationDlg (mSession, mConsole);
-}
-
-void VBoxConsoleWnd::vmReset()
-{
-    if (mConsole)
-    {
-        if (vboxProblem().confirmVMReset (this))
-            mConsole->console().Reset();
-    }
-}
-
-void VBoxConsoleWnd::vmPause (bool aOn)
-{
-    if (mConsole)
-    {
-        mConsole->pause (aOn);
-        updateAppearanceOf (PauseAction);
-    }
-}
-
-void VBoxConsoleWnd::vmACPIShutdown()
-{
-    if (!mSession.GetConsole().GetGuestEnteredACPIMode())
-        return vboxProblem().cannotSendACPIToMachine();
-
-    if (mConsole)
-    {
-        CConsole console = mConsole->console();
-        console.PowerButton();
-        if (!console.isOk())
-            vboxProblem().cannotACPIShutdownMachine (console);
-    }
-}
-
-void VBoxConsoleWnd::vmClose()
-{
-    if (mConsole)
-        close();
-}
-
-void VBoxConsoleWnd::devicesSwitchVrdp (bool aOn)
-{
-    if (!mConsole) return;
-
-    CVRDPServer vrdpServer = mSession.GetMachine().GetVRDPServer();
-    /* This method should not be executed if vrdpServer is null */
-    Assert (!vrdpServer.isNull());
-
-    vrdpServer.SetEnabled (aOn);
-    updateAppearanceOf (VRDPStuff);
-}
-
-void VBoxConsoleWnd::devicesOpenNetworkDialog()
-{
-    if (!mConsole) return;
-
-    VBoxNetworkDialog dlg (mConsole, mSession);
-    dlg.exec();
-}
-
-void VBoxConsoleWnd::devicesOpenSFDialog()
-{
-    if (!mConsole) return;
-
-    VBoxSFDialog dlg (mConsole, mSession);
-    dlg.exec();
-}
-
-void VBoxConsoleWnd::devicesInstallGuestAdditions()
-{
-    char szAppPrivPath [RTPATH_MAX];
-    int rc = RTPathAppPrivateNoArch (szAppPrivPath, sizeof (szAppPrivPath));
-    AssertRC (rc);
-
-    QString src1 = QString (szAppPrivPath) + "/VBoxGuestAdditions.iso";
-    QString src2 = qApp->applicationDirPath() + "/additions/VBoxGuestAdditions.iso";
-
-    /* Check the standard image locations */
-    if (QFile::exists (src1))
-        return installGuestAdditionsFrom (src1);
-    else if (QFile::exists (src2))
-        return installGuestAdditionsFrom (src2);
-
-    /* Check for the already registered image */
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    QString name = QString ("VBoxGuestAdditions_%1.iso").arg (vbox.GetVersion().remove ("_OSE"));
-
-    CMediumVector vec = vbox.GetDVDImages();
-    for (CMediumVector::ConstIterator it = vec.begin(); it != vec.end(); ++ it)
-    {
-        QString path = it->GetLocation();
-        /* Compare the name part ignoring the file case */
-        QString fn = QFileInfo (path).fileName();
-        if (RTPathCompare (name.toUtf8().constData(), fn.toUtf8().constData()) == 0)
-            return installGuestAdditionsFrom (path);
-    }
-
-    /* Download the required image */
-    int result = vboxProblem().cannotFindGuestAdditions (
-        QDir::toNativeSeparators (src1), QDir::toNativeSeparators (src2));
-    if (result == QIMessageBox::Yes)
-    {
-        QString source = QString ("http://download.virtualbox.org/virtualbox/%1/")
-                                  .arg (vbox.GetVersion().remove ("_OSE")) + name;
-        QString target = QDir (vboxGlobal().virtualBox().GetHomeFolder())
-                               .absoluteFilePath (name);
-
-        UIDownloaderAdditions *pDl = UIDownloaderAdditions::create();
-        /* Configure the additions downloader. */
-        pDl->setSource(source);
-        pDl->setTarget(target);
-        pDl->setAction(mDevicesInstallGuestToolsAction);
-        pDl->setParentWidget(this);
-        /* After the download is finished the user may like to install the
-         * additions.*/
-        connect(pDl, SIGNAL(downloadFinished(const QString&)),
-                this, SLOT(installGuestAdditionsFrom(const QString&)));
-        /* Add the progress bar widget to the statusbar. */
-        statusBar()->addWidget(pDl->processWidget(this), 0);
-        /* Start the download: */
-        pDl->startDownload();
-    }
-}
-
-void VBoxConsoleWnd::prepareStorageMenu()
-{
-    QMenu *menu = qobject_cast <QMenu*> (sender());
-    Assert (menu);
-    menu->clear();
-
-    KDeviceType deviceType = menu == mDevicesCDMenu ? KDeviceType_DVD :
-                             menu == mDevicesFDMenu ? KDeviceType_Floppy :
-                                                      KDeviceType_Null;
-    Assert (deviceType != KDeviceType_Null);
-
-    VBoxDefs::MediumType mediumType = menu == mDevicesCDMenu ? VBoxDefs::MediumType_DVD :
-                                      menu == mDevicesFDMenu ? VBoxDefs::MediumType_Floppy :
-                                                               VBoxDefs::MediumType_Invalid;
-    Assert (mediumType != VBoxDefs::MediumType_Invalid);
-
-    CMachine machine = mSession.GetMachine();
-    const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
-    foreach (const CMediumAttachment &attachment, attachments)
-    {
-        CStorageController controller = machine.GetStorageControllerByName (attachment.GetController());
-        if (   !controller.isNull()
-            && (attachment.GetType() == deviceType))
-        {
-            /* Attachment menu item */
-            QMenu *attachmentMenu = 0;
-            if (menu->menuAction()->data().toInt() > 1)
-            {
-                attachmentMenu = new QMenu (menu);
-                attachmentMenu->setTitle (QString ("%1 (%2)").arg (controller.GetName())
-                                          .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(),
-                                                                                    attachment.GetPort(),
-                                                                                    attachment.GetDevice()))));
-                switch (controller.GetBus())
-                {
-                    case KStorageBus_IDE:
-                        attachmentMenu->setIcon (QIcon (":/ide_16px.png")); break;
-                    case KStorageBus_SATA:
-                        attachmentMenu->setIcon (QIcon (":/sata_16px.png")); break;
-                    case KStorageBus_SCSI:
-                        attachmentMenu->setIcon (QIcon (":/scsi_16px.png")); break;
-                    case KStorageBus_Floppy:
-                        attachmentMenu->setIcon (QIcon (":/floppy_16px.png")); break;
-                    default:
-                        break;
-                }
-                menu->addMenu (attachmentMenu);
-            }
-            else attachmentMenu = menu;
-
-            /* Mount Medium actions */
-            CMediumVector mediums;
-            switch (mediumType)
-            {
-                case VBoxDefs::MediumType_DVD:
-                    mediums += vboxGlobal().virtualBox().GetHost().GetDVDDrives();
-                    mediums += vboxGlobal().virtualBox().GetDVDImages();
-                    break;
-                case VBoxDefs::MediumType_Floppy:
-                    mediums += vboxGlobal().virtualBox().GetHost().GetFloppyDrives();
-                    mediums += vboxGlobal().virtualBox().GetFloppyImages();
-                    break;
-                default:
-                    break;
-            }
-
-            int mediumsToBeShown = 0;
-            const int maxMediumsToBeShown = 5;
-            CMedium currentMedium = attachment.GetMedium();
-            QString currentId = currentMedium.isNull() ? QString::null : currentMedium.GetId();
-            bool currentUsed = false;
-            foreach (CMedium medium, mediums)
-            {
-                bool isMediumUsed = false;
-                foreach (const CMediumAttachment &otherAttachment, attachments)
-                {
-                    if (otherAttachment != attachment)
-                    {
-                        CMedium otherMedium = otherAttachment.GetMedium();
-                        if (!otherMedium.isNull() && otherMedium.GetId() == medium.GetId())
-                        {
-                            isMediumUsed = true;
-                            break;
-                        }
-                    }
-                }
-                if (!isMediumUsed)
-                {
-                    if (!currentUsed && !currentMedium.isNull() && mediumsToBeShown == maxMediumsToBeShown - 1)
-                        medium = currentMedium;
-
-                    if (medium.GetId() == currentId)
-                        currentUsed = true;
-
-                    QAction *mountMediumAction = new QAction (VBoxMedium (medium, mediumType).name(), attachmentMenu);
-                    mountMediumAction->setCheckable (true);
-                    mountMediumAction->setChecked (!currentMedium.isNull() && medium.GetId() == currentId);
-                    mountMediumAction->setData (QVariant::fromValue (MountTarget (controller.GetName(),
-                                                                                  attachment.GetPort(),
-                                                                                  attachment.GetDevice(),
-                                                                                  medium.GetId())));
-                    connect (mountMediumAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium()));
-                    attachmentMenu->addAction (mountMediumAction);
-                    ++ mediumsToBeShown;
-                    if (mediumsToBeShown == maxMediumsToBeShown)
-                        break;
-                }
-            }
-
-            /* Virtual Media Manager action */
-            QAction *callVMMAction = new QAction (attachmentMenu);
-            callVMMAction->setIcon (QIcon (":/diskimage_16px.png"));
-            callVMMAction->setData (QVariant::fromValue (MountTarget (controller.GetName(),
-                                                                      attachment.GetPort(),
-                                                                      attachment.GetDevice(),
-                                                                      mediumType)));
-            connect (callVMMAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium()));
-            attachmentMenu->addAction (callVMMAction);
-
-            /* Separator */
-            attachmentMenu->addSeparator();
-
-            /* Unmount Medium action */
-            QAction *unmountMediumAction = new QAction (attachmentMenu);
-            unmountMediumAction->setEnabled (!currentMedium.isNull());
-            unmountMediumAction->setData (QVariant::fromValue (MountTarget (controller.GetName(),
-                                                                            attachment.GetPort(),
-                                                                            attachment.GetDevice())));
-            connect (unmountMediumAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium()));
-            attachmentMenu->addAction (unmountMediumAction);
-
-            /* Switch CD/FD naming */
-            switch (mediumType)
-            {
-                case VBoxDefs::MediumType_DVD:
-                    callVMMAction->setText (tr ("More CD/DVD Images..."));
-                    unmountMediumAction->setText (tr ("Unmount CD/DVD Device"));
-                    unmountMediumAction->setIcon (VBoxGlobal::iconSet (":/cd_unmount_16px.png",
-                                                                       ":/cd_unmount_dis_16px.png"));
-                    break;
-                case VBoxDefs::MediumType_Floppy:
-                    callVMMAction->setText (tr ("More Floppy Images..."));
-                    unmountMediumAction->setText (tr ("Unmount Floppy Device"));
-                    unmountMediumAction->setIcon (VBoxGlobal::iconSet (":/fd_unmount_16px.png",
-                                                                       ":/fd_unmount_dis_16px.png"));
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    if (menu->menuAction()->data().toInt() == 0)
-    {
-        /* Empty menu item */
-        Assert (menu->isEmpty());
-        QAction *emptyMenuAction = new QAction (menu);
-        emptyMenuAction->setEnabled (false);
-        switch (mediumType)
-        {
-            case VBoxDefs::MediumType_DVD:
-                emptyMenuAction->setText (tr ("No CD/DVD Devices Attached"));
-                break;
-            case VBoxDefs::MediumType_Floppy:
-                emptyMenuAction->setText (tr ("No Floppy Devices Attached"));
-                break;
-            default:
-                break;
-        }
-        emptyMenuAction->setIcon (VBoxGlobal::iconSet (":/delete_16px.png", ":/delete_dis_16px.png"));
-        menu->addAction (emptyMenuAction);
-    }
-}
-
-void VBoxConsoleWnd::prepareNetworkMenu()
-{
-    mDevicesNetworkMenu->clear();
-    mDevicesNetworkMenu->addAction (mDevicesNetworkDialogAction);
-}
-
-void VBoxConsoleWnd::prepareSFMenu()
-{
-    mDevicesSFMenu->clear();
-    mDevicesSFMenu->addAction (mDevicesSFDialogAction);
-}
-
-void VBoxConsoleWnd::mountMedium()
-{
-    /* Get sender action */
-    QAction *action = qobject_cast <QAction*> (sender());
-    Assert (action);
-
-    /* Get current machine */
-    CMachine machine = mSession.GetMachine();
-
-    /* Get mount-target */
-    MountTarget target = action->data().value <MountTarget>();
-
-    /* Current mount-target attributes */
-    CMediumAttachment currentAttachment = machine.GetMediumAttachment (target.name, target.port, target.device);
-    CMedium currentMedium = currentAttachment.GetMedium();
-    QString currentId = currentMedium.isNull() ? QString ("") : currentMedium.GetId();
-
-    /* New mount-target attributes */
-    QString newId = QString ("");
-    bool selectWithMediaManager = target.type != VBoxDefs::MediumType_Invalid;
-
-    /* Open Virtual Media Manager to select image id */
-    if (selectWithMediaManager)
-    {
-        /* Search for already used images */
-        QStringList usedImages;
-        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
-        {
-            CMedium medium = attachment.GetMedium();
-            if (attachment != currentAttachment && !medium.isNull() && !medium.GetHostDrive())
-                usedImages << medium.GetId();
-        }
-        /* Open VMM Dialog */
-        VBoxMediaManagerDlg dlg (this);
-        dlg.setup (target.type, true /* select? */, true /* refresh? */, machine, currentId, true, usedImages);
-        if (dlg.exec() == QDialog::Accepted)
-            newId = dlg.selectedId();
-        else return;
-    }
-    /* Use medium which was sent */
-    else if (!target.id.isNull() && target.id != currentId)
-        newId = target.id;
-
-    bool mount = !newId.isEmpty();
-
-    /* Remount medium to the predefined port/device */
-    bool wasMounted = false;
-    machine.MountMedium (target.name, target.port, target.device, newId, false /* force */);
-    if (machine.isOk())
-        wasMounted = true;
-    else
-    {
-        /* Ask for force remounting */
-        if (vboxProblem().cannotRemountMedium (this, machine, vboxGlobal().findMedium (mount ? newId : currentId), mount, true /* retry? */) == QIMessageBox::Ok)
-        {
-            /* Force remount medium to the predefined port/device. */
-            machine.MountMedium (target.name, target.port, target.device, newId, true /* force */);
-            if (machine.isOk())
-                wasMounted = true;
-            else
-                vboxProblem().cannotRemountMedium (this, machine, vboxGlobal().findMedium (mount ? newId : currentId), mount, false /* retry? */);
-        }
-    }
-
-    /* Save medium mounted at runtime */
-    if (wasMounted && mIsAutoSaveMedia)
-    {
-        machine.SaveSettings();
-        if (!machine.isOk())
-            vboxProblem().cannotSaveMachineSettings (machine);
-    }
-}
-
-/**
- *  Attach/Detach selected USB Device.
- */
-void VBoxConsoleWnd::switchUSB (QAction *aAction)
-{
-    if (!mConsole) return;
-
-    CConsole console = mSession.GetConsole();
-    AssertWrapperOk (mSession);
-
-    CUSBDevice usb = mDevicesUSBMenu->getUSB (aAction);
-    /* if null then some other item but a USB device is selected */
-    if (usb.isNull())
-        return;
-
-    if (!aAction->isChecked())
-    {
-        console.DetachUSBDevice (usb.GetId());
-        if (!console.isOk())
-        {
-            /// @todo (r=dmik) the dialog should be either modeless
-            //  or we have to pause the VM
-            vboxProblem().cannotDetachUSBDevice (console, vboxGlobal().details (usb));
-        }
-    }
-    else
-    {
-        console.AttachUSBDevice (usb.GetId());
-        if (!console.isOk())
-        {
-            /// @todo (r=dmik) the dialog should be either modeless
-            //  or we have to pause the VM
-            vboxProblem().cannotAttachUSBDevice (console, vboxGlobal().details (usb));
-        }
-    }
-}
-
-void VBoxConsoleWnd::showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent)
-{
-    if (aInd == mCDLed)
-    {
-        mDevicesCDMenu->exec (aEvent->globalPos());
-    }
-#if 0 /* TODO: Allow to setup status-bar! */
-    else if (aInd == mFDLed)
-    {
-        mDevicesFDMenu->exec (aEvent->globalPos());
-    }
-#endif
-    else if (aInd == mNetLed)
-    {
-        if (mDevicesNetworkMenu->isEnabled())
-            mDevicesNetworkMenu->exec (aEvent->globalPos());
-    }
-    else if (aInd == mUSBLed)
-    {
-        if (mDevicesUSBMenu->isEnabled())
-            mDevicesUSBMenu->exec (aEvent->globalPos());
-    }
-    else if (aInd == mSFLed)
-    {
-        if (mDevicesSFMenu->isEnabled())
-            mDevicesSFMenu->exec (aEvent->globalPos());
-    }
-    else if (aInd == mMouseLed)
-    {
-        mVmDisMouseIntegrMenu->exec (aEvent->globalPos());
-    }
-#if 0 /* TODO: Allow to setup status-bar! */
-    else if (aInd == mVrdpLed)
-    {
-        mDevicesVRDPMenu->exec (aEvent->globalPos());
-    }
-    else if (aInd == mAutoresizeLed)
-    {
-        mVmAutoresizeMenu->exec (aEvent->globalPos());
-    }
-#endif
-}
-
-void VBoxConsoleWnd::updateDeviceLights()
-{
-    if (mConsole)
-    {
-        CConsole &console = mConsole->console();
-        int st;
-        if (mHDLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_HardDisk);
-            if (mHDLed->state() != st)
-                mHDLed->setState (st);
-        }
-        if (mCDLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_DVD);
-            if (mCDLed->state() != st)
-                mCDLed->setState (st);
-        }
-#if 0 /* TODO: Allow to setup status-bar! */
-        if (mFDLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_Floppy);
-            if (mFDLed->state() != st)
-                mFDLed->setState (st);
-        }
-#endif
-        if (mNetLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_Network);
-            if (mNetLed->state() != st)
-                mNetLed->setState (st);
-        }
-        if (mUSBLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_USB);
-            if (mUSBLed->state() != st)
-                mUSBLed->setState (st);
-        }
-        if (mSFLed->state() != KDeviceActivity_Null)
-        {
-            st = console.GetDeviceActivity (KDeviceType_SharedFolder);
-            if (mSFLed->state() != st)
-                mSFLed->setState (st);
-        }
-    }
-}
-
-void VBoxConsoleWnd::updateNetworkIPs()
-{
-    updateAppearanceOf(NetworkStuff);
-}
-
-void VBoxConsoleWnd::updateMachineState (KMachineState aState)
-{
-    bool guruMeditation = false;
-
-    if (mConsole && mMachineState != aState)
-    {
-        switch (aState)
-        {
-            case KMachineState_Stuck:
-            {
-                guruMeditation = true;
-                break;
-            }
-            case KMachineState_Paused:
-            {
-                if (!mVmPauseAction->isChecked())
-                    mVmPauseAction->setChecked (true);
-                break;
-            }
-            case KMachineState_Running:
-            case KMachineState_Teleporting:         /** @todo Live Migration: Check out this. */
-            case KMachineState_LiveSnapshotting:
-            {
-                if (   (   mMachineState == KMachineState_Paused
-                        || mMachineState == KMachineState_TeleportingPausedVM)
-                    && mVmPauseAction->isChecked()
-                   )
-                    mVmPauseAction->setChecked (false);
-                break;
-            }
-#ifdef Q_WS_X11
-            case KMachineState_Starting:
-            case KMachineState_Restoring:
-            case KMachineState_TeleportingIn:
-            {
-                /* The keyboard handler may wish to do some release logging
-                   on startup.  Tell it that the logger is now active. */
-                doXKeyboardLogging (QX11Info::display());
-                break;
-            }
-#endif
-            default:
-                break;
-        }
-
-        bool isRunningOrPaused = aState == KMachineState_Running
-                              || aState == KMachineState_Teleporting
-                              || aState == KMachineState_LiveSnapshotting /** @todo Live Migration: Check out this. */
-                              || aState == KMachineState_Paused;
-
-        /* Enable/Disable actions that are not managed by updateAppearanceOf() */
-
-        mRunningActions->setEnabled (   aState == KMachineState_Running
-                                     || aState == KMachineState_Teleporting
-                                     || aState == KMachineState_LiveSnapshotting  /** @todo Live Migration: Check out this. */
-                                    );
-        mRunningOrPausedActions->setEnabled (isRunningOrPaused);
-
-        mMachineState = aState;
-
-        updateAppearanceOf (Caption |
-                            HardDiskStuff | DVDStuff | FloppyStuff |
-                            NetworkStuff | USBStuff | VRDPStuff |
-                            PauseAction | DisableMouseIntegrAction);
-
-        if (   aState == KMachineState_PoweredOff
-            || aState == KMachineState_Saved
-            || aState == KMachineState_Teleported
-            || aState == KMachineState_Aborted
-           )
-        {
-            /* VM has been powered off or saved or aborted, no matter
-             * internally or externally -- we must *safely* close the console
-             * window unless auto closure is disabled. */
-            if (!mNoAutoClose)
-                tryClose();
-        }
-    }
-
-    if (guruMeditation)
-    {
-        mConsole->setIgnoreGuestResize (true);
-
-        CConsole console = mConsole->console();
-        QString logFolder = console.GetMachine().GetLogFolder();
-
-        /* Take the screenshot for debugging purposes and save it */
-        QString fname = logFolder + "/VBox.png";
-
-        CDisplay dsp = console.GetDisplay();
-        ULONG width = 0;
-        ULONG height = 0;
-        ULONG bpp = 0;
-        dsp.GetScreenResolution(0, width, height, bpp);
-        QImage shot = QImage (width, height, QImage::Format_RGB32);
-        dsp.TakeScreenShot (0, shot.bits(), shot.width(), shot.height());
-        shot.save (QFile::encodeName (fname), "PNG");
-
-        if (vboxProblem().remindAboutGuruMeditation (console, QDir::toNativeSeparators (logFolder)))
-        {
-            qApp->processEvents();
-            console.PowerDown();
-            if (!console.isOk())
-                vboxProblem().cannotStopMachine (console);
-        }
-    }
-
-#ifdef Q_WS_MAC
-    if (mConsole)
-        mConsole->updateDockOverlay();
-#endif
-}
-
-void VBoxConsoleWnd::updateMouseState (int aState)
-{
-    mVmDisableMouseIntegrAction->setEnabled (aState & VBoxConsoleView::MouseAbsolute);
-
-    if ((aState & VBoxConsoleView::MouseAbsoluteDisabled) &&
-        (aState & VBoxConsoleView::MouseAbsolute) &&
-        !(aState & VBoxConsoleView::MouseCaptured))
-    {
-        mMouseLed->setState (4);
-    }
-    else
-    {
-        mMouseLed->setState (aState & (VBoxConsoleView::MouseAbsolute | VBoxConsoleView::MouseCaptured));
-    }
-}
-
-void VBoxConsoleWnd::updateAdditionsState (const QString &aVersion,
-                                           bool aActive,
-                                           bool aSeamlessSupported,
-                                           bool aGraphicsSupported)
-{
-    mVmAutoresizeGuestAction->setEnabled (aActive && aGraphicsSupported);
-    if ((mIsSeamlessSupported != aSeamlessSupported) ||
-        (mIsGraphicsSupported != aGraphicsSupported))
-    {
-        mVmSeamlessAction->setEnabled (aSeamlessSupported && aGraphicsSupported);
-        mIsSeamlessSupported = aSeamlessSupported;
-        mIsGraphicsSupported = aGraphicsSupported;
-        /* If seamless mode should be enabled then check if it is enabled
-         * currently and re-enable it if open-view procedure is finished */
-        if (mVmSeamlessAction->isChecked() && mIsOpenViewFinished && aSeamlessSupported && aGraphicsSupported)
-            toggleFullscreenMode (true, true);
-        /* Disable auto-resizing if advanced graphics are not available */
-        mConsole->setAutoresizeGuest (mIsGraphicsSupported && mVmAutoresizeGuestAction->isChecked(), false);
-        mVmAutoresizeGuestAction->setEnabled (mIsGraphicsSupported);
-    }
-
-    /* Check the GA version only in case of additions are active */
-    if (!aActive)
-        return;
-
-    /* Check the Guest Additions version and warn the user about possible
-     * compatibility issues in case if the installed version is outdated. */
-    uint version = aVersion.toUInt();
-    QString versionStr = QString ("%1.%2")
-        .arg (RT_HIWORD (version)).arg (RT_LOWORD (version));
-    QString expectedStr = QString ("%1.%2")
-        .arg (VMMDEV_VERSION_MAJOR).arg (VMMDEV_VERSION_MINOR); /** @todo r=bird: This isn't want we want! We want the VirtualBox version of the additions, all three numbers. See @bugref{4084}.*/
-
-    if (RT_HIWORD (version) < VMMDEV_VERSION_MAJOR)
-    {
-        vboxProblem().warnAboutTooOldAdditions (this, versionStr, expectedStr);
-    }
-    else if (RT_HIWORD (version) == VMMDEV_VERSION_MAJOR &&
-             RT_LOWORD (version) <  VMMDEV_VERSION_MINOR)
-    {
-        vboxProblem().warnAboutOldAdditions (this, versionStr, expectedStr);
-    }
-    else if (version > VMMDEV_VERSION)
-    {
-        vboxProblem().warnAboutNewAdditions (this, versionStr, expectedStr);
-    }
-}
-
-void VBoxConsoleWnd::updateNetworkAdaptersState()
-{
-    updateAppearanceOf (NetworkStuff);
-}
-
-void VBoxConsoleWnd::updateUsbState()
-{
-    updateAppearanceOf (USBStuff);
-}
-
-void VBoxConsoleWnd::updateMediaDriveState (VBoxDefs::MediumType aType)
-{
-    Assert (aType == VBoxDefs::MediumType_DVD || aType == VBoxDefs::MediumType_Floppy);
-    updateAppearanceOf (aType == VBoxDefs::MediumType_DVD ? DVDStuff :
-                        aType == VBoxDefs::MediumType_Floppy ? FloppyStuff :
-                        AllStuff);
-}
-
-void VBoxConsoleWnd::updateSharedFoldersState()
-{
-    updateAppearanceOf (SharedFolderStuff);
-}
-
-/**
- *  This slot is called just after leaving the fullscreen/seamless mode,
- *  when the console was resized to previous size.
- */
-void VBoxConsoleWnd::onExitFullscreen()
-{
-    mConsole->setIgnoreMainwndResize (false);
-}
-
-void VBoxConsoleWnd::unlockActionsSwitch()
-{
-    if (mIsSeamless)
-        mVmSeamlessAction->setEnabled (true);
-    else if (mIsFullscreen)
-        mVmFullscreenAction->setEnabled (true);
-    else
-    {
-        mVmSeamlessAction->setEnabled (mIsSeamlessSupported && mIsGraphicsSupported);
-        mVmFullscreenAction->setEnabled (true);
-    }
-
-#ifdef Q_WS_MAC
-    if (!mIsSeamless)
-    {
-        /* Fade back to the normal gamma */
-        CGDisplayFade (mFadeToken, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, false);
-        CGReleaseDisplayFadeReservation (mFadeToken);
-    }
-    mConsole->setMouseCoalescingEnabled (true);
-#endif
-
-#ifdef Q_WS_X11
-    if (vboxGlobal().isKWinManaged() && !mIsSeamless && !mIsFullscreen)
-    {
-        /* Workaround for a KWin bug to let console window to exit
-         * seamless mode correctly. */
-        setWindowFlags(Qt::Window);
-        setVisible(true);
-    }
-#endif
-}
-
-void VBoxConsoleWnd::mtExitMode()
-{
-    if (mIsSeamless)
-        mVmSeamlessAction->toggle();
-    else
-        mVmFullscreenAction->toggle();
-}
-
-void VBoxConsoleWnd::mtCloseVM()
-{
-    mVmCloseAction->trigger();
-}
-
-void VBoxConsoleWnd::mtMaskUpdate()
-{
-    if (mIsSeamless)
-        setMask (mConsole->lastVisibleRegion());
-}
-
-void VBoxConsoleWnd::changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &aEvent)
-{
-#ifdef Q_WS_MAC
-    if (mConsole)
-    {
-        mConsole->setDockIconEnabled (aEvent.mChanged);
-        mConsole->updateDockOverlay();
-    }
-#else
-    Q_UNUSED (aEvent);
-#endif
-}
-
-void VBoxConsoleWnd::changePresentationMode (const VBoxChangePresentationModeEvent &aEvent)
-{
-    Q_UNUSED (aEvent);
-#ifdef Q_WS_MAC
-# ifdef QT_MAC_USE_COCOA
-    if (mIsFullscreen)
-    {
-        /* First check if we are on the primary screen, only than the
-           presentation mode have to be changed. */
-        QDesktopWidget* pDesktop = QApplication::desktop();
-        if (pDesktop->screenNumber(this) == pDesktop->primaryScreen())
-        {
-            QString testStr = vboxGlobal().virtualBox().GetExtraData (VBoxDefs::GUI_PresentationModeEnabled).toLower();
-            /* Default to false if it is an empty value */
-            if (testStr.isEmpty() || testStr == "false")
-                SetSystemUIMode (kUIModeAllHidden, 0);
-            else
-                SetSystemUIMode (kUIModeAllSuppressed, 0);
-        }
-    }
-    else
-        SetSystemUIMode (kUIModeNormal, 0);
-# endif /* QT_MAC_USE_COCOA */
-#endif
-}
-
-/**
- *  Called (on non-UI thread!) when a global GUI setting changes.
- */
-void VBoxConsoleWnd::processGlobalSettingChange (const char * /* aPublicName */, const char * /* aName */)
-{
-    mHostkeyName->setText (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey()));
-}
-
-void VBoxConsoleWnd::installGuestAdditionsFrom (const QString &aSource)
-{
-    CVirtualBox vbox = vboxGlobal().virtualBox();
-    QString uuid;
-
-    CMedium image = vbox.FindDVDImage (aSource);
-    if (image.isNull())
-    {
-        image = vbox.OpenDVDImage (aSource, uuid);
-        if (vbox.isOk())
-            uuid = image.GetId();
-    }
-    else
-        uuid = image.GetId();
-
-    if (!vbox.isOk())
-        return vboxProblem().cannotOpenMedium (this, vbox, VBoxDefs::MediumType_DVD, aSource);
-
-    Assert (!uuid.isNull());
-    CMachine m = mSession.GetMachine();
-
-    QString ctrName;
-    LONG ctrPort = -1, ctrDevice = -1;
-    /* Searching for the first suitable slot */
-    {
-        CStorageControllerVector controllers = m.GetStorageControllers();
-        int i = 0;
-        while (i < controllers.size() && ctrName.isNull())
-        {
-            CStorageController controller = controllers [i];
-            CMediumAttachmentVector attachments = m.GetMediumAttachmentsOfController (controller.GetName());
-            int j = 0;
-            while (j < attachments.size() && ctrName.isNull())
-            {
-                CMediumAttachment attachment = attachments [j];
-                if (attachment.GetType() == KDeviceType_DVD)
-                {
-                    ctrName = controller.GetName();
-                    ctrPort = attachment.GetPort();
-                    ctrDevice = attachment.GetDevice();
-                }
-                ++ j;
-            }
-            ++ i;
-        }
-    }
-
-    if (!ctrName.isNull())
-    {
-        bool isMounted = false;
-
-        /* Mount medium to the predefined port/device */
-        m.MountMedium (ctrName, ctrPort, ctrDevice, uuid, false /* force */);
-        if (m.isOk())
-            isMounted = true;
-        else
-        {
-            /* Ask for force mounting */
-            if (vboxProblem().cannotRemountMedium (this, m, VBoxMedium (image, VBoxDefs::MediumType_DVD), true /* mount? */, true /* retry? */) == QIMessageBox::Ok)
-            {
-                /* Force mount medium to the predefined port/device */
-                m.MountMedium (ctrName, ctrPort, ctrDevice, uuid, true /* force */);
-                if (m.isOk())
-                    isMounted = true;
-                else
-                    vboxProblem().cannotRemountMedium (this, m, VBoxMedium (image, VBoxDefs::MediumType_DVD), true /* mount? */, false /* retry? */);
-            }
-        }
-
-        /* Save medium mounted at runtime */
-        if (isMounted && mIsAutoSaveMedia)
-        {
-            m.SaveSettings();
-            if (!m.isOk())
-                vboxProblem().cannotSaveMachineSettings (m);
-        }
-    }
-    else
-        vboxProblem().cannotMountGuestAdditions (m.GetName());
-}
-
-void VBoxConsoleWnd::sltDownloaderUserManualEmbed()
-{
-    /* If there is User Manual downloader created => show the process bar: */
-    if (UIDownloaderUserManual *pDl = UIDownloaderUserManual::current())
-        statusBar()->addWidget(pDl->processWidget(this), 0);
-}
-
-/**
- *  This function checks the status of required features and
- *  makes a warning and/or some action if something necessary
- *  is not in good condition.
- *  Does nothing if no console view was opened.
- */
-void VBoxConsoleWnd::checkRequiredFeatures()
-{
-    if (!mConsole) return;
-
-    CConsole console = mConsole->console();
-
-    /* Check if the virtualization feature is required. */
-    bool is64BitsGuest    = vboxGlobal().virtualBox().GetGuestOSType (
-                            console.GetGuest().GetOSTypeId()).GetIs64Bit();
-    bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType (
-                            console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx();
-    Assert(!is64BitsGuest || fRecommendVirtEx);
-    bool isVirtEnabled    = console.GetDebugger().GetHWVirtExEnabled();
-    if (fRecommendVirtEx && !isVirtEnabled)
-    {
-        bool ret;
-        bool fVTxAMDVSupported = vboxGlobal().virtualBox().GetHost()
-                                 .GetProcessorFeature (KProcessorFeature_HWVirtEx);
-
-        vmPause (true);
-
-        if (is64BitsGuest)
-            ret = vboxProblem().warnAboutVirtNotEnabled64BitsGuest(fVTxAMDVSupported);
-        else
-            ret = vboxProblem().warnAboutVirtNotEnabledGuestRequired(fVTxAMDVSupported);
-
-        if (ret == true)
-            close();
-        else
-            vmPause (false);
-    }
-}
-
-void VBoxConsoleWnd::activateUICustomizations()
-{
-    VBoxGlobalSettings settings = vboxGlobal().settings();
-    /* Process known keys */
-    menuBar()->setHidden (settings.isFeatureActive ("noMenuBar"));
-    statusBar()->setHidden (settings.isFeatureActive ("noStatusBar"));
-}
-
-void VBoxConsoleWnd::updateAppearanceOf (int aElement)
-{
-    if (!mConsole) return;
-
-    CMachine machine = mSession.GetMachine();
-    CConsole console = mConsole->console();
-
-    bool isStrictRunningOrPaused = mMachineState == KMachineState_Running
-                                || mMachineState == KMachineState_Paused;
-    bool isRunningOrPaused = isStrictRunningOrPaused
-                          || mMachineState == KMachineState_Teleporting
-                          || mMachineState == KMachineState_LiveSnapshotting;
-
-    if (aElement & Caption)
-    {
-        QString snapshotName;
-        if (machine.GetSnapshotCount() > 0)
-        {
-            CSnapshot snapshot = machine.GetCurrentSnapshot();
-            snapshotName = " (" + snapshot.GetName() + ")";
-        }
-        setWindowTitle (machine.GetName() + snapshotName +
-                        " [" + vboxGlobal().toString (mMachineState) + "] - " +
-                        mCaptionPrefix);
-        mMiniToolBar->setDisplayText (machine.GetName() + snapshotName);
-    }
-    if (aElement & HardDiskStuff)
-    {
-        QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity "
-                          "of the virtual hard disks:</nobr>%1</p>", "HDD tooltip");
-        QString data;
-        bool attachmentsPresent = false;
-
-        CStorageControllerVector controllers = machine.GetStorageControllers();
-        foreach (const CStorageController &controller, controllers)
-        {
-            QString attData;
-            CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName());
-            foreach (const CMediumAttachment &attachment, attachments)
-            {
-                if (attachment.GetType() != KDeviceType_HardDisk)
-                    continue;
-                attData += QString ("<br>&nbsp;<nobr>%1:&nbsp;%2</nobr>")
-                    .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
-                    .arg (VBoxMedium (attachment.GetMedium(), VBoxDefs::MediumType_HardDisk).location());
-                attachmentsPresent = true;
-            }
-            if (!attData.isNull())
-                data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData;
-        }
-
-        if (!attachmentsPresent)
-            data += tr ("<br><nobr><b>No hard disks attached</b></nobr>", "HDD tooltip");
-
-        mHDLed->setToolTip (tip.arg (data));
-        mHDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null);
-    }
-    if (aElement & DVDStuff)
-    {
-        QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity "
-                          "of the CD/DVD devices:</nobr>%1</p>", "CD/DVD tooltip");
-        QString data;
-        bool attachmentsPresent = false;
-
-        CStorageControllerVector controllers = machine.GetStorageControllers();
-        foreach (const CStorageController &controller, controllers)
-        {
-            QString attData;
-            CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName());
-            foreach (const CMediumAttachment &attachment, attachments)
-            {
-                if (attachment.GetType() != KDeviceType_DVD)
-                    continue;
-                VBoxMedium vboxMedium (attachment.GetMedium(), VBoxDefs::MediumType_DVD);
-                attData += QString ("<br>&nbsp;<nobr>%1:&nbsp;%2</nobr>")
-                    .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
-                    .arg (vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
-                if (!vboxMedium.isNull())
-                    attachmentsPresent = true;
-            }
-            if (!attData.isNull())
-                data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData;
-        }
-
-        if (data.isNull())
-            data = tr ("<br><nobr><b>No CD/DVD devices attached</b></nobr>", "CD/DVD tooltip");
-
-        mCDLed->setToolTip (tip.arg (data));
-        mCDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null);
-    }
-#if 0 /* TODO: Allow to setup status-bar! */
-    if (aElement & FloppyStuff)
-    {
-        QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity "
-                          "of the floppy devices:</nobr>%1</p>", "FD tooltip");
-        QString data;
-        bool attachmentsPresent = false;
-
-        CStorageControllerVector controllers = machine.GetStorageControllers();
-        foreach (const CStorageController &controller, controllers)
-        {
-            QString attData;
-            CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController (controller.GetName());
-            foreach (const CMediumAttachment &attachment, attachments)
-            {
-                if (attachment.GetType() != KDeviceType_Floppy)
-                    continue;
-                VBoxMedium vboxMedium (attachment.GetMedium(), VBoxDefs::MediumType_Floppy);
-                attData += QString ("<br>&nbsp;<nobr>%1:&nbsp;%2</nobr>")
-                    .arg (vboxGlobal().toString (StorageSlot (controller.GetBus(), attachment.GetPort(), attachment.GetDevice())))
-                    .arg (vboxMedium.isNull() || vboxMedium.isHostDrive() ? vboxMedium.name() : vboxMedium.location());
-                if (!vboxMedium.isNull())
-                    attachmentsPresent = true;
-            }
-            if (!attData.isNull())
-                data += QString ("<br><nobr><b>%1</b></nobr>").arg (controller.GetName()) + attData;
-        }
-
-        if (data.isNull())
-            data = tr ("<br><nobr><b>No floppy devices attached</b></nobr>", "FD tooltip");
-
-        mFDLed->setToolTip (tip.arg (data));
-        mFDLed->setState (attachmentsPresent ? KDeviceActivity_Idle : KDeviceActivity_Null);
-    }
-#endif
-    if (aElement & NetworkStuff)
-    {
-        ulong maxCount = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount();
-        ulong count = 0;
-        for (ulong slot = 0; slot < maxCount; ++ slot)
-            if (machine.GetNetworkAdapter (slot).GetEnabled())
-                ++ count;
-        mNetLed->setState (count > 0 ? KDeviceActivity_Idle : KDeviceActivity_Null);
-
-        mDevicesNetworkDialogAction->setEnabled (isStrictRunningOrPaused && count > 0);
-        mDevicesNetworkMenu->setEnabled (isStrictRunningOrPaused && count > 0);
-
-        QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of the "
-                           "network interfaces:</nobr>%1</p>", "Network adapters tooltip");
-        QString info;
-
-        for (ulong slot = 0, uEnabled = 0; slot < maxCount; ++ slot)
-        {
-            const CNetworkAdapter &adapter = machine.GetNetworkAdapter (slot);
-            if (adapter.GetEnabled())
-            {
-                QString strFlags;
-                QString strCount;
-                ULONG64 timestamp;
-                machine.GetGuestProperty("/VirtualBox/GuestInfo/Net/Count", strCount, timestamp, strFlags);
-                RTTIMESPEC time;
-                uint64_t u64Now = RTTimeSpecGetNano(RTTimeNow(&time));
-                QString strIP;
-                if (   u64Now - timestamp < UINT64_C(60000000000)
-                    && strCount.toInt() > 0)
-                    strIP = machine.GetGuestPropertyValue(QString("/VirtualBox/GuestInfo/Net/%1/V4/IP").arg(uEnabled));
-                info += tr ("<br><nobr><b>Adapter %1 (%2)</b>: %3 cable %4</nobr>", "Network adapters tooltip")
-                    .arg (slot + 1)
-                    .arg (vboxGlobal().toString (adapter.GetAttachmentType()))
-                    .arg (strIP.isEmpty() ? "" : "IP " + strIP + ", ")
-                    .arg (adapter.GetCableConnected() ?
-                          tr ("connected", "Network adapters tooltip") :
-                          tr ("disconnected", "Network adapters tooltip"));
-                uEnabled++;
-            }
-        }
-
-        if (info.isNull())
-            info = tr ("<br><nobr><b>All network adapters are disabled</b></nobr>", "Network adapters tooltip");
-
-        mNetLed->setToolTip (tip.arg (info));
-    }
-    if (aElement & USBStuff)
-    {
-        if (!mUSBLed->isHidden())
-        {
-            QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of "
-                              "the attached USB devices:</nobr>%1</p>", "USB device tooltip");
-            QString info;
-
-            CUSBController usbctl = machine.GetUSBController();
-            if (!usbctl.isNull() && usbctl.GetEnabled())
-            {
-                mDevicesUSBMenu->setEnabled (isStrictRunningOrPaused);
-
-                CUSBDeviceVector devsvec = console.GetUSBDevices();
-                for (int i = 0; i < devsvec.size(); ++ i)
-                {
-                    CUSBDevice usb = devsvec [i];
-                    info += QString ("<br><b><nobr>%1</nobr></b>").arg (vboxGlobal().details (usb));
-                }
-                if (info.isNull())
-                    info = tr ("<br><nobr><b>No USB devices attached</b></nobr>", "USB device tooltip");
-            }
-            else
-            {
-                mDevicesUSBMenu->setEnabled (false);
-                info = tr ("<br><nobr><b>USB Controller is disabled</b></nobr>", "USB device tooltip");
-            }
-
-            mUSBLed->setToolTip (tip.arg (info));
-        }
-    }
-    if (aElement & VRDPStuff)
-    {
-        CVRDPServer vrdpsrv = mSession.GetMachine().GetVRDPServer();
-        if (!vrdpsrv.isNull())
-        {
-            /* update menu&status icon state */
-            bool isVRDPEnabled = vrdpsrv.GetEnabled();
-            mDevicesSwitchVrdpAction->setChecked (isVRDPEnabled);
-#if 0 /* TODO: Allow to setup status-bar! */
-            mVrdpLed->setState (isVRDPEnabled ? 1 : 0);
-
-            QString tip = tr ("Indicates whether the Remote Display (VRDP Server) "
-                              "is enabled (<img src=:/vrdp_16px.png/>) or not "
-                              "(<img src=:/vrdp_disabled_16px.png/>).");
-            if (vrdpsrv.GetEnabled())
-                tip += tr ("<hr>The VRDP Server is listening on port %1").arg (vrdpsrv.GetPort());
-            mVrdpLed->setToolTip (tip);
-#endif
-        }
-    }
-    if (aElement & SharedFolderStuff)
-    {
-        QString tip = tr ("<p style='white-space:pre'><nobr>Indicates the activity of "
-                          "the machine's shared folders:</nobr>%1</p>", "Shared folders tooltip");
-
-        QString data;
-        QMap <QString, QString> sfs;
-
-        mDevicesSFMenu->setEnabled (true);
-
-        /* Permanent folders */
-        CSharedFolderVector psfvec = machine.GetSharedFolders();
-
-        for (int i = 0; i < psfvec.size(); ++ i)
-        {
-            CSharedFolder sf = psfvec [i];
-            sfs.insert (sf.GetName(), sf.GetHostPath());
-        }
-
-        /* Transient folders */
-        CSharedFolderVector tsfvec = console.GetSharedFolders();
-
-        for (int i = 0; i < tsfvec.size(); ++ i)
-        {
-            CSharedFolder sf = tsfvec[i];
-            sfs.insert (sf.GetName(), sf.GetHostPath());
-        }
-
-        for (QMap <QString, QString>::const_iterator it = sfs.constBegin(); it != sfs.constEnd(); ++ it)
-        {
-            /* Select slashes depending on the OS type */
-            if (VBoxGlobal::isDOSType (console.GetGuest().GetOSTypeId()))
-                data += QString ("<br><nobr><b>\\\\vboxsvr\\%1&nbsp;</b></nobr><nobr>%2</nobr>")
-                                 .arg (it.key(), it.value());
-            else
-                data += QString ("<br><nobr><b>%1&nbsp;</b></nobr><nobr>%2</nobr>")
-                                 .arg (it.key(), it.value());
-        }
-
-        if (sfs.count() == 0)
-            data = tr ("<br><nobr><b>No shared folders</b></nobr>", "Shared folders tooltip");
-
-        mSFLed->setToolTip (tip.arg (data));
-    }
-    if (aElement & VirtualizationStuff)
-    {
-        bool virtEnabled = console.GetDebugger().GetHWVirtExEnabled();
-        QString virtualization = virtEnabled ?
-            VBoxGlobal::tr ("Enabled", "details report (VT-x/AMD-V)") :
-            VBoxGlobal::tr ("Disabled", "details report (VT-x/AMD-V)");
-
-        bool nestEnabled = console.GetDebugger().GetHWVirtExNestedPagingEnabled();
-        QString nestedPaging = nestEnabled ?
-            VBoxVMInformationDlg::tr ("Enabled", "nested paging") :
-            VBoxVMInformationDlg::tr ("Disabled", "nested paging");
-
-        QString tip (tr ("Indicates the status of the hardware virtualization "
-                         "features used by this virtual machine:"
-                         "<br><nobr><b>%1:</b>&nbsp;%2</nobr>"
-                         "<br><nobr><b>%3:</b>&nbsp;%4</nobr>",
-                         "Virtualization Stuff LED")
-                         .arg (VBoxGlobal::tr ("VT-x/AMD-V", "details report"), virtualization)
-                         .arg (VBoxVMInformationDlg::tr ("Nested Paging", "details report"), nestedPaging));
-
-        int cpuCount = console.GetMachine().GetCPUCount();
-        if (cpuCount > 1)
-            tip += tr ("<br><nobr><b>%1:</b>&nbsp;%2</nobr>", "Virtualization Stuff LED")
-                       .arg (VBoxGlobal::tr ("Processor(s)", "details report")).arg (cpuCount);
-
-        mVirtLed->setToolTip (tip);
-        mVirtLed->setState (virtEnabled);
-    }
-    if (aElement & PauseAction)
-    {
-        if (!mVmPauseAction->isChecked())
-        {
-            mVmPauseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("&Pause"), "P"));
-            mVmPauseAction->setStatusTip (tr ("Suspend the execution of the virtual machine"));
-        }
-        else
-        {
-            mVmPauseAction->setText (VBoxGlobal::insertKeyToActionText (tr ("R&esume"), "P"));
-            mVmPauseAction->setStatusTip (tr ("Resume the execution of the virtual machine" ) );
-        }
-        mVmPauseAction->setEnabled (isRunningOrPaused);
-    }
-    if (aElement & DisableMouseIntegrAction)
-    {
-        if (!mVmDisableMouseIntegrAction->isChecked())
-        {
-            mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Disable &Mouse Integration"), "I"));
-            mVmDisableMouseIntegrAction->setStatusTip (tr ("Temporarily disable host mouse pointer integration"));
-        }
-        else
-        {
-            mVmDisableMouseIntegrAction->setText (VBoxGlobal::insertKeyToActionText (tr ("Enable &Mouse Integration"), "I"));
-            mVmDisableMouseIntegrAction->setStatusTip (tr ("Enable temporarily disabled host mouse pointer integration"));
-        }
-        if (   mMachineState == KMachineState_Running
-            || mMachineState == KMachineState_Teleporting
-            || mMachineState == KMachineState_LiveSnapshotting
-           )
-            mVmDisableMouseIntegrAction->setEnabled (mConsole->mouseCanAbsolute() && mConsole->mouseCanRelative() && !mConsole->mouseNeedsHostCursor());
-        else
-            mVmDisableMouseIntegrAction->setEnabled (false);
-    }
-}
-
-/**
- * @return @c true if successfully performed the requested operation and false
- * otherwise.
- */
-bool VBoxConsoleWnd::toggleFullscreenMode (bool aOn, bool aSeamless)
-{
-    /* Please note: For some platforms like the Mac, the calling order of the
-     * functions in this methods is vital. So please be careful on changing
-     * this. */
-
-    QSize initialSize = size();
-    if (aSeamless || mConsole->isAutoresizeGuestActive())
-    {
-        QRect screen = aSeamless ?
-            QApplication::desktop()->availableGeometry (this) :
-            QApplication::desktop()->screenGeometry (this);
-        ULONG64 availBits = mSession.GetMachine().GetVRAMSize() /* vram */
-                          * _1M /* mb to bytes */
-                          * 8; /* to bits */
-        ULONG width = 0;
-        ULONG height = 0;
-        ULONG guestBpp = 0;
-        mConsole->console().GetDisplay().GetScreenResolution(0, width, height, guestBpp);
-        ULONG64 usedBits = (screen.width() /* display width */
-                         * screen.height() /* display height */
-                         * guestBpp
-                         + _1M * 8) /* current cache per screen - may be changed in future */
-                         * mSession.GetMachine().GetMonitorCount() /**< @todo fix assumption that all screens have same resolution */
-                         + 4096 * 8; /* adapter info */
-        if (aOn && (availBits < usedBits))
-        {
-            if (aSeamless)
-            {
-                vboxProblem().cannotEnterSeamlessMode (
-                    screen.width(), screen.height(), guestBpp,
-                    (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
-                return false;
-            }
-            else
-            {
-                int result = vboxProblem().cannotEnterFullscreenMode (
-                    screen.width(), screen.height(), guestBpp,
-                    (((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M);
-                if (result == QIMessageBox::Cancel)
-                    return false;
-            }
-        }
-    }
-
-    AssertReturn (mConsole, false);
-    AssertReturn ((mHiddenChildren.empty() == aOn), false);
-    AssertReturn ((aSeamless && mIsSeamless != aOn) ||
-                  (!aSeamless && mIsFullscreen != aOn), false);
-    if (aOn)
-        AssertReturn ((aSeamless && !mIsFullscreen) ||
-                      (!aSeamless && !mIsSeamless), false);
-
-    if (aOn)
-    {
-        /* Take the toggle hot key from the menu item. Since
-         * VBoxGlobal::extractKeyFromActionText gets exactly the
-         * linked key without the 'Host+' part we are adding it here. */
-        QString hotKey = QString ("Host+%1")
-            .arg (VBoxGlobal::extractKeyFromActionText (aSeamless ?
-                  mVmSeamlessAction->text() : mVmFullscreenAction->text()));
-
-        Assert (!hotKey.isEmpty());
-
-        /* Show the info message. */
-        bool ok = aSeamless ?
-            vboxProblem().confirmGoingSeamless (hotKey) :
-            vboxProblem().confirmGoingFullscreen (hotKey);
-        if (!ok)
-            return false;
-    }
-
-#ifdef Q_WS_MAC
-    if (!aSeamless)
-    {
-        /* Fade to black */
-        CGAcquireDisplayFadeReservation (kCGMaxDisplayReservationInterval, &mFadeToken);
-        CGDisplayFade (mFadeToken, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, true);
-    }
-#endif
-
-    if (aSeamless)
-    {
-        /* Activate the auto-resize feature required for the seamless mode. */
-        if (!mVmAutoresizeGuestAction->isChecked())
-            mVmAutoresizeGuestAction->setChecked (true);
-
-        /* Activate the mouse integration feature for the seamless mode. */
-        if (mVmDisableMouseIntegrAction->isChecked())
-            mVmDisableMouseIntegrAction->setChecked (false);
-
-        mVmAdjustWindowAction->setEnabled (!aOn);
-        mVmFullscreenAction->setEnabled (!aOn);
-        mVmAutoresizeGuestAction->setEnabled (!aOn);
-        mVmDisableMouseIntegrAction->setEnabled (!aOn);
-
-        mConsole->console().GetDisplay().SetSeamlessMode (aOn);
-        mIsSeamless = aOn;
-    }
-    else
-    {
-        mIsFullscreen = aOn;
-        mVmAdjustWindowAction->setEnabled (!aOn);
-        mVmSeamlessAction->setEnabled (!aOn && mIsSeamlessSupported && mIsGraphicsSupported);
-    }
-
-    bool wasHidden = isHidden();
-
-    /* Temporarily disable the mode-related action to make sure
-     * user can not leave the mode before he enter it and inside out. */
-    aSeamless ? mVmSeamlessAction->setEnabled (false) :
-                mVmFullscreenAction->setEnabled (false);
-
-    /* Calculate initial console size */
-    QSize consoleSize;
-
-    if (aOn)
-    {
-        consoleSize = mConsole->frameSize();
-        consoleSize -= QSize (mConsole->frameWidth() * 2, mConsole->frameWidth() * 2);
-
-        /* Toggle console to manual resize mode. */
-        mConsole->setIgnoreMainwndResize (true);
-
-        /* Memorize the maximized state. */
-        QDesktopWidget *dtw = QApplication::desktop();
-        mWasMax = isWindowMaximized() &&
-                  dtw->availableGeometry().width()  == frameSize().width() &&
-                  dtw->availableGeometry().height() == frameSize().height();
-
-        /* Save the previous scroll-view minimum size before entering
-         * fullscreen/seamless state to restore this minimum size before
-         * the exiting fullscreen. Required for correct scroll-view and
-         * guest display update in SDL mode. */
-        mPrevMinSize = mConsole->minimumSize();
-        mConsole->setMinimumSize (0, 0);
-
-        /* let the widget take the whole available desktop space */
-        QRect scrGeo = aSeamless ?
-            dtw->availableGeometry (this) : dtw->screenGeometry (this);
-
-        /* It isn't guaranteed that the guest os set the video mode that
-         * we requested. So after all the resizing stuff set the clipping
-         * mask and the spacing shifter to the corresponding values. */
-        if (aSeamless)
-            setViewInSeamlessMode (scrGeo);
-
-#ifdef Q_WS_WIN
-        mPrevRegion = dtw->screenGeometry (this);
-#endif
-
-        /* Hide all but the central widget containing the console view. */
-        QList <QWidget*> list (findChildren <QWidget*> ());
-        QList <QWidget*> excludes;
-        excludes << centralWidget() << centralWidget()->findChildren <QWidget*> ();
-        foreach (QWidget *w, list)
-        {
-            if (!excludes.contains (w))
-            {
-                if (!w->isHidden())
-                {
-                    w->hide();
-                    mHiddenChildren.append (w);
-                }
-            }
-        }
-
-        /* Adjust colors and appearance. */
-        mErasePalette = centralWidget()->palette();
-        QPalette palette(mErasePalette);
-        palette.setColor (centralWidget()->backgroundRole(), Qt::black);
-        centralWidget()->setPalette (palette);
-        centralWidget()->setAutoFillBackground (!aSeamless);
-        mConsoleStyle = mConsole->frameStyle();
-        mConsole->setFrameStyle (QFrame::NoFrame);
-        mConsole->setMaximumSize (scrGeo.size());
-        mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
-        mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
-    }
-    else
-    {
-        /* Reset the shifting spacers. */
-        mShiftingSpacerLeft->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerTop->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerRight->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-        mShiftingSpacerBottom->changeSize (0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
-
-        /* Restore the previous scroll-view minimum size before the exiting
-         * fullscreen. Required for correct scroll-view and guest display
-         * update in SDL mode. */
-        mConsole->setMinimumSize (mPrevMinSize);
-
-#ifdef Q_WS_MAC
-        if (aSeamless)
-        {
-            /* Please note: All the stuff below has to be done before the
-             * window switch back to normal size. Qt changes the winId on the
-             * fullscreen switch and make this stuff useless with the old
-             * winId. So please be careful on rearrangement of the method
-             * calls. */
-            /* Undo all mac specific installations */
-            ::darwinSetShowsWindowTransparent (this, false);
-        }
-#endif
-
-        /* Adjust colors and appearance. */
-        clearMask();
-        centralWidget()->setPalette (mErasePalette);
-        centralWidget()->setAutoFillBackground (false);
-        mConsole->setFrameStyle (mConsoleStyle);
-        mConsole->setMaximumSize (mConsole->sizeHint());
-        mConsole->setHorizontalScrollBarPolicy (Qt::ScrollBarAsNeeded);
-        mConsole->setVerticalScrollBarPolicy (Qt::ScrollBarAsNeeded);
-
-        /* Show everything hidden when going fullscreen. */
-        foreach (QPointer <QWidget> child, mHiddenChildren)
-            if (child) child->show();
-        mHiddenChildren.clear();
-    }
-
-    /* Set flag for waiting host resize if it awaited during mode entering */
-    if ((mIsFullscreen || mIsSeamless) && (consoleSize != initialSize))
-        mIsWaitingModeResize = true;
-
-    if (!aOn)
-    {
-        /* Animation takes a bit long, the mini toolbar is still disappearing
-         * when switched to normal mode so hide it completely */
-        mMiniToolBar->hide();
-        mMiniToolBar->updateDisplay (false, true);
-    }
-
-    /* Toggle qt full-screen mode */
-    switchToFullscreen (aOn, aSeamless);
-
-    if (aOn)
-    {
-        mMiniToolBar->setSeamlessMode (aSeamless);
-        mMiniToolBar->updateDisplay (true, true);
-    }
-
-#ifdef Q_WS_MAC
-    if (aOn && aSeamless)
-    {
-        /* Please note: All the stuff below has to be done after the window has
-         * switched to fullscreen. Qt changes the winId on the fullscreen
-         * switch and make this stuff useless with the old winId. So please be
-         * careful on rearrangement of the method calls. */
-        ::darwinSetShowsWindowTransparent (this, true);
-    }
-#endif
-
-    /* Send guest size hint */
-    mConsole->toggleFSMode (consoleSize);
-
-    /* Process all console attributes changes and sub-widget hidings */
-    qApp->processEvents();
-
-    if (!mIsWaitingModeResize)
-        onExitFullscreen();
-
-    /* Unlock FS actions locked during modes toggling */
-    QTimer::singleShot (300, this, SLOT (unlockActionsSwitch()));
-
-#ifdef Q_WS_MAC /* wasHidden is wrong on the mac it seems. */
-    /** @todo figure out what is really wrong here... */
-    if (!wasHidden)
-        show();
-#else
-    if (wasHidden)
-        hide();
-#endif
-
-    return true;
-}
-
-void VBoxConsoleWnd::switchToFullscreen (bool aOn, bool aSeamless)
-{
-#ifdef Q_WS_MAC
-# ifndef QT_MAC_USE_COCOA
-    /* setWindowState removes the window group connection somehow. So save it
-     * temporary. */
-    WindowGroupRef g = GetWindowGroup (::darwinToNativeWindow (this));
-# endif  /* !QT_MAC_USE_COCOA */
-    if (aSeamless)
-        if (aOn)
-        {
-            /* Save for later restoring */
-            mNormalGeometry = geometry();
-            mSavedFlags = windowFlags();
-            /* Remove the frame from the window */
-            const QRect fullscreen (qApp->desktop()->screenGeometry (qApp->desktop()->screenNumber (this)));
-            setParent (0, Qt::Window | Qt::FramelessWindowHint | (windowFlags() & 0xffff0000));
-            setGeometry (fullscreen);
-            /* Set it maximized */
-            setWindowState (windowState() ^ Qt::WindowMaximized);
-        }
-        else
-        {
-            /* Restore old values */
-            setParent (0, mSavedFlags);
-            setGeometry (mNormalGeometry);
-        }
-    else
-    {
-        /* Here we are going really fullscreen */
-        setWindowState (windowState() ^ Qt::WindowFullScreen);
-        changePresentationMode (VBoxChangePresentationModeEvent(aOn));
-    }
-
-# ifndef QT_MAC_USE_COCOA
-    /* Reassign the correct window group. */
-    SetWindowGroup (::darwinToNativeWindow (this), g);
-# endif /* !QT_MAC_USE_COCOA */
-#else
-    NOREF (aOn);
-    NOREF (aSeamless);
-    setWindowState (windowState() ^ Qt::WindowFullScreen);
-#endif
-}
-
-void VBoxConsoleWnd::setViewInSeamlessMode (const QRect &aTargetRect)
-{
-#ifndef Q_WS_MAC
-    /* It isn't guaranteed that the guest os set the video mode that
-     * we requested. So after all the resizing stuff set the clipping
-     * mask and the spacing shifter to the corresponding values. */
-    QDesktopWidget *dtw = QApplication::desktop();
-    QRect sRect = dtw->screenGeometry (this);
-    QRect aRect (aTargetRect);
-    mMaskShift.scale (aTargetRect.left(), aTargetRect.top(), Qt::IgnoreAspectRatio);
-    /* Set the clipping mask */
-    mStrictedRegion = aRect;
-    /* Set the shifting spacer */
-    mShiftingSpacerLeft->changeSize (RT_ABS (sRect.left() - aRect.left()), 0,
-                                     QSizePolicy::Fixed, QSizePolicy::Preferred);
-    mShiftingSpacerTop->changeSize (0, RT_ABS (sRect.top() - aRect.top()),
-                                    QSizePolicy::Preferred, QSizePolicy::Fixed);
-    mShiftingSpacerRight->changeSize (RT_ABS (sRect.right() - aRect.right()), 0,
-                                      QSizePolicy::Fixed, QSizePolicy::Preferred);
-    mShiftingSpacerBottom->changeSize (0, RT_ABS (sRect.bottom() - aRect.bottom()),
-                                           QSizePolicy::Preferred, QSizePolicy::Fixed);
-#else // !Q_WS_MAC
-    NOREF (aTargetRect);
-#endif // !Q_WS_MAC
-}
-
-/**
- *  Closes the console view opened by openView().
- *  Does nothing if no console view was opened.
- */
-void VBoxConsoleWnd::closeView()
-{
-    LogFlowFuncEnter();
-
-    if (!mConsole)
-    {
-        LogFlow (("Already closed!\n"));
-        LogFlowFuncLeave();
-        return;
-    }
-
-    mConsole->detach();
-    centralWidget()->layout()->removeWidget (mConsole);
-    delete mConsole;
-    mConsole = 0;
-    mSession.Close();
-    mSession.detach();
-
-    LogFlowFuncLeave();
-}
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-
-/**
- * Prepare the Debug menu.
- */
-void VBoxConsoleWnd::dbgPrepareDebugMenu()
-{
-    /* The "Logging" item. */
-    bool fEnabled = false;
-    bool fChecked = false;
-    CConsole console = mSession.GetConsole();
-    if (console.isOk())
-    {
-        CMachineDebugger cdebugger = console.GetDebugger();
-        if (console.isOk())
-        {
-            fEnabled = true;
-            fChecked = cdebugger.GetLogEnabled() != FALSE;
-        }
-    }
-    if (fEnabled != mDbgLoggingAction->isEnabled())
-        mDbgLoggingAction->setEnabled (fEnabled);
-    if (fChecked != mDbgLoggingAction->isChecked())
-        mDbgLoggingAction->setChecked (fChecked);
-}
-
-/**
- * Called when the Debug->Statistics... menu item is selected.
- */
-void VBoxConsoleWnd::dbgShowStatistics()
-{
-    if (dbgCreated())
-        mDbgGuiVT->pfnShowStatistics (mDbgGui);
-}
-
-/**
- * Called when the Debug->Command Line... menu item is selected.
- */
-void VBoxConsoleWnd::dbgShowCommandLine()
-{
-    if (dbgCreated())
-        mDbgGuiVT->pfnShowCommandLine (mDbgGui);
-}
-
-/**
- * Called when the Debug->Logging menu item is selected.
- */
-void VBoxConsoleWnd::dbgLoggingToggled (bool aState)
-{
-    NOREF(aState);
-    CConsole console = mSession.GetConsole();
-    if (console.isOk())
-    {
-        CMachineDebugger cdebugger = console.GetDebugger();
-        if (console.isOk())
-            cdebugger.SetLogEnabled (aState);
-    }
-}
-
-/**
- * Ensures that the debugger GUI instance is ready.
- *
- * @returns true if instance is fine and dandy.
- * @returns flase if it's not.
- */
-bool VBoxConsoleWnd::dbgCreated()
-{
-    if (mDbgGui)
-        return true;
-
-    RTLDRMOD hLdrMod = vboxGlobal().getDebuggerModule();
-    if (hLdrMod == NIL_RTLDRMOD)
-        return false;
-
-    PFNDBGGUICREATE pfnGuiCreate;
-    int rc = RTLdrGetSymbol (hLdrMod, "DBGGuiCreate", (void**) &pfnGuiCreate);
-    if (RT_SUCCESS (rc))
-    {
-        ISession *pISession = mSession.raw();
-        rc = pfnGuiCreate (pISession, &mDbgGui, &mDbgGuiVT);
-        if (RT_SUCCESS (rc))
-        {
-            if (DBGGUIVT_ARE_VERSIONS_COMPATIBLE (mDbgGuiVT->u32Version, DBGGUIVT_VERSION) ||
-                mDbgGuiVT->u32EndVersion == mDbgGuiVT->u32Version)
-            {
-                mDbgGuiVT->pfnSetParent (mDbgGui, (QWidget*) this);
-                mDbgGuiVT->pfnSetMenu (mDbgGui, (QMenu*) mDbgMenu);
-                dbgAdjustRelativePos();
-                return true;
-            }
-
-            LogRel (("DBGGuiCreate failed, incompatible versions (loaded %#x/%#x, expected %#x)\n",
-                     mDbgGuiVT->u32Version, mDbgGuiVT->u32EndVersion, DBGGUIVT_VERSION));
-        }
-        else
-            LogRel (("DBGGuiCreate failed, rc=%Rrc\n", rc));
-    }
-    else
-        LogRel (("RTLdrGetSymbol(,\"DBGGuiCreate\",) -> %Rrc\n", rc));
-
-    mDbgGui = 0;
-    mDbgGuiVT = 0;
-    return false;
-}
-
-/**
- * Destroys the debugger GUI instacne if it has been created.
- */
-void VBoxConsoleWnd::dbgDestroy()
-{
-    if (mDbgGui)
-    {
-        mDbgGuiVT->pfnDestroy (mDbgGui);
-        mDbgGui = 0;
-        mDbgGuiVT = 0;
-    }
-}
-
-/**
- * Tells the debugger GUI that the console window has moved or been resized.
- */
-void VBoxConsoleWnd::dbgAdjustRelativePos()
-{
-    if (mDbgGui)
-    {
-        QRect rct = frameGeometry();
-        mDbgGuiVT->pfnAdjustRelativePos (mDbgGui, rct.x(), rct.y(), rct.width(), rct.height());
-    }
-}
-
-#endif /* VBOX_WITH_DEBUGGER_GUI */
-
-VBoxNetworkDialog::VBoxNetworkDialog (QWidget *aParent, CSession &aSession)
-    : QIWithRetranslateUI <QDialog> (aParent)
-    , mSettings (0)
-    , mSession (aSession)
-{
-    setModal (true);
-    /* Setup Dialog's options */
-    setWindowIcon (QIcon (":/nw_16px.png"));
-    setSizeGripEnabled (true);
-
-    /* Setup main dialog's layout */
-    QVBoxLayout *mainLayout = new QVBoxLayout (this);
-    VBoxGlobal::setLayoutMargin (mainLayout, 10);
-    mainLayout->setSpacing (10);
-
-    /* Setup settings layout */
-    mSettings = new VBoxVMSettingsNetworkPage (true);
-    mSettings->setOrderAfter (this);
-    VBoxGlobal::setLayoutMargin (mSettings->layout(), 0);
-    mSettings->getFrom (aSession.GetMachine());
-    mainLayout->addWidget (mSettings);
-
-    /* Setup button's layout */
-    QIDialogButtonBox *buttonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
-
-    connect (buttonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog()));
-    connect (buttonBox, SIGNAL (accepted()), this, SLOT (accept()));
-    connect (buttonBox, SIGNAL (rejected()), this, SLOT (reject()));
-    mainLayout->addWidget (buttonBox);
-
-    retranslateUi();
-}
-
-void VBoxNetworkDialog::retranslateUi()
-{
-    setWindowTitle (tr ("Network Adapters"));
-}
-
-void VBoxNetworkDialog::accept()
-{
-    mSettings->putBackTo();
-    CMachine machine = mSession.GetMachine();
-    machine.SaveSettings();
-    if (!machine.isOk())
-        vboxProblem().cannotSaveMachineSettings (machine);
-    QDialog::accept();
-}
-
-void VBoxNetworkDialog::showEvent (QShowEvent *aEvent)
-{
-    resize (450, 300);
-    VBoxGlobal::centerWidget (this, parentWidget());
-    setMinimumWidth (400);
-    QDialog::showEvent (aEvent);
-}
-
-VBoxSFDialog::VBoxSFDialog (QWidget *aParent, CSession &aSession)
-    : QIWithRetranslateUI <QDialog> (aParent)
-    , mSettings (0)
-    , mSession (aSession)
-{
-    setModal (true);
-    /* Setup Dialog's options */
-    setWindowIcon (QIcon (":/select_file_16px.png"));
-    setSizeGripEnabled (true);
-
-    /* Setup main dialog's layout */
-    QVBoxLayout *mainLayout = new QVBoxLayout (this);
-    VBoxGlobal::setLayoutMargin (mainLayout, 10);
-    mainLayout->setSpacing (10);
-
-    /* Setup settings layout */
-    mSettings = new VBoxVMSettingsSF (MachineType | ConsoleType, this);
-    VBoxGlobal::setLayoutMargin (mSettings->layout(), 0);
-    mSettings->getFromConsole (aSession.GetConsole());
-    mSettings->getFromMachine (aSession.GetMachine());
-    mainLayout->addWidget (mSettings);
-
-    /* Setup button's layout */
-    QIDialogButtonBox *buttonBox = new QIDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help);
-
-    connect (buttonBox, SIGNAL (helpRequested()), &vboxProblem(), SLOT (showHelpHelpDialog()));
-    connect (buttonBox, SIGNAL (accepted()), this, SLOT (accept()));
-    connect (buttonBox, SIGNAL (rejected()), this, SLOT (reject()));
-    mainLayout->addWidget (buttonBox);
-
-    retranslateUi();
-}
-
-void VBoxSFDialog::retranslateUi()
-{
-    setWindowTitle (tr ("Shared Folders"));
-}
-
-void VBoxSFDialog::accept()
-{
-    mSettings->putBackToConsole();
-    mSettings->putBackToMachine();
-    CMachine machine = mSession.GetMachine();
-    machine.SaveSettings();
-    if (!machine.isOk())
-        vboxProblem().cannotSaveMachineSettings (machine);
-    QDialog::accept();
-}
-
-void VBoxSFDialog::showEvent (QShowEvent *aEvent)
-{
-    resize (450, 300);
-    VBoxGlobal::centerWidget (this, parentWidget());
-    setMinimumWidth (400);
-    QDialog::showEvent (aEvent);
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.h	(revision 29793)
+++ 	(revision )
@@ -1,454 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxConsoleWnd class declaration
- */
-
-/*
- * Copyright (C) 2006-2009 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef __VBoxConsoleWnd_h__
-#define __VBoxConsoleWnd_h__
-
-/* Global includes */
-#include <QColor>
-#include <QDialog>
-#include <QMainWindow>
-#include <QMap>
-#include <QMenu>
-#include <QPointer>
-
-/* Local includes */
-#include "COMDefs.h"
-#include "QIWithRetranslateUI.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxHelpActions.h"
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-# include <VBox/dbggui.h>
-#endif
-#ifdef Q_WS_MAC
-# include "VBoxUtils.h"
-# include <ApplicationServices/ApplicationServices.h>
-# ifndef QT_MAC_USE_COCOA
-#  include <Carbon/Carbon.h>
-# endif /* !QT_MAC_USE_COCOA */
-#endif
-
-/* Global forwards */
-class QAction;
-class QActionGroup;
-class QLabel;
-class QSpacerItem;
-class QIWidgetValidator;
-
-/* Local forwards */
-class QIMenu;
-class QIStateIndicator;
-class VBoxChangeDockIconUpdateEvent;
-class VBoxChangePresentationModeEvent;
-class VBoxConsoleView;
-class VBoxMiniToolBar;
-class VBoxSwitchMenu;
-class VBoxUSBMenu;
-
-class VBoxConsoleWnd : public QIWithRetranslateUI2 <QMainWindow>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxConsoleWnd (VBoxConsoleWnd **aSelf, QWidget* aParent = 0, Qt::WindowFlags aFlags = Qt::Window);
-    virtual ~VBoxConsoleWnd();
-
-    bool isWindowMaximized()
-    {
-#ifdef Q_WS_MAC
-        /* On Mac OS X we didn't really jump to the fullscreen mode but
-         * maximize the window. This situation has to be considered when
-         * checking for maximized or fullscreen mode. */
-        return !isTrueSeamless() && ::darwinIsWindowMaximized(this);
-#else /* Q_WS_MAC */
-        return QMainWindow::isMaximized();
-#endif /* Q_WS_MAC */
-    }
-    bool isWindowFullScreen() const
-    {
-#ifdef Q_WS_MAC
-        /* On Mac OS X we didn't really jump to the fullscreen mode but
-         * maximize the window. This situation has to be considered when
-         * checking for maximized or fullscreen mode. */
-        return isTrueFullscreen() || isTrueSeamless();
-#else /* Q_WS_MAC */
-        return QMainWindow::isFullScreen();
-#endif /* Q_WS_MAC */
-    }
-    bool isTrueFullscreen() const { return mIsFullscreen; }
-    bool isTrueSeamless() const { return mIsSeamless; }
-
-    KMachineState machineState() const { return mMachineState; }
-
-    bool openView (const CSession &aSession);
-
-    void setMouseIntegrationLocked (bool aDisabled);
-
-    void popupMainMenu (bool aCenter);
-
-    void setMask (const QRegion &aRegion);
-    void clearMask();
-
-    /* informs that the guest display is resized */
-    void onDisplayResize (ulong aWidth, ulong aHeight);
-
-    /* used for obtaining the extradata settings */
-    CSession &session() { return mSession; }
-signals:
-
-    void closing();
-
-protected:
-
-    bool event (QEvent *aEvent);
-    void closeEvent (QCloseEvent *aEvent);
-#ifdef Q_WS_X11
-    bool x11Event (XEvent *aEvent);
-#endif
-
-    void retranslateUi();
-
-private slots:
-
-    void finalizeOpenView();
-    void tryClose();
-
-    void vmFullscreen (bool aOn);
-    void vmSeamless (bool aOn);
-    void vmAutoresizeGuest (bool aOn);
-    void vmAdjustWindow();
-    void vmDisableMouseIntegration (bool aOff);
-    void vmTypeCAD();
-#ifdef Q_WS_X11
-    void vmTypeCABS();
-#endif
-    void vmTakeSnapshot();
-    void vmShowInfoDialog();
-    void vmReset();
-    void vmPause (bool aOn);
-    void vmACPIShutdown();
-    void vmClose();
-
-    void devicesSwitchVrdp (bool aOn);
-    void devicesOpenNetworkDialog();
-    void devicesOpenSFDialog();
-    void devicesInstallGuestAdditions();
-
-    void prepareStorageMenu();
-    void prepareNetworkMenu();
-    void prepareSFMenu();
-
-    void mountMedium();
-    void switchUSB (QAction *aAction);
-
-    void showIndicatorContextMenu (QIStateIndicator *aInd, QContextMenuEvent *aEvent);
-
-    void updateDeviceLights();
-    void updateNetworkIPs();
-    void updateMachineState (KMachineState aState);
-    void updateMouseState (int aState);
-    void updateAdditionsState (const QString &aVersion, bool aActive,
-                               bool aSeamlessSupported, bool aGraphicsSupported);
-    void updateNetworkAdaptersState();
-    void updateUsbState();
-    void updateMediaDriveState (VBoxDefs::MediumType aType);
-    void updateSharedFoldersState();
-
-    void onExitFullscreen();
-    void unlockActionsSwitch();
-
-    void mtExitMode();
-    void mtCloseVM();
-    void mtMaskUpdate();
-
-    void changeDockIconUpdate (const VBoxChangeDockIconUpdateEvent &aEvent);
-    void changePresentationMode (const VBoxChangePresentationModeEvent &aEvent);
-    void processGlobalSettingChange (const char *aPublicName, const char *aName);
-
-    void installGuestAdditionsFrom (const QString &aSource);
-
-    void sltDownloaderUserManualEmbed();
-
-#ifdef RT_OS_DARWIN /* Stupid moc doesn't recognize Q_WS_MAC */
-    void sltDockPreviewModeChanged(QAction *pAction);
-#endif /* RT_OS_DARWIN */
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    void dbgPrepareDebugMenu();
-    void dbgShowStatistics();
-    void dbgShowCommandLine();
-    void dbgLoggingToggled (bool aBool);
-#endif
-
-private:
-
-    enum /* Stuff */
-    {
-        HardDiskStuff               = 0x01,
-        DVDStuff                    = 0x02,
-        FloppyStuff                 = 0x04,
-        PauseAction                 = 0x08,
-        NetworkStuff                = 0x10,
-        DisableMouseIntegrAction    = 0x20,
-        Caption                     = 0x40,
-        USBStuff                    = 0x80,
-        VRDPStuff                   = 0x100,
-        SharedFolderStuff           = 0x200,
-        VirtualizationStuff         = 0x400,
-        AllStuff                    = 0xFFFF,
-    };
-
-    void checkRequiredFeatures();
-    void activateUICustomizations();
-
-    void updateAppearanceOf (int aElement);
-
-    bool toggleFullscreenMode (bool aOn, bool aSeamless);
-    void switchToFullscreen (bool aOn, bool aSeamless);
-    void setViewInSeamlessMode (const QRect &aTargetRect);
-
-    void closeView();
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    bool dbgCreated();
-    void dbgDestroy();
-    void dbgAdjustRelativePos();
-#endif
-
-    /* COM Variables */
-    CSession mSession;
-
-    /* Machine State */
-    KMachineState mMachineState;
-
-    /* Window Variables */
-    QString mCaptionPrefix;
-    int mConsoleStyle;
-
-    /* Menu items */
-    QIMenu *mMainMenu;
-    QMenu *mVMMenu;
-    QMenu *mVMMenuMini;
-    QMenu *mDevicesMenu;
-    QMenu *mDevicesCDMenu;
-    QMenu *mDevicesFDMenu;
-    QMenu *mDevicesNetworkMenu;
-    QMenu *mDevicesSFMenu;
-    VBoxUSBMenu *mDevicesUSBMenu;
-    VBoxSwitchMenu *mVmDisMouseIntegrMenu;
-#if 0 /* todo: allow to setup */
-    VBoxSwitchMenu *mDevicesVRDPMenu;
-    VBoxSwitchMenu *mVmAutoresizeMenu;
-#endif
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    QMenu *mDbgMenu;
-#endif
-    QMenu *mHelpMenu;
-
-    QActionGroup *mRunningActions;
-    QActionGroup *mRunningOrPausedActions;
-
-    /* Machine actions */
-    QAction *mVmFullscreenAction;
-    QAction *mVmSeamlessAction;
-    QAction *mVmAutoresizeGuestAction;
-    QAction *mVmAdjustWindowAction;
-    QAction *mVmDisableMouseIntegrAction;
-    QAction *mVmTypeCADAction;
-#ifdef Q_WS_X11
-    QAction *mVmTypeCABSAction;
-#endif
-    QAction *mVmTakeSnapshotAction;
-    QAction *mVmShowInformationDlgAction;
-    QAction *mVmResetAction;
-    QAction *mVmPauseAction;
-    QAction *mVmACPIShutdownAction;
-    QAction *mVmCloseAction;
-
-    /* Devices actions */
-    QAction *mDevicesNetworkDialogAction;
-    QAction *mDevicesSFDialogAction;
-    QAction *mDevicesSwitchVrdpSeparator;
-    QAction *mDevicesSwitchVrdpAction;
-    QAction *mDevicesInstallGuestToolsAction;
-
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /* Debugger actions */
-    QAction *mDbgStatisticsAction;
-    QAction *mDbgCommandLineAction;
-    QAction *mDbgLoggingAction;
-#endif
-
-    /* Help actions */
-    VBoxHelpActions mHelpActions;
-
-    /* Widgets */
-    VBoxConsoleView *mConsole;
-    VBoxMiniToolBar *mMiniToolBar;
-#ifdef VBOX_WITH_DEBUGGER_GUI
-    /** The handle to the debugger gui. */
-    PDBGGUI mDbgGui;
-    /** The virtual method table for the debugger GUI. */
-    PCDBGGUIVT mDbgGuiVT;
-#endif
-
-#ifdef Q_WS_MAC
-    QMenu *m_pDockMenu;
-    QMenu *m_pDockSettingsMenu;
-    QAction *m_pDockDisablePreview;
-    QAction *m_pDockEnablePreviewMonitor;
-#endif /* Q_WS_MAC */
-
-    /* Timer to update LEDs */
-    QTimer *mIdleTimer;
-    QTimer *mNetworkTimer;
-
-    /* LEDs */
-    QIStateIndicator *mHDLed;
-    QIStateIndicator *mCDLed;
-#if 0 /* todo: allow to setup */
-    QIStateIndicator *mFDLed;
-#endif
-    QIStateIndicator *mNetLed;
-    QIStateIndicator *mUSBLed;
-    QIStateIndicator *mSFLed;
-    QIStateIndicator *mVirtLed;
-    QIStateIndicator *mMouseLed;
-    QIStateIndicator *mHostkeyLed;
-    QWidget *mHostkeyLedContainer;
-    QLabel *mHostkeyName;
-#if 0 /* todo: allow to setup */
-    QIStateIndicator *mVrdpLed;
-    QIStateIndicator *mAutoresizeLed;
-#endif
-
-    /* Normal Mode */
-    QRect mNormalGeo;
-
-    /* Fullscreen/Seamless Mode */
-    QList < QPointer <QWidget> > mHiddenChildren;
-    QSpacerItem *mShiftingSpacerLeft;
-    QSpacerItem *mShiftingSpacerTop;
-    QSpacerItem *mShiftingSpacerRight;
-    QSpacerItem *mShiftingSpacerBottom;
-    QPalette mErasePalette;
-    QSize mPrevMinSize;
-    QSize mMaskShift;
-    QRegion mStrictedRegion;
-#ifdef Q_WS_WIN
-    QRegion mPrevRegion;
-#endif
-#ifdef Q_WS_MAC
-    //QRegion mCurrRegion;
-# ifndef QT_MAC_USE_COCOA
-    //EventHandlerRef mDarwinRegionEventHandlerRef;
-# endif
-    /* For seamless maximizing */
-    QRect mNormalGeometry;
-    Qt::WindowFlags mSavedFlags;
-    /* For the fade effect if the the window goes fullscreen */
-    CGDisplayFadeReservationToken mFadeToken;
-#endif
-
-    /* Different bool flags */
-    bool mIsOpenViewFinished : 1;
-    bool mIsFirstTimeStarted : 1;
-    bool mIsAutoSaveMedia : 1;
-    bool mNoAutoClose : 1;
-    bool mIsFullscreen : 1;
-    bool mIsSeamless : 1;
-    bool mIsSeamlessSupported : 1;
-    bool mIsGraphicsSupported : 1;
-    bool mIsWaitingModeResize : 1;
-    bool mWasMax : 1;
-};
-
-/* We want to make the first action highlighted but not
- * selected, but Qt makes the both or neither one of this,
- * so, just move the focus to the next eligible object,
- * which will be the first menu action. This little
- * subclass made only for that purpose. */
-class QIMenu : public QMenu
-{
-    Q_OBJECT;
-
-public:
-
-    QIMenu (QWidget *aParent) : QMenu (aParent) {}
-
-    void selectFirstAction() { QMenu::focusNextChild(); }
-};
-
-class VBoxSettingsPage;
-class VBoxNetworkDialog : public QIWithRetranslateUI <QDialog>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxNetworkDialog (QWidget *aParent, CSession &aSession);
-
-protected:
-
-    void retranslateUi();
-
-protected slots:
-
-    virtual void accept();
-
-protected:
-
-    void showEvent (QShowEvent *aEvent);
-
-private:
-
-    VBoxSettingsPage *mSettings;
-    CSession &mSession;
-};
-
-class VBoxVMSettingsSF;
-class VBoxSFDialog : public QIWithRetranslateUI <QDialog>
-{
-    Q_OBJECT;
-
-public:
-
-    VBoxSFDialog (QWidget *aParent, CSession &aSession);
-
-protected:
-
-    void retranslateUi();
-
-protected slots:
-
-    virtual void accept();
-
-protected:
-
-    void showEvent (QShowEvent *aEvent);
-
-private:
-
-    VBoxVMSettingsSF *mSettings;
-    CSession &mSession;
-};
-
-#endif // __VBoxConsoleWnd_h__
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxFBDDRAW.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBDDRAW.cpp	(revision 29793)
+++ 	(revision )
@@ -1,516 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * DDRAW framebuffer implementation
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#if defined (VBOX_GUI_USE_DDRAW)
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include "VBoxFrameBuffer.h"
-
-#include "VBoxConsoleView.h"
-
-#include <qapplication.h>
-//Added by qt3to4:
-#include <QMoveEvent>
-#include <QPaintEvent>
-
-#include <iprt/param.h>
-#include <iprt/alloc.h>
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-#define LOGDDRAW Log
-
-/* @todo
- * - when paused in Guest VRAM mode after pause the screen is dimmed. because VRAM is dimmed.
- * - when GUI window is resized, somehow take this into account,  blit only visible parts.
- */
-
-/*
- * Helpers.
- */
-static LPDIRECTDRAW7 getDDRAW (void)
-{
-    LPDIRECTDRAW7 pDDRAW = NULL;
-    LPDIRECTDRAW iface = NULL;
-
-    HRESULT rc = DirectDrawCreate (NULL, &iface, NULL);
-
-    if (rc != DD_OK)
-    {
-        LOGDDRAW(("DDRAW: Could not create DirectDraw interface rc= 0x%08X\n", rc));
-    }
-    else
-    {
-        rc = iface->QueryInterface (IID_IDirectDraw7, (void**)&pDDRAW);
-
-        if (rc != DD_OK)
-        {
-            LOGDDRAW(("DDRAW: Could not query DirectDraw 7 interface rc = 0x%08X\n", rc));
-        }
-        else
-        {
-            rc = pDDRAW->SetCooperativeLevel (NULL, DDSCL_NORMAL);
-
-            if (rc != DD_OK)
-            {
-                LOGDDRAW(("DDRAW: Could not set the DirectDraw cooperative level rc = 0x%08X\n", rc));
-                pDDRAW->Release ();
-            }
-        }
-
-        iface->Release();
-    }
-
-    return rc == DD_OK? pDDRAW: NULL;
-}
-
-static LPDIRECTDRAWSURFACE7 createPrimarySurface (LPDIRECTDRAW7 pDDRAW)
-{
-    LPDIRECTDRAWSURFACE7 pPrimarySurface = NULL;
-
-    DDSURFACEDESC2 sd;
-    memset (&sd, 0, sizeof (sd));
-    sd.dwSize = sizeof (sd);
-    sd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
-    sd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-    sd.dwBackBufferCount = 0;
-
-    HRESULT rc = pDDRAW->CreateSurface (&sd, &pPrimarySurface, NULL);
-
-    if (rc != DD_OK)
-    {
-        LOGDDRAW(("DDRAW: Could not create primary DirectDraw surface rc = 0x%08X\n", rc));
-    }
-
-    return rc == DD_OK? pPrimarySurface: NULL;
-}
-
-static LPDIRECTDRAWCLIPPER createClipper (LPDIRECTDRAW7 pDDRAW, HWND hwnd)
-{
-    LPDIRECTDRAWCLIPPER pClipper = NULL;
-
-    HRESULT rc = pDDRAW->CreateClipper (0, &pClipper, NULL);
-
-    if (rc != DD_OK)
-    {
-        LOGDDRAW(("DDRAW: Could not create DirectDraw clipper rc = 0x%08X\n", rc));
-    }
-    else
-    {
-        rc = pClipper->SetHWnd (0, hwnd);
-
-        if (rc != DD_OK)
-        {
-            LOGDDRAW(("DDRAW: Could not set the HWND on clipper rc = 0x%08X\n", rc));
-            pClipper->Release ();
-        }
-    }
-
-    return rc == DD_OK? pClipper: NULL;
-}
-
-//
-// VBoxDDRAWFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-/** @class VBoxDDRAWFrameBuffer
- *
- *  The VBoxDDRAWFrameBuffer class is a class that implements the IFrameBuffer
- *  interface and uses Win32 DirectDraw to store and render VM display data.
- */
-
-VBoxDDRAWFrameBuffer::VBoxDDRAWFrameBuffer (VBoxConsoleView *aView) :
-    VBoxFrameBuffer (aView),
-    mDDRAW (NULL),
-    mClipper (NULL),
-    mSurface (NULL),
-    mPrimarySurface (NULL),
-    mPixelFormat (FramebufferPixelFormat_FOURCC_RGB),
-    mUsesGuestVRAM (false),
-    mWndX (0),
-    mWndY (0),
-    mSynchronousUpdates (true)
-{
-    memset (&mSurfaceDesc, 0, sizeof (mSurfaceDesc));
-
-    LOGDDRAW (("DDRAW: Creating\n"));
-
-    /* Release all created objects if something will go wrong. */
-    BOOL bReleaseObjects = TRUE;
-
-    mDDRAW = getDDRAW ();
-
-    if (mDDRAW)
-    {
-        mClipper = createClipper (mDDRAW, mView->viewport()->winId());
-
-        if (mClipper)
-        {
-            mPrimarySurface = createPrimarySurface (mDDRAW);
-
-            if (mPrimarySurface)
-            {
-                mPrimarySurface->SetClipper (mClipper);
-
-                VBoxResizeEvent *re =
-                    new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
-                                         NULL, 0, 0, 640, 480);
-
-                if (re)
-                {
-                    resizeEvent (re);
-                    delete re;
-
-                    if (mSurface)
-                    {
-                        /* Everything was initialized. */
-                        bReleaseObjects = FALSE;
-                    }
-                }
-            }
-        }
-    }
-
-    if (bReleaseObjects)
-    {
-        releaseObjects();
-    }
-}
-
-VBoxDDRAWFrameBuffer::~VBoxDDRAWFrameBuffer()
-{
-    releaseObjects();
-}
-
-void VBoxDDRAWFrameBuffer::releaseObjects()
-{
-    deleteSurface ();
-
-    if (mPrimarySurface)
-    {
-        if (mClipper)
-        {
-            mPrimarySurface->SetClipper (NULL);
-        }
-
-        mPrimarySurface->Release ();
-        mPrimarySurface = NULL;
-    }
-
-    if (mClipper)
-    {
-        mClipper->Release();
-        mClipper = NULL;
-    }
-
-    if (mDDRAW)
-    {
-        mDDRAW->Release();
-        mDDRAW = NULL;
-    }
-}
-
-/** @note This method is called on EMT from under this object's lock */
-STDMETHODIMP VBoxDDRAWFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
-                                                 ULONG aW, ULONG aH)
-{
-    LOGDDRAW(("DDRAW: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));
-
-    if (mSynchronousUpdates)
-    {
-//#warning check me!
-        mView->viewport()->update (aX, aY, aW, aH);
-    }
-    else
-    {
-        drawRect (aX, aY, aW, aH);
-    }
-
-    return S_OK;
-}
-
-void VBoxDDRAWFrameBuffer::paintEvent (QPaintEvent *pe)
-{
-    LOGDDRAW (("DDRAW: paintEvent %d,%d %dx%d\n",
-               pe->rect().x(), pe->rect().y(),
-               pe->rect().width(), pe->rect().height()));
-
-    drawRect (pe->rect().x(), pe->rect().y(),
-              pe->rect().width(), pe->rect().height());
-}
-
-void VBoxDDRAWFrameBuffer::resizeEvent (VBoxResizeEvent *re)
-{
-    LOGDDRAW (("DDRAW: resizeEvent %d, %p, %d %d %dx%d\n",
-               re->pixelFormat(), re->VRAM(), re->bitsPerPixel(),
-               re->bytesPerLine(), re->width(), re->height()));
-
-    VBoxFrameBuffer::resizeEvent (re);
-
-    bool ok = createSurface (re->pixelFormat(), re->VRAM (), re->bitsPerPixel(),
-                             re->bytesPerLine (), re->width(), re->height());
-    if (!ok && re->pixelFormat() != FramebufferPixelFormat_Opaque)
-    {
-        /* try to create a fallback surface with indirect buffer
-         * (only if haven't done so already) */
-        ok = createSurface (FramebufferPixelFormat_Opaque,
-                            NULL, 0, 0, re->width(), re->height());
-    }
-
-    Assert (ok);
-
-    getWindowPosition();
-
-//#warning: port me
-//    mView->setBackgroundMode (Qt::NoBackground);
-}
-
-void VBoxDDRAWFrameBuffer::moveEvent (QMoveEvent *me)
-{
-    getWindowPosition();
-}
-
-/*
- * Private methods.
- */
-
-/**
- * Creates a new surface in the requested format.
- * On success, returns @c true and assigns the created surface to mSurface
- * and its definition to mSurfaceDesc. On failure, returns @c false.
- *
- * If @a aPixelFormat is other than FramebufferPixelFormat_Opaque,
- * then the method will attempt to attach @a aVRAM directly to the created
- * surface. If this fails, the caller may call this method again with
- * @a aPixelFormat set to FramebufferPixelFormat_Opaque to try
- * setting up an indirect fallback buffer for the surface. This opeartion may
- * theoretically also fail.
- *
- * @note Deletes the existing surface before attemting to create a new one.
- */
-bool VBoxDDRAWFrameBuffer::createSurface (ULONG aPixelFormat, uchar *aVRAM,
-                                          ULONG aBitsPerPixel, ULONG aBytesPerLine,
-                                          ULONG aWidth, ULONG aHeight)
-{
-    deleteSurface();
-
-    DDSURFACEDESC2 sd;
-
-    /* Prepare the surface description structure. */
-    memset (&sd, 0, sizeof (sd));
-
-    sd.dwSize  = sizeof (sd);
-    sd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH |
-                 DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT;
-
-    sd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
-    sd.dwWidth = aWidth;
-    sd.dwHeight = aHeight;
-
-    /* Setup the desired pixel format on the surface. */
-
-    sd.ddpfPixelFormat.dwSize = sizeof (sd.ddpfPixelFormat);
-    sd.ddpfPixelFormat.dwFlags = DDPF_RGB;
-
-    if (aPixelFormat == FramebufferPixelFormat_FOURCC_RGB)
-    {
-        /* Try to use the guest VRAM directly */
-
-        switch (aBitsPerPixel)
-        {
-            case 32:
-                sd.ddpfPixelFormat.dwRGBBitCount = 32;
-                sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
-                sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
-                sd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-                break;
-            case 24:
-                sd.ddpfPixelFormat.dwRGBBitCount = 24;
-                sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
-                sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
-                sd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-                break;
-            case 16:
-                sd.ddpfPixelFormat.dwRGBBitCount = 16;
-                sd.ddpfPixelFormat.dwRBitMask = 0xF800;
-                sd.ddpfPixelFormat.dwGBitMask = 0x07E0;
-                sd.ddpfPixelFormat.dwBBitMask = 0x001F;
-                break;
-            default:
-                /* we don't directly support any other color depth */
-                return false;
-        }
-
-        sd.lPitch = (LONG) aBytesPerLine;
-
-        sd.lpSurface = aVRAM;
-        mUsesGuestVRAM = true;
-
-        mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-    }
-    else
-    if (aPixelFormat != FramebufferPixelFormat_Opaque)
-    {
-        /* we don't directly support any other pixel format */
-        return false;
-    }
-    else
-    {
-        /* for the Opaque format, we use the indirect memory buffer as a
-         * 32 bpp surface. */
-
-        sd.ddpfPixelFormat.dwRGBBitCount = 32;
-        sd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
-        sd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
-        sd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
-
-        sd.lPitch = sd.dwWidth * 4;
-
-        /* Allocate the memory buffer for the surface */
-        sd.lpSurface = RTMemAlloc (sd.lPitch * sd.dwHeight);
-        if (sd.lpSurface == NULL)
-        {
-            LOGDDRAW (("DDRAW: could not allocate memory for surface.\n"));
-            return false;
-        }
-        mUsesGuestVRAM = false;
-
-        mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-    }
-
-    /* create the surface */
-    HRESULT rc = mDDRAW->CreateSurface (&sd, &mSurface, NULL);
-
-    if (rc != DD_OK)
-    {
-        LOGDDRAW (("DDRAW: Could not create DirectDraw surface, rc=0x%08X\n", rc));
-        deleteSurface();
-        return false;
-    }
-
-    /* Initialize the surface description member. It will be used to obtain
-     * address, bpp and bpl. */
-    mSurfaceDesc = sd;
-
-    LOGDDRAW(("DDRAW: Created %s surface: format = %d, address = %p\n",
-              mUsesGuestVRAM ? "GuestVRAM": "system memory",
-              aPixelFormat, address ()));
-
-    if (!mUsesGuestVRAM)
-    {
-        /* Clear just created surface. */
-        memset (address(), 0, bytesPerLine() * height());
-    }
-
-    return true;
-}
-
-void VBoxDDRAWFrameBuffer::deleteSurface ()
-{
-    if (mSurface)
-    {
-        mSurface->Release ();
-        mSurface = NULL;
-
-        if (!mUsesGuestVRAM)
-        {
-            RTMemFree (mSurfaceDesc.lpSurface);
-        }
-
-        memset (&mSurfaceDesc, '\0', sizeof (mSurfaceDesc));
-        mUsesGuestVRAM = false;
-    }
-}
-
-/**
- * Draws a rectangular area of guest screen DDRAW surface onto the
- * host screen primary surface.
- */
-void VBoxDDRAWFrameBuffer::drawRect (ULONG x, ULONG y, ULONG w, ULONG h)
-{
-    LOGDDRAW (("DDRAW: drawRect: %d,%d, %dx%d\n", x, y, w, h));
-
-    if (mSurface && w > 0 && h > 0)
-    {
-        RECT rectSrc;
-        RECT rectDst;
-
-        rectSrc.left   = x;
-        rectSrc.right  = x + w;
-        rectSrc.top    = y;
-        rectSrc.bottom = y + h;
-
-        rectDst.left   = mWndX + x;
-        rectDst.right  = rectDst.left + w;
-        rectDst.top    = mWndY + y;
-        rectDst.bottom = rectDst.top + h;
-
-        /* DDBLT_ASYNC performs this blit asynchronously through the
-         *   first in, first out (FIFO) hardware in the order received.
-         *   If no room is available in the FIFO hardware, the call fails.
-         * DDBLT_WAIT waits if blitter is busy, and returns as soon as the
-         *   blit can be set up or another error occurs.
-         *
-         * I assume that DDBLT_WAIT will also wait for a room in the FIFO.
-         */
-        HRESULT rc = mPrimarySurface->Blt (&rectDst, mSurface, &rectSrc, DDBLT_ASYNC | DDBLT_WAIT, NULL);
-
-        if (rc != DD_OK)
-        {
-            /* Repeat without DDBLT_ASYNC. */
-            LOGDDRAW(("DDRAW: drawRect: async blit failed rc = 0x%08X\n", rc));
-            rc = mPrimarySurface->Blt (&rectDst, mSurface, &rectSrc, DDBLT_WAIT, NULL);
-
-            if (rc != DD_OK)
-            {
-                LOGDDRAW(("DDRAW: drawRect: sync blit failed rc = 0x%08X\n", rc));
-            }
-        }
-    }
-
-    return;
-}
-
-void VBoxDDRAWFrameBuffer::getWindowPosition (void)
-{
-//    if (mPrimarySurface)
-//    {
-//        /* Lock surface to synchronize with Blt in drawRect. */
-//        DDSURFACEDESC2 sd;
-//        memset (&sd, 0, sizeof (sd));
-//        sd.dwSize  = sizeof (sd);
-//
-//        HRESULT rc = mPrimarySurface->Lock (NULL, &sd, DDLOCK_WAIT | DDLOCK_WRITEONLY, NULL);
-//        LOGDDRAW(("DDRAW: getWindowPosition rc = 0x%08X\n", rc));
-//    }
-
-    RECT rect;
-    GetWindowRect (mView->viewport()->winId(), &rect);
-    mWndX = rect.left;
-    mWndY = rect.top;
-
-//    if (mPrimarySurface)
-//    {
-//        mPrimarySurface->Unlock (NULL);
-//    }
-}
-
-#endif /* defined (VBOX_GUI_USE_DDRAW) */
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp	(revision 29794)
@@ -23,7 +23,5 @@
 
 #include "VBoxFBOverlay.h"
-#include "VBoxFrameBuffer.h"
-
-#include "VBoxConsoleView.h"
+
 #include "VBoxProblemReporter.h"
 #include "VBoxGlobal.h"
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp	(revision 29794)
@@ -24,22 +24,10 @@
 #include "VBoxFrameBuffer.h"
 
-#include "VBoxConsoleView.h"
-//#include "VBoxProblemReporter.h"
-//#include "VBoxGlobal.h"
-
 /* Qt includes */
 #include <QGLWidget>
 
-//#include <iprt/asm.h>
-//
 #ifdef VBOX_WITH_VIDEOHWACCEL
 #include <VBox/VBoxVideo.h>
-//#include <VBox/types.h>
-//#include <VBox/ssm.h>
 #endif
-//#include <iprt/semaphore.h>
-//
-//#include <QFile>
-//#include <QTextStream>
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
@@ -51,18 +39,4 @@
  *  is then converted to QPixmap and blitted to the console view widget.
  */
-
-VBoxQGLFrameBuffer::VBoxQGLFrameBuffer (VBoxConsoleView *aView) :
-    VBoxFrameBuffer (aView),
-    mCmdPipe(aView)
-{
-//    mWidget = new GLWidget(aView->viewport());
-#ifndef VBOXQGL_PROF_BASE
-    resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
-                                      NULL, 0, 0, 640, 480));
-#else
-    resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
-                                      NULL, 0, 0, VBOXQGL_PROF_WIDTH, VBOXQGL_PROF_HEIGHT));
-#endif
-}
 
 /** @note This method is called on EMT from under this object's lock */
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQuartz2D.cpp	(revision 29793)
+++ 	(revision )
@@ -1,467 +1,0 @@
-/* $Id$ */
-/** @file
- * Qt GUI (aka VirtualBox) - Quartz2D framebuffer implementation.
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#if defined (VBOX_GUI_USE_QUARTZ2D)
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include <iprt/asm.h>
-
-/* VBox includes */
-#include "VBoxFrameBuffer.h"
-#include "VBoxConsoleView.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxGlobal.h"
-#include "VBoxUtils.h"
-/* Needed for checking against seamless mode */
-#include "VBoxConsoleWnd.h"
-#include "VBoxIChatTheaterWrapper.h"
-
-#include <QDesktopWidget>
-
-#include "iprt/system.h"
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-//#define COMP_WITH_SHADOW
-//#define OVERLAY_CLIPRECTS
-
-/** @class VBoxQuartz2DFrameBuffer
- *
- *  The VBoxQuartz2dFrameBuffer class is a class that implements the IFrameBuffer
- *  interface and uses Apples Quartz2D to store and render VM display data.
- */
-
-#ifndef QT_MAC_USE_COCOA
-static OSStatus darwinSNWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
-{
-    if (     aInUserData
-        && ::GetEventClass (aInEvent) == kEventClassWindow
-        && ::GetEventKind (aInEvent) == kEventWindowBoundsChanged)
-        static_cast<VBoxQuartz2DFrameBuffer *> (aInUserData)->testAndSetSNCarbonFix();
-
-    return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
-}
-#endif /* QT_MAC_USE_COCOA */
-
-VBoxQuartz2DFrameBuffer::VBoxQuartz2DFrameBuffer (VBoxConsoleView *aView)
-    : VBoxFrameBuffer(aView)
-    , mDataAddress(NULL)
-    , mBitmapData(NULL)
-    , mPixelFormat(FramebufferPixelFormat_FOURCC_RGB)
-    , mImage(NULL)
-    , mRegion (NULL)
-    , mRegionUnused (NULL)
-#ifndef QT_MAC_USE_COCOA
-    , mSnowLeoCarbonFix (false)
-    , mDarwinSNWindowHandlerRef (NULL)
-#endif /* QT_MAC_USE_COCOA */
-{
-    Log (("Quartz2D: Creating\n"));
-
-#ifndef QT_MAC_USE_COCOA
-    /* There seems to be a big bug on Snow Leopard regarding hardware
-     * accelerated image handling in Carbon. If our VM image is used on a
-     * second monitor it seems not really to be valid. (maybe the OpenGL
-     * texture is not properly shared between the two contexts). As a
-     * workaround we make a deep copy on every paint event. This workaround
-     * should only be in place if we are firstly on Snow Leopard and secondly
-     * on any screen beside the primary one. To track the current screen, we
-     * install a event handler for the window move event. Whenever the user
-     * drag the window around we recheck the current screen of the window. */
-    char szInfo[64];
-    int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
-    if (RT_SUCCESS (rc) &&
-        szInfo[0] == '1') /* higher than 1x.x.x */
-    {
-        EventTypeSpec eventTypes[] =
-        {
-            { kEventClassWindow, kEventWindowBoundsChanged }
-        };
-        ::InstallWindowEventHandler (::darwinToNativeWindow (mView->viewport()), darwinSNWindowHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],
-                                     this, &mDarwinSNWindowHandlerRef);
-        /* Initialize it now */
-        testAndSetSNCarbonFix();
-    }
-#endif /* QT_MAC_USE_COCOA */
-
-    VBoxResizeEvent event(FramebufferPixelFormat_Opaque,
-                          NULL, 0, 0, 640, 480);
-    resizeEvent (&event);
-}
-
-VBoxQuartz2DFrameBuffer::~VBoxQuartz2DFrameBuffer()
-{
-    Log (("Quartz2D: Deleting\n"));
-    clean();
-#ifndef QT_MAC_USE_COCOA
-    if (mDarwinSNWindowHandlerRef)
-    {
-       ::RemoveEventHandler (mDarwinSNWindowHandlerRef);
-       mDarwinSNWindowHandlerRef = NULL;
-    }
-#endif /* QT_MAC_USE_COCOA */
-}
-
-/** @note This method is called on EMT from under this object's lock */
-STDMETHODIMP VBoxQuartz2DFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
-                                                 ULONG aW, ULONG aH)
-{
-/*    Log (("Quartz2D: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));*/
-
-    QApplication::postEvent (mView,
-                             new VBoxRepaintEvent (aX, aY, aW, aH));
-    return S_OK;
-}
-
-STDMETHODIMP VBoxQuartz2DFrameBuffer::SetVisibleRegion (BYTE *aRectangles, ULONG aCount)
-{
-    PRTRECT rects = (PRTRECT)aRectangles;
-
-    if (!rects)
-        return E_POINTER;
-
-    /** @todo r=bird: Is this thread safe? If I remember the code flow correctly, the
-     * GUI thread could be happily jogging along paintEvent now on another cpu core.
-     * This function is called on the EMT (emulation thread). Which means, blocking
-     * execution waiting for a lock is out of the question. A quick solution using
-     * ASMAtomic(Cmp)XchgPtr and a struct { cAllocated; cRects; aRects[1]; }
-     * *mRegion, *mUnusedRegion; should suffice (and permit you to reuse allocations). */
-    RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *) &mRegionUnused, NULL);
-    if (rgnRcts && rgnRcts->allocated < aCount)
-    {
-        RTMemFree (rgnRcts);
-        rgnRcts = NULL;
-    }
-    if (!rgnRcts)
-    {
-        ULONG allocated = RT_ALIGN_32 (aCount + 1, 32);
-        allocated = RT_MAX (128, allocated);
-        rgnRcts = (RegionRects *) RTMemAlloc (RT_OFFSETOF (RegionRects, rcts[allocated]));
-        if (!rgnRcts)
-            return E_OUTOFMEMORY;
-        rgnRcts->allocated = allocated;
-    }
-    rgnRcts->used = 0;
-
-    QRegion reg;
-//    printf ("Region rects follow...\n");
-    QRect vmScreenRect (0, 0, width(), height());
-    for (ULONG ind = 0; ind < aCount; ++ ind)
-    {
-        QRect rect;
-        rect.setLeft (rects->xLeft);
-        rect.setTop (rects->yTop);
-        /* QRect are inclusive */
-        rect.setRight (rects->xRight - 1);
-        rect.setBottom (rects->yBottom - 1);
-
-        /* The rect should intersect with the vm screen. */
-        rect = vmScreenRect.intersect (rect);
-        ++ rects;
-        /* Make sure only valid rects are distributed */
-        /* todo: Test if the other framebuffer implementation have the same
-         * problem with invalid rects (In Linux/Windows) */
-        if (rect.isValid() &&
-           rect.width() > 0 && rect.height() > 0)
-            reg += rect;
-        else
-            continue;
-
-        CGRect *cgRct = &rgnRcts->rcts[rgnRcts->used];
-        cgRct->origin.x = rect.x();
-        cgRct->origin.y = height() - rect.y() - rect.height();
-        cgRct->size.width = rect.width();
-        cgRct->size.height = rect.height();
-//        printf ("Region rect[%d - %d]: %d %d %d %d\n", rgnRcts->used, aCount, rect.x(), rect.y(), rect.height(), rect.width());
-        rgnRcts->used++;
-    }
-//    printf ("..................................\n");
-
-    void *pvOld = ASMAtomicXchgPtr ((void * volatile *) &mRegion, rgnRcts);
-    if (    pvOld
-        &&  !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegionUnused, pvOld, NULL))
-        RTMemFree (pvOld);
-
-    QApplication::postEvent (mView, new VBoxSetRegionEvent (reg));
-
-    return S_OK;
-}
-
-void VBoxQuartz2DFrameBuffer::paintEvent (QPaintEvent *aEvent)
-{
-    /* For debugging /Developer/Applications/Performance Tools/Quartz
-     * Debug.app is a nice tool to see which parts of the screen are
-     * updated.*/
-
-    Assert (mImage);
-
-    VBoxConsoleWnd *main = qobject_cast <VBoxConsoleWnd *> (vboxGlobal().mainWindow());
-    Assert (VALID_PTR (main));
-    QWidget* viewport = mView->viewport();
-    Assert (VALID_PTR (viewport));
-    /* Get the dimensions of the viewport */
-    CGRect viewRect = ::darwinToCGRect (viewport->geometry());
-    /* Get the context of this window from Qt */
-    CGContextRef ctx = ::darwinToCGContextRef (viewport);
-    Assert (VALID_PTR (ctx));
-
-    /* Flip the context */
-    CGContextTranslateCTM (ctx, 0, viewRect.size.height);
-    CGContextScaleCTM (ctx, 1.0, -1.0);
-
-    /* We handle the seamless mode as a special case. */
-    if (   main
-        && main->isTrueSeamless())
-    {
-        /* Here we paint the windows without any wallpaper.
-         * So the background would be set transparently. */
-
-        /* Create a subimage of the current view.
-         * Currently this subimage is the whole screen. */
-        CGImageRef subImage;
-        if (!mView->pauseShot().isNull())
-        {
-            CGImageRef pauseImg = ::darwinToCGImageRef (&mView->pauseShot());
-            subImage = CGImageCreateWithImageInRect (pauseImg, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));
-            CGImageRelease (pauseImg);
-        }
-        else
-        {
-
-#ifndef QT_MAC_USE_COCOA
-            /* For the reason of this see the constructor. */
-            if (mSnowLeoCarbonFix)
-            {
-                CGImageRef copy = CGImageCreateCopy (mImage);
-                subImage = CGImageCreateWithImageInRect (copy, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));
-                CGImageRelease (copy);
-            }else
-#endif /* QT_MAC_USE_COCOA */
-                subImage = CGImageCreateWithImageInRect (mImage, CGRectMake (mView->contentsX(), mView->contentsY(), mView->visibleWidth(), mView->visibleHeight()));
-        }
-        Assert (VALID_PTR (subImage));
-        /* Clear the background (Make the rect fully transparent) */
-        CGContextClearRect (ctx, viewRect);
-#ifdef OVERLAY_CLIPRECTS
-        CGContextSetRGBFillColor (ctx, 0.0, 0.0, 5.0, 0.7);
-        CGContextFillRect (ctx, viewRect);
-#endif
-#ifdef COMP_WITH_SHADOW
-        /* Enable shadows */
-        CGContextSetShadow (ctx, CGSizeMake (10, -10), 10);
-        CGContextBeginTransparencyLayer (ctx, NULL);
-#endif
-        /* Grab the current visible region. */
-        RegionRects *rgnRcts = (RegionRects *) ASMAtomicXchgPtr ((void * volatile *) &mRegion, NULL);
-        if (rgnRcts)
-        {
-            if (rgnRcts->used > 0)
-            {
-                /* Add the clipping rects all at once. They are defined in
-                 * SetVisibleRegion. */
-                CGContextBeginPath (ctx);
-                CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used);
-                /* Now convert the path to a clipping path. */
-                CGContextClip (ctx);
-            }
-            /* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls). */
-            if (    !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegion, rgnRcts, NULL)
-                &&  !ASMAtomicCmpXchgPtr ((void * volatile *) &mRegionUnused, rgnRcts, NULL))
-                RTMemFree (rgnRcts);
-        }
-        /* In any case clip the drawing to the view window */
-        CGContextClipToRect (ctx, viewRect);
-        /* At this point draw the real vm image */
-        CGContextDrawImage (ctx, ::darwinFlipCGRect (viewRect, viewRect.size.height), subImage);
-#ifdef COMP_WITH_SHADOW
-        CGContextEndTransparencyLayer (ctx);
-#endif
-        CGImageRelease (subImage);
-#ifdef OVERLAY_CLIPRECTS
-        if (rgnRcts && rgnRcts->used > 0)
-        {
-            CGContextBeginPath (ctx);
-            CGContextAddRects (ctx, rgnRcts->rcts, rgnRcts->used);
-            CGContextSetRGBStrokeColor (ctx, 1.0, 0.0, 0.0, 0.7);
-            CGContextDrawPath (ctx, kCGPathStroke);
-        }
-        CGContextSetRGBStrokeColor (ctx, 0.0, 1.0, 0.0, 0.7);
-        CGContextStrokeRect (ctx, viewRect);
-#endif
-    }
-    else
-    {
-        /* Here we paint if we didn't care about any masks */
-
-        /* Create a subimage of the current view in the size
-         * of the bounding box of the current paint event */
-        QRect ir = aEvent->rect();
-        QRect is = QRect (ir.x() + mView->contentsX(), ir.y() + mView->contentsY(), ir.width(), ir.height());
-        CGImageRef subImage;
-        if (!mView->pauseShot().isNull())
-        {
-            CGImageRef pauseImg = ::darwinToCGImageRef (&mView->pauseShot());
-            subImage = CGImageCreateWithImageInRect (pauseImg, ::darwinToCGRect (is));
-            CGImageRelease (pauseImg);
-        }
-        else
-        {
-#ifndef QT_MAC_USE_COCOA
-            /* For the reason of this see the constructor. */
-            if (mSnowLeoCarbonFix)
-            {
-                CGImageRef copy = CGImageCreateCopy (mImage);
-                subImage = CGImageCreateWithImageInRect (copy, ::darwinToCGRect (is));
-                CGImageRelease (copy);
-            }else
-#endif /* QT_MAC_USE_COCOA */
-                subImage = CGImageCreateWithImageInRect (mImage, ::darwinToCGRect (is));
-        }
-        Assert (VALID_PTR (subImage));
-        /* Ok, for more performance we set a clipping path of the
-         * regions given by this paint event. */
-        QVector<QRect> a = aEvent->region().rects();
-        if (!a.isEmpty())
-        {
-            CGContextBeginPath (ctx);
-            /* Add all region rects to the current context as path components */
-            for (int i = 0; i < a.size(); ++i)
-                CGContextAddRect (ctx, ::darwinFlipCGRect (::darwinToCGRect (a[i]), viewRect.size.height));
-            /* Now convert the path to a clipping path. */
-            CGContextClip (ctx);
-        }
-
-        /* In any case clip the drawing to the view window */
-        CGContextClipToRect (ctx, viewRect);
-        /* At this point draw the real vm image */
-        CGContextDrawImage (ctx, ::darwinFlipCGRect (::darwinToCGRect (ir), viewRect.size.height), subImage);
-
-        CGImageRelease (subImage);
-    }
-}
-
-void VBoxQuartz2DFrameBuffer::resizeEvent (VBoxResizeEvent *aEvent)
-{
-#if 0
-    printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n",
-           aEvent->pixelFormat(), (unsigned int)aEvent->VRAM(),
-           aEvent->bitsPerPixel(), aEvent->bytesPerLine(),
-           aEvent->width(), aEvent->height());
-#endif
-
-    /* Clean out old stuff */
-    clean();
-
-    mWdt = aEvent->width();
-    mHgt = aEvent->height();
-
-    bool remind = false;
-
-    /* We need a color space in any case */
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    /* Check if we support the pixel format/colordepth and can use the guest VRAM directly.
-     * Mac OS X supports 16 bit also but not in the 565 mode. So we could use
-     * 32 bit only. */
-    if (   aEvent->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB
-        && aEvent->bitsPerPixel() == 32)
-    {
-//        printf ("VRAM\n");
-        /* Create the image copy of the framebuffer */
-        CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * mWdt * mHgt, NULL);
-        mImage = CGImageCreate (mWdt, mHgt, 8, aEvent->bitsPerPixel(), aEvent->bytesPerLine(), cs,
-                                kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
-                                kCGRenderingIntentDefault);
-        mDataAddress = aEvent->VRAM();
-        CGDataProviderRelease (dp);
-    }
-    else
-    {
-        remind = true;
-//        printf ("No VRAM\n");
-        /* Create the memory we need for our image copy
-         * Read somewhere that an alignment of 16 is
-         * best for optimal performance. So why not. */
-//        int bitmapBytesPerRow = RT_ALIGN (mWdt * 4, 16);
-        int bitmapBytesPerRow = mWdt * 4;
-        int bitmapByteCount = (bitmapBytesPerRow * mHgt);
-        mBitmapData = RTMemAlloc (bitmapByteCount);
-        CGDataProviderRef dp = CGDataProviderCreateWithData (NULL, mBitmapData, bitmapByteCount, NULL);
-        mImage = CGImageCreate (mWdt, mHgt, 8, 32, bitmapBytesPerRow, cs,
-                               kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, dp, 0, false,
-                               kCGRenderingIntentDefault);
-        mDataAddress = static_cast <uchar*> (mBitmapData);
-        CGDataProviderRelease (dp);
-    }
-    CGColorSpaceRelease (cs);
-#ifdef VBOX_WITH_ICHAT_THEATER
-    setImageRef (mImage);
-#endif
-
-//    if (remind)
-//    {
-//        class RemindEvent : public VBoxAsyncEvent
-//        {
-//            ulong mRealBPP;
-//        public:
-//            RemindEvent (ulong aRealBPP)
-//                : mRealBPP (aRealBPP) {}
-//            void handle()
-//            {
-//                vboxProblem().remindAboutWrongColorDepth (mRealBPP, 32);
-//            }
-//        };
-//        (new RemindEvent (aEvent->bitsPerPixel()))->post();
-//    }
-}
-
-void VBoxQuartz2DFrameBuffer::clean()
-{
-    if (mImage)
-    {
-        CGImageRelease (mImage);
-        mImage = NULL;
-    }
-    if (mBitmapData)
-    {
-        RTMemFree (mBitmapData);
-        mBitmapData = NULL;
-    }
-    if (mRegion)
-    {
-        RTMemFree ((void *) mRegion);
-        mRegion = NULL;
-    }
-    if (mRegionUnused)
-    {
-        RTMemFree ((void *) mRegionUnused);
-        mRegionUnused = NULL;
-    }
-}
-
-#ifndef QT_MAC_USE_COCOA
-void VBoxQuartz2DFrameBuffer::testAndSetSNCarbonFix()
-{
-    QWidget* viewport = mView->viewport();
-    Assert (VALID_PTR (viewport));
-    QDesktopWidget dw;
-    mSnowLeoCarbonFix = dw.primaryScreen() != dw.screenNumber (viewport);
-}
-#endif /* QT_MAC_USE_COCOA */
-
-#endif /* defined (VBOX_GUI_USE_QUARTZ2D) */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.cpp	(revision 29793)
+++ 	(revision )
@@ -1,676 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxFrameBuffer class and subclasses implementation
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#ifdef VBOX_WITH_PRECOMPILED_HEADERS
-# include "precomp.h"
-#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
-#include "VBoxFrameBuffer.h"
-
-#include "VBoxConsoleView.h"
-#include "VBoxProblemReporter.h"
-#include "VBoxGlobal.h"
-
-/* Qt includes */
-#include <QPainter>
-#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
-
-//
-// VBoxFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-/** @class VBoxFrameBuffer
- *
- *  Base class for all frame buffer implementations.
- */
-
-#if defined (Q_OS_WIN32)
-static CComModule _Module;
-#else
-NS_DECL_CLASSINFO (VBoxFrameBuffer)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI (VBoxFrameBuffer, IFramebuffer)
-#endif
-
-VBoxFrameBuffer::VBoxFrameBuffer (VBoxConsoleView *aView)
-    : mView (aView)
-    , mWdt (0), mHgt (0)
-#if defined (Q_OS_WIN32)
-    , refcnt (0)
-#endif
-{
-    AssertMsg (mView, ("VBoxConsoleView must not be null\n"));
-    mWinId = (mView && mView->viewport()) ? (ULONG64) mView->viewport()->winId() : 0;
-    int rc = RTCritSectInit(&mCritSect);
-    AssertRC(rc);
-}
-
-VBoxFrameBuffer::~VBoxFrameBuffer()
-{
-    RTCritSectDelete(&mCritSect);
-}
-
-// IFramebuffer implementation methods.
-// Just forwarders to relevant class methods.
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(Address) (BYTE **aAddress)
-{
-    if (!aAddress)
-        return E_POINTER;
-    *aAddress = address();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(Width) (ULONG *aWidth)
-{
-    if (!aWidth)
-        return E_POINTER;
-    *aWidth = (ULONG) width();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(Height) (ULONG *aHeight)
-{
-    if (!aHeight)
-        return E_POINTER;
-    *aHeight = (ULONG) height();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(BitsPerPixel) (ULONG *aBitsPerPixel)
-{
-    if (!aBitsPerPixel)
-        return E_POINTER;
-    *aBitsPerPixel = bitsPerPixel();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(BytesPerLine) (ULONG *aBytesPerLine)
-{
-    if (!aBytesPerLine)
-        return E_POINTER;
-    *aBytesPerLine = bytesPerLine();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(PixelFormat) (
-    ULONG *aPixelFormat)
-{
-    if (!aPixelFormat)
-        return E_POINTER;
-    *aPixelFormat = pixelFormat();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(UsesGuestVRAM) (
-    BOOL *aUsesGuestVRAM)
-{
-    if (!aUsesGuestVRAM)
-        return E_POINTER;
-    *aUsesGuestVRAM = usesGuestVRAM();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(HeightReduction) (ULONG *aHeightReduction)
-{
-    if (!aHeightReduction)
-        return E_POINTER;
-    /* no reduction */
-    *aHeightReduction = 0;
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay)
-{
-    if (!aOverlay)
-        return E_POINTER;
-    /* not yet implemented */
-    *aOverlay = 0;
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::COMGETTER(WinId) (ULONG64 *winId)
-{
-    if (!winId)
-        return E_POINTER;
-    *winId = mWinId;
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::Lock()
-{
-    this->lock();
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::Unlock()
-{
-    this->unlock();
-    return S_OK;
-}
-
-/** @note This method is called on EMT from under this object's lock */
-STDMETHODIMP VBoxFrameBuffer::RequestResize (ULONG aScreenId, ULONG aPixelFormat,
-                                             BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
-                                             ULONG aWidth, ULONG aHeight,
-                                             BOOL *aFinished)
-{
-    NOREF(aScreenId);
-    QApplication::postEvent (mView,
-                             new VBoxResizeEvent (aPixelFormat, aVRAM, aBitsPerPixel,
-                                                  aBytesPerLine, aWidth, aHeight));
-
-#ifdef DEBUG_sunlover
-    LogFlowFunc (("pixelFormat=%d, vram=%p, bpp=%d, bpl=%d, w=%d, h=%d\n",
-          aPixelFormat, aVRAM, aBitsPerPixel, aBytesPerLine, aWidth, aHeight));
-#endif /* DEBUG_sunlover */
-
-    /*
-     *  the resize has been postponed, return FALSE
-     *  to cause the VM thread to sleep until IDisplay::ResizeFinished()
-     *  is called from the VBoxResizeEvent event handler.
-     */
-
-    *aFinished = FALSE;
-    return S_OK;
-}
-
-/**
- * Returns whether we like the given video mode.
- *
- * @returns COM status code
- * @param   width     video mode width in pixels
- * @param   height    video mode height in pixels
- * @param   bpp       video mode bit depth in bits per pixel
- * @param   supported pointer to result variable
- */
-STDMETHODIMP VBoxFrameBuffer::VideoModeSupported (ULONG aWidth, ULONG aHeight,
-                                                  ULONG aBPP, BOOL *aSupported)
-{
-    NOREF(aBPP);
-    LogFlowThisFunc(("aWidth=%lu, aHeight=%lu, aBPP=%lu\n",
-                     (unsigned long) aWidth,  (unsigned long) aHeight,
-                      (unsigned long) aBPP));
-    if (!aSupported)
-        return E_POINTER;
-    *aSupported = TRUE;
-    QRect screen = mView->desktopGeometry();
-    if (   (screen.width() != 0)
-        && (aWidth > (ULONG) screen.width())
-       )
-        *aSupported = FALSE;
-    if (   (screen.height() != 0)
-        && (aHeight > (ULONG) screen.height())
-       )
-        *aSupported = FALSE;
-    LogFlowThisFunc(("screenW=%lu, screenH=%lu -> aSupported=%s\n",
-                    screen.width(), screen.height(), *aSupported ? "TRUE" : "FALSE"));
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::GetVisibleRegion(BYTE *aRectangles, ULONG aCount,
-                                               ULONG *aCountCopied)
-{
-    PRTRECT rects = (PRTRECT)aRectangles;
-
-    if (!rects)
-        return E_POINTER;
-
-    /// @todo what and why?
-
-    NOREF(aCount);
-    NOREF(aCountCopied);
-
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::SetVisibleRegion (BYTE *aRectangles, ULONG aCount)
-{
-    PRTRECT rects = (PRTRECT)aRectangles;
-
-    if (!rects)
-        return E_POINTER;
-
-    QRegion reg;
-    for (ULONG ind = 0; ind < aCount; ++ ind)
-    {
-        QRect rect;
-        rect.setLeft (rects->xLeft);
-        rect.setTop (rects->yTop);
-        /* QRect are inclusive */
-        rect.setRight (rects->xRight - 1);
-        rect.setBottom (rects->yBottom - 1);
-        reg += rect;
-        ++ rects;
-    }
-    QApplication::postEvent (mView, new VBoxSetRegionEvent (reg));
-
-    return S_OK;
-}
-
-STDMETHODIMP VBoxFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
-{
-    Q_UNUSED (pCommand);
-    return E_NOTIMPL;
-}
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-void VBoxFrameBuffer::doProcessVHWACommand(QEvent * pEvent)
-{
-    Q_UNUSED(pEvent);
-    /* should never be here */
-    AssertBreakpoint();
-}
-#endif
-
-//
-// VBoxQImageFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_QIMAGE)
-
-/** @class VBoxQImageFrameBuffer
- *
- *  The VBoxQImageFrameBuffer class is a class that implements the IFrameBuffer
- *  interface and uses QImage as the direct storage for VM display data. QImage
- *  is then converted to QPixmap and blitted to the console view widget.
- */
-
-VBoxQImageFrameBuffer::VBoxQImageFrameBuffer (VBoxConsoleView *aView) :
-    VBoxFrameBuffer (aView)
-{
-    /* Initialize the framebuffer the first time */
-    resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
-                                      NULL, 0, 0, 640, 480));
-}
-
-/** @note This method is called on EMT from under this object's lock */
-STDMETHODIMP VBoxQImageFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
-                                                  ULONG aW, ULONG aH)
-{
-    /* We're not on the GUI thread and update() isn't thread safe in
-     * Qt 4.3.x on the Win, Qt 3.3.x on the Mac (4.2.x is),
-     * on Linux (didn't check Qt 4.x there) and probably on other
-     * non-DOS platforms, so post the event instead. */
-    QApplication::postEvent (mView,
-                             new VBoxRepaintEvent (aX, aY, aW, aH));
-
-    return S_OK;
-}
-
-void VBoxQImageFrameBuffer::paintEvent (QPaintEvent *pe)
-{
-    const QRect &r = pe->rect().intersected (QRect (0, 0, mWdt, mHgt));
-
-    /* Some outdated rectangle during processing VBoxResizeEvent */
-    if (r.isEmpty())
-        return;
-
-#if 0
-    LogFlowFunc (("%dx%d-%dx%d (img=%dx%d)\n",
-                  r.x(), r.y(), r.width(), r.height(),
-                  img.width(), img.height()));
-#endif
-
-    QPainter painter (mView->viewport());
-
-    if (r.width() < mWdt * 2 / 3)
-    {
-        /* This method is faster for narrow updates */
-        mPM = QPixmap::fromImage (mImg.copy (r.x() + mView->contentsX(),
-                                             r.y() + mView->contentsY(),
-                                             r.width(), r.height()));
-        painter.drawPixmap (r.x(), r.y(), mPM);
-    }
-    else
-    {
-        /* This method is faster for wide updates */
-        mPM = QPixmap::fromImage (QImage (mImg.scanLine (r.y() + mView->contentsY()),
-                                  mImg.width(), r.height(), mImg.bytesPerLine(),
-                                  QImage::Format_RGB32));
-        painter.drawPixmap (r.x(), r.y(), mPM,
-                            r.x() + mView->contentsX(), 0, 0, 0);
-    }
-}
-
-void VBoxQImageFrameBuffer::resizeEvent (VBoxResizeEvent *re)
-{
-#if 0
-    LogFlowFunc (("fmt=%d, vram=%p, bpp=%d, bpl=%d, width=%d, height=%d\n",
-                  re->pixelFormat(), re->VRAM(),
-                  re->bitsPerPixel(), re->bytesPerLine(),
-                  re->width(), re->height()));
-#endif
-
-    mWdt = re->width();
-    mHgt = re->height();
-
-    bool remind = false;
-    bool fallback = false;
-    ulong bitsPerLine = re->bytesPerLine() * 8;
-
-    /* check if we support the pixel format and can use the guest VRAM directly */
-    if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB)
-    {
-        QImage::Format format;
-        switch (re->bitsPerPixel())
-        {
-            /* 32-, 8- and 1-bpp are the only depths supported by QImage */
-            case 32:
-                format = QImage::Format_RGB32;
-                break;
-            case 8:
-                format = QImage::Format_Indexed8;
-                remind = true;
-                break;
-            case 1:
-                format = QImage::Format_Mono;
-                remind = true;
-                break;
-            default:
-                format = QImage::Format_Invalid; /* set it to something so gcc keeps quiet. */
-                remind = true;
-                fallback = true;
-                break;
-        }
-
-        if (!fallback)
-        {
-            /* QImage only supports 32-bit aligned scan lines... */
-            Assert ((re->bytesPerLine() & 3) == 0);
-            fallback = ((re->bytesPerLine() & 3) != 0);
-        }
-        if (!fallback)
-        {
-            /* ...and the scan lines ought to be a whole number of pixels. */
-            Assert ((bitsPerLine & (re->bitsPerPixel() - 1)) == 0);
-            fallback = ((bitsPerLine & (re->bitsPerPixel() - 1)) != 0);
-        }
-        if (!fallback)
-        {
-            ulong virtWdt = bitsPerLine / re->bitsPerPixel();
-            mImg = QImage ((uchar *) re->VRAM(), virtWdt, mHgt, format);
-            mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-            mUsesGuestVRAM = true;
-        }
-    }
-    else
-    {
-        fallback = true;
-    }
-
-    if (fallback)
-    {
-        /* we don't support either the pixel format or the color depth,
-         * fallback to a self-provided 32bpp RGB buffer */
-        mImg = QImage (mWdt, mHgt, QImage::Format_RGB32);
-        mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-        mUsesGuestVRAM = false;
-    }
-
-    if (remind)
-    {
-        class RemindEvent : public VBoxAsyncEvent
-        {
-            ulong mRealBPP;
-        public:
-            RemindEvent (ulong aRealBPP)
-                : mRealBPP (aRealBPP) {}
-            void handle()
-            {
-                vboxProblem().remindAboutWrongColorDepth (mRealBPP, 32);
-            }
-        };
-        (new RemindEvent (re->bitsPerPixel()))->post();
-    }
-}
-
-#endif
-
-//
-// VBoxQGLFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_QGLFB)
-
-/* The class is defined in VBoxFBQGL.cpp */
-
-#endif
-
-//
-// VBoxSDLFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_SDL)
-
-#include "VBoxX11Helper.h"
-
-/** @class VBoxSDLFrameBuffer
- *
- *  The VBoxSDLFrameBuffer class is a class that implements the IFrameBuffer
- *  interface and uses SDL to store and render VM display data.
- */
-
-VBoxSDLFrameBuffer::VBoxSDLFrameBuffer (VBoxConsoleView *aView) :
-    VBoxFrameBuffer (aView)
-{
-    mScreen = NULL;
-    mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-    mSurfVRAM = NULL;
-
-    X11ScreenSaverSettingsInit();
-    resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
-                                      NULL, 0, 0, 640, 480));
-}
-
-VBoxSDLFrameBuffer::~VBoxSDLFrameBuffer()
-{
-    if (mSurfVRAM)
-    {
-        SDL_FreeSurface (mSurfVRAM);
-        mSurfVRAM = NULL;
-    }
-    X11ScreenSaverSettingsSave();
-    SDL_QuitSubSystem (SDL_INIT_VIDEO);
-    X11ScreenSaverSettingsRestore();
-}
-
-/** @note This method is called on EMT from under this object's lock */
-STDMETHODIMP VBoxSDLFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
-                                               ULONG aW, ULONG aH)
-{
-#if !defined (Q_WS_WIN) && !defined (Q_WS_PM)
-    /* we're not on the GUI thread and update() isn't thread safe in Qt 3.3.x
-       on the Mac (4.2.x is), on Linux (didn't check Qt 4.x there) and
-       probably on other non-DOS platforms, so post the event instead. */
-    QApplication::postEvent (mView,
-                             new VBoxRepaintEvent (aX, aY, aW, aH));
-#else
-    /* we're not on the GUI thread, so update() instead of repaint()! */
-    mView->viewport()->update (aX - mView->contentsX(),
-                               aY - mView->contentsY(),
-                               aW, aH);
-#endif
-    return S_OK;
-}
-
-void VBoxSDLFrameBuffer::paintEvent (QPaintEvent *pe)
-{
-    if (mScreen)
-    {
-#ifdef Q_WS_X11
-        /* make sure we don't conflict with Qt's drawing */
-        //XSync(QPaintDevice::x11Display(), FALSE);
-#endif
-        if (mScreen->pixels)
-        {
-            QRect r = pe->rect();
-
-            if (mSurfVRAM)
-            {
-                SDL_Rect rect = { (Sint16) r.x(), (Sint16) r.y(),
-                                  (Sint16) r.width(), (Sint16) r.height() };
-                SDL_BlitSurface (mSurfVRAM, &rect, mScreen, &rect);
-                /** @todo may be: if ((mScreen->flags & SDL_HWSURFACE) == 0) */
-                SDL_UpdateRect (mScreen, r.x(), r.y(), r.width(), r.height());
-            }
-            else
-            {
-                SDL_UpdateRect (mScreen, r.x(), r.y(), r.width(), r.height());
-            }
-        }
-    }
-}
-
-void VBoxSDLFrameBuffer::resizeEvent (VBoxResizeEvent *re)
-{
-    /* Check whether the guest resolution has not been changed. */
-    bool fSameResolutionRequested = (   width()  == re->width()
-                                     && height() == re->height()
-                                    );
-
-    /* Check if the guest VRAM can be used as the source bitmap. */
-    bool fallback = false;
-
-    Uint32 Rmask = 0;
-    Uint32 Gmask = 0;
-    Uint32 Bmask = 0;
-
-    if (re->pixelFormat() == FramebufferPixelFormat_FOURCC_RGB)
-    {
-        switch (re->bitsPerPixel())
-        {
-            case 32:
-                Rmask = 0x00FF0000;
-                Gmask = 0x0000FF00;
-                Bmask = 0x000000FF;
-                break;
-            case 24:
-                Rmask = 0x00FF0000;
-                Gmask = 0x0000FF00;
-                Bmask = 0x000000FF;
-                break;
-            case 16:
-                Rmask = 0xF800;
-                Gmask = 0x07E0;
-                Bmask = 0x001F;
-                break;
-            default:
-                /* Unsupported format leads to the indirect buffer */
-                fallback = true;
-                break;
-        }
-    }
-    else
-    {
-        /* Unsupported format leads to the indirect buffer */
-        fallback = true;
-    }
-
-    mWdt = re->width();
-    mHgt = re->height();
-
-    /* Recreate the source surface. */
-    if (mSurfVRAM)
-    {
-        SDL_FreeSurface(mSurfVRAM);
-        mSurfVRAM = NULL;
-    }
-
-    if (!fallback)
-    {
-        /* It is OK to create the source surface from the guest VRAM. */
-        mSurfVRAM = SDL_CreateRGBSurfaceFrom(re->VRAM(), re->width(), re->height(),
-                                             re->bitsPerPixel(),
-                                             re->bytesPerLine(),
-                                             Rmask, Gmask, Bmask, 0);
-        LogFlowFunc (("Created VRAM surface %p\n", mSurfVRAM));
-        if (mSurfVRAM == NULL)
-        {
-            fallback = true;
-        }
-    }
-
-    if (fSameResolutionRequested)
-    {
-        LogFlowFunc(("the same resolution requested, skipping the resize.\n"));
-        return;
-    }
-
-    /* close SDL so we can init it again */
-    if (mScreen)
-    {
-        X11ScreenSaverSettingsSave();
-        SDL_QuitSubSystem (SDL_INIT_VIDEO);
-        X11ScreenSaverSettingsRestore();
-        mScreen = NULL;
-    }
-
-    /*
-     *  initialize the SDL library, use its super hack to integrate it with our
-     *  client window
-     */
-    static char sdlHack[64];
-    LogFlowFunc (("Using client window 0x%08lX to initialize SDL\n",
-                  mView->viewport()->winId()));
-    /* Note: SDL_WINDOWID must be decimal (not hex) to work on Win32 */
-    sprintf (sdlHack, "SDL_WINDOWID=%lu", mView->viewport()->winId());
-    putenv (sdlHack);
-    X11ScreenSaverSettingsSave();
-    int rc = SDL_InitSubSystem (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
-    X11ScreenSaverSettingsRestore();
-    AssertMsg (rc == 0, ("SDL initialization failed: %s\n", SDL_GetError()));
-    NOREF(rc);
-
-#ifdef Q_WS_X11
-    /* undo signal redirections from SDL, it'd steal keyboard events from us! */
-    signal (SIGINT, SIG_DFL);
-    signal (SIGQUIT, SIG_DFL);
-#endif
-
-    LogFlowFunc (("Setting SDL video mode to %d x %d\n", mWdt, mHgt));
-
-    /* Pixel format is RGB in any case */
-    mPixelFormat = FramebufferPixelFormat_FOURCC_RGB;
-
-    mScreen = SDL_SetVideoMode (mWdt, mHgt, 0,
-                                SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL);
-    AssertMsg (mScreen, ("SDL video mode could not be set!\n"));
-}
-
-#endif
-
-//
-// VBoxDDRAWFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_DDRAW)
-
-/* The class is defined in VBoxFBDDRAW.cpp */
-
-#endif
-
-//
-// VBoxQuartz2DFrameBuffer class
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_QUARTZ2D)
-
-/* The class is defined in VBoxQuartz2D.cpp */
-
-#endif
-
Index: unk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxFrameBuffer.h	(revision 29793)
+++ 	(revision )
@@ -1,520 +1,0 @@
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * VBoxFrameBuffer class and subclasses declarations
- */
-
-/*
- * Copyright (C) 2006-2007 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef ___VBoxFrameBuffer_h___
-#define ___VBoxFrameBuffer_h___
-#include "COMDefs.h"
-#include <iprt/critsect.h>
-
-/* Qt includes */
-#include <QImage>
-#include <QPixmap>
-#include <QMutex>
-#include <QPaintEvent>
-#include <QMoveEvent>
-#if defined (VBOX_GUI_USE_QGL)
-#include "VBoxFBOverlay.h"
-#endif
-
-#if defined (VBOX_GUI_USE_SDL)
-#include <SDL.h>
-#include <signal.h>
-#endif
-
-#if defined (Q_WS_WIN) && defined (VBOX_GUI_USE_DDRAW)
-// VBox/cdefs.h defines these:
-#undef LOWORD
-#undef HIWORD
-#undef LOBYTE
-#undef HIBYTE
-#include <ddraw.h>
-#endif
-
-class VBoxConsoleView;
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Frame buffer resize event.
- */
-class VBoxResizeEvent : public QEvent
-{
-public:
-
-    VBoxResizeEvent (ulong aPixelFormat, uchar *aVRAM,
-                     ulong aBitsPerPixel, ulong aBytesPerLine,
-                     ulong aWidth, ulong aHeight) :
-        QEvent ((QEvent::Type) VBoxDefs::ResizeEventType),
-        mPixelFormat (aPixelFormat), mVRAM (aVRAM), mBitsPerPixel (aBitsPerPixel),
-        mBytesPerLine (aBytesPerLine), mWidth (aWidth), mHeight (aHeight) {}
-    ulong pixelFormat() { return mPixelFormat; }
-    uchar *VRAM() { return mVRAM; }
-    ulong bitsPerPixel() { return mBitsPerPixel; }
-    ulong bytesPerLine() { return mBytesPerLine; }
-    ulong width() { return mWidth; }
-    ulong height() { return mHeight; }
-
-private:
-
-    ulong mPixelFormat;
-    uchar *mVRAM;
-    ulong mBitsPerPixel;
-    ulong mBytesPerLine;
-    ulong mWidth;
-    ulong mHeight;
-};
-
-/**
- *  Frame buffer repaint event.
- */
-class VBoxRepaintEvent : public QEvent
-{
-public:
-    VBoxRepaintEvent (int iX, int iY, int iW, int iH) :
-        QEvent ((QEvent::Type) VBoxDefs::RepaintEventType),
-        ex (iX), ey (iY), ew (iW), eh (iH)
-    {}
-    int x() { return ex; }
-    int y() { return ey; }
-    int width() { return ew; }
-    int height() { return eh; }
-private:
-    int ex, ey, ew, eh;
-};
-
-/**
- *  Frame buffer set region event.
- */
-class VBoxSetRegionEvent : public QEvent
-{
-public:
-    VBoxSetRegionEvent (const QRegion &aReg)
-        : QEvent ((QEvent::Type) VBoxDefs::SetRegionEventType)
-        , mReg (aReg) {}
-    QRegion region() { return mReg; }
-private:
-    QRegion mReg;
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Common IFramebuffer implementation for all methods used by GUI to maintain
- *  the VM display video memory.
- *
- *  Note that although this class can be called from multiple threads
- *  (in particular, the GUI thread and EMT) it doesn't protect access to every
- *  data field using its mutex lock. This is because all synchronization between
- *  the GUI and the EMT thread is supposed to be done using the
- *  IFramebuffer::NotifyUpdate() and IFramebuffer::RequestResize() methods
- *  (in particular, the \a aFinished parameter of these methods is responsible
- *  for the synchronization). These methods are always called on EMT and
- *  therefore always follow one another but never in parallel.
- *
- *  Using this object's mutex lock (exposed also in IFramebuffer::Lock() and
- *  IFramebuffer::Unlock() implementations) usually makes sense only if some
- *  third-party thread (i.e. other than GUI or EMT) needs to make sure that
- *  *no* VM display update or resize event can occur while it is accessing
- *  IFramebuffer properties or the underlying display memory storage area.
- *
- *  See IFramebuffer documentation for more info.
- */
-
-class VBoxFrameBuffer : VBOX_SCRIPTABLE_IMPL(IFramebuffer)
-{
-public:
-
-    VBoxFrameBuffer (VBoxConsoleView *aView);
-    virtual ~VBoxFrameBuffer();
-
-    NS_DECL_ISUPPORTS
-
-#if defined (Q_OS_WIN32)
-
-    STDMETHOD_(ULONG, AddRef)()
-    {
-        return ::InterlockedIncrement (&refcnt);
-    }
-
-    STDMETHOD_(ULONG, Release)()
-    {
-        long cnt = ::InterlockedDecrement (&refcnt);
-        if (cnt == 0)
-            delete this;
-        return cnt;
-    }
-#endif
-    VBOX_SCRIPTABLE_DISPATCH_IMPL(IFramebuffer)
-
-    // IFramebuffer COM methods
-    STDMETHOD(COMGETTER(Address)) (BYTE **aAddress);
-    STDMETHOD(COMGETTER(Width)) (ULONG *aWidth);
-    STDMETHOD(COMGETTER(Height)) (ULONG *aHeight);
-    STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *aBitsPerPixel);
-    STDMETHOD(COMGETTER(BytesPerLine)) (ULONG *aBytesPerLine);
-    STDMETHOD(COMGETTER(PixelFormat)) (ULONG *aPixelFormat);
-    STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *aUsesGuestVRAM);
-    STDMETHOD(COMGETTER(HeightReduction)) (ULONG *aHeightReduction);
-    STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay);
-    STDMETHOD(COMGETTER(WinId)) (ULONG64 *winId);
-
-    STDMETHOD(Lock)();
-    STDMETHOD(Unlock)();
-
-    STDMETHOD(RequestResize) (ULONG aScreenId, ULONG aPixelFormat,
-                              BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
-                              ULONG aWidth, ULONG aHeight,
-                              BOOL *aFinished);
-
-    STDMETHOD(VideoModeSupported) (ULONG aWidth, ULONG aHeight, ULONG aBPP,
-                                   BOOL *aSupported);
-
-    STDMETHOD(GetVisibleRegion)(BYTE *aRectangles, ULONG aCount, ULONG *aCountCopied);
-    STDMETHOD(SetVisibleRegion)(BYTE *aRectangles, ULONG aCount);
-
-    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
-
-    ulong width() { return mWdt; }
-    ulong height() { return mHgt; }
-
-    virtual ulong pixelFormat()
-    {
-        return FramebufferPixelFormat_FOURCC_RGB;
-    }
-
-    virtual bool usesGuestVRAM()
-    {
-        return false;
-    }
-
-    void lock() { RTCritSectEnter(&mCritSect); }
-    void unlock() { RTCritSectLeave(&mCritSect); }
-
-    virtual uchar *address() = 0;
-    virtual ulong bitsPerPixel() = 0;
-    virtual ulong bytesPerLine() = 0;
-
-    /**
-     *  Called on the GUI thread (from VBoxConsoleView) when some part of the
-     *  VM display viewport needs to be repainted on the host screen.
-     */
-    virtual void paintEvent (QPaintEvent *pe) = 0;
-
-    /**
-     *  Called on the GUI thread (from VBoxConsoleView) after it gets a
-     *  VBoxResizeEvent posted from the RequestResize() method implementation.
-     */
-    virtual void resizeEvent (VBoxResizeEvent *re)
-    {
-        mWdt = re->width();
-        mHgt = re->height();
-    }
-
-    /**
-     *  Called on the GUI thread (from VBoxConsoleView) when the VM console
-     *  window is moved.
-     */
-    virtual void moveEvent (QMoveEvent * /*me*/ ) {}
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    /* this method is called from the GUI thread
-     * to perform the actual Video HW Acceleration command processing
-     * the event is framebuffer implementation specific */
-    virtual void doProcessVHWACommand(QEvent * pEvent);
-
-    virtual void viewportResized(QResizeEvent * /*re*/){}
-
-    virtual void viewportScrolled(int /*dx*/, int /*dy*/){}
-
-    virtual void setView(VBoxConsoleView * pView) { mView = pView; }
-#endif
-
-protected:
-
-    VBoxConsoleView *mView;
-    RTCRITSECT mCritSect;
-    int mWdt;
-    int mHgt;
-    uint64_t mWinId;
-
-#if defined (Q_OS_WIN32)
-private:
-    long refcnt;
-#endif
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_QIMAGE)
-
-class VBoxQImageFrameBuffer : public VBoxFrameBuffer
-{
-public:
-
-    VBoxQImageFrameBuffer (VBoxConsoleView *aView);
-
-    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH);
-
-    ulong pixelFormat() { return mPixelFormat; }
-    bool usesGuestVRAM() { return mUsesGuestVRAM; }
-
-    uchar *address() { return mImg.bits(); }
-    ulong bitsPerPixel() { return mImg.depth(); }
-    ulong bytesPerLine() { return mImg.bytesPerLine(); }
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-
-private:
-
-    QPixmap mPM;
-    QImage mImg;
-    ulong mPixelFormat;
-    bool mUsesGuestVRAM;
-};
-
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_QGLFB)
-
-class VBoxQGLFrameBuffer : public VBoxFrameBuffer
-{
-public:
-
-    VBoxQGLFrameBuffer (VBoxConsoleView *aView);
-
-    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH);
-#ifdef VBOXQGL_PROF_BASE
-    STDMETHOD(RequestResize) (ULONG aScreenId, ULONG aPixelFormat,
-                              BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
-                              ULONG aWidth, ULONG aHeight,
-                              BOOL *aFinished);
-#endif
-
-#ifdef VBOX_WITH_VIDEOHWACCEL
-    STDMETHOD(ProcessVHWACommand)(BYTE *pCommand);
-#endif
-
-    ulong pixelFormat() { return vboxWidget()->vboxPixelFormat(); }
-    bool usesGuestVRAM() { return vboxWidget()->vboxUsesGuestVRAM(); }
-
-    uchar *address() { return vboxWidget()->vboxAddress(); }
-    ulong bitsPerPixel() { return vboxWidget()->vboxBitsPerPixel(); }
-    ulong bytesPerLine() { return vboxWidget()->vboxBytesPerLine(); }
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-    void doProcessVHWACommand(QEvent * pEvent);
-
-private:
-//    void vboxMakeCurrent();
-    class VBoxGLWidget * vboxWidget();
-
-    class VBoxVHWACommandElementProcessor mCmdPipe;
-};
-
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_SDL)
-
-class VBoxSDLFrameBuffer : public VBoxFrameBuffer
-{
-public:
-
-    VBoxSDLFrameBuffer (VBoxConsoleView *aView);
-    virtual ~VBoxSDLFrameBuffer();
-
-    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH);
-
-    uchar *address()
-    {
-        SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen;
-        return surf ? (uchar *) (uintptr_t) surf->pixels : 0;
-    }
-
-    ulong bitsPerPixel()
-    {
-        SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen;
-        return surf ? surf->format->BitsPerPixel : 0;
-    }
-
-    ulong bytesPerLine()
-    {
-        SDL_Surface *surf = mSurfVRAM ? mSurfVRAM : mScreen;
-        return surf ? surf->pitch : 0;
-    }
-
-    ulong pixelFormat()
-    {
-        return mPixelFormat;
-    }
-
-    bool usesGuestVRAM()
-    {
-        return mSurfVRAM != NULL;
-    }
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-
-private:
-
-    SDL_Surface *mScreen;
-    SDL_Surface *mSurfVRAM;
-
-    ulong mPixelFormat;
-};
-
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (VBOX_GUI_USE_DDRAW)
-
-class VBoxDDRAWFrameBuffer : public VBoxFrameBuffer
-{
-public:
-
-    VBoxDDRAWFrameBuffer (VBoxConsoleView *aView);
-    virtual ~VBoxDDRAWFrameBuffer();
-
-    STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
-                             ULONG aW, ULONG aH);
-
-    uchar *address() { return (uchar *) mSurfaceDesc.lpSurface; }
-    ulong bitsPerPixel() { return mSurfaceDesc.ddpfPixelFormat.dwRGBBitCount; }
-    ulong bytesPerLine() { return (ulong) mSurfaceDesc.lPitch; }
-
-    ulong pixelFormat() { return mPixelFormat; };
-
-    bool usesGuestVRAM() { return mUsesGuestVRAM; }
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-    void moveEvent (QMoveEvent *me);
-
-private:
-
-    void releaseObjects();
-
-    bool createSurface (ULONG aPixelFormat, uchar *pvVRAM,
-                        ULONG aBitsPerPixel, ULONG aBytesPerLine,
-                        ULONG aWidth, ULONG aHeight);
-    void deleteSurface();
-    void drawRect (ULONG x, ULONG y, ULONG w, ULONG h);
-    void getWindowPosition (void);
-
-    LPDIRECTDRAW7        mDDRAW;
-    LPDIRECTDRAWCLIPPER  mClipper;
-    LPDIRECTDRAWSURFACE7 mSurface;
-    DDSURFACEDESC2       mSurfaceDesc;
-    LPDIRECTDRAWSURFACE7 mPrimarySurface;
-
-    ulong mPixelFormat;
-
-    bool mUsesGuestVRAM;
-
-    int mWndX;
-    int mWndY;
-
-    bool mSynchronousUpdates;
-};
-
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (Q_WS_MAC) && defined (VBOX_GUI_USE_QUARTZ2D)
-
-#include <Carbon/Carbon.h>
-
-class VBoxQuartz2DFrameBuffer : public VBoxFrameBuffer
-{
-public:
-
-    VBoxQuartz2DFrameBuffer (VBoxConsoleView *aView);
-    virtual ~VBoxQuartz2DFrameBuffer ();
-
-    STDMETHOD (NotifyUpdate) (ULONG aX, ULONG aY,
-                              ULONG aW, ULONG aH);
-    STDMETHOD (SetVisibleRegion) (BYTE *aRectangles, ULONG aCount);
-
-    uchar *address() { return mDataAddress; }
-    ulong bitsPerPixel() { return CGImageGetBitsPerPixel (mImage); }
-    ulong bytesPerLine() { return CGImageGetBytesPerRow (mImage); }
-    ulong pixelFormat() { return mPixelFormat; };
-    bool usesGuestVRAM() { return mBitmapData == NULL; }
-
-    const CGImageRef imageRef() const { return mImage; }
-
-    void paintEvent (QPaintEvent *pe);
-    void resizeEvent (VBoxResizeEvent *re);
-
-#ifndef QT_MAC_USE_COCOA
-    void testAndSetSNCarbonFix();
-#endif /* QT_MAC_USE_COCOA */
-
-private:
-
-    void clean();
-
-    uchar *mDataAddress;
-    void *mBitmapData;
-    ulong mPixelFormat;
-    CGImageRef mImage;
-    typedef struct
-    {
-        /** The size of this structure expressed in rcts entries. */
-        ULONG allocated;
-        /** The number of entries in the rcts array. */
-        ULONG used;
-        /** Variable sized array of the rectangle that makes up the region. */
-        CGRect rcts[1];
-    } RegionRects;
-    /** The current valid region, all access is by atomic cmpxchg or atomic xchg.
-     *
-     * The protocol for updating and using this has to take into account that
-     * the producer (SetVisibleRegion) and consumer (paintEvent) are running
-     * on different threads. Therefore the producer will create a new RegionRects
-     * structure before atomically replace the existing one. While the consumer
-     * will read the value by atomically replace it by NULL, and then when its
-     * done try restore it by cmpxchg. If the producer has already put a new
-     * region there, it will be discarded (see mRegionUnused).
-     */
-    RegionRects volatile *mRegion;
-    /** For keeping the unused region and thus avoid some RTMemAlloc/RTMemFree calls.
-     * This is operated with atomic cmpxchg and atomic xchg. */
-    RegionRects volatile *mRegionUnused;
-
-#ifndef QT_MAC_USE_COCOA
-    bool mSnowLeoCarbonFix;
-    EventHandlerRef mDarwinSNWindowHandlerRef;
-#endif /* QT_MAC_USE_COCOA */
-};
-
-#endif /* Q_WS_MAC && VBOX_GUI_USE_QUARTZ2D */
-
-#endif // !___VBoxFrameBuffer_h___
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp	(revision 29794)
@@ -23,5 +23,4 @@
 #include "VBoxSelectorWnd.h"
 #include "VBoxVMListView.h"
-#include "VBoxConsoleWnd.h"
 #include "VBoxToolBar.h"
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxTakeSnapshotDlg.cpp	(revision 29794)
@@ -28,10 +28,8 @@
 #include "VBoxProblemReporter.h"
 #include "VBoxUtils.h"
-# ifdef Q_WS_MAC
-#  ifdef VBOX_WITH_NEW_RUNTIME_CORE
-#   include "UIMachineWindowNormal.h"
-#   include "VBoxSnapshotsWgt.h"
-#  endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
-# endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
+#ifdef Q_WS_MAC
+# include "UIMachineWindowNormal.h"
+# include "VBoxSnapshotsWgt.h"
+#endif /* Q_WS_MAC */
 
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
@@ -41,5 +39,4 @@
 {
 #ifdef Q_WS_MAC
-# ifdef VBOX_WITH_NEW_RUNTIME_CORE
     /* No sheets in another mode than normal for now. Firstly it looks ugly and
      * secondly in some cases it is broken. */
@@ -47,14 +44,4 @@
         || qobject_cast<VBoxSnapshotsWgt*>(pParent))
         setWindowFlags (Qt::Sheet);
-# endif /* !VBOX_WITH_NEW_RUNTIME_CORE */
-# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
-    /* Sheets are broken if the window is in fullscreen mode. So make it a
-     * normal window in that case. */
-    VBoxConsoleWnd *cwnd = qobject_cast<VBoxConsoleWnd*> (pParent);
-    if (cwnd == NULL ||
-        (!cwnd->isTrueFullscreen() &&
-         !cwnd->isTrueSeamless()))
-        setWindowFlags (Qt::Sheet);
-# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
 #endif /* Q_WS_MAC */
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.cpp	(revision 29794)
@@ -23,21 +23,18 @@
 /* Global Includes */
 #include <QTimer>
+#include <QScrollBar>
 
 /* Local Includes */
 #include <VBoxVMInformationDlg.h>
 #include <VBoxGlobal.h>
-#include <VBoxConsoleView.h>
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
 #include "UIMachineLogic.h"
 #include "UIMachineWindow.h"
 #include "UIMachineView.h"
 #include "UISession.h"
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
 
 VBoxVMInformationDlg::InfoDlgMap VBoxVMInformationDlg::mSelfArray = InfoDlgMap();
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
 void VBoxVMInformationDlg::createInformationDlg(UIMachineWindow *pMachineWindow)
 {
@@ -103,100 +100,4 @@
      * more than one screens. */
     connect (pMachineWindow->machineView(), SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
-    connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int)));
-    connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
-    connect (mStatTimer, SIGNAL (timeout()), this, SLOT (processStatistics()));
-
-    /* Loading language constants */
-    retranslateUi();
-
-    /* Details page update */
-    updateDetails();
-
-    /* Statistics page update */
-    processStatistics();
-    mStatTimer->start (5000);
-
-    /* Preload dialog attributes for this vm */
-    QString dlgsize = mSession.GetMachine().GetExtraData (VBoxDefs::GUI_InfoDlgState);
-    if (dlgsize.isEmpty())
-    {
-        mWidth = 400;
-        mHeight = 450;
-        mMax = false;
-    }
-    else
-    {
-        QStringList list = dlgsize.split (',');
-        mWidth = list [0].toInt(), mHeight = list [1].toInt();
-        mMax = list [2] == "max";
-    }
-
-    /* Make statistics page the default one */
-    mInfoStack->setCurrentIndex (1);
-}
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-
-void VBoxVMInformationDlg::createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole)
-{
-    CMachine machine = aSession.GetMachine();
-    if (mSelfArray.find (machine.GetName()) == mSelfArray.end())
-    {
-        /* Creating new information dialog if there is no one existing */
-        VBoxVMInformationDlg *id = new VBoxVMInformationDlg (aConsole, aSession, Qt::Window);
-        id->centerAccording (aConsole);
-        id->setAttribute (Qt::WA_DeleteOnClose);
-        mSelfArray [machine.GetName()] = id;
-    }
-
-    VBoxVMInformationDlg *info = mSelfArray [machine.GetName()];
-    info->show();
-    info->raise();
-    info->setWindowState (info->windowState() & ~Qt::WindowMinimized);
-    info->activateWindow();
-}
-
-VBoxVMInformationDlg::VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags)
-# ifdef Q_WS_MAC
-    : QIWithRetranslateUI2 <QIMainDialog> (aConsole, aFlags)
-# else /* Q_WS_MAC */
-    : QIWithRetranslateUI2 <QIMainDialog> (0, aFlags)
-# endif /* Q_WS_MAC */
-    , mConsole (aConsole)
-    , mSession (aSession)
-    , mIsPolished (false)
-    , mStatTimer (new QTimer (this))
-{
-    /* Apply UI decorations */
-    Ui::VBoxVMInformationDlg::setupUi (this);
-
-#ifdef Q_WS_MAC
-    /* No icon for this window on the mac, cause this would act as proxy icon which isn't necessary here. */
-    setWindowIcon (QIcon());
-#else
-    /* Apply window icons */
-    setWindowIcon (vboxGlobal().iconSetFull (QSize (32, 32), QSize (16, 16),
-                                             ":/session_info_32px.png", ":/session_info_16px.png"));
-#endif
-
-    /* Enable size grip without using a status bar. */
-    setSizeGripEnabled (true);
-
-    /* Setup focus-proxy for pages */
-    mPage1->setFocusProxy (mDetailsText);
-    mPage2->setFocusProxy (mStatisticText);
-
-    /* Setup browsers */
-    mDetailsText->viewport()->setAutoFillBackground (false);
-    mStatisticText->viewport()->setAutoFillBackground (false);
-
-    /* Setup margins */
-    mDetailsText->setViewportMargins (5, 5, 5, 5);
-    mStatisticText->setViewportMargins (5, 5, 5, 5);
-
-    /* Setup handlers */
-    /* Setup handlers */
-    connect (mConsole, SIGNAL (mediaDriveChanged (VBoxDefs::MediumType)), this, SLOT (updateDetails()));
-    connect (mConsole, SIGNAL (sharedFoldersChanged()), this, SLOT (updateDetails()));
-    connect (mConsole, SIGNAL (resizeHintDone()), this, SLOT (processStatistics()));
     connect (mInfoStack, SIGNAL (currentChanged (int)), this, SLOT (onPageChanged (int)));
     connect (&vboxGlobal(), SIGNAL (mediumEnumFinished (const VBoxMediaList &)), this, SLOT (updateDetails()));
Index: /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.h	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMInformationDlg.h	(revision 29794)
@@ -25,5 +25,4 @@
 #include "QIWithRetranslateUI.h"
 
-class VBoxConsoleView;
 class UIMachineWindow;
 class QTimer;
@@ -40,15 +39,9 @@
     typedef QMap <QString, VBoxVMInformationDlg*> InfoDlgMap;
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
     static void createInformationDlg(UIMachineWindow *pMachineWindow);
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-    static void createInformationDlg (const CSession &aSession, VBoxConsoleView *aConsole);
 
 protected:
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
     VBoxVMInformationDlg (UIMachineWindow *pMachineWindow, Qt::WindowFlags aFlags);
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-    VBoxVMInformationDlg (VBoxConsoleView *aConsole, const CSession &aSession, Qt::WindowFlags aFlags);
    ~VBoxVMInformationDlg();
 
@@ -78,5 +71,4 @@
     static InfoDlgMap  mSelfArray;
 
-    VBoxConsoleView   *mConsole;
     CSession           mSession;
     bool               mIsPolished;
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/AbstractDockIconPreview.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/AbstractDockIconPreview.cpp	(revision 29793)
+++ 	(revision )
@@ -1,144 +1,0 @@
-/* $Id$ */
-/** @file
- * Qt GUI - Realtime Dock Icon Preview
- */
-
-/*
- * Copyright (C) 2009 Oracle Corporation
- *
- * 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.
- */
-
-/* VBox includes */
-#include "AbstractDockIconPreview.h"
-#include "VBoxConsoleWnd.h"
-#include "VBoxFrameBuffer.h"
-
-AbstractDockIconPreview::AbstractDockIconPreview (VBoxConsoleWnd * /* aMainWnd */, const QPixmap& /* aOverlayImage */)
-{
-}
-
-void AbstractDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
-{
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    Assert (cs);
-    /* Create the image copy of the framebuffer */
-    CGDataProviderRef dp = CGDataProviderCreateWithData (aFrameBuffer, aFrameBuffer->address(), aFrameBuffer->bitsPerPixel() / 8 * aFrameBuffer->width() * aFrameBuffer->height(), NULL);
-    Assert (dp);
-    CGImageRef ir = CGImageCreate (aFrameBuffer->width(), aFrameBuffer->height(), 8, 32, aFrameBuffer->bytesPerLine(), cs,
-                                   kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host, dp, 0, false,
-                                   kCGRenderingIntentDefault);
-    Assert (ir);
-
-    /* Update the dock preview icon */
-    updateDockPreview (ir);
-
-    /* Release the temp data and image */
-    CGImageRelease (ir);
-    CGDataProviderRelease (dp);
-    CGColorSpaceRelease (cs);
-}
-
-AbstractDockIconPreviewHelper::AbstractDockIconPreviewHelper (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-    :  mMainWnd (aMainWnd)
-     , mDockIconRect (CGRectMake (0, 0, 128, 128))
-     , mDockMonitor (NULL)
-     , mDockMonitorGlossy (NULL)
-     , mUpdateRect (CGRectMake (0, 0, 0, 0))
-     , mMonitorRect (CGRectMake (0, 0, 0, 0))
-{
-    mOverlayImage   = ::darwinToCGImageRef (&aOverlayImage);
-    Assert (mOverlayImage);
-
-    mStatePaused    = ::darwinToCGImageRef ("state_paused_16px.png");
-    Assert (mStatePaused);
-    mStateSaving    = ::darwinToCGImageRef ("state_saving_16px.png");
-    Assert (mStateSaving);
-    mStateRestoring = ::darwinToCGImageRef ("state_restoring_16px.png");
-    Assert (mStateRestoring);
-}
-
-AbstractDockIconPreviewHelper::~AbstractDockIconPreviewHelper()
-{
-    CGImageRelease (mOverlayImage);
-    if (mDockMonitor)
-        CGImageRelease (mDockMonitor);
-    if (mDockMonitorGlossy)
-        CGImageRelease (mDockMonitorGlossy);
-
-    CGImageRelease (mStatePaused);
-    CGImageRelease (mStateSaving);
-    CGImageRelease (mStateRestoring);
-}
-
-void AbstractDockIconPreviewHelper::initPreviewImages()
-{
-    if (!mDockMonitor)
-    {
-        mDockMonitor = ::darwinToCGImageRef ("monitor.png");
-        Assert (mDockMonitor);
-        /* Center it on the dock icon context */
-        mMonitorRect = centerRect (CGRectMake (0, 0,
-                                               CGImageGetWidth (mDockMonitor),
-                                               CGImageGetWidth (mDockMonitor)));
-    }
-
-    if (!mDockMonitorGlossy)
-    {
-        mDockMonitorGlossy = ::darwinToCGImageRef ("monitor_glossy.png");
-        Assert (mDockMonitorGlossy);
-        /* This depends on the content of monitor.png */
-        mUpdateRect = CGRectMake (mMonitorRect.origin.x + 7 + 1,
-                                  mMonitorRect.origin.y + 8 + 1,
-                                  118 - 7 - 2,
-                                  103 - 8 - 2);
-    }
-}
-
-CGImageRef AbstractDockIconPreviewHelper::stateImage() const
-{
-    CGImageRef img;
-    if (   mMainWnd->machineState() == KMachineState_Paused
-        || mMainWnd->machineState() == KMachineState_TeleportingPausedVM)
-        img = mStatePaused;
-    else if (   mMainWnd->machineState() == KMachineState_Restoring
-             || mMainWnd->machineState() == KMachineState_TeleportingIn)
-        img = mStateRestoring;
-    else if (   mMainWnd->machineState() == KMachineState_Saving
-             || mMainWnd->machineState() == KMachineState_LiveSnapshotting)
-        img = mStateSaving;
-    else
-        img = NULL;
-    return img;
-}
-
-void AbstractDockIconPreviewHelper::drawOverlayIcons (CGContextRef aContext)
-{
-    CGRect overlayRect = CGRectMake (0, 0, 0, 0);
-    /* The overlay image at bottom/right */
-    if (mOverlayImage)
-    {
-        overlayRect = CGRectMake (mDockIconRect.size.width - CGImageGetWidth (mOverlayImage),
-                                  mDockIconRect.size.height - CGImageGetHeight (mOverlayImage),
-                                  CGImageGetWidth (mOverlayImage),
-                                  CGImageGetHeight (mOverlayImage));
-        CGContextDrawImage (aContext, flipRect (overlayRect), mOverlayImage);
-    }
-    CGImageRef sImage = stateImage();
-    /* The state image at bottom/right */
-    if (sImage)
-    {
-        CGRect stateRect = CGRectMake (overlayRect.origin.x - CGImageGetWidth (sImage) / 2.0,
-                                       overlayRect.origin.y - CGImageGetHeight (sImage) / 2.0,
-                                       CGImageGetWidth (sImage),
-                                       CGImageGetHeight (sImage));
-        CGContextDrawImage (aContext, flipRect (stateRect), sImage);
-    }
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/AbstractDockIconPreview.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/AbstractDockIconPreview.h	(revision 29793)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * Abstract class for the dock icon preview
- */
-
-/*
- * Copyright (C) 2009 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef ___AbstractVBoxDockIconPreview_h___
-#define ___AbstractVBoxDockIconPreview_h___
-
-/* System includes */
-#include <ApplicationServices/ApplicationServices.h>
-
-/* VBox includes */
-#include "VBoxUtils-darwin.h"
-
-class VBoxConsoleWnd;
-class VBoxFrameBuffer;
-
-class QPixmap;
-
-class AbstractDockIconPreview
-{
-public:
-    AbstractDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
-    virtual ~AbstractDockIconPreview() {};
-
-    virtual void updateDockOverlay() = 0;
-    virtual void updateDockPreview (CGImageRef aVMImage) = 0;
-    virtual void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
-
-    virtual void setOriginalSize (int /* aWidth */, int /* aHeight */) {}
-};
-
-class AbstractDockIconPreviewHelper
-{
-public:
-    AbstractDockIconPreviewHelper (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
-    virtual ~AbstractDockIconPreviewHelper();
-    void initPreviewImages();
-    inline CGImageRef stateImage() const;
-    void drawOverlayIcons (CGContextRef aContext);
-
-    /* Flipping is necessary cause the drawing context in Carbon is flipped by 180 degree */
-    inline CGRect flipRect (CGRect aRect) const { return ::darwinFlipCGRect (aRect, mDockIconRect); }
-    inline CGRect centerRect (CGRect aRect) const { return ::darwinCenterRectTo (aRect, mDockIconRect); }
-    inline CGRect centerRectTo (CGRect aRect, const CGRect& aToRect) const { return ::darwinCenterRectTo (aRect, aToRect); }
-
-    /* Private member vars */
-    VBoxConsoleWnd *mMainWnd;
-    const CGRect mDockIconRect;
-
-    CGImageRef mOverlayImage;
-    CGImageRef mDockMonitor;
-    CGImageRef mDockMonitorGlossy;
-
-    CGImageRef mStatePaused;
-    CGImageRef mStateSaving;
-    CGImageRef mStateRestoring;
-
-    CGRect mUpdateRect;
-    CGRect mMonitorRect;
-};
-
-#endif /* ___AbstractVBoxDockIconPreview_h___ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/CarbonDockIconPreview.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/CarbonDockIconPreview.cpp	(revision 29793)
+++ 	(revision )
@@ -1,218 +1,0 @@
-/* $Id$ */
-/** @file
- * CarbonDockIconPreview class implementation
- */
-
-/*
- * Copyright (C) 2009 Oracle Corporation
- *
- * 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.
- */
-
-/* VBox includes */
-#include "CarbonDockIconPreview.h"
-#include "VBoxUtils-darwin.h"
-
-#include "iprt/assert.h"
-#include "iprt/mem.h"
-
-RT_C_DECLS_BEGIN
-void darwinCreateVBoxDockIconTileView (void);
-void darwinDestroyVBoxDockIconTileView (void);
-
-CGContextRef darwinBeginCGContextForApplicationDockTile (void);
-void darwinEndCGContextForApplicationDockTile (CGContextRef aContext);
-
-void darwinOverlayApplicationDockTileImage (CGImageRef pImage);
-void darwinRestoreApplicationDockTileImage (void);
-
-void darwinDrawMainWindow (NativeWindowRef pMainWin, CGContextRef aContext);
-RT_C_DECLS_END
-
-/* Import private function to capture the window content of any given window. */
-CG_EXTERN_C_BEGIN
-typedef int CGSWindowID;
-typedef void *CGSConnectionID;
-CG_EXTERN CGSWindowID GetNativeWindowFromWindowRef(WindowRef ref);
-CG_EXTERN CGSConnectionID CGSMainConnectionID(void);
-CG_EXTERN void CGContextCopyWindowCaptureContentsToRect(CGContextRef c, CGRect dstRect, CGSConnectionID connection, CGSWindowID window, int zero);
-CG_EXTERN_C_END
-
-CarbonDockIconPreview::CarbonDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-  : AbstractDockIconPreview (aMainWnd, aOverlayImage)
-  , AbstractDockIconPreviewHelper (aMainWnd, aOverlayImage)
-  , mBitmapData (NULL)
-{
-}
-
-CarbonDockIconPreview::~CarbonDockIconPreview()
-{
-    if (mBitmapData)
-        RTMemFree (mBitmapData);
-}
-
-void CarbonDockIconPreview::updateDockOverlay()
-{
-    /* Remove all previously set tile images */
-    ::RestoreApplicationDockTileImage();
-
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    Assert (cs);
-
-    /* Four bytes per color */
-    int bitmapBytesPerRow = mDockIconRect.size.width * 4;
-    int bitmapByteCount = bitmapBytesPerRow * mDockIconRect.size.height;
-
-    initOverlayData (bitmapByteCount);
-    Assert (mBitmapData);
-
-    CGContextRef context = CGBitmapContextCreate (mBitmapData,
-                                                  mDockIconRect.size.width,
-                                                  mDockIconRect.size.height,
-                                                  8,
-                                                  bitmapBytesPerRow,
-                                                  cs,
-                                                  kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
-    /* Clear the background to be transparent */
-    CGContextSetBlendMode (context, kCGBlendModeNormal);
-    CGContextClearRect (context, (mDockIconRect));
-
-    /* Draw the state image & the overlay image */
-    drawOverlayIcons (context);
-
-    /* Flush the content */
-    CGContextFlush (context);
-
-    /* Create a image out of the bitmap context */
-    CGImageRef overlayImage = CGBitmapContextCreateImage (context);
-    Assert (overlayImage);
-
-    /* Update the dock overlay icon */
-    ::OverlayApplicationDockTileImage (overlayImage);
-
-    /* Release the temp image */
-    CGImageRelease (overlayImage);
-    CGColorSpaceRelease (cs);
-}
-
-void CarbonDockIconPreview::updateDockPreview (CGImageRef aVMImage)
-{
-    Assert (aVMImage);
-
-    /* Create the context to draw on */
-    CGContextRef context = BeginCGContextForApplicationDockTile ();
-    updateDockPreviewImpl (context, aVMImage);
-    /* This flush updates the dock icon */
-    CGContextFlush (context);
-    EndCGContextForApplicationDockTile (context);
-}
-
-void CarbonDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
-{
-    AbstractDockIconPreview::updateDockPreview (aFrameBuffer);
-}
-
-void CarbonDockIconPreview::updateDockPreviewImpl (CGContextRef aContext, CGImageRef aVMImage)
-{
-    Assert (aContext);
-
-    /* Initialize all dependent images in the case it wasn't done already */
-    initPreviewImages();
-
-    CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
-    Assert (cs);
-
-    /* Clear the background to be transparent */
-    CGContextSetBlendMode (aContext, kCGBlendModeNormal);
-    CGContextClearRect (aContext, flipRect (mDockIconRect));
-
-    /* Draw the monitor as the background */
-    CGContextDrawImage (aContext, flipRect (mMonitorRect), mDockMonitor);
-
-    /* Calculate the size of the dock icon image and fit it into 128x128 */
-    int scaledWidth;
-    int scaledHeight;
-    float aspect = static_cast <float> (CGImageGetWidth (aVMImage)) / CGImageGetHeight (aVMImage);
-    if (aspect > 1.0)
-    {
-        scaledWidth = mUpdateRect.size.width;
-        scaledHeight = mUpdateRect.size.height / aspect;
-    }
-    else
-    {
-        scaledWidth = mUpdateRect.size.width * aspect;
-        scaledHeight = mUpdateRect.size.height;
-    }
-
-    CGRect iconRect = centerRectTo (CGRectMake (0, 0,
-                                                scaledWidth, scaledHeight),
-                                    mUpdateRect);
-    /* Draw the VM content */
-    CGContextDrawImage (aContext, flipRect (iconRect), aVMImage);
-
-//    darwinDrawMainWindow(darwinToNativeWindow (mMainWnd), aContext);
-#if 0 // ndef QT_MAC_USE_COCOA
-    /* Process the content of any external OpenGL window. */
-    WindowRef w = darwinToNativeWindow (mMainWnd);
-    WindowGroupRef g = GetWindowGroup (w);
-    WindowGroupContentOptions wgco = kWindowGroupContentsReturnWindows | kWindowGroupContentsRecurse | kWindowGroupContentsVisible;
-    ItemCount c = CountWindowGroupContents (g, wgco);
-    float a1 = iconRect.size.width / static_cast <float> (CGImageGetWidth (aVMImage));
-    float a2 = iconRect.size.height / static_cast <float> (CGImageGetHeight (aVMImage));
-    Rect tmpR;
-    GetWindowBounds (w, kWindowContentRgn, &tmpR);
-    HIRect mainRect = CGRectMake (tmpR.left, tmpR.top, tmpR.right-tmpR.left, tmpR.bottom-tmpR.top);
-    /* Iterate over every window in the returned window group. */
-    for (ItemCount i = 0; i <= c; ++i)
-    {
-        WindowRef wc;
-        OSStatus status = GetIndexedWindow (g, i, wgco, &wc);
-        /* Skip the main window */
-        if (status == noErr &&
-            wc != w)
-        {
-            WindowClass winClass;
-            status = GetWindowClass (wc, &winClass);
-            /* Check that the class is of type overlay window */
-            if (status == noErr &&
-                winClass == kOverlayWindowClass)
-            {
-                Rect tmpR1;
-                GetWindowBounds (wc, kWindowContentRgn, &tmpR1);
-                HIRect rect;
-                rect.size.width = (tmpR1.right-tmpR1.left) * a1;
-                rect.size.height = (tmpR1.bottom-tmpR1.top) * a2;
-                rect.origin.x = iconRect.origin.x + (tmpR1.left - mainRect.origin.x) * a1;
-                rect.origin.y = iconRect.origin.y + (tmpR1.top  - mainRect.origin.y) * a2;
-                /* This is a big, bad hack. The following functions aren't
-                 * documented nor official supported by apple. But its the only way
-                 * to capture the OpenGL content of a window without fiddling
-                 * around with gPixelRead or something like that. */
-                CGSWindowID wid = GetNativeWindowFromWindowRef (wc);
-                CGContextCopyWindowCaptureContentsToRect(aContext, flipRect (rect), CGSMainConnectionID(), wid, 0);
-            }
-        }
-    }
-#endif /* QT_MAC_USE_COCOA */
-
-    /* Draw the glossy overlay */
-    CGContextDrawImage (aContext, flipRect (mMonitorRect), mDockMonitorGlossy);
-
-    /* Draw the state image & the overlay image */
-    drawOverlayIcons (aContext);
-
-    CGColorSpaceRelease (cs);
-}
-
-void CarbonDockIconPreview::initOverlayData (int aBitmapByteCount)
-{
-    if (!mBitmapData)
-        mBitmapData = RTMemAlloc (aBitmapByteCount);
-}
-
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/CarbonDockIconPreview.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/CarbonDockIconPreview.h	(revision 29793)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * CarbonDockIconPreview class declaration
- */
-
-/*
- * Copyright (C) 2009 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef ___CarbonDockIconPreview_h___
-#define ___CarbonDockIconPreview_h___
-
-/* VBox includes */
-#include "AbstractDockIconPreview.h"
-
-class CarbonDockIconPreview: public AbstractDockIconPreview, protected AbstractDockIconPreviewHelper
-{
-public:
-    CarbonDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
-    ~CarbonDockIconPreview();
-
-    virtual void updateDockOverlay();
-    virtual void updateDockPreview (CGImageRef aVMImage);
-    virtual void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
-
-private:
-    inline void initOverlayData (int aBitmapByteCount);
-    void updateDockPreviewImpl (CGContextRef aContext, CGImageRef aVMImage);
-
-    void *mBitmapData;
-};
-
-#endif /* ___CarbonDockIconPreview_h___ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaDockIconPreview.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaDockIconPreview.h	(revision 29793)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * CocoaDockIconPreview class declaration
- */
-
-/*
- * Copyright (C) 2009 Oracle Corporation
- *
- * 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.
- */
-
-#ifndef ___CocoaDockIconPreview_h___
-#define ___CocoaDockIconPreview_h___
-
-/* Qt includes */
-#include "AbstractDockIconPreview.h"
-
-class CocoaDockIconPreviewPrivate;
-
-class CocoaDockIconPreview: public AbstractDockIconPreview
-{
-public:
-    CocoaDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage);
-    ~CocoaDockIconPreview();
-
-    virtual void updateDockOverlay();
-    virtual void updateDockPreview (CGImageRef aVMImage);
-    virtual void updateDockPreview (VBoxFrameBuffer *aFrameBuffer);
-
-    virtual void setOriginalSize (int aWidth, int aHeight);
-
-private:
-    CocoaDockIconPreviewPrivate *d;
-};
-
-#endif /* ___CocoaDockIconPreview_h___ */
-
Index: unk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaDockIconPreview.mm
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaDockIconPreview.mm	(revision 29793)
+++ 	(revision )
@@ -1,308 +1,0 @@
-/* $Id$ */
-/** @file
- *
- * VBox frontends: Qt GUI ("VirtualBox"):
- * Cocoa helper for the dock icon preview
- */
-
-/*
- * Copyright (C) 2009-2010 Oracle Corporation
- *
- * 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.
- */
-
-/* VBox includes */
-#include "CocoaDockIconPreview.h"
-#include "VBoxCocoaHelper.h"
-
-/* System includes */
-#import <Cocoa/Cocoa.h>
-
-@interface DockTileMonitor: NSView
-{
-    CocoaDockIconPreviewPrivate *p;
-
-    NSImageView *mScreenContent;
-    NSImageView *mMonitorGlossy;
-}
-- (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent;
-- (NSImageView*)screenContent;
-- (void)resize:(NSSize)size;
-@end
-
-@interface DockTileOverlay: NSView
-{
-    CocoaDockIconPreviewPrivate *p;
-}
-- (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent;
-@end
-
-@interface DockTile: NSView
-{
-    CocoaDockIconPreviewPrivate *p;
-
-    DockTileMonitor *mMonitor;
-    NSImageView     *mAppIcon;
-
-    DockTileOverlay *mOverlay;
-}
-- (id)initWithParent:(CocoaDockIconPreviewPrivate*)parent;
-- (NSView*)screenContent;
-- (void)cleanup;
-- (void)restoreAppIcon;
-- (void)updateAppIcon;
-- (void)restoreMonitor;
-- (void)updateMonitorWithImage:(CGImageRef)image;
-- (void)resizeMonitor:(NSSize)size;
-@end
-
-/*
- * Helper class which allow us to access all members/methods of AbstractDockIconPreviewHelper
- * from any Cocoa class.
- */
-class CocoaDockIconPreviewPrivate: public AbstractDockIconPreviewHelper
-{
-public:
-    inline CocoaDockIconPreviewPrivate (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-      :AbstractDockIconPreviewHelper (aMainWnd, aOverlayImage)
-    {
-        mDockTile = [[DockTile alloc] initWithParent:this];
-    }
-
-    inline ~CocoaDockIconPreviewPrivate()
-    {
-        [mDockTile release];
-    }
-
-    DockTile *mDockTile;
-};
-
-/*
- * Cocoa wrapper for the abstract dock icon preview class
- */
-CocoaDockIconPreview::CocoaDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-  : AbstractDockIconPreview (aMainWnd, aOverlayImage)
-{
-    CocoaAutoreleasePool pool;
-
-    d = new CocoaDockIconPreviewPrivate (aMainWnd, aOverlayImage);
-}
-
-CocoaDockIconPreview::~CocoaDockIconPreview()
-{
-    CocoaAutoreleasePool pool;
-
-    delete d;
-}
-
-void CocoaDockIconPreview::updateDockOverlay()
-{
-    CocoaAutoreleasePool pool;
-
-    [d->mDockTile updateAppIcon];
-}
-
-void CocoaDockIconPreview::updateDockPreview (CGImageRef aVMImage)
-{
-    CocoaAutoreleasePool pool;
-
-    [d->mDockTile updateMonitorWithImage:aVMImage];
-}
-
-void CocoaDockIconPreview::updateDockPreview (VBoxFrameBuffer *aFrameBuffer)
-{
-    CocoaAutoreleasePool pool;
-
-    AbstractDockIconPreview::updateDockPreview (aFrameBuffer);
-}
-
-
-void CocoaDockIconPreview::setOriginalSize (int aWidth, int aHeight)
-{
-    CocoaAutoreleasePool pool;
-
-    [d->mDockTile resizeMonitor:NSMakeSize (aWidth, aHeight)];
-}
-
-/*
- * Class for arranging/updating the layers for the glossy monitor preview.
- */
-@implementation DockTileMonitor;
-- (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent
-{
-    self = [super initWithFrame:frame];
-
-    if (self != nil)
-    {
-        p = parent;
-        /* The screen content view */
-        mScreenContent = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mUpdateRect))];
-//        [mScreenContent setImageAlignment: NSImageAlignCenter];
-        [mScreenContent setImageAlignment: NSImageAlignTop| NSImageAlignLeft];
-        [mScreenContent setImageScaling: NSScaleToFit];
-        [self addSubview: mScreenContent];
-        /* The state view */
-        mMonitorGlossy = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mMonitorRect))];
-        [mMonitorGlossy setImage: darwinCGImageToNSImage (p->mDockMonitorGlossy)];
-        [self addSubview: mMonitorGlossy];
-    }
-
-    return self;
-}
-
-- (void)drawRect:(NSRect)aRect;
-{
-    NSImage *dockMonitor = darwinCGImageToNSImage (p->mDockMonitor);
-    [dockMonitor drawInRect:NSRectFromCGRect (p->flipRect (p->mMonitorRect)) fromRect:aRect operation:NSCompositeSourceOver fraction:1.0];
-    [dockMonitor release];
-}
-
-- (NSImageView*)screenContent
-{
-    return mScreenContent;
-}
-
-- (void)resize:(NSSize)size;
-{
-    /* Calculate the new size based on the aspect ratio of the original screen
-       size */
-    float w, h;
-    if (size.width > size.height)
-    {
-        w = p->mUpdateRect.size.width;
-        h = ((float)size.height / size.width * p->mUpdateRect.size.height);
-    }
-    else
-    {
-        w = ((float)size.width / size.height * p->mUpdateRect.size.width);
-        h = p->mUpdateRect.size.height;
-    }
-    CGRect r = (p->flipRect (p->centerRectTo (CGRectMake (0, 0, (int)w, (int)h), p->mUpdateRect)));
-    r.origin.x = (int)r.origin.x;
-    r.origin.y = (int)r.origin.y;
-    r.size.width = (int)r.size.width;
-    r.size.height = (int)r.size.height;
-//    printf("gui %f %f %f %f\n", r.origin.x, r.origin.y, r.size.width, r.size.height);
-    /* Center within the update rect */
-    [mScreenContent setFrame:NSRectFromCGRect (r)];
-}
-@end
-
-/*
- * Simple implementation for the overlay of the OS & the state icon. Is used both
- * in the application icon & preview mode.
- */
-@implementation DockTileOverlay
-- (id)initWithFrame:(NSRect)frame parent:(CocoaDockIconPreviewPrivate*)parent
-{
-    self = [super initWithFrame:frame];
-
-    if (self != nil)
-        p = parent;
-
-    return self;
-}
-
-- (void)drawRect:(NSRect)aRect;
-{
-    NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
-    CGContextRef pCGContext = (CGContextRef)[nsContext graphicsPort];
-    p->drawOverlayIcons (pCGContext);
-}
-@end
-
-/*
- * VirtualBox Dock Tile implementation. Manage the switching between the icon
- * and preview mode & forwards all update request to the appropriate methods.
- */
-@implementation DockTile
-- (id)initWithParent:(CocoaDockIconPreviewPrivate*)parent
-{
-    self = [super init];
-
-    if (self != nil)
-    {
-        p = parent;
-        /* Add self as the content view of the dock tile */
-        NSDockTile *dock = [[NSApplication sharedApplication] dockTile];
-        [dock setContentView: self];
-        /* App icon is default */
-        [self restoreAppIcon];
-        /* The overlay */
-        mOverlay = [[DockTileOverlay alloc] initWithFrame:NSRectFromCGRect(p->flipRect (p->mDockIconRect)) parent:p];
-        [self addSubview: mOverlay];
-    }
-
-    return self;
-}
-
-- (NSView*)screenContent
-{
-    return [mMonitor screenContent];
-}
-
-- (void)cleanup
-{
-    if (mAppIcon != nil)
-    {
-        [mAppIcon removeFromSuperview];
-        [mAppIcon release];
-        mAppIcon = nil;
-    }
-    if (mMonitor != nil)
-    {
-        [mMonitor removeFromSuperview];
-        [mMonitor release];
-        mMonitor = nil;
-    }
-}
-
-- (void)restoreAppIcon
-{
-    if (mAppIcon == nil)
-    {
-        [self cleanup];
-        mAppIcon = [[NSImageView alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mDockIconRect))];
-        [mAppIcon setImage: [NSImage imageNamed:@"NSApplicationIcon"]];
-        [self addSubview: mAppIcon positioned:NSWindowBelow relativeTo:mOverlay];
-    }
-}
-
-- (void)updateAppIcon
-{
-    [self restoreAppIcon];
-    [[[NSApplication sharedApplication] dockTile] display];
-}
-
-- (void)restoreMonitor
-{
-    if (mMonitor == nil)
-    {
-        p->initPreviewImages();
-        [self cleanup];
-        mMonitor = [[DockTileMonitor alloc] initWithFrame:NSRectFromCGRect (p->flipRect (p->mDockIconRect)) parent:p];
-        [self addSubview: mMonitor positioned:NSWindowBelow relativeTo:mOverlay];
-    }
-}
-
-- (void)updateMonitorWithImage:(CGImageRef)image
-{
-    [self restoreMonitor];
-    NSImage *nsimage = darwinCGImageToNSImage (image);
-    [[mMonitor screenContent] setImage: nsimage];
-    [nsimage release];
-    [[[NSApplication sharedApplication] dockTile] display];
-}
-
-- (void)resizeMonitor:(NSSize)size;
-{
-    [mMonitor resize:size];
-}
-@end
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/DockIconPreview.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/DockIconPreview.h	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/DockIconPreview.h	(revision 29794)
@@ -23,12 +23,4 @@
 #ifdef QT_MAC_USE_COCOA
 
-#include "CocoaDockIconPreview.h"
-class VBoxDockIconPreview: public CocoaDockIconPreview
-{
-public:
-    VBoxDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-      : CocoaDockIconPreview (aMainWnd, aOverlayImage) {}
-};
-
 #include "UICocoaDockIconPreview.h"
 class UIDockIconPreview: public UICocoaDockIconPreview
@@ -39,14 +31,4 @@
 };
 
-#else /* QT_MAC_USE_COCOA */
-
-#include "CarbonDockIconPreview.h"
-class VBoxDockIconPreview: public CarbonDockIconPreview
-{
-public:
-    VBoxDockIconPreview (VBoxConsoleWnd *aMainWnd, const QPixmap& aOverlayImage)
-      : CarbonDockIconPreview (aMainWnd, aOverlayImage) {}
-};
-
 #endif /* QT_MAC_USE_COCOA */
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp	(revision 29794)
@@ -158,5 +158,4 @@
  *
  ********************************************************************************/
-#include "VBoxConsoleView.h"
 
 bool darwinIsMenuOpen (void)
@@ -265,105 +264,2 @@
 }
 
-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;
-            void *wp;
-            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
-                return noErr;
-            ShowWindow (w);
-            /* We have to make sure that newly created windows are on top of
-               all other windows. This fixes issues with compiz & additional
-               created OpenGL windows. */
-            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether);
-            BringToFront (w);
-            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether, 0);
-            PostUpdateContext(w, wp);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxHideWindow)
-        {
-            //printf ("HideWindow requested\n");
-            WindowPtr w;
-            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
-                return noErr;
-            HideWindow (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;
-            void *wp;
-            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
-                return noErr;
-            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
-            QPoint p1 = view->mapToGlobal (QPoint (p.x, p.y));
-            //printf ("Pos: %d %d\n", p1.x(), p1.y());
-            MoveWindow (w, p1.x(), p1.y(), true);
-            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
-            PostUpdateContext(w, wp);
-            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;
-            void *wp;
-            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
-                return noErr;
-            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
-            //printf ("Size: %f %f\n", s.width, s.height);
-            SizeWindow (w, s.width, s.height, true);
-            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
-            PostUpdateContext(w, wp);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxDisposeWindow)
-        {
-            //printf ("DisposeWindow requested\n");
-            WindowPtr w;
-            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
-                return noErr;
-            DisposeWindow (w);
-            return noErr;
-        }
-        if (eventKind == kEventVBoxUpdateDock)
-        {
-            //printf ("UpdateDock requested\n");
-            view->updateDockIcon();
-            return noErr;
-        }
-    }
-
-    return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
-}
-
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMessageBox.cpp	(revision 29794)
@@ -26,5 +26,4 @@
 #include "QIDialogButtonBox.h"
 #ifdef Q_WS_MAC
-# include "VBoxConsoleWnd.h"
 # include "VBoxSelectorWnd.h"
 #endif /* Q_WS_MAC */
@@ -39,8 +38,8 @@
 #include <QKeyEvent>
 
-#if defined(VBOX_WITH_NEW_RUNTIME_CORE) && defined(Q_WS_MAC)
+#ifdef Q_WS_MAC
 # include "UIMachineWindowFullscreen.h"
 # include "UIMachineWindowSeamless.h"
-#endif /* defined(VBOX_WITH_NEW_RUNTIME_CORE) && defined(Q_WS_MAC) */
+#endif /* Q_WS_MAC */
 
 /** @class QIMessageBox
@@ -64,19 +63,8 @@
 {
 #ifdef Q_WS_MAC
-    VBoxConsoleWnd *cwnd = qobject_cast<VBoxConsoleWnd*> (aParent);
-# ifdef VBOX_WITH_NEW_RUNTIME_CORE
     /* No sheets in another mode than normal for now. Firstly it looks ugly and
      * secondly in some cases it is broken. */
-    if (   !(   qobject_cast<UIMachineWindowFullscreen*>(aParent)
-             || qobject_cast<UIMachineWindowSeamless*>(aParent))
-        && !cwnd)
-        setWindowFlags (Qt::Sheet);
-    else
-# endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-    /* Sheets are broken if the window is in fullscreen mode. So make it a
-     * normal window in that case. */
-    if (cwnd == NULL ||
-        (!cwnd->isTrueFullscreen() &&
-         !cwnd->isTrueSeamless()))
+    if (!(   qobject_cast<UIMachineWindowFullscreen*>(aParent)
+          || qobject_cast<UIMachineWindowSeamless*>(aParent)))
         setWindowFlags (Qt::Sheet);
 #endif /* Q_WS_MAC */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 29794)
@@ -24,5 +24,4 @@
 #include "VBoxDefs.h"
 #include "VBoxSelectorWnd.h"
-#include "VBoxConsoleWnd.h"
 #include "VBoxProblemReporter.h"
 #include "QIHotKeyEdit.h"
@@ -30,16 +29,13 @@
 #include "QIDialogButtonBox.h"
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
-# include "UIMachine.h"
-# include "UISession.h"
-#endif
+#include "UIMachine.h"
+#include "UISession.h"
 #ifdef VBOX_WITH_REGISTRATION
 # include "UIRegistrationWzd.h"
 #endif
 #include "VBoxUpdateDlg.h"
-
 #ifdef VBOX_WITH_VIDEOHWACCEL
-#include "VBoxFrameBuffer.h"
-#endif
+# include "VBoxFBOverlay.h"
+#endif /* VBOX_WITH_VIDEOHWACCEL */
 
 /* Qt includes */
@@ -597,8 +593,6 @@
 VBoxGlobal::VBoxGlobal()
     : mValid (false)
-    , mSelectorWnd (NULL), mConsoleWnd (NULL)
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
+    , mSelectorWnd (NULL)
     , m_pVirtualMachine(0)
-#endif
     , mMainWindow (NULL)
 #ifdef VBOX_WITH_REGISTRATION
@@ -761,46 +755,10 @@
     if (isVMConsoleProcess())
     {
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
         if (m_pVirtualMachine)
             return m_pVirtualMachine->mainWindow();
-        else
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-            return &consoleWnd();
     }
     return NULL;
 }
 
-/**
- *  Returns a reference to the main VBox VM Console window.
- *  The reference is valid until application termination.
- *
- *  There is only one such a window per VirtualBox application.
- */
-VBoxConsoleWnd &VBoxGlobal::consoleWnd()
-{
-#if defined (VBOX_GUI_SEPARATE_VM_PROCESS)
-    AssertMsg (vboxGlobal().isVMConsoleProcess(),
-               ("Must be a VM console process"));
-#endif
-
-    Assert (mValid);
-
-    if (!mConsoleWnd)
-    {
-        /*
-         *  We pass the address of mConsoleWnd to the constructor to let it be
-         *  initialized right after the constructor is called. It is necessary
-         *  to avoid recursion, since this method may be (and will be) called
-         *  from the below constructor or from constructors/methods it calls.
-         */
-        VBoxConsoleWnd *w = new VBoxConsoleWnd (&mConsoleWnd, 0);
-        Assert (w == mConsoleWnd);
-        NOREF(w);
-    }
-
-    return *mConsoleWnd;
-}
-
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
 bool VBoxGlobal::createVirtualMachine(const CSession &session)
 {
@@ -819,5 +777,4 @@
     return m_pVirtualMachine;
 }
-#endif
 
 bool VBoxGlobal::brandingIsActive (bool aForce /* = false*/)
@@ -2596,14 +2553,5 @@
         return false;
 
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
-# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
-    if (session.GetMachine().GetMonitorCount() > 1)
-# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
-        return createVirtualMachine(session);
-# ifndef VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS
-    else
-# endif /* VBOX_FORCE_NEW_RUNTIME_CORE_ALWAYS */
-#endif /* VBOX_WITH_NEW_RUNTIME_CORE */
-        return consoleWnd().openView(session);
+    return createVirtualMachine(session);
 }
 
@@ -5420,12 +5368,8 @@
 #endif
 
-    if (mConsoleWnd)
-        delete mConsoleWnd;
     if (mSelectorWnd)
         delete mSelectorWnd;
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
     if (m_pVirtualMachine)
         delete m_pVirtualMachine;
-#endif
 
     /* ensure CGuestOSType objects are no longer used */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 29794)
@@ -41,7 +41,5 @@
 class QLabel;
 class QToolButton;
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
 class UIMachine;
-#endif
 
 // VirtualBox callback events
@@ -278,5 +276,4 @@
 
 class VBoxSelectorWnd;
-class VBoxConsoleWnd;
 class UIRegistrationWzd;
 class VBoxUpdateDlg;
@@ -311,9 +308,6 @@
     QWidget *vmWindow();
 
-    VBoxConsoleWnd &consoleWnd();
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
     bool createVirtualMachine(const CSession &session);
     UIMachine* virtualMachine();
-#endif
 
     /* main window handle storage */
@@ -913,8 +907,5 @@
 
     VBoxSelectorWnd *mSelectorWnd;
-    VBoxConsoleWnd *mConsoleWnd;
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
     UIMachine *m_pVirtualMachine;
-#endif
     QWidget* mMainWindow;
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp	(revision 29794)
@@ -22,10 +22,7 @@
 #include "VBoxGlobal.h"
 #include "VBoxSelectorWnd.h"
-#include "VBoxConsoleWnd.h"
 #include "VBoxProgressDialog.h"
 #include "UIDownloaderUserManual.h"
-#ifdef VBOX_WITH_NEW_RUNTIME_CORE
-# include "UIMachine.h"
-#endif
+#include "UIMachine.h"
 
 #include "VBoxAboutDlg.h"
@@ -2228,5 +2225,5 @@
 void VBoxProblemReporter::cannotImportAppliance (const CProgress &aProgress, CAppliance* aAppliance, QWidget *aParent /* = NULL */) const
 {
-    AssertWrapperOk (aProgress);
+//    AssertWrapperOk (aProgress);
 
     message (aParent ? aParent : mainWindowShown(),
Index: /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 29793)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 29794)
@@ -27,5 +27,4 @@
 #include "VBoxProblemReporter.h"
 #include "VBoxSelectorWnd.h"
-#include "VBoxConsoleWnd.h"
 #include "VBoxUtils.h"
 #ifdef QT_MAC_USE_COCOA
