VirtualBox

Changeset 83934 in vbox


Ignore:
Timestamp:
Apr 22, 2020 7:12:40 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137483
Message:

bugref:9637. Using a separate X11 connection for RandR event monitoring.

File:
1 edited

Legend:

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

    r83933 r83934  
    3939 *    # The order of the outputs (monitors) is assumed to be the same in RANDROUTPUT array and
    4040        XRRScreenResources.outputs array.
     41 *  - This code does 2 related but separate things: 1- It resizes and enables/disables monitors upon host's
     42      requests (see the infinite loop in run()). 2- it listens to RandR events (caused by this or any other X11 client)
     43      on a different thread and notifies host about the new monitor positions. See sendMonitorPositions(...). This is
     44      mainly work around since we have realized that vmsvga does not convey correct monitor positions thru FIFO.
    4145 */
    4246#include <stdio.h>
     
    111115{
    112116    Display *pDisplay;
     117    /* We use a separate connection for randr event listening for sharing  a
     118       single display object with resizing (main) and event listening threads ends up having a deadlock.*/
     119    Display *pDisplayRandRMonitoring;
    113120    Window rootWindow;
    114121    int iDefaultScreen;
     
    499506    XRRMonitorInfo *pMonitorInfo = NULL;
    500507#ifdef WITH_DISTRO_XRAND_XINERAMA
    501     pMonitorInfo = XRRGetMonitors(x11Context.pDisplay, DefaultRootWindow(x11Context.pDisplay), true, &iMonitorCount);
     508    pMonitorInfo = XRRGetMonitors(x11Context.pDisplayRandRMonitoring,
     509                                  DefaultRootWindow(x11Context.pDisplayRandRMonitoring), true, &iMonitorCount);
    502510#else
    503511    if (x11Context.pXRRGetMonitors)
    504         pMonitorInfo = x11Context.pXRRGetMonitors(x11Context.pDisplay, DefaultRootWindow(x11Context.pDisplay), true, &iMonitorCount);
     512        pMonitorInfo = x11Context.pXRRGetMonitors(x11Context.pDisplayRandRMonitoring,
     513                                                  DefaultRootWindow(x11Context.pDisplayRandRMonitoring), true, &iMonitorCount);
    505514#endif
    506515    if (!pMonitorInfo)
     
    519528        for (int i = 0; i < iMonitorCount; ++i)
    520529        {
    521             int iMonitorID = getMonitorIdFromName(XGetAtomName(x11Context.pDisplay, pMonitorInfo[i].name)) - 1;
     530            int iMonitorID = getMonitorIdFromName(XGetAtomName(x11Context.pDisplayRandRMonitoring, pMonitorInfo[i].name)) - 1;
    522531            if (iMonitorID >= x11Context.hOutputCount || iMonitorID == -1)
    523532                continue;
     
    543552{
    544553    XEvent event;
    545     XNextEvent(x11Context.pDisplay, &event);
     554    XNextEvent(x11Context.pDisplayRandRMonitoring, &event);
    546555    int eventTypeOffset = event.type - x11Context.hRandREventBase;
    547556    switch (eventTypeOffset)
     
    657666    }
    658667#ifdef WITH_DISTRO_XRAND_XINERAMA
    659     XRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, 0);
     668    XRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, 0);
    660669    XRRFreeScreenResources(x11Context.pScreenResources);
    661670#else
    662671    if (x11Context.pXRRSelectInput)
    663         x11Context.pXRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, 0);
     672        x11Context.pXRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, 0);
    664673    if (x11Context.pXRRFreeScreenResources)
    665674        x11Context.pXRRFreeScreenResources(x11Context.pScreenResources);
    666675#endif
    667676    XCloseDisplay(x11Context.pDisplay);
     677    XCloseDisplay(x11Context.pDisplayRandRMonitoring);
    668678}
    669679
     
    764774        VBClLogFatalError("%s called with bad argument\n", __func__);
    765775    x11Context.pDisplay = XOpenDisplay(NULL);
     776    x11Context.pDisplayRandRMonitoring = XOpenDisplay(NULL);
    766777    if (x11Context.pDisplay == NULL)
    767778        return;
     
    770781    {
    771782        XCloseDisplay(x11Context.pDisplay);
     783        XCloseDisplay(x11Context.pDisplayRandRMonitoring);
    772784        x11Context.pDisplay = NULL;
     785        x11Context.pDisplayRandRMonitoring = NULL;
    773786        return;
    774787    }
     
    778791    {
    779792        XCloseDisplay(x11Context.pDisplay);
     793        XCloseDisplay(x11Context.pDisplayRandRMonitoring);
    780794        x11Context.pDisplay = NULL;
     795        x11Context.pDisplayRandRMonitoring = NULL;
    781796        return;
    782797    }
     
    813828    /* Select the XEvent types we want to listen to. */
    814829#ifdef WITH_DISTRO_XRAND_XINERAMA
    815     XRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, x11Context.hEventMask);
     830    XRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, x11Context.hEventMask);
    816831#else
    817832    if (x11Context.pXRRSelectInput)
    818         x11Context.pXRRSelectInput(x11Context.pDisplay, x11Context.rootWindow, x11Context.hEventMask);
     833        x11Context.pXRRSelectInput(x11Context.pDisplayRandRMonitoring, x11Context.rootWindow, x11Context.hEventMask);
    819834#endif
    820835    x11Context.iDefaultScreen = DefaultScreen(x11Context.pDisplay);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette