UIMachineViewNormal.cpp revision 88b337f29f5e1a84251d66e3f0a40b9764a5f077
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMachineViewNormal class implementation
*/
/*
* 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.
*/
/* Global includes */
#include <QApplication>
#include <QDesktopWidget>
#include <QMainWindow>
#include <QMenuBar>
#include <QScrollBar>
#include <QTimer>
/* Local includes */
#include "VBoxGlobal.h"
#include "UISession.h"
#include "UIActionPoolRuntime.h"
#include "UIMachineLogic.h"
#include "UIMachineWindow.h"
#include "UIMachineViewNormal.h"
#include "UIFrameBuffer.h"
#ifdef VBOX_WITH_VIDEOHWACCEL
, bool bAccelerate2DVideo
#endif
)
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
)
, m_bIsGuestAutoresizeEnabled(gActionPool->action(UIActionIndexRuntime_Toggle_GuestAutoresize)->isChecked())
{
/* Initialization: */
}
{
/* Save machine view settings: */
/* Cleanup frame buffer: */
}
{
/* Check if we should restrict minimum size: */
/* Resend the last resize hint if there was a fullscreen or
* seamless transition previously. If we were not in graphical
* mode initially after the transition this happens when we
* switch. */
}
{
{
case ResizeEventType:
{
return guestResizeEvent(pEvent, false);
}
default:
break;
}
}
{
{
{
{
/* We call this on every resize as:
* * Window frame geometry can change on resize.
* * On X11 we set information here which becomes available
* asynchronously at an unknown time after window
* creation. As long as the information is not available
* we make a best guess.
*/
break;
}
default:
break;
}
}
#ifdef Q_WS_WIN
{
/* Due to windows host uses separate 'focus set' to let menubar to
* operate while popped up (see UIMachineViewNormal::event() for details),
* it also requires backward processing: */
{
/* If menubar gets the focus while not popped up => give it back: */
{
if (!QApplication::activePopupWidget())
setFocus();
}
default:
break;
}
}
#endif /* Q_WS_WIN */
}
void UIMachineViewNormal::prepareCommon()
{
/* Base class common settings: */
/* Setup size-policy: */
/* Maximum size to sizehint: */
}
void UIMachineViewNormal::prepareFilters()
{
/* Base class filters: */
#ifdef Q_WS_WIN
/* Install menu-bar event-filter: */
#endif /* Q_WS_WIN */
}
{
/* Base class connections: */
/* Guest additions state-change updater: */
}
{
{
/* Get the current machine: */
/* We send a guest size hint if needed to reverse a transition
* to fullscreen or seamless. */
if (!strHintSent.isEmpty())
{
/* Temporarily restrict the size to prevent a brief resize to the
* framebuffer dimensions (see @a UIMachineView::sizeHint()) before
* the following resize() is acted upon. */
}
}
}
{
/* Store guest size in case we are switching to fullscreen: */
}
{
if (m_bIsGuestAutoresizeEnabled != fEnabled)
{
}
}
{
#ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
/* Calculate client window offsets: */
/* Get the best size w/o scroll bars: */
/* Resize the frame to fit the contents: */
s -= pTopLevelWidget->size();
if (bAdjustPosition)
{
if (dwt->isVirtualDesktop())
/* Compose complex available region */
for (int i = 0; i < dwt->numScreens(); ++ i)
else
/* Get just a simple available rectangle */
frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */);
}
#if 0
/* Center the frame on the desktop: */
#endif
/* Finally, set the frame geometry */
pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);
#else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
}
{
}
{
/* The area taken up by the machine window on the desktop, including window
* frame, title, menu bar and status bar. */
/* The window shouldn't be allowed to expand beyond the working area
* unless it already does. In that case the guest shouldn't expand it
* any further though. */
/* The current size of the machine display. */
/* To work out how big the guest display can get without the window going
* over the maximum size we calculated above, we work out how much space
* the other parts of the window (frame, menu bar, status bar and so on)
* take up and subtract that space from the maximum window size. The
* central widget shouldn't be bigger than the window, but we bound it for
* sanity (or insanity) reasons. */
}
{
/* 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. */
{
else
setMinimumSize(0, 0);
}
}