display.cpp revision c0cab362f95a958b144b2102395358f8d1405149
/* $Id$ */
/** @file
* X11 guest client - display management.
*/
/*
* 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 <X11/cursorfont.h>
#include <VBox/VBoxGuestLib.h>
#include "VBoxClient.h"
static int initDisplay()
{
int rc = VINF_SUCCESS;
uint32_t fMouseFeatures = 0;
LogFlowFunc(("enabling dynamic resizing\n"));
if (-1 == rcSystem)
{
}
if (RT_SUCCESS(rc))
{
if (0 != WEXITSTATUS(rcSystem))
}
if (RT_SUCCESS(rc))
else
/* Log and ignore the return value, as there is not much we can do with
* it. */
/* Enable support for switching between hardware and software cursors */
LogFlowFunc(("enabling relative mouse re-capturing support\n"));
if (RT_SUCCESS(rc))
{
{
0);
if (RT_SUCCESS(rc))
}
else
}
if (RT_FAILURE(rc))
{
}
return VINF_SUCCESS;
}
void cleanupDisplay(void)
{
uint32_t fMouseFeatures = 0;
LogFlowFunc(("\n"));
if (RT_SUCCESS(rc))
LogFlowFunc(("returning\n"));
}
/** This thread just runs a dummy X11 event loop to be sure that we get
* terminated should the X server exit. */
static int x11ConnectionMonitor(RTTHREAD, void *)
{
while (true)
return 0;
}
/**
* 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 runDisplay()
{
LogFlowFunc(("\n"));
return VERR_NOT_FOUND;
RTTHREADTYPE_INFREQUENT_POLLER, 0, "X11 monitor");
if (RT_FAILURE(rc))
return rc;
while (true)
{
{
&iDisplay, 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(rc2))
else
{
system("VBoxRandR");
}
}
}
if ( RT_SUCCESS(rc)
{
}
}
LogFlowFunc(("returning VINF_SUCCESS\n"));
return VINF_SUCCESS;
}
{
public:
virtual const char *getPidFilePath()
{
return ".vboxclient-display.pid";
}
{
int rc = initDisplay();
if (RT_SUCCESS(rc))
rc = runDisplay();
return rc;
}
virtual void cleanup()
{
}
};
{
return new DisplayService;
}