VirtualBox

Changeset 18994 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Apr 17, 2009 2:24:31 PM (16 years ago)
Author:
vboxsync
Message:

Additions/x11/VBoxClient: run a dummy thread in the autoresize daemon to watch for X server termination

File:
1 edited

Legend:

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

    r18938 r18994  
    6565}
    6666
     67/** This thread just runs a dummy X11 event loop to be sure that we get
     68 * terminated should the X server exit. */
     69static int x11ConnectionMonitor(RTTHREAD, void *)
     70{
     71    XEvent ev;
     72    Display *pDisplay = XOpenDisplay(NULL);
     73    while (true)
     74        XNextEvent(pDisplay, &ev);
     75}
     76
    6777/**
    6878 * Display change request monitor thread function.
     
    7585{
    7686    LogFlowFunc(("\n"));
    77     /* Keep an open display so that we terminate if X11 does. */
    78     Display *pDisplay = XOpenDisplay(NULL);
    7987    uint32_t cx0 = 0, cy0 = 0, cBits0 = 0, iDisplay0 = 0;
    80     int rc = VbglR3GetLastDisplayChangeRequest(&cx0, &cy0, &cBits0, &iDisplay0);
     88    int rc = RTThreadCreate(NULL, x11ConnectionMonitor, NULL, 0,
     89                   RTTHREADTYPE_INFREQUENT_POLLER, 0, "X11 monitor");
     90    if (RT_FAILURE(rc))
     91        return rc;
     92    VbglR3GetLastDisplayChangeRequest(&cx0, &cy0, &cBits0, &iDisplay0);
    8193    while (true)
    8294    {
    8395        uint32_t cx = 0, cy = 0, cBits = 0, iDisplay = 0;
    8496        rc = VbglR3DisplayChangeWaitEvent(&cx, &cy, &cBits, &iDisplay);
    85         /* Make sure we are still connected to X.  If the X server has
    86          * terminated then we should get a resize event above. */
    87         XPending(pDisplay);
    8897        /* Ignore the request if it is stale */
    89         if ((cx != cx0) || (cy != cy0))
     98        if ((cx != cx0) || (cy != cy0) || RT_FAILURE(rc))
    9099        {
    91100                /* If we are not stopping, sleep for a bit to avoid using up too
     
    100109        cy0 = 0;
    101110    }
    102     XCloseDisplay(pDisplay);
    103111    LogFlowFunc(("returning VINF_SUCCESS\n"));
    104112    return VINF_SUCCESS;
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