Fix for Xinerama



On the new debian system, the xinerama library is “” (and no more “”).
I propose to update the code to:

void juce_updateMultiMonitorInfo (Array <Rectangle<int> >& monitorCoords, const bool /*clipToWorkArea*/)
    if (display == 0)

    int major_opcode, first_event, first_error;

    ScopedXLock xlock;
    if (XQueryExtension (display, "XINERAMA", &major_opcode, &first_event, &first_error))
        typedef Bool (*tXineramaIsActive) (Display*);
        typedef XineramaScreenInfo* (*tXineramaQueryScreens) (Display*, int*);

        static tXineramaIsActive xXineramaIsActive = 0;
        static tXineramaQueryScreens xXineramaQueryScreens = 0;

        if (xXineramaIsActive == 0 || xXineramaQueryScreens == 0)
            void* h = dlopen ("", RTLD_GLOBAL | RTLD_NOW);
+            if (h == 0) h = dlopen ("", RTLD_GLOBAL | RTLD_NOW);
            if (h != 0)

The basic idea in linux generally is that dlopen checks either full path or soname. The xinerama library has soname of “” (meaning version 1 of the API of xinerama).
When they change the API, the soname increase so it doesn’t break code using old API.

So I don’t know on other Linux system, but at least on gentoo, ubuntu, and debian, the dlopen code should load the “.so.API” version (for xinerama, API == 1).
In a perfect world, we should find out the soname (the command readelf -a /path/to/ | grep “SONAME” returns it) before writing the dlopen call.

Please notice that /usr/lib/ is in the xinerama-dev package (because you need it when you link) but it’s not in the default xinerama package.


Thanks, that sounds like a good suggestion!