UIMultiScreenLayout.cpp revision f7aceb294f917c0af317644a35e3cf8f78880b65
/* $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 "UIFrameBuffer.h"
#include "UISession.h"
#include "UIMessageCenter.h"
#include "UIExtraDataManager.h"
#include "VBoxGlobal.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()
{
LogRelFlow(("UIMultiScreenLayout::update: Started...\n"));
/* 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. */
bool fShouldWeAutoMountGuestScreens = gEDataManager->shouldWeAutoMountGuestScreens(vboxGlobal().managedVMUuid());
LogRelFlow(("UIMultiScreenLayout::update: GUI/AutomountGuestScreens is %s.\n", fShouldWeAutoMountGuestScreens ? "enabled" : "disabled"));
{
/* 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: */
iHostScreen = gEDataManager->hostScreenForPassedGuestScreen(iGuestScreen, vboxGlobal().managedVMUuid());
/* Revalidate: */
}
if (!fValid)
{
/* Check the position of the guest window in normal mode.
* This makes sure that on first use fullscreen/seamless window opens on the same host-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 host-screens
* and they will magically open there in fullscreen/seamless also. */
QRect geo = gEDataManager->machineWindowGeometry(m_pMachineLogic->visualStateType(), iGuestScreen, vboxGlobal().managedVMUuid());
/* If geometry is valid: */
{
/* Get top-left corner position: */
/* Check which host-screen the position belongs to: */
/* 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: */
}
/* Do we have opinion about what to do with excessive guest-screen? */
else if (fShouldWeAutoMountGuestScreens)
{
/* Then we have to disable excessive guest-screen: */
}
}
/* Are we still have available host-screens
* and have opinion about what to do with disabled guest-screens? */
{
/* How many excessive host-screens do we have? */
/* How many disabled guest-screens do we have? */
/* We have to try to enable disabled guest-screens if any: */
{
/* Defaults: */
/* Try to get previous guest-screen arguments: */
{
if (pFrameBuffer->width() > 0)
if (pFrameBuffer->height() > 0)
pFrameBuffer->setAutoEnabled(true);
}
/* Re-enable guest-screen with proper resolution: */
LogRelFlow(("UIMultiScreenLayout::update: Enabling guest-screen %d with following resolution: %dx%d.\n",
}
}
/* Update menu actions: */
updateMenuActions(false);
LogRelFlow(("UIMultiScreenLayout::update: Finished!\n"));
}
void UIMultiScreenLayout::rebuild()
{
LogRelFlow(("UIMultiScreenLayout::rebuild: Started...\n"));
/* Update view-menu: */
/* Update layout: */
update();
LogRelFlow(("UIMultiScreenLayout::rebuild: Finished!\n"));
}
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);
}
}
/* Make sure memory requirements matched: */
if (!fSuccess)
return;
/* Swap the maps: */
/* Update menu actions: */
updateMenuActions(true);
/* Inform the observer: */
}
{
}
{
/* Get machine: */
/* Enumerate all the guest screens: */
else
}
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();
}
{
/* Make sure view-menu was set: */
if (!m_pViewMenu)
return;
/* 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)
gEDataManager->setHostScreenForPassedGuestScreen(iViewAction, iHostScreen, vboxGlobal().managedVMUuid());
/* 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;
}