seamless-x11.h revision bd8e360cd1db83dcb2694ea9122ce3bc5bae678a
/** @file
*
* Seamless mode:
* Linux guest.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* 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.
*/
#ifndef __Additions_linux_seamless_x11_h
# define __Additions_linux_seamless_x11_h
#include "seamless-guest.h"
#include <map>
#include <vector>
#define VIRTUAL_ROOTS_PROP "_NET_VIRTUAL_ROOTS"
/**
* Wrapper class around the VBoxGuestX11Pointer to provide reference semantics.
* See auto_ptr in the C++ <memory> header.
*/
struct VBoxGuestX11PointerRef
{
T *mValue;
};
/** An auto pointer for pointers which have to be XFree'd. */
{
T *mValue;
/** release method to get the pointer's value and "reset" the pointer. */
/** reset the pointer value to zero or to another pointer. */
/** Copy constructor */
/** Copy from equivalent class */
/** Assignment operator. */
{
return *this;
}
/** Assignment from equivalent class. */
{
return *this;
}
/** Assignment from a pointer. */
{
if (0 != mValue)
{
}
return *this;
}
/** Dereference with * operator. */
/** Dereference with -> operator. */
/** Accessing the value inside. */
/** Convert a reference structure into an X11 pointer. */
/** Assign from a reference structure into an X11 pointer. */
{
{
}
return *this;
}
/** Typecast an X11 pointer to a reference structure. */
/** Typecast an X11 pointer to an X11 pointer around a different type. */
};
/**
* Wrapper class around an X11 display pointer which takes care of closing the display
* when it is destroyed at the latest.
*/
{
VBoxGuestX11Display(char *name = 0)
{
}
~VBoxGuestX11Display() { close(); }
};
/** Structure containing information about a guest window's position and visible area.
Used inside of VBoxGuestWindowList. */
struct VBoxGuestWinInfo {
/** Is this window currently mapped? */
bool mMapped;
/** Co-ordinates in the guest screen. */
/** Window dimensions. */
/** Number of rectangles used to represent the visible area. */
int mcRects;
/** Rectangles representing the visible area. These must be allocated by XMalloc
and will be freed automatically if non-null when the class is destroyed. */
/** The index of the virtual root that this window is a child of. */
int mParent;
/** Constructor. */
{
}
// We don't want a copy constructor or assignment operator
VBoxGuestWinInfo(const VBoxGuestWinInfo&);
};
/**
* This class is just a wrapper around a map of structures containing information about
* the windows on the guest system. It has a function for adding a structure (see addWindow),
* for removing it by window handle (see removeWindow) and an iterator for
* going through the list.
*/
{
// We don't want a copy constructor or an assignment operator
VBoxGuestWindowList(const VBoxGuestWindowList&);
// Private class members
// Just proxy iterators to map::iterator
// Constructor
VBoxGuestWindowList(void) {}
// Destructor
{
/* We use post-increment in the operation to prevent the iterator from being invalidated. */
}
// Standard operations
{
}
{
}
{
}
};
/** Structure containing information about a windows handle and position, for keeping
track of desktop windows. Used internally by VBoxGuestSeamlessX11. */
struct VBoxGuestDesktopInfo
{
/** The Window handle for this window. */
/** Co-ordinates relative to the root window (I hope!). */
/** Is this window mapped? */
bool mMapped;
/** Constructor */
{
mx = x;
my = y;
}
};
{
// We don't want a copy constructor or assignment operator
VBoxGuestSeamlessX11(const VBoxGuestSeamlessX11&);
// Private member variables
/** Pointer to the observer class. */
/** Our connection to the X11 display we are running on. */
/** Vector to keep track of which windows are to be treated as desktop windows. */
/** Class to keep track of visible guest windows. */
/** Keeps track of the total number of rectangles needed for the visible area of all
guest windows on the last call to getRects. Used for pre-allocating space in
the vector of rectangles passed to the host. */
int mcRects;
/** Is seamles mode currently enabled? */
bool isEnabled;
// Private methods
// Methods to handle X11 events
// Methods to manage guest window information
/**
* Store information about a desktop window and register for structure events on it.
* If it is mapped, go through the list of it's children and add information about
* mapped children to the tree of visible windows, making sure that those windows are
* not already in our list of desktop windows.
*
* @param hWin the window concerned - should be a "desktop" window
*/
void monitorDesktopWindows(void);
void rebuildWindowTree(void);
void freeWindowTree(void);
void updateHostSeamlessInfo(void);
/**
* Initialise the guest and ensure that it is capable of handling seamless mode
* @param pObserver Observer class to connect host and guest interfaces
*
* @returns iprt status code
*/
/**
* Shutdown seamless event monitoring.
*/
void uninit(void)
{
if (0 != mObserver)
{
stop();
}
mObserver = 0;
}
/**
* Initialise seamless event reporting in the guest.
*
* @returns IPRT status code
*/
int start(void);
/** Stop reporting seamless events. */
void stop(void);
/** Get the current list of visible rectangles. */
/** Process next event in the X11 event queue - called by the event thread. */
void nextEvent(void);
/** Send ourselves an X11 client event to wake up the event thread - called by
the event thread. */
bool interruptEvent(void);
VBoxGuestSeamlessX11(void)
{
}
~VBoxGuestSeamlessX11() { uninit(); }
};
#endif /* __Additions_linux_seamless_x11_h not defined */