UIMultiScreenLayout.cpp revision 9f72be0517ae135bdd3e6ee140d3321b40aeb6e7
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMultiScreenLayout class implementation
*/
/*
* Copyright (C) 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;
* 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.
*/
/* Qt includes: */
#include <QApplication>
#include <QDesktopWidget>
#include <QMap>
#include <QMenu>
/* GUI includes: */
#include "UIDefs.h"
#include "UIMultiScreenLayout.h"
#include "UIActionPoolRuntime.h"
#include "UIMachineLogic.h"
#include "UISession.h"
#include "UIMessageCenter.h"
/* COM includes: */
#include "COMEnums.h"
#include "CSession.h"
#include "CConsole.h"
#include "CMachine.h"
#include "CDisplay.h"
, m_pScreenMap(new QMap<int, int>())
{
#if (QT_VERSION >= 0x040600)
#else /* (QT_VERSION >= 0x040600) */
#endif /* !(QT_VERSION >= 0x040600) */
}
{
delete m_pScreenMap;
while (!m_screenMenuList.isEmpty())
{
delete m_screenMenuList.first();
}
}
{
if (m_cHostScreens > 1)
{
pMenu->addSeparator();
for (int i = 0; i < m_cGuestScreens; ++i)
{
pScreenGroup->setExclusive(true);
for (int a = 0; a < m_cHostScreens; ++a)
{
pAction->setCheckable(true);
}
}
}
}
void UIMultiScreenLayout::update()
{
/* Make a pool of available host screens. */
for (int i = 0; i < m_cHostScreens; ++i)
availableScreens << i;
/* Load all combinations stored in the settings file. We have to make sure
* they are valid, which means there have to be unique combinations and all
* guests screens need there own host screen. */
for (int i = 0; i < m_cGuestScreens; ++i)
{
/* If the user ever selected a combination in the view menu, we have the following entry: */
bool fOk;
/* Check if valid: */
if (!( fOk /* Valid data */
{
/* If not, check the position of the guest window in normal mode.
* This makes sure that on first use the window opens on the same
* screen as the normal window was before. This even works with
* multi-screen. The user just have to move all the normal windows
* to the target screens and they will magically open there in
* seamless/fullscreen also. */
QString strTest1 = machine.GetExtraData(GUI_LastNormalWindowPosition + (i > 0 ? QString::number(i): ""));
{
/* If parsing was successfully, convert it to a position. */
/* Check to which screen the position belongs. */
if (!( fOk1 /* Valid data */
&& fOk2 /* Valid data */
/* If not, simply pick the next one of the still available
* host screens. */
}
else
/* If not, simply pick the next one of the still available host
* screens. */
}
/* Remove the just selected screen from the list of available screens. */
}
/* Get the list of all view-menu actions: */
QList<QAction*> viewMenuActions = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu()->actions();
/* Get the list of all view related actions: */
for (int i = 0; i < viewMenuActions.size(); ++i)
{
viewActions << viewMenuActions[i];
}
/* Mark currently chosen action: */
for (int i = 0; i < viewActions.size(); ++i)
{
for (int w = 0; w < screenActions.size(); ++w)
{
pTmpAction->blockSignals(true);
pTmpAction->blockSignals(false);
}
}
}
int UIMultiScreenLayout::hostScreenCount() const
{
return m_cHostScreens;
}
int UIMultiScreenLayout::guestScreenCount() const
{
return m_cGuestScreens;
}
{
}
{
return memoryRequirements(m_pScreenMap);
}
bool UIMultiScreenLayout::isHostTaskbarCovert() const
{
/* Check for all screens which are in use if they have some
* screen geometry. Only if they are the same for all screens, there are no
* host area covert. This is a little bit ugly, but there seems no other
* is present. */
for (int i = 0; i < m_pScreenMap->size(); ++i)
{
return true;
}
return false;
}
{
int cGuestScreen = RT_LOWORD(a);
int cHostScreen = RT_HIWORD(a);
/* Search for the virtual screen which is currently displayed on the
* requested host screen. When there is one found, we swap both. */
if (r != -1)
/* Set the new host screen */
bool fSuccess = true;
{
* _1M /* MiB to bytes */
* 8; /* to bits */
if (!fSuccess)
{
/* We have to little video memory for the new layout, so say it to the
* user and revert all changes. */
else
fSuccess = msgCenter().cannotSwitchScreenInFullscreen((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M) != QIMessageBox::Cancel;
}
}
if (fSuccess)
{
/* Swap the temporary with the previous map. */
delete m_pScreenMap;
}
/* Get the list of all view-menu actions: */
QList<QAction*> viewMenuActions = gActionPool->action(UIActionIndexRuntime_Menu_View)->menu()->actions();
/* Get the list of all view related actions: */
for (int i = 0; i < viewMenuActions.size(); ++i)
{
viewActions << viewMenuActions[i];
}
/* Update the menu items. Even if we can't switch we have to revert the menu items. */
for (int i = 0; i < viewActions.size(); ++i)
{
machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(i), QString::number(iHostScreen));
for (int w = 0; w < screenActions.size(); ++w)
{
pTmpAction->blockSignals(true);
pTmpAction->blockSignals(false);
}
}
/* On success inform the observer. */
if (fSuccess)
}
{
for (int i = 0; i < m_cGuestScreens; ++ i)
{
else
guestBpp + /* guest bits per pixel */
}
return usedBits;
}