Novice trying to understand Xrandr and multi monitor setup

TJ Olaes contact at olaes.net
Wed May 25 03:38:53 UTC 2016


Good evening.

I have a dual monitor setup and am trying to figure out why ScreenCount
returns 1.  My code is as follows:

/**
 * Compiles with:
 * g++ -std=c++11 queryx11.cpp -lX11 -o queryx11
 */

#include <iostream>
#include <memory>

#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>

int main(void) {
        auto display = std::unique_ptr<Display, int(*)(Display*)>(
                XOpenDisplay(NULL),
                XCloseDisplay
                );
        if (!display) {
                std::cerr << "Cannot open display" << std::endl;
                return 1;
        }

        std::cout << "ScreenCount returns: " << ScreenCount(display.get())
<< std::endl;
        std::cout << "DisplayString returns: " <<
DisplayString(display.get()) << std::endl;
        std::cout << "DefaultScreen returns: " <<
DefaultScreen(display.get()) << std::endl;

        return 0;
}

This returns:

ScreenCount returns: 1
DisplayString returns: :0
DefaultScreen returns: 0

In my Xorg.0.log, the following lines are shown:

[     4.397] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[     4.398] (==) No Layout section.  Using the first Screen section.
[     4.398] (==) No screen section available. Using defaults.
[     4.398] (**) |-->Screen "Default Screen Section" (0)
[     4.398] (**) |   |-->Monitor "<default monitor>"
[     4.399] (==) No monitor specified for screen "Default Screen Section".
        Using a default monitor configuration.
[     4.399] (==) Automatically adding devices
[     4.399] (==) Automatically enabling devices
[     4.399] (==) Automatically adding GPU devices

FWIW I'm using Xrandr, and I've tried doing "xrandr --auto" just to see
what it detects and I still get the same result.  I'm completely lost at
this point and would appreciate any help.

Thank you for your time.

-TJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20160524/a0052151/attachment.html>


More information about the xorg mailing list