UIMachineView.h revision 4429cc47d1e3ca88d6237e5ee7a876dc409cdc24
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMachineView class declaration
*/
/*
* Copyright (C) 2010-2012 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 ___UIMachineView_h___
#define ___UIMachineView_h___
/* Qt includes: */
#include <QAbstractScrollArea>
#include <QEventLoop>
/* GUI includes: */
#include "UIMachineDefs.h"
#include "UIExtraDataDefs.h"
#ifdef Q_WS_MAC
# include <CoreFoundation/CFBase.h>
#endif /* Q_WS_MAC */
/* COM includes: */
#include "COMEnums.h"
/* Forward declarations: */
#ifdef VBOX_WITH_DRAG_AND_DROP
#endif
{
/** Notifies about frame-buffer resize. */
void sigFrameBufferResize();
/** Policy for determining which guest resolutions we wish to
* handle. We also accept anything smaller than the current
* resolution. */
enum MaxGuestSizePolicy
{
/** Policy not set correctly. */
/** Anything up to a fixed size. */
/** Anything up to available space on the host desktop. */
/** We accept anything. */
};
/* Factory function to create machine-view: */
#ifdef VBOX_WITH_VIDEOHWACCEL
, bool bAccelerate2DVideo
#endif /* VBOX_WITH_VIDEOHWACCEL */
);
/* Factory function to destroy required machine-view: */
/* Public setters: */
/** Adjusts guest screen size to correspond current machine-window size.
* @note Reimplemented in sub-classes. Base implementation does nothing. */
virtual void maybeAdjustGuestScreenSize() {}
/* Framebuffer aspect ratio: */
double aspectRatio() const;
/* Slot to perform guest resize: */
/* Handler: Frame-buffer NotifyChange stuff: */
/* Handler: Frame-buffer NotifyUpdate stuff: */
/* Handler: Frame-buffer SetVisibleRegion stuff: */
/* Handler: Frame-buffer 3D overlay visibility stuff: */
/* Watch dog for desktop resizes: */
void sltDesktopResized();
/* Console callback handlers: */
virtual void sltMachineStateChanged();
/* Machine-view constructor: */
#ifdef VBOX_WITH_VIDEOHWACCEL
, bool bAccelerate2DVideo
#endif /* VBOX_WITH_VIDEOHWACCEL */
);
/* Machine-view destructor: */
virtual ~UIMachineView();
/* Prepare routines: */
void prepareViewport();
void prepareFrameBuffer();
virtual void prepareCommon();
virtual void prepareFilters();
virtual void prepareConnections();
virtual void prepareConsoleConnections();
void loadMachineViewSettings();
/* Cleanup routines: */
//virtual void saveMachineViewSettings() {}
//virtual void cleanupConsoleConnections() {}
//virtual void cleanupFilters() {}
//virtual void cleanupCommon() {}
virtual void cleanupFrameBuffer();
//virtual void cleanupViewport();
/* Protected getters: */
UIActionPool* actionPool() const;
UIMachineLogic* machineLogic() const;
int contentsX() const;
int contentsY() const;
int contentsWidth() const;
int contentsHeight() const;
int visibleWidth() const;
int visibleHeight() const;
/** Atomically store the maximum guest resolution which we currently wish
* to handle for @a maxGuestSize() to read. Should be called if anything
* happens (e.g. a screen hotplug) which might cause the value to change.
* @sa m_u64MaxGuestSize. */
/** Atomically read the maximum guest resolution which we currently wish to
* handle. This may safely be called from another thread (called by
* UIFramebuffer on EMT).
* @sa m_u64MaxGuestSize. */
/** Retrieve the last non-fullscreen guest size hint (from extra data).
*/
/* Protected setters: */
/** Store a guest size hint value to extra data, called on switching to
* fullscreen. */
/* Protected helpers: */
virtual void takePauseShotLive();
virtual void takePauseShotSnapshot();
/** The available area on the current screen for application windows. */
/** Calculate how big the guest desktop can be while still fitting on one
* host screen. */
virtual void updateSliders();
#ifdef Q_WS_MAC
void updateDockIcon();
#endif /* Q_WS_MAC */
/** What view mode (normal, fullscreen etc.) are we in? */
UIVisualStateType visualStateType() const;
/** Is this a fullscreen-type view? */
bool isFullscreenOrSeamless() const;
/* Cross-platforms event processors: */
#ifdef VBOX_WITH_DRAG_AND_DROP
void dragIsPending(void);
#endif /* VBOX_WITH_DRAG_AND_DROP */
/* Platform specific event processors: */
#if defined(Q_WS_WIN)
#endif
/* Protected members: */
/** HACK: when switching out of fullscreen or seamless we wish to override
* the default size hint to avoid short resizes back to fullscreen size.
* Not explicitly initialised (i.e. invalid by default). */
/** The policy for calculating the maximum guest resolution which we wish
* to handle. */
/** The maximum guest size for fixed size policy. */
/** Maximum guest resolution which we wish to handle. Must be accessed
* atomically.
* @note The background for this variable is that we need this value to be
* available to the EMT thread, but it can only be calculated by the
* GUI, and GUI code can only safely be called on the GUI thread due to
* (at least) X11 threading issues. So we calculate the value in advance,
* monitor things in case it changes and update it atomically when it does.
*/
/** @todo This should be private. */
volatile uint64_t m_u64MaxGuestSize;
#ifdef VBOX_WITH_VIDEOHWACCEL
bool m_fAccelerate2DVideo : 1;
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* 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. */
/** @todo This class is now unused - can it be removed altogether? */
{
: QEventLoop(0)
, m_iTimerId(0)
{
/* Also start timer to unlock pool in case of
* required condition doesn't happens by some reason: */
}
{
/* Kill the timer: */
}
{
/* 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___