seamless-x11.cpp revision 3b3b3f38fab88ab36be8fef50a2a1edb7fca7e51
/** @file
* X11 Seamless mode.
*/
/*
* Copyright (C) 2008 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 "seamless-guest.h"
#include <limits.h>
#include "vector.h"
#ifdef TESTCASE
#define DefaultRootWindow XDefaultRootWindow
#endif
/*****************************************************************************
* Static functions *
*****************************************************************************/
{
LogRelFlowFunc(("\n"));
True /* only_if_exists */);
if (propNameAtom == None)
{
return NULL;
}
int actFmt = 0;
unsigned long nBytesAfter = 0;
unsigned char *propVal = 0;
return NULL;
LogRelFlowFunc(("returning\n"));
return propVal;
}
/**
* Initialise the guest and ensure that it is capable of handling seamless mode
*
* @returns true if it can handle seamless, false otherwise
*/
{
int rc = VINF_SUCCESS;
LogRelFlowFunc(("\n"));
if (0 != mObserver) /* Assertion */
{
LogRel(("VBoxClient: ERROR: attempt to initialise seamless guest object twice!\n"));
return VERR_INTERNAL_ERROR;
}
{
LogRel(("VBoxClient: seamless guest object failed to acquire a connection to the display.\n"));
return VERR_ACCESS_DENIED;
}
return rc;
}
/**
* Read information about currently visible windows in the guest and subscribe to X11
* events about changes to this information.
*
* @note This class does not contain its own event thread, so an external thread must
* call nextEvent() for as long as events are wished.
* @todo This function should switch the guest to fullscreen mode.
*/
int VBoxGuestSeamlessX11::start(void)
{
int rc = VINF_SUCCESS;
/** Dummy values for XShapeQueryExtension */
LogRelFlowFunc(("\n"));
mEnabled = true;
return rc;
}
/** Stop reporting seamless events to the host. Free information about guest windows
and stop requesting updates. */
void VBoxGuestSeamlessX11::stop(void)
{
LogRelFlowFunc(("\n"));
mEnabled = false;
LogRelFlowFunc(("returning\n"));
}
void VBoxGuestSeamlessX11::monitorClientList(void)
{
LogRelFlowFunc(("called\n"));
}
void VBoxGuestSeamlessX11::unmonitorClientList(void)
{
LogRelFlowFunc(("called\n"));
}
/**
* Recreate the table of toplevel windows of clients on the default root window of the
* X server.
*/
void VBoxGuestSeamlessX11::rebuildWindowTree(void)
{
LogRelFlowFunc(("called\n"));
mChanged = true;
}
/**
* Look at the list of children of a virtual root window and add them to the list of clients
* if they belong to a client which is not a virtual root.
*
* @param hRoot the virtual root window to be examined
*/
{
/** Unused out parameters of XQueryTree */
/** The list of children of the root supplied, raw pointer */
/** The list of children of the root supplied, auto-pointer */
/** The number of children of the root supplied */
unsigned cChildren;
LogRelFlowFunc(("\n"));
return;
for (unsigned i = 0; i < cChildren; ++i)
LogRelFlowFunc(("returning\n"));
}
{
LogRelFlowFunc(("\n"));
bool fAddWin = true;
char *pszWinName = NULL;
if (isVirtualRoot(hClient))
fAddWin = false;
{
fAddWin = false;
}
fAddWin = false;
long dummyLong;
&dummyLong)))
{
LogRelFlowFunc(("window %lu, client window %lu has no size hints\n",
fAddWin = false;
}
if (fAddWin)
{
bool hasShape = false;
hClient));
if (mSupportsShape)
{
if (!pRects)
cRects = 0;
else
{
if ( (cRects > 1)
|| (pRects[0].x != 0)
|| (pRects[0].y != 0)
)
hasShape = true;
}
}
pRects);
}
LogRelFlowFunc(("returning\n"));
}
/**
* Checks whether a window is a virtual root.
* @returns true if it is, false otherwise
* @param hWin the window to be examined
*/
{
unsigned char *windowTypeRaw = NULL;
unsigned long ulCount;
bool rc = false;
LogRelFlowFunc(("\n"));
if (windowTypeRaw != NULL)
{
if ( (ulCount != 0)
rc = true;
}
if (windowTypeRaw)
return rc;
}
{
delete pInfo;
return VINF_SUCCESS;
}
/**
* Free all information in the tree of visible windows
*/
void VBoxGuestSeamlessX11::freeWindowTree(void)
{
/* We use post-increment in the operation to prevent the iterator from being invalidated. */
LogRelFlowFunc(("\n"));
LogRelFlowFunc(("returning\n"));
}
/**
* Waits for a position or shape-related event from guest windows
*
* @note Called from the guest event thread.
*/
void VBoxGuestSeamlessX11::nextEvent(void)
{
LogRelFlowFunc(("\n"));
/* Start by sending information about the current window setup to the host. We do this
here because we want to send all such information from a single thread. */
if (mChanged)
{
updateRects();
}
mChanged = false;
{
case ConfigureNotify:
break;
case MapNotify:
break;
case VBoxShapeNotify: /* This is defined wrong in my X11 header files! */
/* the window member in xany is in the same place as in the shape event */
break;
case UnmapNotify:
break;
default:
break;
}
LogRelFlowFunc(("returning\n"));
}
/**
* Handle a configuration event in the seamless event thread by setting the new position.
*
* @param event the X11 event structure
*/
{
LogRelFlowFunc(("\n"));
if (pInfo)
{
return;
{
if (!pRects)
cRects = 0;
}
mChanged = true;
}
LogRelFlowFunc(("returning\n"));
}
/**
* Handle a map event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogRelFlowFunc(("\n"));
if (!pInfo)
{
mChanged = true;
}
LogRelFlowFunc(("returning\n"));
}
/**
* Handle a window shape change event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogRelFlowFunc(("\n"));
if (pInfo)
{
&iOrdering);
if (!pRects)
cRects = 0;
mChanged = true;
}
LogRelFlowFunc(("returning\n"));
}
/**
* Handle an unmap event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogRelFlowFunc(("\n"));
mChanged = true;
LogRelFlowFunc(("returning\n"));
}
/**
* Gets the list of visible rectangles
*/
{
return mpRects;
}
/**
* Gets the number of rectangles in the visible rectangle list
*/
{
return mcRects;
}
{
{
{
if (!pRect)
return VERR_NO_MEMORY;
}
}
else
{
if (!pRect)
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
/**
* Updates the list of seamless rectangles
*/
int VBoxGuestSeamlessX11::updateRects(void)
{
LogRelFlowFunc(("\n"));
unsigned cRects = 0;
if (0 != mcRects)
{
if (RT_FAILURE(rc))
return rc;
}
&rects);
if (mpRects)
LogRelFlowFunc(("returning\n"));
return VINF_SUCCESS;
}
/**
* Send a client event to wake up the X11 seamless event loop prior to stopping it.
*
* @note This function should only be called from the host event thread.
*/
bool VBoxGuestSeamlessX11::interruptEvent(void)
{
bool rc = false;
LogRelFlowFunc(("\n"));
/* Message contents set to zero. */
reinterpret_cast<XEvent *>(&clientMessage)))
{
rc = true;
}
return rc;
}