UIMachineView.h revision af62929dce3cc5e14c75438cd2b893f82ae6dbc8
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMachineView class declaration
*/
/*
* Copyright (C) 2010 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___UIMachineView_h___
#define ___UIMachineView_h___
/* Global includes */
#include <QAbstractScrollArea>
#include <QEventLoop>
/* Local includes */
#include "COMDefs.h"
#include "UIMachineDefs.h"
#ifdef Q_WS_MAC
# include <CoreFoundation/CFBase.h>
#endif /* Q_WS_MAC */
/* Local forwards */
{
/* Desktop geometry types: */
/* Factory function to create required view sub-child: */
#ifdef VBOX_WITH_VIDEOHWACCEL
, bool bAccelerate2DVideo
#endif
/* Public getters: */
int keyboardState() const;
int mouseState() const;
/* Public setters: */
/* Public members: */
void keyboardStateChanged(int iState);
void mouseStateChanged(int iState);
/* Utility signals: */
void resizeHintDone();
/* Machine view constructor/destructor: */
#ifdef VBOX_WITH_VIDEOHWACCEL
, bool bAccelerate2DVideo
#endif
virtual ~UIMachineView();
/* Protected getters: */
int contentsX() const;
int contentsY() const;
int contentsWidth() const;
int contentsHeight() const;
int visibleWidth() const;
int visibleHeight() const;
UIMachineLogic* machineLogic() const;
bool isHostKeyPressed() const { return m_bIsHostkeyPressed; }
bool isMachineWindowResizeIgnored() const { return m_bIsMachineWindowResizeIgnored; }
QSize desktopGeometry() const;
/* Protected setters: */
void setMachineWindowResizeIgnored(bool fIgnore = true) { m_bIsMachineWindowResizeIgnored = fIgnore; }
/* Protected helpers: */
void updateMouseCursorShape();
#ifdef Q_WS_WIN32
void updateMouseCursorClipping();
#endif
virtual void calculateDesktopGeometry() = 0;
virtual void maybeRestrictMinimumSize() = 0;
virtual void updateSliders();
#ifdef Q_WS_MAC
void updateDockIcon();
void setMouseCoalescingEnabled(bool fOn);
#endif /* Q_WS_MAC */
/* Prepare routines: */
virtual void prepareFrameBuffer();
virtual void prepareCommon();
virtual void prepareFilters();
virtual void prepareConsoleConnections();
virtual void loadMachineViewSettings();
/* Cleanup routines: */
//virtual void saveMachineViewSettings() {}
//virtual void cleanupConsoleConnections() {}
//virtual void cleanupFilters() {}
virtual void cleanupCommon();
virtual void cleanupFrameBuffer();
/* Cross-platforms event processors: */
/* Protected variables: */
/* Console callback handlers: */
virtual void sltMachineStateChanged();
virtual void sltMousePointerShapeChanged();
virtual void sltMouseCapabilityChanged();
/* Session callback handlers: */
virtual void sltMouseCapturedStatusChanged();
/* Cross-platforms event processors: */
/* Platform specific event processors: */
#if defined(Q_WS_WIN32)
void darwinGrabKeyboardEvents(bool fGrab);
# 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
/* Private helpers: */
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
void emitKeyboardStateChanged();
void emitMouseStateChanged();
void saveKeyStates();
void releaseAllPressedKeys(bool aReleaseHostKey = true);
void sendChangedKeyStates();
/* Private members: */
const VBoxGlobalSettings &m_globalSettings;
bool m_bIsAutoCaptureDisabled : 1;
bool m_bIsKeyboardCaptured : 1;
bool m_bIsHostkeyPressed : 1;
bool m_bIsHostkeyAlone : 1;
bool m_bIsHostkeyInCapture : 1;
bool m_bIsMachineWindowResizeIgnored : 1;
bool m_fPassCAD;
#ifdef VBOX_WITH_VIDEOHWACCEL
bool m_fAccelerate2DVideo;
#endif
#ifdef Q_WS_MAC
/** The current modifier key mask. Used to figure out which modifier
* key was pressed when we get a kEventRawKeyModifiersChanged event. */
bool m_fKeyboardGrabbed;
#endif /* Q_WS_MAC */
/* Friend classes: */
};
/* This maintenance class is a part of future roll-back mechanism.
* It allows to block main GUI thread until specific event received.
* Later it will become more abstract but now its just used to help
* fullscreen & seamless modes to restore normal guest size hint. */
{
: QEventLoop(0)
, m_iTimerId(0)
{
/* Install object event watcher: */
/* Also start timer to unlock pool in case of
* required condition doesn't happens by some reason: */
}
{
/* Kill the timer: */
}
{
{
case VBoxDefs::ResizeEventType:
{
/* Its a specific part related to fullscreen/seamless modes.
* Here we are waiting for guest resize event to be sure what
* non-normal modes successfully restored previous guest size hint.
* And we just unlocking the 'this' blocker afterwards: */
exit();
return false;
}
default:
break;
}
}
{
/* If that timer event occurs => it seems
* guest resize event doesn't comes in time,
* shame on it, but we just unlocking 'this': */
exit();
}
int m_iTimerId;
};
#endif // !___UIMachineView_h___