VirtualBox

Ignore:
Timestamp:
Feb 20, 2008 4:02:21 PM (17 years ago)
Author:
vboxsync
Message:

Additions/x11: seamless for Linux guests now works in a limited way on X.org 1.3 and above with KDE

Location:
trunk/src/VBox/Additions/x11/xclient
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/xclient/Makefile.kmk

    r6970 r7048  
    4747        displaychange-x11.cpp
    4848 VBoxClient_LIBS += \
    49         Xext
     49        Xext Xmu
    5050endif
    5151
     
    8181        $(LIB_RUNTIME) \
    8282        Xext \
     83        Xmu \
    8384        X11
    8485 endif
  • trunk/src/VBox/Additions/x11/xclient/seamless-x11.cpp

    r6959 r7048  
    2929
    3030#include <X11/Xatom.h>
     31#include <X11/Xmu/WinUtil.h>
    3132
    3233/*****************************************************************************
     
    3435*****************************************************************************/
    3536
    36 static VBoxGuestX11Pointer<unsigned char> XXGetProperty (Display *aDpy, Window aWnd,
    37                                                          Atom aPropType, const char *aPropName,
    38                                                          unsigned long *nItems)
     37static unsigned char *XXGetProperty (Display *aDpy, Window aWnd, Atom aPropType,
     38                                    const char *aPropName, unsigned long *nItems)
    3939{
    4040    Atom propNameAtom = XInternAtom (aDpy, aPropName,
     
    4242    if (propNameAtom == None)
    4343    {
    44         return VBoxGuestX11Pointer<unsigned char>(0);
     44        return NULL;
    4545    }
    4646
     
    5454                                 nItems, &nBytesAfter, &propVal);
    5555    if (rc != Success)
    56         return VBoxGuestX11Pointer<unsigned char>(0);
    57 
    58     return VBoxGuestX11Pointer<unsigned char>(propVal);
     56        return NULL;
     57
     58    return propVal;
    5959}
    6060
     
    6767{
    6868    int rc = VINF_SUCCESS;
    69     /** Dummy value for XXGetProperty */
    70     unsigned long nItems;
    7169
    7270    if (0 != mObserver)  /* Assertion */
     
    7977        LogRel(("VBoxClient: seamless guest object failed to acquire a connection to the display.\n"));
    8078        return VERR_ACCESS_DENIED;
    81     }
    82     if (0 == XXGetProperty(mDisplay, DefaultRootWindow(mDisplay.get()), XA_WINDOW,
    83                            NET_CLIENT_LIST, &nItems).get())
    84     {
    85         LogRel(("VBoxClient: _NET_CLIENT_LIST property not supported by guest window manager.  Seamless mode will not be enabled.\n"));
    8679    }
    8780    mObserver = pObserver;
     
    129122}
    130123
     124/**
     125 * Recreate the table of toplevel windows of clients on the default root window of the
     126 * X server.
     127 */
    131128void VBoxGuestSeamlessX11::rebuildWindowTree(void)
    132129{
    133     VBoxGuestX11Pointer<unsigned char> clientListRaw;
    134     VBoxGuestX11Pointer<Window> clientList;
    135     unsigned long nItems;
    136 
    137130    freeWindowTree();
    138     clientListRaw = XXGetProperty(mDisplay, DefaultRootWindow(mDisplay.get()), XA_WINDOW,
    139                                   NET_CLIENT_LIST, &nItems);
    140     clientList = reinterpret_cast<Window *>(clientListRaw.release());
    141     for (unsigned i = 0; i < nItems; ++i)
    142     {
    143         VBoxGuestX11Pointer<unsigned char> windowTypeRaw;
    144         VBoxGuestX11Pointer<Atom> windowType;
    145         unsigned long ulCount;
    146 
    147         windowTypeRaw = XXGetProperty(mDisplay, clientList.get()[i], XA_ATOM,
    148                                       WM_TYPE_PROP, &ulCount);
    149         windowType = reinterpret_cast<Atom *>(windowTypeRaw.release());
    150         if (   (ulCount != 0)
    151             && (*windowType != XInternAtom(mDisplay, WM_TYPE_DESKTOP_PROP, True)))
    152         {
    153             addClientWindow(clientList.get()[i]);
    154         }
    155     }
    156 }
     131    addClients(DefaultRootWindow(mDisplay.get()));
     132}
     133
     134
     135/**
     136 * Look at the list of children of a virtual root window and add them to the list of clients
     137 * if they belong to a client which is not a virtual root.
     138 *
     139 * @param hRoot the virtual root window to be examined
     140 */
     141void VBoxGuestSeamlessX11::addClients(const Window hRoot)
     142{
     143    /** Unused out parameters of XQueryTree */
     144    Window hRealRoot, hParent;
     145    /** The list of children of the root supplied, raw pointer */
     146    Window *phChildrenRaw;
     147    /** The list of children of the root supplied, auto-pointer */
     148    VBoxGuestX11Pointer<Window> phChildren;
     149    /** The number of children of the root supplied */
     150    unsigned cChildren;
     151
     152    if (!XQueryTree(mDisplay.get(), hRoot, &hRealRoot, &hParent, &phChildrenRaw, &cChildren))
     153        return;
     154    phChildren = phChildrenRaw;
     155    for (unsigned i = 0; i < cChildren; ++i)
     156    {
     157        Window hClient = XmuClientWindow(mDisplay.get(), phChildren.get()[i]);
     158        if (hClient != phChildren.get()[i] && !isVirtualRoot(hClient))
     159            addClientWindow(phChildren.get()[i]);
     160    }
     161}
     162
     163
     164/**
     165 * Checks whether a window is a virtual root.
     166 * @returns true if it is, false otherwise
     167 * @param hWin the window to be examined
     168 */
     169bool VBoxGuestSeamlessX11::isVirtualRoot(Window hWin)
     170{
     171    unsigned char *windowTypeRaw;
     172    VBoxGuestX11Pointer<Atom> windowType;
     173    unsigned long ulCount;
     174    bool rc = false;
     175
     176    windowTypeRaw = XXGetProperty(mDisplay, hWin, XA_ATOM, WM_TYPE_PROP, &ulCount);
     177    windowType = reinterpret_cast<Atom *>(windowTypeRaw);
     178    if (   (ulCount != 0)
     179        && (*windowType == XInternAtom(mDisplay, WM_TYPE_DESKTOP_PROP, True)))
     180        rc = true;
     181    return rc;
     182}
     183
    157184
    158185void VBoxGuestSeamlessX11::addClientWindow(const Window hWin)
  • trunk/src/VBox/Additions/x11/xclient/seamless-x11.h

    r6893 r7048  
    294294    void unmonitorClientList(void);
    295295    void rebuildWindowTree(void);
     296    void addClients(const Window hRoot);
     297    bool isVirtualRoot(Window hWin);
    296298    void addClientWindow(Window hWin);
    297299    void freeWindowTree(void);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette