VirtualBox

Changeset 7106 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 25, 2008 1:20:19 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28353
Message:

Additions/X11: more updates to seamless mode

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/xclient/seamless-x11.cpp

    r7080 r7106  
    3030#include <X11/Xatom.h>
    3131#include <X11/Xmu/WinUtil.h>
     32
     33/* This is defined wrong in my X11 header files! */
     34#define VBoxShapeNotify 64
    3235
    3336/*****************************************************************************
     
    154157    phChildren = phChildrenRaw;
    155158    for (unsigned i = 0; i < cChildren; ++i)
    156     {
    157         Window hClient = XmuClientWindow(mDisplay.get(), phChildren.get()[i]);
    158         if (!isVirtualRoot(hClient))
    159             addClientWindow(phChildren.get()[i]);
     159        addClientWindow(phChildren.get()[i]);
     160}
     161
     162
     163void VBoxGuestSeamlessX11::addClientWindow(const Window hWin)
     164{
     165    XWindowAttributes winAttrib;
     166    bool fAddWin = true;
     167    char *pszWinName = NULL;
     168    Window hClient = XmuClientWindow(mDisplay, hWin);
     169
     170    if (isVirtualRoot(hClient))
     171        fAddWin = false;
     172    if (fAddWin && !XGetWindowAttributes(mDisplay, hWin, &winAttrib))
     173    {
     174        LogRelFunc(("VBoxClient: Failed to get the window attributes for window %d\n", hWin));
     175        fAddWin = false;
     176    }
     177    if (fAddWin && (winAttrib.map_state == IsUnmapped))
     178        fAddWin = false;
     179    if (fAddWin && (XFetchName(mDisplay, hClient, &pszWinName) != 0) && (pszWinName != NULL))
     180        XFree(pszWinName);
     181    else
     182        /* kwin sometimes creates temporary fullscreen windows with no name. */
     183        fAddWin = false;
     184    if (fAddWin)
     185    {
     186        VBoxGuestX11Pointer<XRectangle> rects;
     187        int cRects = 0, iOrdering;
     188        bool hasShape = false;
     189
     190        if (mSupportsShape)
     191        {
     192            XShapeSelectInput(mDisplay, hWin, ShapeNotifyMask);
     193            rects = XShapeGetRectangles(mDisplay, hWin, ShapeBounding, &cRects, &iOrdering);
     194            if (0 == rects.get())
     195                cRects = 0;
     196            else
     197            {
     198                if (   (cRects > 1)
     199                    || (rects.get()[0].x != 0)
     200                    || (rects.get()[0].y != 0)
     201                    || (rects.get()[0].width != winAttrib.width)
     202                    || (rects.get()[0].height != winAttrib.height)
     203                   )
     204                    hasShape = true;
     205            }
     206        }
     207        mGuestWindows.addWindow(hWin, hasShape, winAttrib.x, winAttrib.y,
     208                                winAttrib.width, winAttrib.height, cRects, rects);
    160209    }
    161210}
     
    183232
    184233
    185 void VBoxGuestSeamlessX11::addClientWindow(const Window hWin)
    186 {
    187     XWindowAttributes winAttrib;
    188     VBoxGuestX11Pointer<XRectangle> rects;
    189     int cRects = 0, iOrdering;
    190 
    191     if (!XGetWindowAttributes(mDisplay, hWin, &winAttrib))
    192     {
    193         LogRelFunc(("VBoxClient: Failed to get the window attributes for window %d\n", hWin));
    194         return;
    195     }
    196     if (mSupportsShape)
    197     {
    198         XShapeSelectInput(mDisplay, hWin, ShapeNotify);
    199         rects = XShapeGetRectangles(mDisplay, hWin, ShapeClip, &cRects, &iOrdering);
    200         if (0 == rects.get())
    201         {
    202             cRects = 0;
    203         }
    204     }
    205     mGuestWindows.addWindow(hWin, winAttrib.map_state != IsUnmapped, winAttrib.x, winAttrib.y,
    206                             winAttrib.width, winAttrib.height, cRects, rects);
    207 }
    208 
    209234/**
    210235 * Free all information in the tree of visible windows
     
    219244    }
    220245}
     246
    221247
    222248/**
     
    241267        doMapEvent(&event.xmap);
    242268        break;
    243     case ShapeNotify:
     269    case VBoxShapeNotify:  /* This is defined wrong in my X11 header files! */
    244270        doShapeEvent(reinterpret_cast<XShapeEvent *>(&event));
    245271        break;
     
    264290    if (iter != mGuestWindows.end())
    265291    {
    266         iter->second->mX = event->x;
    267         iter->second->mY = event->y;
    268         iter->second->mWidth = event->width;
    269         iter->second->mHeight = event->height;
     292        XWindowAttributes winAttrib;
     293
     294        if (XGetWindowAttributes(mDisplay, event->window, &winAttrib))
     295        {
     296            iter->second->mX = winAttrib.x;
     297            iter->second->mY = winAttrib.y;
     298            iter->second->mWidth = winAttrib.width;
     299            iter->second->mHeight = winAttrib.height;
     300        }
    270301    }
    271302}
     
    287318}
    288319
     320
    289321/**
    290322 * Handle a window shape change event in the seamless event thread.
     
    295327{
    296328    VBoxGuestWindowList::iterator iter;
    297     VBoxGuestX11Pointer<XRectangle> rects;
    298     int cRects, iOrdering;
    299329
    300330    iter = mGuestWindows.find(event->window);
    301331    if (iter != mGuestWindows.end())
    302332    {
    303         rects = XShapeGetRectangles(mDisplay, iter->first, ShapeClip, &cRects, &iOrdering);
    304         if (0 == rects.get())
    305         {
    306             cRects = 0;
    307         }
     333        VBoxGuestX11Pointer<XRectangle> rects;
     334        int cRects = 0, iOrdering;
     335
     336        rects = XShapeGetRectangles(mDisplay, event->window, ShapeBounding, &cRects, &iOrdering);
     337        iter->second->mhasShape = true;
     338        iter->second->mcRects = cRects;
    308339        iter->second->mapRects = rects;
    309         iter->second->mcRects = cRects;
    310340    }
    311341}
     
    342372         it != mGuestWindows.end(); ++it)
    343373    {
    344         if (it->second->mMapped)
     374        if (it->second->mhasShape)
    345375        {
    346             if (it->second->mcRects > 0)
    347             {
    348                 for (int i = 0; i < it->second->mcRects; ++i)
    349                 {
    350                     RTRECT rect;
    351                     rect.xLeft   =   it->second->mX
    352                                    + it->second->mapRects.get()[i].x;
    353                     rect.yBottom =   it->second->mY
    354                                    + it->second->mapRects.get()[i].y
    355                                    + it->second->mapRects.get()[i].height;
    356                     rect.xRight  =   it->second->mX
    357                                    + it->second->mapRects.get()[i].x
    358                                    + it->second->mapRects.get()[i].width;
    359                     rect.yTop    =   it->second->mY
    360                                    + it->second->mapRects.get()[i].y;
    361                     apRects.get()->push_back(rect);
    362                 }
    363                 cRects += it->second->mcRects;
    364             }
    365             else
     376            for (int i = 0; i < it->second->mcRects; ++i)
    366377            {
    367378                RTRECT rect;
    368                 rect.xLeft   =  it->second->mX;
    369                 rect.yBottom =  it->second->mY
    370                               + it->second->mHeight;
    371                 rect.xRight  =  it->second->mX
    372                               + it->second->mWidth;
    373                 rect.yTop    =  it->second->mY;
     379                rect.xLeft   =   it->second->mX
     380                                + it->second->mapRects.get()[i].x;
     381                rect.yBottom =   it->second->mY
     382                                + it->second->mapRects.get()[i].y
     383                                + it->second->mapRects.get()[i].height;
     384                rect.xRight  =   it->second->mX
     385                                + it->second->mapRects.get()[i].x
     386                                + it->second->mapRects.get()[i].width;
     387                rect.yTop    =   it->second->mY
     388                                + it->second->mapRects.get()[i].y;
    374389                apRects.get()->push_back(rect);
    375                 ++cRects;
    376390            }
     391            cRects += it->second->mcRects;
     392        }
     393        else
     394        {
     395            RTRECT rect;
     396            rect.xLeft   =  it->second->mX;
     397            rect.yBottom =  it->second->mY
     398                          + it->second->mHeight;
     399            rect.xRight  =  it->second->mX
     400                          + it->second->mWidth;
     401            rect.yTop    =  it->second->mY;
     402            apRects.get()->push_back(rect);
     403            ++cRects;
    377404        }
    378405    }
  • trunk/src/VBox/Additions/x11/xclient/seamless-x11.h

    r7080 r7106  
    160160public:
    161161    /** Is the window currently mapped? */
    162     bool mMapped;
     162    bool mhasShape;
    163163    /** Co-ordinates in the guest screen. */
    164164    int mX, mY;
     
    171171    VBoxGuestX11Pointer<XRectangle> mapRects;
    172172    /** Constructor. */
    173     VBoxGuestWinInfo(bool isMapped, int x, int y, int w, int h, int cRects,
     173    VBoxGuestWinInfo(bool hasShape, int x, int y, int w, int h, int cRects,
    174174                     VBoxGuestX11Pointer<XRectangle> rects)
    175175            : mapRects(rects)
    176176    {
    177         mMapped = isMapped, mX = x; mY = y; mWidth = w; mHeight = h; mcRects = cRects;
     177        mhasShape = hasShape, mX = x; mY = y; mWidth = w; mHeight = h; mcRects = cRects;
    178178    }
    179179
Note: See TracChangeset for help on using the changeset viewer.

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