UISession.cpp revision 63053bf6ac5b4b7ea12b8d049180069e14f35d04
/* $Id$ */
/** @file
* VBox Qt GUI - UISession class implementation.
*/
/*
* Copyright (C) 2006-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 <QWidget>
#ifdef Q_WS_MAC
# include <QTimer>
#endif /* Q_WS_MAC */
/* GUI includes: */
#include "VBoxGlobal.h"
#include "UIExtraDataManager.h"
#include "UISession.h"
#include "UIMachine.h"
#include "UIMedium.h"
#include "UIActionPoolRuntime.h"
#include "UIMachineLogic.h"
#include "UIMachineView.h"
#include "UIMachineWindow.h"
#include "UIMessageCenter.h"
#include "UIPopupCenter.h"
#include "UIWizardFirstRun.h"
#include "UIConsoleEventHandler.h"
#include "UIFrameBuffer.h"
#include "UISettingsDialogSpecific.h"
#ifdef VBOX_WITH_VIDEOHWACCEL
# include "VBoxFBOverlay.h"
#endif /* VBOX_WITH_VIDEOHWACCEL */
#ifdef Q_WS_MAC
# include "UIMenuBar.h"
# include "VBoxUtils-darwin.h"
#endif /* Q_WS_MAC */
#ifdef Q_WS_X11
# include <QX11Info>
# ifndef VBOX_WITHOUT_XCURSOR
# endif /* VBOX_WITHOUT_XCURSOR */
#endif /* Q_WS_X11 */
# include "UIKeyboardHandler.h"
# include <signal.h>
#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
/* COM includes: */
#include "CConsole.h"
#include "CSystemProperties.h"
#include "CMachineDebugger.h"
#include "CGuest.h"
#include "CStorageController.h"
#include "CMediumAttachment.h"
#include "CDisplay.h"
#include "CNetworkAdapter.h"
#include "CHostNetworkInterface.h"
#include "CVRDEServer.h"
#include "CUSBController.h"
#include "CUSBDeviceFilters.h"
#include "CHostVideoInputDevice.h"
#include "CSnapshot.h"
#include "CMedium.h"
#endif
#ifdef Q_WS_MAC
/**
* MacOS X: Application Services: Core Graphics: Display reconfiguration callback.
*
* Notifies UISession about @a display configuration change.
* Corresponding change described by Core Graphics @a flags.
* Uses UISession @a pHandler to process this change.
*
* @note Last argument (@a pHandler) must always be valid pointer to UISession object.
* @note Calls for UISession::sltHandleHostDisplayAboutToChange() slot if display configuration changed.
*/
void cgDisplayReconfigurationCallback(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *pHandler)
{
/* Which flags we are handling? */
| kCGDisplayRemoveFlag /* display removed */
| kCGDisplaySetModeFlag /* display mode changed */;
/* Handle 'display-add' case: */
if (flags & kCGDisplayAddFlag)
LogRelFlow(("UISession::cgDisplayReconfigurationCallback: Display added.\n"));
/* Handle 'display-remove' case: */
else if (flags & kCGDisplayRemoveFlag)
LogRelFlow(("UISession::cgDisplayReconfigurationCallback: Display removed.\n"));
/* Handle 'mode-set' case: */
else if (flags & kCGDisplaySetModeFlag)
LogRelFlow(("UISession::cgDisplayReconfigurationCallback: Display mode changed.\n"));
/* Ask handler to process our callback: */
if (flags & iHandledFlags)
}
#endif /* Q_WS_MAC */
/* Base variables: */
, m_pActionPool(0)
#ifdef Q_WS_MAC
, m_pMenuBar(0)
#endif /* Q_WS_MAC */
/* Common variables: */
#ifndef Q_WS_MAC
, m_pMachineWindowIcon(0)
#endif /* !Q_WS_MAC */
#ifdef Q_WS_WIN
, m_alphaCursor(0)
#endif /* Q_WS_WIN */
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
, m_fAllCloseActionsRestricted(false)
/* Common flags: */
, m_fIsStarted(false)
, m_fIsFirstTimeStarted(false)
, m_fIsGuestResizeIgnored(false)
, m_fIsAutoCaptureDisabled(false)
/* Guest additions flags: */
, m_fIsGuestSupportsGraphics(false)
, m_fIsGuestSupportsSeamless(false)
/* Mouse flags: */
, m_fNumLock(false)
, m_fCapsLock(false)
, m_fScrollLock(false)
/* Mouse flags: */
, m_fIsMouseSupportsAbsolute(false)
, m_fIsMouseSupportsRelative(false)
, m_fIsMouseSupportsMultiTouch(false)
, m_fIsMouseHostCursorNeeded(false)
, m_fIsMouseCaptured(false)
, m_fIsMouseIntegrated(true)
, m_fIsValidPointerShapePresent(false)
, m_fIsHidingHostPointer(true)
{
/* Prepare actions: */
/* Prepare connections: */
/* Prepare console event-handlers: */
/* Prepare screens: */
/* Prepare framebuffers: */
/* Load settings: */
#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
}
{
#ifdef Q_WS_WIN
/* Destroy alpha cursor: */
if (m_alphaCursor)
#endif /* Q_WS_WIN */
/* Save settings: */
/* Cleanup framebuffers: */
/* Cleanup console event-handlers: */
/* Cleanup connections: */
/* Cleanup actions: */
}
{
/* Do nothing if we had started already: */
return;
/* Prepare powerup: */
bool fPrepared = preparePowerUp();
if (!fPrepared)
return;
/* Apply debug settings from the command line. */
{
if (vboxGlobal().isPatmDisabled())
debugger.SetPATMEnabled(false);
if (vboxGlobal().isCsamDisabled())
debugger.SetCSAMEnabled(false);
debugger.SetRecompileSupervisor(true);
if (vboxGlobal().isUserCodeExecedRecompiled())
debugger.SetRecompileUser(true);
if (vboxGlobal().areWeToExecuteAllInIem())
debugger.SetExecuteAllInIEM(true);
if (!vboxGlobal().isDefaultWarpPct())
}
/* Power UP machine: */
#ifdef VBOX_WITH_DEBUGGER_GUI
CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled() ?
#else /* !VBOX_WITH_DEBUGGER_GUI */
#endif /* !VBOX_WITH_DEBUGGER_GUI */
/* Check for immediate failure: */
{
if (vboxGlobal().showStartVMErrors())
return;
}
/* Guard progressbar warnings from auto-closing: */
if (uimachine()->machineLogic())
if (isSaved())
{
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_state_restore_90px.png", 0, 0);
/* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
}
else
/* Check for a progress failure: */
{
if (vboxGlobal().showStartVMErrors())
return;
}
/* Allow further auto-closing: */
if (uimachine()->machineLogic())
/* Check if we missed a really quick termination after successful startup, and process it if we did: */
if (isTurnedOff())
{
return;
}
/* Check if the required virtualization features are active. We get this
* info only when the session is active. */
bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetIs64Bit();
bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(console.GetGuest().GetOSTypeId()).GetRecommendedVirtEx();
AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));
if (fRecommendVirtEx && !fIsVirtEnabled)
{
bool fShouldWeClose;
setPause(true);
if (fIs64BitsGuest)
else
if (fShouldWeClose)
{
/* At this point the console is powered up. So we have to close
* this session again. */
{
/* Guard progressbar warnings from auto-closing: */
if (uimachine()->machineLogic())
/* Show the power down progress dialog */
/* Allow further auto-closing: */
if (uimachine()->machineLogic())
}
else
return;
}
setPause(false);
}
#ifdef VBOX_WITH_VIDEOHWACCEL
LogRel(("2D video acceleration is %s.\n",
? "enabled"
: "disabled"));
#endif
/* Check if HID LEDs sync is enabled and add a log message about it. */
LogRel(("HID LEDs sync is enabled.\n"));
else
LogRel(("HID LEDs sync is disabled.\n"));
#else
LogRel(("HID LEDs sync is not supported on this platform.\n"));
#endif
#ifdef VBOX_GUI_WITH_PIDFILE
vboxGlobal().createPidfile();
#endif
/* Warn listeners about machine was started: */
emit sigStarted();
}
{
/* Prepare the saving progress: */
{
/* Show the saving progress: */
{
/* Failed in progress: */
return false;
}
}
else
{
/* Failed in console: */
return false;
}
/* Passed: */
return true;
}
{
/* Send ACPI shutdown signal if possible: */
{
/* Failed in console: */
return false;
}
/* Passed: */
return true;
}
{
/* Prepare the power-off progress: */
{
/* Show the power-off progress: */
{
/* Discard the current state if requested: */
if (fIncludingDiscard)
{
/* Prepare the snapshot-discard progress: */
/* Show the snapshot-discard progress: */
msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
if (progress.GetResultCode() != 0)
}
}
else
{
/* Failed in progress: */
return false;
}
}
else
{
/* Failed in console: */
/* This can happen if VBoxSVC is not running: */
fServerCrashed = true;
else
return false;
}
/* Passed: */
return true;
}
void UISession::closeRuntimeUI()
{
/* Start corresponding slot asynchronously: */
}
{
return uimachine()->machineLogic();
}
{
return machineLogic()->mainMachineWindow();
}
{
}
{
}
{
if (fOn)
else
if (!ok)
{
if (fOn)
else
}
return ok;
}
{
/* This flag indicates whether we want to do the usual .ISO mounting or not.
* First try updating the Guest Additions directly without mounting the .ISO. */
bool fDoMount = false;
/* Auto-update in GUI currently is disabled. */
fDoMount = true;
#else /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
if (fResult)
{
":/progress_install_guest_additions_90px.png",
0, 500 /* 500ms delay. */);
if (progressInstall.GetCanceled())
return;
{
/* If we got back a VBOX_E_NOT_SUPPORTED we don't complain (guest OS
* simply isn't supported yet), so silently fall back to "old" .ISO
* mounting method. */
if ( !SUCCEEDED_WARNING(rc)
&& rc != VBOX_E_NOT_SUPPORTED)
{
/* Log the error message in the release log. */
}
fDoMount = true; /* Since automatic updating failed, fall back to .ISO mounting. */
}
}
#endif /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */
/* Do we still want mounting? */
if (!fDoMount)
return;
/* Open corresponding medium: */
CMedium image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */);
else
{
return;
}
/* Make sure GA medium ID is valid: */
/* Get machine: */
/* Searching for the first suitable controller/slot: */
{
foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName()))
{
{
break;
}
}
if (!strControllerName.isNull())
break;
}
/* Make sure suitable controller/slot were found: */
if (strControllerName.isNull())
{
return;
}
/* Try to find UIMedium among cached: */
{
/* Create new one if necessary: */
}
/* Mount medium to corresponding controller/slot: */
{
/* Ask for force mounting: */
true /* retry? */, mainMachineWindow()))
{
false /* retry? */, mainMachineWindow());
}
}
}
void UISession::sltCloseRuntimeUI()
{
* They then should unlock their event-loops synchronously.
* If all such loops are unlocked, we can close Runtime UI: */
QApplication::activePopupWidget() : 0)
{
/* First we should try to close this widget: */
/* If widget rejected the 'close-event' we can
* still hide it and hope it will behave correctly
* and unlock his event-loop if any: */
/* Restart this slot asynchronously: */
return;
}
/* Finally close the Runtime UI: */
}
#ifdef RT_OS_DARWIN
{
/* Update Mac OS X menu-bar: */
updateMenu();
}
#endif /* RT_OS_DARWIN */
void UISession::sltMousePointerShapeChange(bool fVisible, bool fAlpha, QPoint hotCorner, QSize size, QVector<uint8_t> shape)
{
/* In case of shape data is present: */
{
/* We are ignoring visibility flag: */
m_fIsHidingHostPointer = false;
/* And updating current cursor shape: */
}
/* In case of shape data is NOT present: */
else
{
/* Remember if we should hide the cursor: */
}
/* Notify listeners about mouse capability changed: */
}
void UISession::sltMouseCapabilityChange(bool fSupportsAbsolute, bool fSupportsRelative, bool fSupportsMultiTouch, bool fNeedsHostCursor)
{
LogRelFlow(("UISession::sltMouseCapabilityChange: "
"Supports absolute: %s, Supports relative: %s, "
"Supports multi-touch: %s, Needs host cursor: %s\n",
/* Check if something had changed: */
{
/* Store new data: */
/* Notify listeners about mouse capability changed: */
}
}
{
/* Check if something had changed: */
if ( m_fNumLock != fNumLock
|| m_fCapsLock != fCapsLock
|| m_fScrollLock != fScrollLock)
{
/* Store new num lock data: */
if (m_fNumLock != fNumLock)
{
}
/* Store new caps lock data: */
if (m_fCapsLock != fCapsLock)
{
}
/* Store new scroll lock data: */
if (m_fScrollLock != fScrollLock)
{
}
/* Notify listeners about mouse capability changed: */
}
}
{
/* Check if something had changed: */
if (m_machineState != state)
{
/* Store new data: */
/* Notify listeners about machine state changed: */
}
}
void UISession::sltVRDEChange()
{
/* Get machine: */
/* Get VRDE server: */
// TODO: Is this status can be changed at runtime?
// Because if no => the place for that stuff is in prepareActions().
/* Notify listeners about VRDE change: */
}
void UISession::sltVideoCaptureChange()
{
/* Get machine: */
actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_T_Start)->setChecked(machine.GetVideoCaptureEnabled());
/* Notify listeners about Video Capture change: */
}
void UISession::sltGuestMonitorChange(KGuestMonitorChangedEventType changeType, ulong uScreenId, QRect screenGeo)
{
/* Ignore KGuestMonitorChangedEventType_NewOrigin change event: */
return;
/* Ignore KGuestMonitorChangedEventType_Disabled event for primary screen: */
return;
/* Process KGuestMonitorChangedEventType_Enabled change event: */
if ( !isScreenVisible(uScreenId)
setScreenVisible(uScreenId, true);
/* Process KGuestMonitorChangedEventType_Disabled change event: */
else if ( isScreenVisible(uScreenId)
setScreenVisible(uScreenId, false);
/* Notify listeners about the change: */
}
#ifdef RT_OS_DARWIN
/**
* MacOS X: Restarts display-reconfiguration watchdog timer from the beginning.
* @note Watchdog is trying to determine display reconfiguration in
* UISession::sltCheckIfHostDisplayChanged() slot every 500ms for 40 tries.
*/
{
LogRelFlow(("UISession::sltHandleHostDisplayAboutToChange()\n"));
if (m_pWatchdogDisplayChange->isActive())
}
/**
* MacOS X: Determines display reconfiguration.
* @note Calls for UISession::sltHandleHostScreenCountChange() if screen count changed.
* @note Calls for UISession::sltHandleHostScreenGeometryChange() if screen geometry changed.
*/
{
LogRelFlow(("UISession::sltCheckIfHostDisplayChanged()\n"));
/* Acquire desktop wrapper: */
/* Check if display count changed: */
{
/* Reset watchdog: */
/* Notify listeners about screen-count changed: */
return sltHandleHostScreenCountChange();
}
else
{
/* Check if at least one display geometry changed: */
{
{
/* Reset watchdog: */
/* Notify listeners about screen-geometry changed: */
return sltHandleHostScreenGeometryChange();
}
}
}
/* Check if watchdog expired, restart if not: */
{
/* Restart watchdog again: */
}
else
{
/* Reset watchdog: */
}
}
#endif /* RT_OS_DARWIN */
{
LogRelFlow(("UISession: Host-screen count changed.\n"));
/* Recache display data: */
/* Notify current machine-logic: */
}
{
LogRelFlow(("UISession: Host-screen geometry changed.\n"));
/* Recache display data: */
/* Notify current machine-logic: */
}
{
LogRelFlow(("UISession: Host-screen available-area changed.\n"));
/* Notify current machine-logic: */
}
void UISession::sltAdditionsChange()
{
/* Get our guest: */
/* Variable flags: */
bool fIsGuestSupportsGraphics = guest.GetFacilityStatus(KAdditionsFacilityType_Graphics, lLastUpdatedIgnored)
bool fIsGuestSupportsSeamless = guest.GetFacilityStatus(KAdditionsFacilityType_Seamless, lLastUpdatedIgnored)
/* Check if something had changed: */
{
/* Store new data: */
/* Notify listeners about guest additions state changed: */
}
}
void UISession::prepareConsoleEventHandlers()
{
/* Initialize console event-handler: */
UIConsoleEventHandler::instance(this);
/* Add console event connections: */
connect(gConsoleEvents, SIGNAL(sigMousePointerShapeChange(bool, bool, QPoint, QSize, QVector<uint8_t>)),
this, SLOT(sltMouseCapabilityChange(bool, bool, bool, bool)));
this, SLOT(sltKeyboardLedsChangeEvent(bool, bool, bool)));
this, SLOT(sltAdditionsChange()));
this, SLOT(sltVRDEChange()));
this, SLOT(sltVideoCaptureChange()));
this, SIGNAL(sigUSBControllerChange()));
this, SIGNAL(sigSharedFolderChange()));
#ifdef Q_WS_MAC
#endif /* Q_WS_MAC */
this, SIGNAL(sigCPUExecutionCapChange()));
}
void UISession::prepareActions()
{
/* Create action-pool: */
UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
/* Storage stuff: */
{
int iDevicesCountCD = 0;
int iDevicesCountFD = 0;
{
}
if (!iDevicesCountCD)
restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
if (!iDevicesCountFD)
restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
}
/* Network stuff: */
{
/* Initialize Network menu: */
bool fAtLeastOneAdapterActive = false;
{
if (adapter.GetEnabled())
{
fAtLeastOneAdapterActive = true;
break;
}
}
if (!fAtLeastOneAdapterActive)
restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
}
/* USB stuff: */
{
/* Check whether there is at least one USB controller with an available proxy. */
&& machine.GetUSBProxyAvailable();
if (!fUSBEnabled)
restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
}
/* WebCams stuff: */
{
/* Check whether there is an accessible video input devices pool: */
if (!fWebCamsEnabled)
restriction = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restriction | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
}
/* Apply cumulative restriction: */
actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restriction);
#ifdef Q_WS_MAC
/* Create Mac OS X menu-bar: */
m_pMenuBar = new UIMenuBar;
{
/* Configure Mac OS X menu-bar: */
this, SLOT(sltHandleMenuBarConfigurationChange()));
/* Update Mac OS X menu-bar: */
updateMenu();
}
#endif /* Q_WS_MAC */
}
void UISession::prepareConnections()
{
#ifdef Q_WS_MAC
/* Install native display reconfiguration callback: */
#else /* !Q_WS_MAC */
/* Install Qt display reconfiguration callbacks: */
this, SLOT(sltHandleHostScreenCountChange()));
this, SLOT(sltHandleHostScreenGeometryChange()));
this, SLOT(sltHandleHostScreenAvailableAreaChange()));
#endif /* !Q_WS_MAC */
}
void UISession::prepareScreens()
{
/* Recache display data: */
#ifdef Q_WS_MAC
/* Prepare display-change watchdog: */
m_pWatchdogDisplayChange = new QTimer(this);
{
this, SLOT(sltCheckIfHostDisplayChanged()));
}
#endif /* Q_WS_MAC */
/* Get machine: */
/* Prepare initial screen visibility status: */
m_monitorVisibilityVector.fill(false);
m_monitorVisibilityVector[0] = true;
/* If machine is in 'saved' state: */
if (isSaved())
{
/* Update screen visibility status from saved-state: */
for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
{
machine.QuerySavedGuestScreenInfo(i, guestOriginX, guestOriginY, guestWidth, guestHeight, fEnabled);
}
/* And make sure at least one of them is visible (primary if others are hidden): */
if (countOfVisibleWindows() < 1)
m_monitorVisibilityVector[0] = true;
}
}
void UISession::prepareFramebuffers()
{
/* Each framebuffer will be really prepared on first UIMachineView creation: */
}
void UISession::loadSessionSettings()
{
/* Load extra-data settings: */
{
/* Get machine ID: */
#ifndef Q_WS_MAC
if (!strIconName.isEmpty())
/* Load user's machine-window name postfix: */
#endif /* !Q_WS_MAC */
/* Determine mouse-capture policy: */
/* Determine Guru Meditation handler type: */
/* Determine HiDPI optimization type: */
/* Is there should be First RUN Wizard? */
/* Should guest autoresize? */
/* Menu-bar options: */
{
QAction *pActionMenuBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings);
QAction *pActionMenuBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility);
pActionMenuBarSwitch->blockSignals(true);
pActionMenuBarSwitch->blockSignals(false);
}
/* Status-bar options: */
{
QAction *pActionStatusBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings);
QAction *pActionStatusBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility);
pActionStatusBarSwitch->blockSignals(true);
pActionStatusBarSwitch->blockSignals(false);
}
/* What is the default close action and the restricted are? */
// Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..
// && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
}
}
void UISession::saveSessionSettings()
{
/* Save extra-data settings: */
{
/* Disable First RUN Wizard: */
/* Remember if guest should autoresize: */
gEDataManager->setGuestScreenAutoResizeEnabled(actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->isChecked(), vboxGlobal().managedVMUuid());
#ifndef Q_WS_MAC
/* Cleanup user's machine-window icon: */
delete m_pMachineWindowIcon;
m_pMachineWindowIcon = 0;
#endif /* !Q_WS_MAC */
}
}
void UISession::cleanupFramebuffers()
{
/* Cleanup framebuffers finally: */
{
if (pFb)
{
/* Mark framebuffer as unused: */
pFb->setMarkAsUnused(true);
/* Detach framebuffer from Display: */
/* Release framebuffer reference: */
m_frameBufferVector[i].setNull();
}
}
}
void UISession::cleanupConsoleEventHandlers()
{
/* Destroy console event-handler: */
}
void UISession::cleanupConnections()
{
#ifdef Q_WS_MAC
/* Remove display reconfiguration callback: */
#endif /* Q_WS_MAC */
}
void UISession::cleanupActions()
{
#ifdef Q_WS_MAC
delete m_pMenuBar;
m_pMenuBar = 0;
#endif /* Q_WS_MAC */
/* Destroy action-pool: */
}
#ifdef Q_WS_MAC
void UISession::updateMenu()
{
/* Rebuild Mac OS X menu-bar: */
m_pMenuBar->clear();
{
pMenuUI->setConsumed(true);
}
}
#endif /* Q_WS_MAC */
{
return mainMachineWindow()->winId();
}
{
m_fIsValidPointerShapePresent = false;
#if defined (Q_WS_WIN)
void *lpBits;
if (fHasAlpha)
else
bi.bV5AlphaMask = 0;
/* Create the DIB section with an alpha channel: */
hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD) 0);
if (fHasAlpha)
{
/* Create an empty mask bitmap: */
}
else
{
/* Word aligned AND mask. Will be allocated and created if necessary. */
/* Width in bytes of the original AND mask scan line. */
if (cbAndMaskScan & 1)
{
/* Original AND mask is not word aligned. */
/* Allocate memory for aligned AND mask. */
{
/* According to MSDN the padding bits must be 0.
* Compute the bit mask to set padding bits to 0 in the last byte of original AND mask. */
Log(("u8LastBytesPaddingMask = %02X, aligned w = %d, width = %d, cbAndMaskScan = %d\n",
unsigned i;
for (i = 0; i < uHeight; i++)
{
src += cbAndMaskScan;
}
}
}
/* Create the AND mask bitmap: */
{
}
}
if (hBitmap && hMonoBitmap)
{
{
dstShapePtr += uWidth;
}
if (hAlphaCursor)
{
/* Set the new cursor: */
if (m_alphaCursor)
m_fIsValidPointerShapePresent = true;
}
}
if (hMonoBitmap)
if (hBitmap)
if (img)
{
{
if (!fHasAlpha)
{
/* Convert AND mask to the alpha channel: */
{
if (!(x % 8))
byte = *(srcAndMaskPtr ++);
else
byte <<= 1;
if (byte & 0x80)
{
/* Linux doesn't support inverted pixels (XOR ops,
* to be exact) in cursor shapes, so we detect such
* pixels and always replace them with black ones to
* make them visible at least over light colors */
if (dstShapePtr [x] & 0x00FFFFFF)
dstShapePtr [x] = 0xFF000000;
else
dstShapePtr [x] = 0x00000000;
}
else
dstShapePtr [x] |= 0xFF000000;
}
}
dstShapePtr += uWidth;
}
/* Set the new cursor: */
m_fIsValidPointerShapePresent = true;
}
/* Create a ARGB image out of the shape data. */
for (unsigned int y = 0; y < uHeight; ++y)
{
for (unsigned int x = 0; x < uWidth; ++x)
{
/* If the alpha channel isn't in the shape data, we have to
* create them from the and-mask. This is a bit field where 1
* represent transparency & 0 opaque respectively. */
if (!fHasAlpha)
{
color |= 0xff000000;
else
{
/* This isn't quite right, but it's the best we can do I think... */
if (color & 0x00ffffff)
color = 0xff000000;
else
color = 0x00000000;
}
}
}
/* Move one scanline forward. */
}
/* Set the new cursor: */
m_fIsValidPointerShapePresent = true;
#else
# warning "port me"
#endif
}
bool UISession::preparePowerUp()
{
/* Notify user about mouse&keyboard auto-capturing: */
/* Shows First Run wizard if necessary: */
/* Check if we are in teleportation waiting mode.
* In that case no first run wizard is necessary. */
if ( isFirstTimeStarted()
&& !(( m_machineState == KMachineState_PoweredOff
&& machine.GetTeleporterEnabled()))
{
if (pWizard)
delete pWizard;
}
#ifdef VBOX_WITH_NETFLT
/* Skip further checks if VM in saved state */
if (isSaved())
return true;
/* Make sure all the attached and enabled network
* adapters are present on the host. This check makes sense
* in two cases only - when attachement type is Bridged Network
* or Host-only Interface. NOTE: Only currently enabled
* attachement type is checked (incorrect parameters check for
* currently disabled attachement types is skipped). */
/* Create host network interface names list */
{
}
ulong cCount = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(machine.GetChipsetType());
{
if (na.GetEnabled())
{
/* Get physical network interface name for currently
* enabled network attachement type */
switch (na.GetAttachmentType())
{
break;
break;
}
{
}
}
}
/* Check if non-existent interfaces found */
if (!failedInterfaceNames.isEmpty())
{
if (msgCenter().UIMessageCenter::cannotStartWithoutNetworkIf(machine.GetName(), failedInterfaceNames.join(", ")))
else
{
return false;
}
}
#endif
return true;
}
{
}
{
}
int UISession::countOfVisibleWindows()
{
int cCountOfVisibleWindows = 0;
for (int i = 0; i < m_monitorVisibilityVector.size(); ++i)
if (m_monitorVisibilityVector[i])
return cCountOfVisibleWindows;
}
{
}
{
}
void UISession::updateHostScreenData()
{
}
/**
* Custom signal handler. When switching VTs, we might not get release events
* for Ctrl-Alt and in case a savestate is performed on the new VT, the VM will
* be saved with modifier keys stuck. This is annoying enough for introducing
* this hack.
*/
/* static */
{
/* only SIGUSR1 is interesting */
}
#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */