autoresize.cpp revision a54b8f61d5d9f7e6f13cc710f4d1906ee7778322
/** @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.
*/
/** @todo this should probably be replaced by something IPRT */
/* For system() and WEXITSTATUS() */
#include <stdlib.h>
#include <errno.h>
#include <VBox/VBoxGuest.h>
#include "VBoxClient.h"
static int initAutoResize()
{
LogFlowFunc(("\n"));
if (-1 == rcSystem)
{
}
if (RT_SUCCESS(rc))
{
if (0 != WEXITSTATUS(rcSystem))
}
if (RT_SUCCESS(rc))
return rc;
}
void cleanupAutoResize(void)
{
LogFlowFunc(("\n"));
LogFlowFunc(("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.
*/
int runAutoResize()
{
LogFlowFunc(("\n"));
while (true)
{
/* 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))
else
system("VBoxRandR");
}
/* We do not want to ignore any further requests. */
cx0 = 0;
cy0 = 0;
}
LogFlowFunc(("returning VINF_SUCCESS\n"));
return VINF_SUCCESS;
}
{
public:
virtual const char *getPidFilePath()
{
return ".vboxclient-autoresize.pid";
}
virtual int run()
{
int rc = initAutoResize();
if (RT_SUCCESS(rc))
rc = runAutoResize();
return rc;
}
virtual void cleanup()
{
}
};
{
return new AutoResizeService;
}