VBoxServiceDisplay.cpp revision 30b809b78e39766d5be596d604cea20a12357e04
/* $Id$ */
/** @file
* VBoxService - Guest Additions Video Mode Hint Monitoring Service.
*/
/*
* Copyright (C) 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <VBox/VBoxGuestLib.h>
#include "VBoxServiceInternal.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/**
* Convenience macro for returning an error.
* @todo It would be nice to have something which displayed the error more
* visibly to the user, say as a host notification.
*/
do { \
return (val); \
while(0)
#define ERROR_PREFIX "VBoxService/Display: "
#define MAX_CLIENTS 16
/** Structure for keeping track of previously received mode hints. */
struct videoMode
{
int cx; /** Width */
int cy; /** Height */
int x; /** X offset, -1 if none. */
int y; /** Y offset, -1 if none. */
bool fEnabled; /** Should this virtual screen be enabled? */
};
struct serviceState
{
/** FDs of currently connected clients, empty slots set to -1. */
/** FD of the socket we listen to for connections */
int fdSocket;
/** Array of video mode hints received up to now or saved in previous runs.
*/
struct videoMode *paLastModeHintsReceived;
/** Size of paLastModeHintsReceived structure. */
};
{
unsigned i;
for (i = 0; i < MAX_CLIENTS; ++i)
pState->cModeHints = 0;
}
/** Set up a socket to pass on size hints to interested clients. */
static int setUpSocket(int *pfdSocket)
{
struct sockaddr_un address;
int fdSocket;
b
if(fdSocket < 0)
sizeof(struct sockaddr_un)) != 0)
return VINF_SUCCESS;
}
/** Tell the VBoxGuest driver which events we want to listen out for. */
static int registerForHostEvents()
{
if (RT_FAILURE(rc))
rc);
return VINF_SUCCESS;
}
{
int rc;
if (RT_FAILURE(rc))
return rc;
rc = registerForHostEvents();
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
return VINF_SUCCESS;
}
{
unsigned iScreen;
int rc;
{
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
{
int rc;
for (;;)
{
if (RT_FAILURE(rc))
return rc;
/** @todo We really want to be able to poll for events and new clients
* in one system call. */
if (pfShutdown)
return VINF_SUCCESS;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
/** @note We only pass on display change information to other user space
* processes, as it can't safely be polled by several processes. */
{
if (RT_FAILURE(rc))
return rc;
}
{
if (RT_FAILURE(rc))
return rc;
}
{
while (rc == VINF_SUCCESS)
{
unsigned iScreen;
&iScreen);
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
}
}
}
/** @copydoc VBOXSERVICE::pfnWorker */
{
struct serviceState State;
int rc;
/*
* Tell the control thread that it can continue spawning services.
*/
/** @todo Set guest capabilities and mouse status (doesn't need host
* cursor) when we support this in the kernel driver. We should do
* this when any process acquires DRM_MASTER and release them when
* it is released. We need a way of detecting this. */
/** @note Update: sysfs attributes can be polled, and the kernel API
* sysfs_notify() releases the poll.
*/
if (RT_SUCCESS(rc))
if (RT_SUCCESS(rc))
return rc;
}
/** @copydoc VBOXSERVICE::pfnStop */
static DECLCALLBACK(void) serviceStop(void)
{
return;
}
/**
* The 'DisplayService' service description.
*/
{
/* pszName. */
"display",
/* pszDescription. */
"Connect display drivers to VMM device",
/* pszUsage. */
NULL,
/* pszOptions. */
NULL,
/* methods */
};