VirtualBox

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


Ignore:
Timestamp:
Aug 14, 2015 3:04:46 PM (9 years ago)
Author:
vboxsync
Message:

Additions/x11/VBoxClient: remove global VT switching handling again.

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

Legend:

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

    r55401 r57357  
    5151    /** Run the service main loop */
    5252    int (*run)(struct VBCLSERVICE **ppInterface, bool fDaemonised);
    53     /** Pause the service loop.  This is used to allow the service to disable
    54      * itself when the X server is switched out.  It must be safe to call on a
    55      * different thread if the VT monitoring thread is used. */
    56     int (*pause)(struct VBCLSERVICE **ppInterface);
    57     /** Resume after pausing.  The same applies here as for @a pause. */
    58     int (*resume)(struct VBCLSERVICE **ppInterface);
    5953    /** Clean up any global resources before we shut down hard.  The last calls
    6054     * to @a pause and @a resume are guaranteed to finish before this is called.
     
    7771}
    7872
    79 union _XEvent;  /* We do not want to pull in the X11 header files here. */
    80 extern void VBClCheckXOrgVT(union _XEvent *pEvent);
    81 extern int VBClStartVTMonitor();
    82 
    8373extern struct VBCLSERVICE **VBClGetClipboardService();
    8474extern struct VBCLSERVICE **VBClGetSeamlessService();
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r54859 r57357  
    314314    VBClServiceDefaultHandler, /* init */
    315315    run,
    316     VBClServiceDefaultHandler, /* pause */
    317     VBClServiceDefaultHandler, /* resume */
    318316    cleanup
    319317};
  • trunk/src/VBox/Additions/x11/VBoxClient/display.cpp

    r57356 r57357  
    388388    init,
    389389    run,
    390     VBClServiceDefaultHandler, /* pause */
    391     VBClServiceDefaultHandler, /* resume */
    392390    cleanup
    393391};
  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r57283 r57357  
    33413341    VBClServiceDefaultHandler, /* init */
    33423342    run,
    3343     VBClServiceDefaultHandler, /* pause */
    3344     VBClServiceDefaultHandler, /* resume */
    33453343    cleanup
    33463344};
  • trunk/src/VBox/Additions/x11/VBoxClient/hostversion.cpp

    r55600 r57357  
    208208    VBClServiceDefaultHandler, /* init */
    209209    run,
    210     VBClServiceDefaultHandler, /* pause */
    211     VBClServiceDefaultHandler, /* resume */
    212210    VBClServiceDefaultCleanup
    213211};
  • trunk/src/VBox/Additions/x11/VBoxClient/main.cpp

    r56995 r57357  
    115115    XGetErrorText(pDisplay, pError->error_code, errorText, sizeof(errorText));
    116116    LogRelFlow(("VBoxClient: an X Window protocol error occurred: %s (error code %d).  Request code: %d, minor code: %d, serial number: %d\n", errorText, pError->error_code, pError->request_code, pError->minor_code, pError->serial));
    117     return 0;  /* We should never reach this. */
     117    return 0;
    118118}
    119119
     
    152152}
    153153
    154 /** Check whether X.Org has acquired or lost the current virtual terminal and
    155  * call the service @a pause() or @a resume() call-back if appropriate.
    156  * The functionality is provided by the vboxvideo driver for pre-1.16 X servers
    157  * and by 1.16 and later series servers.
    158  * This can either be called directly from a service's event loop or the service
    159  * can call VBClStartVTMonitor() to start an event loop in a separate thread.
    160  * Property notification for the root window should be selected first.  Services
    161  * are not required to check VT changes if they do not need the information.
    162  * @param  pEvent an event received on a display connection which will be
    163  *                checked to see if it is change to the XFree86_has_VT property
    164  */
    165 void VBClCheckXOrgVT(union _XEvent *pEvent)
    166 {
    167     Atom actualType;
    168     int actualFormat;
    169     unsigned long cItems, cbLeft;
    170     bool fHasVT = false;
    171     unsigned long *pValue;
    172     int rc;
    173     Display *pDisplay = pEvent->xany.display;
    174     Atom hasVT = XInternAtom(pDisplay, "XFree86_has_VT", False);
    175 
    176     if (   pEvent->type != PropertyNotify
    177         || pEvent->xproperty.window != DefaultRootWindow(pDisplay)
    178         || pEvent->xproperty.atom != hasVT)
    179         return;
    180     XGetWindowProperty(pDisplay, DefaultRootWindow(pDisplay), hasVT, 0, 1,
    181                        False, XA_INTEGER, &actualType, &actualFormat, &cItems,
    182                        &cbLeft, (unsigned char **)&pValue);
    183     if (cItems && actualFormat == 32)
    184     {
    185         fHasVT = *pValue != 0;
    186         XFree(pValue);
    187     }
    188     else
    189         return;
    190     if (fHasVT)
    191     {
    192         rc = (*g_pService)->resume(g_pService);
    193         if (RT_FAILURE(rc))
    194             VBClFatalError(("Error resuming the service: %Rrc\n", rc));
    195     }
    196     if (!fHasVT)
    197     {
    198         rc = (*g_pService)->pause(g_pService);
    199         if (RT_FAILURE(rc))
    200             VBClFatalError(("Error pausing the service: %Rrc\n", rc));
    201     }
    202 }
    203 
    204 /**
    205  * Thread which notifies the service when we switch to a different VT or back
    206  * and cleans up when the X server exits.
    207  * @note runs until programme exit.
    208  */
    209 static int pfnMonitorThread(RTTHREAD self, void *pvUser)
    210 {
    211     Display *pDisplay;
    212     bool fHasVT = true;
    213 
    214     pDisplay = XOpenDisplay(NULL);
    215     if (!pDisplay)
    216         VBClFatalError(("Failed to open the X11 display\n"));
    217     XSelectInput(pDisplay, DefaultRootWindow(pDisplay), PropertyChangeMask);
    218     while (true)
    219     {
    220         XEvent event;
    221 
    222         XNextEvent(pDisplay, &event);
    223         VBClCheckXOrgVT(&event);
    224     }
    225     return VINF_SUCCESS;  /* Should never be reached. */
    226 }
    227 
    228 /**
    229  * Start a thread which notifies the service when we switch to a different
    230  * VT or back, and terminates us when the X server exits.  This should be called
    231  * by most services which do not regularly run an X11 event loop.
    232  */
    233 int VBClStartVTMonitor()
    234 {
    235     return RTThreadCreate(NULL, pfnMonitorThread, NULL, 0,
    236                           RTTHREADTYPE_INFREQUENT_POLLER, 0, "MONITOR");
    237 }
    238 
    239154/**
    240155 * Print out a usage message and exit with success.
  • trunk/src/VBox/Additions/x11/VBoxClient/seamless.cpp

    r57344 r57357  
    355355    init,
    356356    run,
    357     VBClServiceDefaultHandler, /* pause */
    358     VBClServiceDefaultHandler, /* resume */
    359357    cleanup
    360358};
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