VirtualBox

Changeset 36806 in vbox


Ignore:
Timestamp:
Apr 21, 2011 10:41:21 PM (14 years ago)
Author:
vboxsync
Message:

Additions/x11/seamless: no more std::autoptr or std::vector, use the new STL-vector-in-C instead

Location:
trunk/src/VBox/Additions/x11/VBoxClient
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-guest.h

    r28800 r36806  
    1919#ifndef __Additions_client_seamless_guest_h
    2020# define __Additions_client_seamless_guest_h
    21 
    22 #include <memory>            /* for auto_ptr */
    23 #include <vector>            /* for vector */
    2421
    2522#include <iprt/types.h>      /* for RTRECT */
     
    4542        INCAPABLE
    4643    };
    47 
    48     /**
    49      * Initialise the guest and ensure that it is capable of handling seamless mode
    50      *
    51      * @param   pObserver An observer object to which to report changes in state and events
    52      *                    by calling its notify() method.  A state change to CAPABLE also
    53      *                    signals new seamless data.
    54      * @returns iprt status code
    55      */
    56     int init(VBoxGuestSeamlessObserver *pObserver);
    57 
    58     /**
    59      * Shutdown seamless event monitoring.
    60      */
    61     void uninit(void);
    62 
    63     /**
    64      * Initialise seamless event reporting in the guest.
    65      *
    66      * @returns IPRT status code
    67      */
    68     int start(void);
    69     /** Stop reporting seamless events. */
    70     void stop(void);
    71     /** Get the current state of the guest (capable or incapable of seamless mode). */
    72     // meEvent getState(void);
    73     /** Get the current list of visible rectangles. */
    74     std::auto_ptr<std::vector<RTRECT> > getRects(void);
    75     /** Process next event in the guest event queue - called by the event thread. */
    76     void nextEvent(void);
    77     /** Wake up the event thread if it is waiting for an event so that it can exit. */
    78     bool interruptEvent(void);
    7944};
    8045
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-host.cpp

    r28800 r36806  
    134134 * Update the set of visible rectangles in the host.
    135135 */
    136 void VBoxGuestSeamlessHost::updateRects(std::auto_ptr<std::vector<RTRECT> > pRects)
     136void VBoxGuestSeamlessHost::updateRects(RTRECT *pRects, size_t cRects)
    137137{
    138138    LogRelFlowFunc(("\n"));
    139     if (0 == pRects.get())  /* Assertion */
     139    if (!pRects)  /* Assertion */
    140140    {
    141141        LogRelThisFunc(("ERROR: called with null pointer!\n"));
    142142        return;
    143143    }
    144     VbglR3SeamlessSendRects(pRects.get()->size(), pRects.get()->empty() ? NULL : &pRects.get()->front());
     144    VbglR3SeamlessSendRects(cRects, pRects);
    145145    LogRelFlowFunc(("returning\n"));
    146146}
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-host.h

    r28800 r36806  
    1818#ifndef __Additions_client_seamless_host_h
    1919# define __Additions_client_seamless_host_h
    20 
    21 #include <memory>                   /* for auto_ptr */
    22 #include <vector>                   /* for vector */
    2320
    2421#include <VBox/log.h>
     
    151148     * Update the set of visible rectangles in the host.
    152149     */
    153     void updateRects(std::auto_ptr<std::vector<RTRECT> > pRects);
     150    void updateRects(RTRECT *pRects, size_t cRects);
    154151
    155152    VBoxGuestSeamlessHost(void) : mThreadFunction(this),
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp

    r36804 r36806  
    2929
    3030#include <limits.h>
     31
     32#include "vector.h"
    3133
    3234#ifdef TESTCASE
     
    297299       here because we want to send all such information from a single thread. */
    298300    if (mChanged)
     301    {
     302        updateRects();
    299303        mObserver->notify();
     304    }
    300305    mChanged = false;
    301306    XNextEvent(mDisplay, &event);
     
    418423}
    419424
     425/**
     426 * Gets the list of visible rectangles
     427 */
     428RTRECT *VBoxGuestSeamlessX11::getRects(void)
     429{
     430    return mpRects;
     431}
     432
     433/**
     434 * Gets the number of rectangles in the visible rectangle list
     435 */
     436size_t VBoxGuestSeamlessX11::getRectCount(void)
     437{
     438    return mcRects;
     439}
     440
     441RTVEC_DECL(RectList, RTRECT)
     442
    420443DECLCALLBACK(int) getRectsCallback(VBoxGuestWinInfo *pInfo,
    421                                    std::vector<RTRECT> *pRects)
     444                                   struct RectList *pRects)
    422445{
    423446    if (pInfo->mhasShape)
     
    425448        for (int i = 0; i < pInfo->mcRects; ++i)
    426449        {
    427             RTRECT rect;
    428             rect.xLeft   =   pInfo->mX
    429                             + pInfo->mpRects[i].x;
    430             rect.yBottom =   pInfo->mY
    431                             + pInfo->mpRects[i].y
    432                             + pInfo->mpRects[i].height;
    433             rect.xRight  =   pInfo->mX
    434                             + pInfo->mpRects[i].x
    435                             + pInfo->mpRects[i].width;
    436             rect.yTop    =   pInfo->mY
    437                             + pInfo->mpRects[i].y;
    438             pRects->push_back(rect);
     450            RTRECT *pRect;
     451           
     452            pRect = RectListPushBack(pRects);
     453            if (!pRect)
     454                return VERR_NO_MEMORY;
     455            pRect->xLeft   =   pInfo->mX
     456                             + pInfo->mpRects[i].x;
     457            pRect->yBottom =   pInfo->mY
     458                             + pInfo->mpRects[i].y
     459                             + pInfo->mpRects[i].height;
     460            pRect->xRight  =   pInfo->mX
     461                             + pInfo->mpRects[i].x
     462                             + pInfo->mpRects[i].width;
     463            pRect->yTop    =   pInfo->mY
     464                             + pInfo->mpRects[i].y;
    439465        }
    440466    }
    441467    else
    442468    {
    443         RTRECT rect;
    444         rect.xLeft   =  pInfo->mX;
    445         rect.yBottom =  pInfo->mY
    446                       + pInfo->mHeight;
    447         rect.xRight  =  pInfo->mX
    448                       + pInfo->mWidth;
    449         rect.yTop    =  pInfo->mY;
    450         pRects->push_back(rect);
     469        RTRECT *pRect;
     470
     471        pRect = RectListPushBack(pRects);
     472        if (!pRect)
     473            return VERR_NO_MEMORY;
     474        pRect->xLeft   =  pInfo->mX;
     475        pRect->yBottom =  pInfo->mY
     476                        + pInfo->mHeight;
     477        pRect->xRight  =  pInfo->mX
     478                        + pInfo->mWidth;
     479        pRect->yTop    =  pInfo->mY;
    451480    }
    452481    return VINF_SUCCESS;
     
    454483
    455484/**
    456  * Sends an updated list of visible rectangles to the host
    457  */
    458 std::auto_ptr<std::vector<RTRECT> > VBoxGuestSeamlessX11::getRects(void)
     485 * Updates the list of seamless rectangles
     486 */
     487int VBoxGuestSeamlessX11::updateRects(void)
    459488{
    460489    LogRelFlowFunc(("\n"));
    461490    unsigned cRects = 0;
    462     std::auto_ptr<std::vector<RTRECT> > apRects(new std::vector<RTRECT>);
     491    struct RectList rects = RTVEC_INITIALIZER;
    463492
    464493    if (0 != mcRects)
    465494    {
    466         apRects.get()->reserve(mcRects * 2);
     495        int rc = RectListReserve(&rects, mcRects * 2);
     496        if (RT_FAILURE(rc))
     497            return rc;
    467498    }
    468499    mGuestWindows.doWithAll((PVBOXGUESTWINCALLBACK)getRectsCallback,
    469                             apRects.get());
    470     mcRects = apRects->size();
    471     LogRelFlowFunc(("returning\n"));
    472     return apRects;
     500                            &rects);
     501    if (mpRects)
     502        RTMemFree(mpRects);
     503    mcRects = RectListSize(&rects);
     504    mpRects = RectListDetach(&rects);
     505    LogRelFlowFunc(("returning\n"));
     506    return VINF_SUCCESS;
    473507}
    474508
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.h

    r36803 r36806  
    2828#include <X11/Xutil.h>
    2929#include <X11/extensions/shape.h>
    30 
    31 #include <vector>
    3230
    3331#define WM_TYPE_PROP "_NET_WM_WINDOW_TYPE"
     
    164162    /** Class to keep track of visible guest windows. */
    165163    VBoxGuestWindowList mGuestWindows;
    166     /** Keeps track of the total number of rectangles needed for the visible area of all
    167         guest windows on the last call to getRects.  Used for pre-allocating space in
    168         the vector of rectangles passed to the host. */
     164    /** The current set of seamless rectangles. */
     165    RTRECT *mpRects;
     166    /** The current number of seamless rectangles. */
    169167    int mcRects;
    170168    /** Do we support the X shaped window extension? */
     
    194192    void freeWindowTree(void);
    195193    void updateHostSeamlessInfo(void);
     194    int updateRects(void);
    196195
    197196public:
     
    225224    void stop(void);
    226225    /** Get the current list of visible rectangles. */
    227     std::auto_ptr<std::vector<RTRECT> > getRects(void);
     226    RTRECT *getRects(void);
     227    /** Get the number of visible rectangles in the current list */
     228    size_t getRectCount(void);
    228229
    229230    /** Process next event in the guest event queue - called by the event thread. */
     
    240241
    241242    VBoxGuestSeamlessX11(void)
    242         : mObserver(0), mDisplay(NULL), mcRects(0), mSupportsShape(false),
    243           mEnabled(false), mChanged(false) {}
     243        : mObserver(0), mDisplay(NULL), mpRects(NULL), mcRects(0),
     244          mSupportsShape(false), mEnabled(false), mChanged(false) {}
    244245
    245246    ~VBoxGuestSeamlessX11()
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.h

    r28800 r36806  
    124124    virtual void notify(void)
    125125    {
    126         mHost->updateRects(mGuest->getRects());
     126        mHost->updateRects(mGuest->getRects(), mGuest->getRectCount());
    127127    }
    128128};
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