/* $Id$ */
/** @file
* VBox Qt GUI - UISession class implementation.
*/
/*
* Copyright (C) 2006-2014 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.
*/
# include <precomp.h>
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* 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 VBOX_GUI_WITH_KEYS_RESET_HANDLER
# include "UIKeyboardHandler.h"
# include <signal.h>
# endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
/* COM includes: */
# include "CSystemProperties.h"
# include "CStorageController.h"
# include "CMediumAttachment.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 /* !VBOX_WITH_PRECOMPILED_HEADERS */
#ifdef Q_WS_X11
# include <QX11Info>
# ifndef VBOX_WITHOUT_XCURSOR
# endif /* VBOX_WITHOUT_XCURSOR */
#endif /* Q_WS_X11 */
#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(("GUI: UISession::cgDisplayReconfigurationCallback: Display added.\n"));
/* Handle 'display-remove' case: */
else if (flags & kCGDisplayRemoveFlag)
LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display removed.\n"));
/* Handle 'mode-set' case: */
else if (flags & kCGDisplaySetModeFlag)
LogRelFlow(("GUI: UISession::cgDisplayReconfigurationCallback: Display mode changed.\n"));
/* Ask handler to process our callback: */
if (flags & iHandledFlags)
}
#endif /* Q_WS_MAC */
/* static */
{
/* Make sure null pointer passed: */
AssertReturn(pSession == 0, false);
/* Create session UI: */
/* Make sure it's prepared: */
{
/* Destroy session UI otherwise: */
/* False in that case: */
return false;
}
/* True by default: */
return true;
}
/* static */
{
/* Make sure valid pointer passed: */
AssertReturnVoid(pSession != 0);
/* Cleanup session UI: */
/* Destroy session: */
delete pSession;
pSession = 0;
}
{
/* Preprocess initialization: */
if (!preprocessInitialization())
return false;
/* Notify user about mouse&keyboard auto-capturing: */
/* 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;
}
/* 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 if this is NOT separate process: */
if (!vboxGlobal().isSeparateProcess())
if (!powerUp())
return false;
/* Check if we missed a really quick termination after successful startup: */
if (isTurnedOff())
return false;
/* Postprocess initialization: */
if (!postprocessInitialization())
return false;
/* Fetch corresponding states: */
if (vboxGlobal().isSeparateProcess())
{
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* Log whether 2D video acceleration is enabled: */
LogRel(("GUI: 2D video acceleration is %s.\n",
? "enabled" : "disabled"));
#endif /* VBOX_WITH_VIDEOHWACCEL */
/* Log whether HID LEDs sync is enabled: */
LogRel(("GUI: HID LEDs sync is %s.\n",
? "enabled" : "disabled"));
#else /* !Q_WS_MAC && !Q_WS_WIN */
LogRel(("GUI: HID LEDs sync is not supported on this platform.\n"));
#endif /* !Q_WS_MAC && !Q_WS_WIN */
#ifdef VBOX_GUI_WITH_PIDFILE
vboxGlobal().createPidfile();
#endif /* VBOX_GUI_WITH_PIDFILE */
/* Warn listeners about we are initialized: */
/* True by default: */
return true;
}
{
/* 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 false;
}
/* Guard progressbar warnings from auto-closing: */
if (uimachine()->machineLogic())
if (isSaved())
{
msgCenter().showModalProgressDialog(progress, machineName(), ":/progress_state_restore_90px.png", 0, 0);
/* After restoring from 'saved' state, machine-window(s) geometry should be adjusted: */
}
else
/* Check for progress failure: */
{
if (vboxGlobal().showStartVMErrors())
return false;
}
/* Allow further auto-closing: */
if (uimachine()->machineLogic())
/* True by default: */
return true;
}
{
/* 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: */
console().PowerButton();
{
/* 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)
return restoreCurrentSnapshot();
}
else
{
/* Failed in progress: */
return false;
}
}
else
{
/* Check the machine state, it might be already gone: */
{
/* Failed in console: */
/* This can happen if VBoxSVC is not running: */
fServerCrashed = true;
else
return false;
}
}
/* Passed: */
return true;
}
{
/* Prepare result: */
bool fResult = false;
/* Simulate try-catch block: */
do
{
/* Search for corresponding VM: */
{
/* Unable to find VM: */
break;
}
/* Open a direct session to modify that VM: */
{
/* Unable to open session: */
break;
}
/* Simulate try-catch block: */
do
{
/* Acquire machine for this session: */
{
/* Unable to acquire machine: */
break;
}
/* Prepare the snapshot-discard progress: */
{
/* Unable to restore snapshot: */
break;
}
/* Show the snapshot-discard progress: */
msgCenter().showModalProgressDialog(prog, machine.GetName(), ":/progress_snapshot_discard_90px.png");
if (prog.GetResultCode() != 0)
{
/* Unable to restore snapshot: */
break;
}
/* Success: */
fResult = true;
}
while (0);
/* Unlock machine finally: */
}
while (0);
/* Return result: */
return fResult;
}
{
/* Start corresponding slot asynchronously: */
}
{
}
{
}
{
}
{
}
{
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: */
/* 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());
}
}
}
{
* 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: */
return;
}
/* Finally close the Runtime UI: */
}
#ifdef RT_OS_DARWIN
{
/* Skip unrelated machine IDs: */
return;
/* 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(("GUI: 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: */
}
}
{
/* Make sure VRDE server is present: */
("VRDE server should NOT be null!\n"));
/* Notify listeners about VRDE change: */
}
{
actionPool()->action(UIActionIndexRT_M_View_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(("GUI: 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(("GUI: 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(("GUI: UISession: Host-screen count changed.\n"));
/* Recache display data: */
/* Notify current machine-logic: */
}
{
LogRelFlow(("GUI: UISession: Host-screen geometry changed.\n"));
/* Recache display data: */
/* Notify current machine-logic: */
}
{
LogRelFlow(("GUI: UISession: Host-screen available-area changed.\n"));
/* Notify current machine-logic: */
}
{
/* 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 really changed: */
}
/* Notify listeners about guest additions state event came: */
}
/* 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_fInitialized(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 session: */
if (!prepareSession())
return false;
/* Prepare actions: */
/* Prepare connections: */
/* Prepare console event-handlers: */
/* Prepare screens: */
/* Prepare framebuffers: */
/* Load settings: */
#endif /* VBOX_GUI_WITH_KEYS_RESET_HANDLER */
/* True by default: */
return true;
}
{
/* Open session: */
? KLockType_Shared : KLockType_VM);
return false;
/* Get machine: */
return false;
/* Get console: */
return false;
/* Get display: */
return false;
/* Get guest: */
return false;
/* Get mouse: */
return false;
/* Get keyboard: */
if (m_keyboard.isNull())
return false;
/* Get debugger: */
if (m_debugger.isNull())
return false;
/* Update machine-name: */
/* Update machine-state: */
/* True by default: */
return true;
}
{
/* Create action-pool: */
{
/* Configure action-pool: */
/* Get host: */
UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
/* VRDE server stuff: */
{
/* Initialize 'View' menu: */
restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
}
/* Storage stuff: */
{
int iDevicesCountCD = 0;
int iDevicesCountFD = 0;
{
}
if (!iDevicesCountCD)
restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
if (!iDevicesCountFD)
restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
}
/* Network stuff: */
{
/* Initialize Network menu: */
bool fAtLeastOneAdapterActive = false;
{
if (adapter.GetEnabled())
{
fAtLeastOneAdapterActive = true;
break;
}
}
if (!fAtLeastOneAdapterActive)
restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
}
/* USB stuff: */
{
/* Check whether there is at least one USB controller with an available proxy. */
&& machine().GetUSBProxyAvailable();
if (!fUSBEnabled)
restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
}
/* WebCams stuff: */
{
/* Check whether there is an accessible video input devices pool: */
if (!fWebCamsEnabled)
restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
}
/* Apply cumulative restriction for 'View' menu: */
actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
/* Apply cumulative restriction for 'Devices' menu: */
actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
#ifdef Q_WS_MAC
/* Create Mac OS X menu-bar: */
m_pMenuBar = new UIMenuBar;
{
/* Configure Mac OS X menu-bar: */
/* Update Mac OS X menu-bar: */
updateMenu();
}
#endif /* Q_WS_MAC */
}
}
{
#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 */
}
{
/* Create console event-handler: */
UIConsoleEventHandler::create(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()));
}
{
/* Recache display data: */
#ifdef Q_WS_MAC
/* Prepare display-change watchdog: */
m_pWatchdogDisplayChange = new QTimer(this);
{
this, SLOT(sltCheckIfHostDisplayChanged()));
}
#endif /* Q_WS_MAC */
/* 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: */
{
}
/* And make sure at least one of them is visible (primary if others are hidden): */
if (countOfVisibleWindows() < 1)
m_monitorVisibilityVector[0] = true;
}
else if (vboxGlobal().isSeparateProcess())
{
/* Update screen visibility status from display directly: */
{
}
/* And make sure at least one of them is visible (primary if others are hidden): */
if (countOfVisibleWindows() < 1)
m_monitorVisibilityVector[0] = true;
}
}
{
/* Each framebuffer will be really prepared on first UIMachineView creation: */
}
{
/* 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? */
#ifndef Q_WS_MAC
/* 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);
}
#endif /* !Q_WS_MAC */
/* 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);
}
/* Input options: */
actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->setChecked(isMouseIntegrated());
/* What is the default close action and the restricted are? */
m_fAllCloseActionsRestricted = (!vboxGlobal().isSeparateProcess() || (m_restrictedCloseActions & MachineCloseAction_Detach))
// Close VM Dialog hides PowerOff_RestoringSnapshot implicitly if PowerOff is hidden..
// && (m_restrictedCloseActions & MachineCloseAction_PowerOff_RestoringSnapshot);
}
}
{
/* Save extra-data settings: */
{
/* Disable First RUN Wizard: */
/* Remember if guest should autoresize: */
if (actionPool())
{
const QAction *pGuestAutoresizeSwitch = actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize);
gEDataManager->setGuestScreenAutoResizeEnabled(pGuestAutoresizeSwitch->isChecked(), vboxGlobal().managedVMUuid());
}
#ifndef Q_WS_MAC
/* Cleanup user's machine-window icon: */
delete m_pMachineWindowIcon;
m_pMachineWindowIcon = 0;
#endif /* !Q_WS_MAC */
}
}
{
/* Cleanup framebuffers finally: */
{
if (pFrameBuffer)
{
/* Mark framebuffer as unused: */
pFrameBuffer->setMarkAsUnused(true);
/* Detach framebuffer from Display: */
pFrameBuffer->detach();
/* Delete framebuffer reference: */
delete pFrameBuffer;
}
}
}
{
/* Destroy console event-handler if necessary: */
if (gConsoleEvents)
}
{
#ifdef Q_WS_MAC
/* Remove display reconfiguration callback: */
#endif /* Q_WS_MAC */
}
{
#ifdef Q_WS_MAC
/* Destroy Mac OS X menu-bar: */
delete m_pMenuBar;
m_pMenuBar = 0;
#endif /* Q_WS_MAC */
/* Destroy action-pool if necessary: */
if (actionPool())
}
{
/* Detach debugger: */
if (!m_debugger.isNull())
m_debugger.detach();
/* Detach keyboard: */
if (!m_keyboard.isNull())
m_keyboard.detach();
/* Detach mouse: */
/* Detach guest: */
/* Detach display: */
/* Detach console: */
/* Detach machine: */
/* Close session: */
{
}
}
{
#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: */
/* Cleanup session: */
}
#ifdef Q_WS_MAC
{
/* 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::preprocessInitialization()
{
#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())
{
else
return false;
}
#endif /* VBOX_WITH_NETFLT */
/* True by default: */
return true;
}
bool UISession::postprocessInitialization()
{
/* Check if the required virtualization features are active. We get this info only when the session is active. */
const bool fIs64BitsGuest = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetIs64Bit();
const bool fRecommendVirtEx = vboxGlobal().virtualBox().GetGuestOSType(guest().GetOSTypeId()).GetRecommendedVirtEx();
AssertMsg(!fIs64BitsGuest || fRecommendVirtEx, ("Virtualization support missed for 64bit guest!\n"));
if (fRecommendVirtEx && !fIsVirtActive)
{
/* Check whether vt-x / amd-v supported: */
/* Pause VM: */
setPause(true);
/* Ask the user about further actions: */
bool fShouldWeClose;
if (fIs64BitsGuest)
else
/* If user asked to close VM: */
if (fShouldWeClose)
{
/* Prevent auto-closure during power off sequence: */
machineLogic()->setPreventAutoClose(true);
/* Power off VM: */
bool fServerCrashed = false;
powerOff(false, fServerCrashed);
return false;
}
/* Resume VM: */
setPause(false);
}
/* True by default: */
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 */