UIMultiScreenLayout.cpp revision 7b601f6c4b83b7e3a0f58a62b198352048c6f7c3
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIMultiScreenLayout class implementation
*/
/*
* 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.
*/
/* Qt includes: */
#include <QApplication>
#include <QDesktopWidget>
#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_pViewMenu(0)
{
}
{
/* Cleanup view-menu: */
}
{
/* Assign view-menu: */
/* Prepare view-menu: */
}
void UIMultiScreenLayout::update()
{
/* Clear screen-map initially: */
m_screenMap.clear();
/* 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. */
{
/* Initialize variables: */
bool fValid = false;
int iHostScreen = -1;
if (!fValid)
{
/* If the user ever selected a combination in the view menu, we have the following entry: */
QString strTest = machine.GetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iGuestScreen));
bool fOk;
/* Check is this value can be converted: */
/* Revalidate: */
}
if (!fValid)
{
/* 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 + (iGuestScreen > 0 ? QString::number(iGuestScreen): ""));
{
/* If parsing was successfully, convert it to a position: */
/* Check to which screen the position belongs: */
/* Revalidate: */
}
}
if (!fValid)
{
/* If still not valid, pick the next one
* if there is still available host screen: */
if (!availableScreens.isEmpty())
{
fValid = true;
}
}
if (fValid)
{
/* Register host screen for the guest screen: */
/* Remove it from the list of available host screens: */
}
}
/* Update menu actions: */
updateMenuActions(false);
}
void UIMultiScreenLayout::rebuild()
{
/* Update view-menu: */
/* Update layout: */
update();
}
int UIMultiScreenLayout::hostScreenCount() const
{
return m_cHostScreens;
}
int UIMultiScreenLayout::guestScreenCount() const
{
return m_guestScreens.size();
}
{
}
{
}
{
return memoryRequirements(m_screenMap);
}
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_screenMap.size(); ++i)
{
return true;
}
return false;
}
{
/* Parse incoming information: */
int iRequestedGuestScreen = RT_LOWORD(a);
int iRequestedHostScreen = 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. */
else
/* Check the memory requirements first: */
bool fSuccess = true;
{
if (!fSuccess)
{
/* We have too little video memory for the new layout, so say it to the user and revert all the changes: */
else
fSuccess = msgCenter().cannotSwitchScreenInFullscreen((((usedBits + 7) / 8 + _1M - 1) / _1M) * _1M) != QIMessageBox::Cancel;
}
}
/* Make sure memory requirements matched: */
if (!fSuccess)
return;
/* Swap the maps: */
/* Update menu actions: */
updateMenuActions(true);
/* Inform the observer: */
}
{
#if (QT_VERSION >= 0x040600)
#else /* (QT_VERSION >= 0x040600) */
#endif /* !(QT_VERSION >= 0x040600) */
}
{
/* Get machine: */
/* Enumerate all the visible guest screens: */
}
void UIMultiScreenLayout::prepareViewMenu()
{
/* Make sure view-menu was set: */
if (!m_pViewMenu)
return;
/* Cleanup menu first: */
{
{
pScreenGroup->setExclusive(true);
for (int a = 0; a < m_cHostScreens; ++a)
{
pAction->setCheckable(true);
}
}
}
/* Update menu actions: */
updateMenuActions(false);
}
void UIMultiScreenLayout::cleanupViewMenu()
{
/* Make sure view-menu was set: */
if (!m_pViewMenu)
return;
/* Cleanup view-menu actions: */
while (!m_screenMenuList.isEmpty())
delete m_screenMenuList.takeFirst();
}
{
/* 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 view actions: */
{
if (fWithSave)
{
machine.SetExtraData(QString("%1%2").arg(GUI_VirtualScreenToHostScreen).arg(iViewAction), strHostScreen);
}
/* Update screen actions: */
for (int j = 0; j < screenActions.size(); ++j)
{
pTmpAction->blockSignals(true);
pTmpAction->blockSignals(false);
}
}
}
{
{
else
guestBpp + /* guest bits per pixel */
}
return usedBits;
}