UISession.h revision d6f3afd6937d062c3b083fff408999023527809c
/** @file
* VBox Qt GUI - UISession class declaration.
*/
/*
* Copyright (C) 2010-2013 Oracle Corporation
*
* 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.
*/
#ifndef ___UISession_h___
#define ___UISession_h___
/* Qt includes: */
#include <QObject>
#include <QCursor>
#include <QEvent>
#include <QMap>
/* GUI includes: */
#include "UIExtraDataDefs.h"
/* COM includes: */
#include "COMEnums.h"
/* Forward declarations: */
#ifndef Q_WS_MAC
#endif /* !Q_WS_MAC */
/* CConsole callback event types: */
enum UIConsoleEventType
{
/* Not used: UIConsoleEventType_SerialPortChange, */
/* Not used: UIConsoleEventType_ParallelPortChange, */
/* Not used: UIConsoleEventType_StorageControllerChange, */
/* Not used: UIConsoleEventType_CPUChange, */
};
{
/* Machine uisession constructor/destructor: */
/* API: Runtime UI stuff: */
void powerUp();
bool saveState();
bool shutdown();
void closeRuntimeUI();
/* Common getters: */
UIMachineLogic* machineLogic() const;
QWidget* mainMachineWindow() const;
#ifndef Q_WS_MAC
/** @name Branding stuff.
** @{ */
/** Returns redefined machine-window icon. */
/** Returns redefined machine-window name postfix. */
/** @} */
#endif /* !Q_WS_MAC */
/** @name Runtime workflow stuff.
** @{ */
/** Returns Guru Meditation handler type. */
/** Returns HiDPI optimization type. */
/** @} */
/** @name Extension Pack stuff.
** @{ */
/** Determines whether extension pack installed and usable. */
bool isExtensionPackUsable() const { return m_fIsExtensionPackUsable; }
/** @} */
/** @name Runtime menus configuration stuff.
** @{ */
#ifdef Q_WS_MAC
/** Determines Application menu allowed actions. */
RuntimeMenuApplicationActionType allowedActionsMenuApplication() const { return m_allowedActionsMenuApplication; }
#endif /* Q_WS_MAC */
/** Determines Machine menu allowed actions. */
RuntimeMenuMachineActionType allowedActionsMenuMachine() const { return m_allowedActionsMenuMachine; }
/** Determines View menu allowed actions. */
/** Determines Devices menu allowed actions. */
RuntimeMenuDevicesActionType allowedActionsMenuDevices() const { return m_allowedActionsMenuDevices; }
#ifdef VBOX_WITH_DEBUGGER_GUI
/** Determines Debugger menu allowed actions. */
RuntimeMenuDebuggerActionType allowedActionsMenuDebugger() const { return m_allowedActionsMenuDebugger; }
#endif /* VBOX_WITH_DEBUGGER_GUI */
/** Determines Help menu allowed actions. */
/** @} */
/** @name Application Close configuration stuff.
* @{ */
/** Returns default close action. */
/** Returns merged restricted close actions. */
/** Returns whether all the close actions are restricted. */
bool isAllCloseActionsRestricted() const { return m_fAllCloseActionsRestricted; }
/** @} */
/** @name Snapshot Operations configuration stuff.
* @{ */
/** Returns whether we should allow snapshot operations. */
bool isSnapshotOperationsAllowed() const { return m_fSnapshotOperationsAllowed; }
/** @} */
/** Returns whether visual @a state is allowed. */
/** Requests visual-state change. */
/** Requests visual-state to be entered when possible. */
void setRequestedVisualState(UIVisualStateType visualStateType) { m_requestedVisualStateType = visualStateType; }
/** Returns requested visual-state to be entered when possible. */
machineState() == KMachineState_Saved ||
machineState() == KMachineState_Teleported ||
machineState() == KMachineState_Aborted; }
bool isStarted() const { return m_fIsStarted; }
bool isFirstTimeStarted() const { return m_fIsFirstTimeStarted; }
bool isGuestResizeIgnored() const { return m_fIsGuestResizeIgnored; }
bool isAutoCaptureDisabled() const { return m_fIsAutoCaptureDisabled; }
/* Guest additions state getters: */
bool isGuestAdditionsActive() const { return (m_ulGuestAdditionsRunLevel > AdditionsRunLevelType_None); }
bool isGuestSupportsGraphics() const { return isGuestAdditionsActive() && m_fIsGuestSupportsGraphics; }
bool isGuestSupportsSeamless() const { return isGuestSupportsGraphics() && m_fIsGuestSupportsSeamless; }
/* Keyboard getters: */
/** Returns keyboard-state. */
int keyboardState() const { return m_iKeyboardState; }
bool isNumLock() const { return m_fNumLock; }
bool isCapsLock() const { return m_fCapsLock; }
bool isScrollLock() const { return m_fScrollLock; }
/* Mouse getters: */
/** Returns mouse-state. */
int mouseState() const { return m_iMouseState; }
bool isMouseSupportsAbsolute() const { return m_fIsMouseSupportsAbsolute; }
bool isMouseSupportsRelative() const { return m_fIsMouseSupportsRelative; }
bool isMouseSupportsMultiTouch() const { return m_fIsMouseSupportsMultiTouch; }
bool isMouseHostCursorNeeded() const { return m_fIsMouseHostCursorNeeded; }
bool isMouseCaptured() const { return m_fIsMouseCaptured; }
bool isMouseIntegrated() const { return m_fIsMouseIntegrated; }
bool isValidPointerShapePresent() const { return m_fIsValidPointerShapePresent; }
bool isHidingHostPointer() const { return m_fIsHidingHostPointer; }
/* Common setters: */
void setGuestResizeIgnored(bool fIsGuestResizeIgnored) { m_fIsGuestResizeIgnored = fIsGuestResizeIgnored; }
void setAutoCaptureDisabled(bool fIsAutoCaptureDisabled) { m_fIsAutoCaptureDisabled = fIsAutoCaptureDisabled; }
/* Keyboard setters: */
void setNumLockAdaptionCnt(uint uNumLockAdaptionCnt) { m_uNumLockAdaptionCnt = uNumLockAdaptionCnt; }
void setCapsLockAdaptionCnt(uint uCapsLockAdaptionCnt) { m_uCapsLockAdaptionCnt = uCapsLockAdaptionCnt; }
/* Mouse setters: */
/* Screen visibility status: */
/* Returns existing framebuffer for the given screen-number;
* Returns 0 (asserts) if screen-number attribute is out of bounds: */
/* Sets framebuffer for the given screen-number;
* Ignores (asserts) if screen-number attribute is out of bounds: */
/* Temporary API: */
void updateStatusVRDE() { sltVRDEChange(); }
void updateStatusVideoCapture() { sltVideoCaptureChange(); }
/* Notifier: Close Runtime UI stuff: */
void sigCloseRuntimeUI();
/* Console callback signals: */
/** Notifies listeners about keyboard state-change. */
void sigKeyboardStateChange(int iState);
/** Notifies listeners about mouse state-change. */
void sigMouseStateChange(int iState);
void sigMousePointerShapeChange();
void sigMouseCapabilityChange();
void sigKeyboardLedsChange();
void sigMachineStateChange();
void sigAdditionsStateChange();
void sigVRDEChange();
void sigVideoCaptureChange();
void sigUSBControllerChange();
void sigUSBDeviceStateChange(const CUSBDevice &device, bool bIsAttached, const CVirtualBoxErrorInfo &error);
void sigSharedFolderChange();
#ifdef RT_OS_DARWIN
void sigShowWindows();
#endif /* RT_OS_DARWIN */
void sigCPUExecutionCapChange();
void sigGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
/* Notifiers: Qt callback stuff: */
void sigHostScreenCountChanged();
void sigHostScreenGeometryChanged();
/* Session signals: */
void sigStarted();
/** Defines @a iKeyboardState. */
void setKeyboardState(int iKeyboardState) { m_iKeyboardState = iKeyboardState; emit sigKeyboardStateChange(m_iKeyboardState); }
/** Defines @a iMouseState. */
void setMouseState(int iMouseState) { m_iMouseState = iMouseState; emit sigMouseStateChange(m_iMouseState); }
/** Marks machine started. */
void sltMarkStarted() { m_fIsStarted = true; }
/* Handler: Close Runtime UI stuff: */
void sltCloseRuntimeUI();
/* Console events slots */
void sltMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape);
void sltMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor);
void sltAdditionsChange();
void sltVRDEChange();
void sltVideoCaptureChange();
void sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo);
/* Handlers: Display reconfiguration stuff: */
#ifdef RT_OS_DARWIN
void sltCheckIfHostDisplayChanged();
#endif /* RT_OS_DARWIN */
void sltHandleHostScreenCountChange();
/* Private getters: */
/* Prepare helpers: */
void prepareConnections();
void prepareConsoleEventHandlers();
void prepareScreens();
void prepareFramebuffers();
void prepareMenuPool();
void loadSessionSettings();
/* Cleanup helpers: */
void saveSessionSettings();
void cleanupMenuPool();
void cleanupFramebuffers();
//void cleanupScreens() {}
void cleanupConsoleEventHandlers();
void cleanupConnections();
/* Update helpers: */
void updateSessionSettings();
/* Common helpers: */
void setPointerShape(const uchar *pShapeData, bool fHasAlpha, uint uXHot, uint uYHot, uint uWidth, uint uHeight);
void reinitMenuPool();
bool preparePowerUp();
int countOfVisibleWindows();
#ifdef Q_WS_MAC
/* Helper: Display reconfiguration stuff: */
void recacheDisplayData();
#endif /* Q_WS_MAC */
/* Private variables: */
/* Screen visibility vector: */
/* Frame-buffers vector: */
/* Common variables: */
#ifndef Q_WS_MAC
/** @name Branding variables.
** @{ */
/** Holds redefined machine-window icon. */
/** Holds redefined machine-window name postfix. */
/** @} */
#endif /* !Q_WS_MAC */
/** @name Runtime workflow variables.
** @{ */
/** Holds Guru Meditation handler type. */
/** Holds HiDPI optimization type. */
/** @} */
/** @name Extension Pack variables.
** @{ */
/** Determines whether extension pack installed and usable. */
bool m_fIsExtensionPackUsable;
/** @} */
/** @name Runtime menus configuration variables.
** @{ */
#ifdef Q_WS_MAC
/** Determines Application menu allowed actions. */
#endif /* Q_WS_MAC */
/** Determines Machine menu allowed actions. */
/** Determines View menu allowed actions. */
/** Determines Devices menu allowed actions. */
#ifdef VBOX_WITH_DEBUGGER_GUI
/** Determines Debugger menu allowed actions. */
#endif /* VBOX_WITH_DEBUGGER_GUI */
/** Determines Help menu allowed actions. */
/** @} */
/** @name Visual-state configuration variables.
** @{ */
/** Determines which visual-state should be entered when possible. */
/** @} */
#if defined(Q_WS_WIN)
#endif
#ifdef Q_WS_MAC
/** @name MacOS X: Display reconfiguration variables.
* @{ */
/** MacOS X: Watchdog timer looking for display reconfiguration. */
/** MacOS X: A list of display geometries we currently have. */
/** @} */
#endif /* Q_WS_MAC */
/** @name Application Close configuration variables.
* @{ */
/** Default close action. */
/** Merged restricted close actions. */
/** Determines whether all the close actions are restricted. */
/** @} */
/** @name Snapshot Operations configuration variables.
* @{ */
/** Determines whether we should allow snapshot operations. */
/** @} */
/* Common flags: */
bool m_fIsStarted : 1;
bool m_fIsFirstTimeStarted : 1;
bool m_fIsGuestResizeIgnored : 1;
bool m_fIsAutoCaptureDisabled : 1;
bool m_fReconfigurable : 1;
/* Guest additions flags: */
bool m_fIsGuestSupportsGraphics : 1;
bool m_fIsGuestSupportsSeamless : 1;
/* Keyboard flags: */
/** Holds the keyboard-state. */
int m_iKeyboardState;
bool m_fNumLock : 1;
bool m_fCapsLock : 1;
bool m_fScrollLock : 1;
/* Mouse flags: */
/** Holds the mouse-state. */
int m_iMouseState;
bool m_fIsMouseSupportsAbsolute : 1;
bool m_fIsMouseSupportsRelative : 1;
bool m_fIsMouseSupportsMultiTouch: 1;
bool m_fIsMouseHostCursorNeeded : 1;
bool m_fIsMouseCaptured : 1;
bool m_fIsMouseIntegrated : 1;
bool m_fIsValidPointerShapePresent : 1;
bool m_fIsHidingHostPointer : 1;
/* Friend classes: */
};
#endif /* !___UISession_h___ */