seamless-host.cpp revision b72771e8c6ba3b3d9ebdd7977730325131ae0f98
/** @file
*
* Seamless mode:
* Linux guest.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*****************************************************************************
* Header files *
*****************************************************************************/
#include "seamless-host.h"
/**
* Start the service.
* @returns iprt status value
*/
int VBoxGuestSeamlessHost::start(void)
{
int rc = VERR_NOT_SUPPORTED;
LogFlowThisFunc(("\n"));
if (mRunning) /* Assertion */
{
LogRel(("VBoxClient: seamless service started twice!\n"));
return VERR_INTERNAL_ERROR;
}
if (RT_FAILURE(rc))
{
}
rc = VbglR3SeamlessSetCap(true);
if (RT_SUCCESS(rc))
{
Log(("VBoxClient: enabled seamless capability on host.\n"));
if (RT_SUCCESS(rc))
{
mRunning = true;
}
else
{
LogRel(("VBoxClient: failed to start seamless event thread, rc=%Rrc. Disabled seamless capability on host again.\n", rc));
VbglR3SeamlessSetCap(false);
}
}
if (RT_FAILURE(rc))
{
}
return rc;
}
/** Stops the service. */
{
LogFlowThisFunc(("returning\n"));
if (!mRunning) /* Assertion */
{
LogRel(("VBoxClient: tried to stop seamless service which is not running!\n"));
return;
}
VbglR3SeamlessSetCap(false);
mRunning = false;
LogFlowThisFunc(("returning\n"));
}
/**
* Waits for a seamless state change events from the host and dispatch it.
*
* @returns IRPT return code.
*/
int VBoxGuestSeamlessHost::nextEvent(void)
{
LogFlowThisFunc(("\n"));
if (RT_SUCCESS(rc))
{
switch(newMode)
{
/* A simplified seamless mode, obtained by making the host VM window borderless and
making the guest desktop transparent. */
#ifdef DEBUG
LogRelFunc(("VMMDev_Seamless_Visible_Region request received (VBoxClient).\n"));
#endif
break;
/* One host window represents one guest window. Not yet implemented. */
LogRelFunc(("Warning: VMMDev_Seamless_Host_Window request received (VBoxClient).\n"));
/* fall through to default */
default:
/* fall through to case VMMDev_Seamless_Disabled */
case VMMDev_Seamless_Disabled:
#ifdef DEBUG
LogRelFunc(("VMMDev_Seamless_Disabled set (VBoxClient).\n"));
#endif
}
}
else
{
}
return rc;
}
/**
* Update the set of visible rectangles in the host.
*/
{
LogFlowThisFunc(("\n"));
{
LogRelThisFunc(("ERROR: called with null pointer!\n"));
return;
}
VbglR3SeamlessSendRects(pRects.get()->size(), pRects.get()->empty() ? NULL : &pRects.get()->front());
LogFlowThisFunc(("returning\n"));
}
/**
* The actual thread function.
*
* @returns iprt status code as thread return value
* @param pParent the VBoxGuestThread running this thread function
*/
{
LogFlowThisFunc(("\n"));
if (0 != mHost)
{
while (!mThread->isStopping())
{
{
/* If we are not stopping, sleep for a bit to avoid using up too
much CPU while retrying. */
}
}
}
LogFlowThisFunc(("returning VINF_SUCCESS\n"));
return VINF_SUCCESS;
}
/**
* Send a signal to the thread function that it should exit
*/
void VBoxGuestSeamlessHostThread::stop(void)
{
LogFlowThisFunc(("\n"));
if (0 != mHost)
{
/**
* @todo is this reasonable? If the thread is in the event loop then the cancelEvent()
* will cause it to exit. If it enters or exits the event loop it will also
* notice that we wish it to exit. And if it is somewhere in-between, the
* yield() should give it time to get to one of places mentioned above.
*/
{
mHost->cancelEvent();
}
}
LogFlowThisFunc(("returning\n"));
}