seamless-x11.cpp revision 2dfc4ba4294e1314066530eab4ffe1b5991d65d4
/** @file
* X11 Seamless mode.
*/
/*
* Copyright (C) 2008 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.
*/
/*****************************************************************************
* Header files *
*****************************************************************************/
#include "seamless-guest.h"
#include <limits.h>
#ifdef TESTCASE
#define DefaultRootWindow XDefaultRootWindow
#endif
/*****************************************************************************
* Static functions *
*****************************************************************************/
{
LogFlowFunc(("\n"));
True /* only_if_exists */);
if (propNameAtom == None)
{
return NULL;
}
int actFmt = 0;
unsigned long nBytesAfter = 0;
unsigned char *propVal = 0;
return NULL;
LogFlowFunc(("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;
LogFlowThisFunc(("\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 */
LogFlowThisFunc(("\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)
{
LogFlowThisFunc(("\n"));
mEnabled = false;
LogFlowThisFunc(("returning\n"));
}
void VBoxGuestSeamlessX11::monitorClientList(void)
{
LogFlowThisFunc(("called\n"));
}
void VBoxGuestSeamlessX11::unmonitorClientList(void)
{
LogFlowThisFunc(("called\n"));
}
/**
* Recreate the table of toplevel windows of clients on the default root window of the
* X server.
*/
void VBoxGuestSeamlessX11::rebuildWindowTree(void)
{
LogFlowThisFunc(("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;
LogFlowThisFunc(("\n"));
return;
for (unsigned i = 0; i < cChildren; ++i)
LogFlowThisFunc(("returning\n"));
}
{
LogFlowThisFunc(("\n"));
bool fAddWin = true;
char *pszWinName = NULL;
if (isVirtualRoot(hClient))
fAddWin = false;
{
fAddWin = false;
}
fAddWin = false;
long dummyLong;
&dummyLong)))
{
LogFlowFunc(("window %lu, client window %lu has no size hints\n",
fAddWin = false;
}
if (fAddWin)
{
bool hasShape = false;
hClient));
if (mSupportsShape)
{
cRects = 0;
else
{
if ( (cRects > 1)
)
hasShape = true;
}
}
}
LogFlowThisFunc(("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;
unsigned long ulCount;
bool rc = false;
LogFlowThisFunc(("\n"));
if (windowTypeRaw != NULL)
{
if ( (ulCount != 0)
rc = true;
}
return rc;
}
/**
* 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. */
LogFlowThisFunc(("\n"));
{
}
LogFlowThisFunc(("returning\n"));
}
/**
* Waits for a position or shape-related event from guest windows
*
* @note Called from the guest event thread.
*/
void VBoxGuestSeamlessX11::nextEvent(void)
{
LogFlowThisFunc(("\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)
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;
}
LogFlowThisFunc(("returning\n"));
}
/**
* Handle a configuration event in the seamless event thread by setting the new position.
*
* @param event the X11 event structure
*/
{
LogFlowThisFunc(("\n"));
{
return;
{
cRects = 0;
}
mChanged = true;
}
LogFlowThisFunc(("returning\n"));
}
/**
* Handle a map event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogFlowThisFunc(("\n"));
{
mChanged = true;
}
LogFlowThisFunc(("returning\n"));
}
/**
* Handle a window shape change event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogFlowThisFunc(("\n"));
{
&iOrdering);
cRects = 0;
mChanged = true;
}
LogFlowThisFunc(("returning\n"));
}
/**
* Handle an unmap event in the seamless event thread.
*
* @param event the X11 event structure
*/
{
LogFlowThisFunc(("\n"));
{
mChanged = true;
}
LogFlowThisFunc(("returning\n"));
}
/**
* Sends an updated list of visible rectangles to the host
*/
{
LogFlowThisFunc(("\n"));
unsigned cRects = 0;
if (0 != mcRects)
{
}
{
{
{
}
}
else
{
++cRects;
}
}
LogFlowThisFunc(("returning\n"));
return apRects;
}
/**
* 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;
LogFlowThisFunc(("\n"));
/* Message contents set to zero. */
reinterpret_cast<XEvent *>(&clientMessage)))
{
rc = true;
}
return rc;
}