VirtualBox

Ignore:
Timestamp:
Aug 14, 2015 9:22:27 AM (9 years ago)
Author:
vboxsync
Message:

Additions/x11/VBoxClient: clean up seamless code slightly and handle pausing and resuming internally to service.

File:
1 edited

Legend:

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

    r55401 r57344  
    4141    mX11MonitorThreadStopping = false;
    4242    mMode = VMMDev_Seamless_Disabled;
    43     mfPaused = false;
     43    mfPaused = true;
    4444}
    4545
     
    8787        if (RT_FAILURE(rc))
    8888            break;
     89        rc = startX11MonitorThread();
     90        if (RT_FAILURE(rc))
     91            break;
    8992    } while(0);
    9093    if (RT_FAILURE(rc))
    91         LogRel(("VBoxClient (seamless): failed to start.  Stage: \"%s\"  Error: %Rrc\n",
     94        VBClFatalError(("VBoxClient (seamless): failed to start.  Stage: \"%s\"  Error: %Rrc\n",
    9295                pcszStage, rc));
    9396    return rc;
     
    170173    if (RT_SUCCESS(rc) || rc == VERR_TRY_AGAIN)
    171174    {
    172         if (mMode == VMMDev_Seamless_Visible_Region && !mfPaused)
    173             /* This does it's own logging on failure. */
    174             rc = startX11MonitorThread();
     175        if (mMode == VMMDev_Seamless_Visible_Region)
     176            mfPaused = false;
    175177        else
    176             /* This does it's own logging on failure. */
    177             rc = stopX11MonitorThread();
     178            mfPaused = true;
     179        mX11Monitor.interruptEventWait();
    178180    }
    179181    else
     
    183185    LogRelFlowFunc(("returning %Rrc\n", rc));
    184186    return rc;
    185 }
    186 
    187 int SeamlessMain::cancelEvent(void)
    188 {
    189     return VbglR3InterruptEventWaits();
    190187}
    191188
     
    199196
    200197    LogRelFlowFunc(("\n"));
    201     rc = pHost->mX11Monitor.start();
    202     if (RT_SUCCESS(rc))
    203     {
    204         while (!pHost->mX11MonitorThreadStopping)
    205             pHost->mX11Monitor.nextConfigurationEvent();
    206         pHost->mX11Monitor.stop();
     198    while (!pHost->mX11MonitorThreadStopping)
     199    {
     200        if (!pHost->mfPaused)
     201        {
     202            rc = pHost->mX11Monitor.start();
     203            if (RT_FAILURE(rc))
     204                VBClFatalError(("Failed to change the X11 seamless service state, mfPaused=%RTbool, rc=%Rrc\n",
     205                                pHost->mfPaused, rc));
     206        }
     207        pHost->mX11Monitor.nextConfigurationEvent();
     208        if (pHost->mfPaused || pHost->mX11MonitorThreadStopping)
     209            pHost->mX11Monitor.stop();
    207210    }
    208211    LogRelFlowFunc(("returning %Rrc\n", rc));
     
    248251}
    249252
    250 /** Pause the service loop. */
    251 int SeamlessMain::pause()
    252 {
    253     int rc;
    254     const char *pcszStage;
    255 
    256     LogRelFlowFunc(("\n"));
    257     mfPaused = true;
    258     do {
    259         pcszStage = "Reporting end of support for seamless capability";
    260         rc = VbglR3SeamlessSetCap(false);
    261         if (RT_FAILURE(rc))
    262             break;
    263         pcszStage = "Interrupting the event loop";
    264         rc = cancelEvent();
    265         if (RT_FAILURE(rc))
    266             break;
    267     } while (0);
    268     if (RT_FAILURE(rc))
    269         LogRelFunc(("Failure.  Stage: \"%s\"  Error: %Rrc (VBoxClient)\n",
    270                     pcszStage, rc));
    271     return rc;
    272 }
    273 
    274 /** Resume after pausing. */
    275 int SeamlessMain::resume()
    276 {
    277     int rc;
    278     const char *pcszStage;
    279 
    280     LogRelFlowFunc(("\n"));
    281     mfPaused = false;
    282     do {
    283         pcszStage = "Reporting support for seamless capability";
    284         rc = VbglR3SeamlessSetCap(true);
    285         if (RT_FAILURE(rc))
    286             break;
    287         pcszStage = "Interrupting the event loop";
    288         rc = cancelEvent();
    289         if (RT_FAILURE(rc))
    290             break;
    291     } while (0);
    292     if (RT_FAILURE(rc))
    293         LogRelFunc(("Failure.  Stage: \"%s\"  Error: %Rrc (VBoxClient)\n",
    294                     pcszStage, rc));
    295     return rc;
    296 }
    297 
    298253/** @todo Expand this? */
    299254int SeamlessMain::selfTest()
     
    382337    if (!pSelf->mIsInitialised)
    383338        return VERR_INTERNAL_ERROR;
    384     rc = VBClStartVTMonitor();
    385     if (RT_FAILURE(rc))
    386         VBClFatalError(("Failed to start the VT monitor thread: %Rrc\n", rc));
    387339    /* This only exits on error. */
    388340    rc = pSelf->mSeamless.run();
     
    391343}
    392344
    393 static int pause(struct VBCLSERVICE **ppInterface)
    394 {
    395     struct SEAMLESSSERVICE *pSelf = getClassFromInterface(ppInterface);
    396 
    397     return pSelf->mSeamless.pause();
    398 }
    399 
    400 static int resume(struct VBCLSERVICE **ppInterface)
    401 {
    402     struct SEAMLESSSERVICE *pSelf = getClassFromInterface(ppInterface);
    403 
    404     return pSelf->mSeamless.resume();
    405 }
    406 
    407345static void cleanup(struct VBCLSERVICE **ppInterface)
    408346{
     
    417355    init,
    418356    run,
    419     pause,
    420     resume,
     357    VBClServiceDefaultHandler, /* pause */
     358    VBClServiceDefaultHandler, /* resume */
    421359    cleanup
    422360};
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