displaychange-x11.cpp revision b72771e8c6ba3b3d9ebdd7977730325131ae0f98
/** @file
*
* Guest client: display auto-resize.
*/
/*
* 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.
*/
#include <VBox/VBoxGuest.h>
/** @todo this should probably be replaced by something IPRT */
/* For system() and WEXITSTATUS() */
#include <stdlib.h>
#include <errno.h>
#include "displaychange.h"
int VBoxGuestDisplayChangeThreadX11::init(void)
{
LogFlowThisFunc(("\n"));
if (-1 == rcSystem)
{
}
if (RT_SUCCESS(rc))
{
if (0 != WEXITSTATUS(rcSystem))
}
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
mInit = true;
return rc;
}
void VBoxGuestDisplayChangeThreadX11::uninit(void)
{
LogFlowThisFunc(("\n"));
mInit = false;
LogFlowThisFunc(("returning\n"));
}
/**
* Display change request monitor thread function.
* Before entering the loop, we re-read the last request
* received, and if the first one received inside the
* loop is identical we ignore it, because it is probably
* stale.
*/
{
LogFlowThisFunc(("\n"));
while (!mThread->isStopping())
{
/* Ignore the request if it is stale */
{
/* If we are not stopping, sleep for a bit to avoid using up too
much CPU while retrying. */
if (RT_FAILURE(rc))
{
if (!mThread->isStopping())
}
else
system("VBoxRandR");
}
/* We do not want to ignore any further requests. */
cx0 = 0;
cy0 = 0;
}
LogFlowThisFunc(("returning VINF_SUCCESS\n"));
return VINF_SUCCESS;
}
/**
* Send a signal to the thread function that it should exit
*/
void VBoxGuestDisplayChangeThreadX11::stop(void)
{
/**
* @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.
*/
LogFlowThisFunc(("\n"));
{
}
LogFlowThisFunc(("returning\n"));
}
int VBoxGuestDisplayChangeMonitor::init(void)
{
int rc = VINF_SUCCESS;
LogFlowThisFunc(("\n"));
if (mInit)
return VINF_SUCCESS;
if (RT_FAILURE(rc))
Log(("VBoxClient: failed to initialise the display change thread, rc=%Rrc (VBoxGuestDisplayChangeMonitor::init)\n", rc));
if (RT_SUCCESS(rc))
{
if (RT_FAILURE(rc))
Log(("VBoxClient: failed to start the display change thread, rc=%Rrc (VBoxGuestDisplayChangeMonitor::init)\n", rc));
}
if (RT_SUCCESS(rc))
mInit = true;
LogFlowThisFunc(("returning %Rrc\n, rc"));
return rc;
}
{
LogFlowThisFunc(("\n"));
if (mInit)
{
}
LogFlowThisFunc(("returning\n"));
}