VirtualBox

Changeset 52564 in vbox


Ignore:
Timestamp:
Sep 2, 2014 8:53:51 AM (10 years ago)
Author:
vboxsync
Message:

Additions/x11/VBoxClient: more clean-up and fix a test case.

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

Legend:

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

    r50375 r52564  
    7171  * @returns true if it can handle seamless, false otherwise
    7272  */
    73 int SeamlessX11::init(SeamlessHostProxy *pHost)
     73int SeamlessX11::init(PFNSENDREGIONUPDATE pHostCallback)
    7474{
    7575    int rc = VINF_SUCCESS;
    7676
    7777    LogRelFlowFunc(("\n"));
    78     if (0 != mHost)  /* Assertion */
     78    if (mHostCallback != NULL)  /* Assertion */
    7979    {
    8080        LogRel(("VBoxClient: ERROR: attempt to initialise seamless guest object twice!\n"));
     
    8686        return VERR_ACCESS_DENIED;
    8787    }
    88     mHost = pHost;
     88    mHostCallback = pHostCallback;
    8989    LogRelFlowFunc(("returning %Rrc\n", rc));
    9090    return rc;
     
    299299    {
    300300        updateRects();
    301         mHost->sendRegionUpdate(mpRects, mcRects);
     301        mHostCallback(mpRects, mcRects);
    302302    }
    303303    mChanged = false;
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless-x11.h

    r50376 r52564  
    3434
    3535/**
    36  * Small virtual class which provides the interface for notifying the host of
    37  * changes to the X11 window configuration, mainly split out from
    38  * @a VBoxGuestSeamlessHost to simplify the unit test.
    39  */
    40 class SeamlessHostProxy
    41 {
    42 public:
    43     virtual void sendRegionUpdate(RTRECT *pRects, size_t cRects) = 0;
    44     virtual ~SeamlessHostProxy() {}
    45 };
     36 * Callback which provides the interface for notifying the host of changes to
     37 * the X11 window configuration, mainly split out from @a VBoxGuestSeamlessHost
     38 * to simplify the unit test.
     39 */
     40typedef void FNSENDREGIONUPDATE(RTRECT *pRects, size_t cRects);
     41typedef FNSENDREGIONUPDATE *PFNSENDREGIONUPDATE;
    4642
    4743/** Structure containing information about a guest window's position and visible area.
     
    164160
    165161    // Private member variables
    166     /** Pointer to the host class. */
    167     SeamlessHostProxy *mHost;
     162    /** Pointer to the host callback. */
     163    PFNSENDREGIONUPDATE mHostCallback;
    168164    /** Our connection to the X11 display we are running on. */
    169165    Display *mDisplay;
     
    205201    /**
    206202     * Initialise the guest and ensure that it is capable of handling seamless mode
    207      * @param   pHost Host interface class to notify of window configuration
     203     * @param   pHost Host interface callback to notify of window configuration
    208204     *                changes.
    209205     *
    210206     * @returns iprt status code
    211207     */
    212     int init(SeamlessHostProxy *pHost);
     208    int init(PFNSENDREGIONUPDATE pHostCallback);
    213209
    214210    /**
     
    217213    void uninit(void)
    218214    {
    219         if (mHost)
     215        if (mHostCallback)
    220216            stop();
    221         mHost = NULL;
     217        mHostCallback = NULL;
    222218        if (mDisplay)
    223219            XCloseDisplay(mDisplay);
     
    251247
    252248    SeamlessX11(void)
    253         : mHost(0), mDisplay(NULL), mpRects(NULL), mcRects(0),
     249        : mHostCallback(NULL), mDisplay(NULL), mpRects(NULL), mcRects(0),
    254250          mSupportsShape(false), mEnabled(false), mChanged(false) {}
    255251
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp

    r52562 r52564  
    5050
    5151/**
     52 * Update the set of visible rectangles in the host.
     53 */
     54static void sendRegionUpdate(RTRECT *pRects, size_t cRects)
     55{
     56    LogRelFlowFunc(("\n"));
     57    if (cRects && !pRects)  /* Assertion */
     58    {
     59        LogRelFunc(("ERROR: called with null pointer!\n"));
     60        return;
     61    }
     62    VbglR3SeamlessSendRects(cRects, pRects);
     63    LogRelFlowFunc(("returning\n"));
     64}
     65
     66/**
    5267 * initialise the service.
    5368 */
     
    6075    do {
    6176        pcszStage = "Connecting to the X server";
    62         rc = mX11Monitor.init(this);
     77        rc = mX11Monitor.init(sendRegionUpdate);
    6378        if (RT_FAILURE(rc))
    6479            break;
     
    175190
    176191/**
    177  * Update the set of visible rectangles in the host.
    178  */
    179 void SeamlessMain::sendRegionUpdate(RTRECT *pRects, size_t cRects)
    180 {
    181     LogRelFlowFunc(("\n"));
    182     if (cRects && !pRects)  /* Assertion */
    183     {
    184         LogRelThisFunc(("ERROR: called with null pointer!\n"));
    185         return;
    186     }
    187     VbglR3SeamlessSendRects(cRects, pRects);
    188     LogRelFlowFunc(("returning\n"));
    189 }
    190 
    191 
    192 /**
    193192 * The actual X11 window configuration change monitor thread function.
    194193 */
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.h

    r50495 r52564  
    2929 * Interface to the host
    3030 */
    31 class SeamlessMain : public SeamlessHostProxy
     31class SeamlessMain
    3232{
    3333private:
     
    109109    int resume();
    110110
    111     /**
    112      * Update the set of visible rectangles in the host.
    113      */
    114     virtual void sendRegionUpdate(RTRECT *pRects, size_t cRects);
    115 
    116111    /** Run a few tests to be sure everything is working as intended. */
    117112    int selfTest();
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp

    r50346 r52564  
    297297}
    298298
    299 /** Dummy host class */
    300 class testHost: public SeamlessHostProxy
    301 {
    302     bool mfNotified;
    303 public:
    304     testHost() : mfNotified(false) {}
    305     virtual void sendRegionUpdate(RTRECT *pRects, size_t cRects)
    306     {
    307         mfNotified = true;
    308     }
    309     virtual ~testHost() {}
    310     bool isNotified(void) { return mfNotified; }
    311 };
     299/** Global "received a notification" flag. */
     300static bool g_fNotified = false;
     301
     302/** Dummy host call-back. */
     303static void sendRegionUpdate(RTRECT *pRects, size_t cRects)
     304{
     305    g_fNotified = true;
     306}
     307
     308static bool gotNotification(void)
     309{
     310    if (!g_fNotified)
     311        return false;
     312    g_fNotified = false;
     313    return true;
     314}
    312315
    313316/*****************************
     
    372375    /** The onscreen positions of those windows. */
    373376    RTRECT *paReportedRects;
     377    /** Do we expect notification after the event? */
     378    bool fExpectNotification;
    374379};
    375380
     
    419424    20,
    420425    RT_ELEMENTS(g_aRects1),
    421     g_aRects1
     426    g_aRects1,
     427    true
    422428};
    423429
     
    454460    20,
    455461    RT_ELEMENTS(g_aRects1),
    456     g_aRects1
     462    g_aRects1,
     463    true
    457464};
    458465
     
    484491    20,
    485492    RT_ELEMENTS(g_aRects1),
    486     g_aRects1
     493    g_aRects1,
     494    true
    487495};
    488496
     
    514522    20,
    515523    0,
    516     NULL
     524    NULL,
     525    true
    517526};
    518527
     
    545554    21,
    546555    RT_ELEMENTS(g_aRects2),
    547     g_aRects2
     556    g_aRects2,
     557    false
    548558};
    549559
     
    574584    20,
    575585    RT_ELEMENTS(g_aRects1),
    576     g_aRects1
     586    g_aRects1,
     587    true
    577588};
    578589
     
    599610{
    600611    SeamlessX11 subject;
    601     testHost host;
    602612    unsigned cErrs = 0;
    603613
    604     subject.init(&host);
     614    subject.init(sendRegionUpdate);
    605615    smlsSetWindowAttributes(pFixture->paAttribsBefore,
    606616                            pFixture->pahWindowsBefore,
     
    619629                           pFixture->paShapeRectsAfter);
    620630    smlsSetNextEvent(pFixture->x11EventType, pFixture->hEventWindow);
    621     if (host.isNotified())  /* Initial window tree rebuild */
     631    if (gotNotification())  /* Initial window tree rebuild */
    622632    {
    623633        RTPrintf("%s: fixture: %s.  Notification was set before the first event!!!\n",
     
    626636    }
    627637    subject.nextConfigurationEvent();
    628     if (!host.isNotified())
     638    if (!gotNotification())
    629639    {
    630640        RTPrintf("%s: fixture: %s.  No notification was sent for the initial window tree rebuild.\n",
     
    634644    smlsSetNextEvent(0, 0);
    635645    subject.nextConfigurationEvent();
    636     if (!host.isNotified())
     646    if (pFixture->fExpectNotification && !gotNotification())
    637647    {
    638648        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