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.

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

Legend:

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

    r57265 r57344  
    2626
    2727#include "seamless-x11.h"
     28#include "VBoxClient.h"
    2829
    2930#include <X11/Xatom.h>
     
    8889    }
    8990    mHostCallback = pHostCallback;
     91    unmonitorClientList();
    9092    LogRelFlowFunc(("returning %Rrc\n", rc));
    9193    return rc;
     
    107109
    108110    LogRelFlowFunc(("\n"));
     111    if (mEnabled)
     112        return VINF_SUCCESS;
    109113    mSupportsShape = XShapeQueryExtension(mDisplay, &event, &error);
    110114    mEnabled = true;
     
    120124{
    121125    LogRelFlowFunc(("\n"));
     126    if (!mEnabled)
     127        return;
    122128    mEnabled = false;
    123129    unmonitorClientList();
     
    135141{
    136142    LogRelFlowFunc(("called\n"));
    137     XSelectInput(mDisplay, DefaultRootWindow(mDisplay), 0);
     143    XSelectInput(mDisplay, DefaultRootWindow(mDisplay), PropertyChangeMask);
    138144}
    139145
     
    270276    Display *pDisplay = (Display *)pvParam;
    271277
     278    XShapeSelectInput(pDisplay, pInfo->Core.Key, 0);
    272279    delete pInfo;
    273280    return VINF_SUCCESS;
     
    491498{
    492499    bool rc = false;
    493 
    494     LogRelFlowFunc(("\n"));
     500    Display *pDisplay = XOpenDisplay(NULL);
     501
     502    LogRelFlowFunc(("\n"));
     503    if (pDisplay == NULL)
     504        VBClFatalError(("Failed to open X11 display.\n"));
    495505    /* Message contents set to zero. */
    496506    XClientMessageEvent clientMessage = { ClientMessage, 0, 0, 0, 0, 0, 8 };
    497507
    498     if (XSendEvent(mDisplay, DefaultRootWindow(mDisplay), false,
    499                    SubstructureNotifyMask, (XEvent *)&clientMessage))
    500     {
    501         XFlush(mDisplay);
     508    if (XSendEvent(pDisplay, DefaultRootWindow(mDisplay), false,
     509                   PropertyChangeMask, (XEvent *)&clientMessage))
    502510        rc = true;
    503     }
     511    XCloseDisplay(pDisplay);
    504512    LogRelFlowFunc(("returning %RTbool\n", rc));
    505513    return rc;
  • 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};
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.h

    r55401 r57344  
    5959    int nextStateChangeEvent(void);
    6060
    61     /**
    62      * Interrupt an event wait and cause the current or next
    63      * @a nextStateChangeEvent call to return immediately.
    64      */
    65     int cancelEvent(void);
    66 
    6761    /** Thread function to monitor X11 window configuration changes. */
    6862    static DECLCALLBACK(int) x11MonitorThread(RTTHREAD self, void *pvUser);
  • trunk/src/VBox/Additions/x11/VBoxClient/testcase/tstSeamlessX11-auto.cpp

    r55401 r57344  
    4545#define TEST_DISPLAY ((Display *)0xffff)
    4646#define TEST_ROOT ((Window)1)
     47
     48extern void vbclFatalError(char *psz)
     49{
     50    RTPrintf("Fatal error: %s\n", psz);
     51    exit(1);
     52}
    4753
    4854extern "C" Display *XOpenDisplay(const char *display_name);
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