VirtualBox

Changeset 50324 in vbox for trunk/src/VBox/Additions/x11


Ignore:
Timestamp:
Feb 5, 2014 10:26:34 AM (11 years ago)
Author:
vboxsync
Message:

Additions/x11/VBoxClient: removed some unnecessary abstraction.

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

Legend:

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

    r48945 r50324  
    106106#endif
    107107                mState = ENABLE;
    108                 mObserver->notify();
     108                mX11MonitorThread->start();
    109109                break;
    110110            case VMMDev_Seamless_Host_Window:
     
    120120#endif
    121121                mState = DISABLE;
    122                 mObserver->notify();
     122                mX11MonitorThread->stop(RT_INDEFINITE_WAIT, 0);
    123123        }
    124124    }
     
    134134 * Update the set of visible rectangles in the host.
    135135 */
    136 void VBoxGuestSeamlessHost::updateRects(RTRECT *pRects, size_t cRects)
     136void VBoxGuestSeamlessHost::notify(RTRECT *pRects, size_t cRects)
    137137{
    138138    LogRelFlowFunc(("\n"));
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-host.h

    r44528 r50324  
    2222#include <VBox/VBoxGuestLib.h>      /* for the R3 guest library functions  */
    2323
    24 #include "seamless-glue.h"          /* for VBoxGuestSeamlessObserver */
    2524#include "thread.h"                 /* for VBoxGuestThread */
    2625
     
    6463
    6564/**
     65 * Small virtual class which provides the interface for notifying the host of
     66 * changes to the X11 window configuration, mainly split out from
     67 * @a VBoxGuestSeamlessHost to simplify the unit test.
     68 */
     69class VBoxGuestSeamlessHostInt
     70{
     71public:
     72    virtual void notify(RTRECT *pRects, size_t cRects) = 0;
     73};
     74
     75/**
    6676 * Interface to the host
    6777 */
    68 class VBoxGuestSeamlessHost
     78class VBoxGuestSeamlessHost : public VBoxGuestSeamlessHostInt
    6979{
    7080    friend class VBoxGuestSeamlessHostThread;
     
    8696    VBoxGuestSeamlessHost& operator=(const VBoxGuestSeamlessHost&);
    8797
    88     /** Observer to connect guest and host and ferry events back and forth. */
    89     VBoxGuestSeamlessObserver *mObserver;
     98    /** Thread to start and stop when we enter and leave seamless mode which
     99     *  monitors X11 windows in the guest. */
     100    VBoxGuestThread *mX11MonitorThread;
    90101    /** Host seamless event (i.e. enter and leave) thread function. */
    91102    VBoxGuestSeamlessHostThread mThreadFunction;
     
    113124    /**
    114125     * Initialise the guest and ensure that it is capable of handling seamless mode
    115      * @param   pObserver Observer class to connect host and guest interfaces
     126     * @param   pX11MonitorThread Thread class to monitor guest windows.
    116127     *
    117128     * @returns iprt status code
    118129     */
    119     int init(VBoxGuestSeamlessObserver *pObserver)
     130    int init(VBoxGuestThread *pX11MonitorThread)
    120131    {
    121132        LogRelFlowFunc(("\n"));
    122         if (mObserver != 0)  /* Assertion */
     133        if (mX11MonitorThread != 0)  /* Assertion */
    123134        {
    124135            LogRel(("VBoxClient: ERROR: attempt to initialise seamless host object twice!\n"));
    125136            return VERR_INTERNAL_ERROR;
    126137        }
    127         mObserver = pObserver;
     138        mX11MonitorThread = pX11MonitorThread;
    128139        LogRelFlowFunc(("returning VINF_SUCCESS\n"));
    129140        return VINF_SUCCESS;
     
    148159     * Update the set of visible rectangles in the host.
    149160     */
    150     void updateRects(RTRECT *pRects, size_t cRects);
     161    virtual void notify(RTRECT *pRects, size_t cRects);
    151162
    152163    VBoxGuestSeamlessHost(void) : mThreadFunction(this),
     
    154165                                  RTTHREADFLAGS_WAITABLE, "Host events")
    155166    {
    156         mObserver = 0;
     167        mX11MonitorThread = 0;
    157168        mRunning = false;
    158169        mState = NONE;
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.cpp

    r48945 r50324  
    2424#include <VBox/log.h>
    2525
    26 #include "seamless-guest.h"
     26#include "seamless-x11.h"
    2727
    2828#include <X11/Xatom.h>
     
    7171  * @returns true if it can handle seamless, false otherwise
    7272  */
    73 int VBoxGuestSeamlessX11::init(VBoxGuestSeamlessObserver *pObserver)
     73int VBoxGuestSeamlessX11::init(VBoxGuestSeamlessHostInt *pHost)
    7474{
    7575    int rc = VINF_SUCCESS;
    7676
    7777    LogRelFlowFunc(("\n"));
    78     if (0 != mObserver)  /* Assertion */
     78    if (0 != mHost)  /* Assertion */
    7979    {
    8080        LogRel(("VBoxClient: ERROR: attempt to initialise seamless guest object twice!\n"));
     
    8686        return VERR_ACCESS_DENIED;
    8787    }
    88     mObserver = pObserver;
     88    mHost = pHost;
    8989    LogRelFlowFunc(("returning %Rrc\n", rc));
    9090    return rc;
     
    299299    {
    300300        updateRects();
    301         mObserver->notify();
     301        mHost->notify(mpRects, mcRects);
    302302    }
    303303    mChanged = false;
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.h

    r44528 r50324  
    2323#include <iprt/avl.h>
    2424
    25 #include "seamless-guest.h"
     25#include "seamless-x11.h"
     26#include "seamless-host.h"
    2627
    2728#include <X11/Xlib.h>
     
    148149class VBoxGuestSeamlessX11;
    149150
    150 class VBoxGuestSeamlessX11 : public VBoxGuestSeamlessGuest
     151class VBoxGuestSeamlessX11
    151152{
    152153private:
     
    156157
    157158    // Private member variables
    158     /** Pointer to the observer class. */
    159     VBoxGuestSeamlessObserver *mObserver;
     159    /** Pointer to the host class. */
     160    VBoxGuestSeamlessHostInt *mHost;
    160161    /** Our connection to the X11 display we are running on. */
    161162    Display *mDisplay;
     
    197198    /**
    198199     * Initialise the guest and ensure that it is capable of handling seamless mode
    199      * @param   pObserver Observer class to connect host and guest interfaces
     200     * @param   pHost Host interface class to notify of window configuration
     201     *                changes.
    200202     *
    201203     * @returns iprt status code
    202204     */
    203     int init(VBoxGuestSeamlessObserver *pObserver);
     205    int init(VBoxGuestSeamlessHostInt *pHost);
    204206
    205207    /**
     
    208210    void uninit(void)
    209211    {
    210         if (0 != mObserver)
     212        if (0 != mHost)
    211213        {
    212214            stop();
    213215        }
    214         mObserver = 0;
     216        mHost = 0;
    215217    }
    216218
     
    241243
    242244    VBoxGuestSeamlessX11(void)
    243         : mObserver(0), mDisplay(NULL), mpRects(NULL), mcRects(0),
     245        : mHost(0), mDisplay(NULL), mpRects(NULL), mcRects(0),
    244246          mSupportsShape(false), mEnabled(false), mChanged(false) {}
    245247
     
    252254};
    253255
    254 typedef VBoxGuestSeamlessX11 VBoxGuestSeamlessGuestImpl;
    255 
    256256#endif /* __Additions_linux_seamless_x11_h not defined */
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.h

    r44528 r50324  
    2222
    2323#include "seamless-host.h"
    24 #include "seamless-guest.h"
    25 #include "seamless-glue.h"
     24#include "seamless-x11.h"
    2625
    27 /** Thread function class for VBoxGuestSeamlessGuest. */
     26/** Thread function class for VBoxGuestSeamlessX11. */
    2827class VBoxGuestSeamlessGuestThread: public VBoxGuestThreadFunction
    2928{
    3029private:
    3130    /** The guest class "owning" us. */
    32     VBoxGuestSeamlessGuestImpl *mGuest;
    33     /** The guest observer monitoring the guest. */
    34     VBoxGuestSeamlessObserver *mObserver;
     31    VBoxGuestSeamlessX11 *mGuest;
    3532    /** Should we exit the thread? */
    3633    bool mExit;
     
    4138
    4239public:
    43     VBoxGuestSeamlessGuestThread(VBoxGuestSeamlessGuestImpl *pGuest,
    44                                  VBoxGuestSeamlessObserver *pObserver)
    45     { mGuest = pGuest; mObserver = pObserver; mExit = false; }
     40    VBoxGuestSeamlessGuestThread(VBoxGuestSeamlessX11 *pGuest)
     41    { mGuest = pGuest; mExit = false; }
    4642    virtual ~VBoxGuestSeamlessGuestThread(void) {}
    4743    /**
     
    7470};
    7571
    76 /** Observer for the host class - start and stop seamless reporting in the guest when the
    77     host requests. */
    78 class VBoxGuestSeamlessHostObserver : public VBoxGuestSeamlessObserver
    79 {
    80 private:
    81     VBoxGuestSeamlessHost *mHost;
    82     VBoxGuestThread *mGuestThread;
    83 
    84 public:
    85     VBoxGuestSeamlessHostObserver(VBoxGuestSeamlessHost *pHost,
    86                                   VBoxGuestThread *pGuestThread)
    87     {
    88         mHost = pHost;
    89         mGuestThread = pGuestThread;
    90     }
    91 
    92     virtual void notify(void)
    93     {
    94         switch (mHost->getState())
    95         {
    96         case VBoxGuestSeamlessHost::ENABLE:
    97              mGuestThread->start();
    98             break;
    99         case VBoxGuestSeamlessHost::DISABLE:
    100              mGuestThread->stop(RT_INDEFINITE_WAIT, 0);
    101             break;
    102         default:
    103             break;
    104         }
    105     }
    106 };
    107 
    108 /** Observer for the guest class - send the host updated seamless rectangle information when
    109     it becomes available. */
    110 class VBoxGuestSeamlessGuestObserver : public VBoxGuestSeamlessObserver
    111 {
    112 private:
    113     VBoxGuestSeamlessHost *mHost;
    114     VBoxGuestSeamlessGuestImpl *mGuest;
    115 
    116 public:
    117     VBoxGuestSeamlessGuestObserver(VBoxGuestSeamlessHost *pHost,
    118                                    VBoxGuestSeamlessGuestImpl *pGuest)
    119     {
    120         mHost = pHost;
    121         mGuest = pGuest;
    122     }
    123 
    124     virtual void notify(void)
    125     {
    126         mHost->updateRects(mGuest->getRects(), mGuest->getRectCount());
    127     }
    128 };
    129 
    13072class VBoxGuestSeamless
    13173{
    13274private:
    13375    VBoxGuestSeamlessHost mHost;
    134     VBoxGuestSeamlessGuestImpl mGuest;
     76    VBoxGuestSeamlessX11 mGuest;
    13577    VBoxGuestSeamlessGuestThread mGuestFunction;
    13678    VBoxGuestThread mGuestThread;
    137     VBoxGuestSeamlessHostObserver mHostObs;
    138     VBoxGuestSeamlessGuestObserver mGuestObs;
    13979
    14080    bool isInitialised;
     
    15292        if (RT_SUCCESS(rc))
    15393        {
    154             rc = mHost.init(&mHostObs);
     94            rc = mHost.init(&mGuestThread);
    15595        }
    15696        if (RT_SUCCESS(rc))
    15797        {
    158             rc = mGuest.init(&mGuestObs);
     98            rc = mGuest.init(&mHost);
    15999        }
    160100        if (RT_SUCCESS(rc))
     
    187127    }
    188128
    189     VBoxGuestSeamless() : mGuestFunction(&mGuest, &mGuestObs),
     129    VBoxGuestSeamless() : mGuestFunction(&mGuest),
    190130                          mGuestThread(&mGuestFunction, 0, RTTHREADTYPE_MSG_PUMP,
    191                                        RTTHREADFLAGS_WAITABLE, "Guest events"),
    192                           mHostObs(&mHost, &mGuestThread), mGuestObs(&mHost, &mGuest)
     131                                       RTTHREADFLAGS_WAITABLE, "Guest events")
    193132    {
    194133        isInitialised = false;
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp

    r44529 r50324  
    2929
    3030#include "../seamless.h"
     31#include "../seamless-host.h"
    3132
    3233#undef DefaultRootWindow
     
    297298}
    298299
    299 /** Dummy observer class */
    300 class testObserver: public VBoxGuestSeamlessObserver
     300/** Dummy host class */
     301class testHost: public VBoxGuestSeamlessHostInt
    301302{
    302303    bool mfNotified;
    303304public:
    304     testObserver() : mfNotified(false) {}
    305     virtual void notify(void)
     305    testHost() : mfNotified(false) {}
     306    virtual void notify(RTRECT *pRects, size_t cRects)
    306307    {
    307308        mfNotified = true;
    308309    }
    309     virtual ~testObserver() {}
     310    virtual ~testHost() {}
    310311    bool isNotified(void) { return mfNotified; }
    311312};
     
    599600{
    600601    VBoxGuestSeamlessX11 subject;
    601     testObserver observer;
     602    testHost host;
    602603    unsigned cErrs = 0;
    603604
    604     subject.init(&observer);
     605    subject.init(&host);
    605606    smlsSetWindowAttributes(pFixture->paAttribsBefore,
    606607                            pFixture->pahWindowsBefore,
     
    619620                           pFixture->paShapeRectsAfter);
    620621    smlsSetNextEvent(pFixture->x11EventType, pFixture->hEventWindow);
    621     if (observer.isNotified())  /* Initial window tree rebuild */
     622    if (host.isNotified())  /* Initial window tree rebuild */
    622623    {
    623624        RTPrintf("%s: fixture: %s.  Notification was set before the first event!!!\n",
     
    626627    }
    627628    subject.nextEvent();
    628     if (!observer.isNotified())
     629    if (!host.isNotified())
    629630    {
    630631        RTPrintf("%s: fixture: %s.  No notification was sent for the initial window tree rebuild.\n",
     
    634635    smlsSetNextEvent(0, 0);
    635636    subject.nextEvent();
    636     if (!observer.isNotified())
     637    if (!host.isNotified())
    637638    {
    638639        RTPrintf("%s: fixture: %s.  No notification was sent after the event.\n",
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