FluffyMan
FluffyMan

Reputation: 31

libxrandr library: how to change properties of connected monitors?

I wrote an application using C++/Qt and libxrandr library to change the resolution and orientation of monitor. But I must extend the functionality. Help me please understand how to do the following:

  1. get a list of connected monitors
  2. change the resolution and orientation of each of them
  3. place them against each other (for example, the first monitor on the left, second from right)

Upvotes: 1

Views: 1886

Answers (1)

FluffyMan
FluffyMan

Reputation: 31

problem solved

XRROutputInfo *output_first_info = XRRGetOutputInfo(dpy, sr, sr->outputs[X]);
XRRSetCrtcConfig(dpy, sr, output_first_info->crtc, CurrentTime, XM, YM, sr->modes[M].id, R, &sr->outputs[X], 1);

where X - number of monitor to configure XM, YM - coordinates in virtual screen M - number of mode

get list of modes for connected monitors:

     

 

int jj = 0;
        for (int i = 0; i < sr->noutput; i++)
        {
            XRROutputInfo *output_info = XRRGetOutputInfo (dpy, sr, sr->outputs[i]);
            XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(dpy, sr, output_info->crtc);

            for (int j = jj; j < output_info->nmode; j++)
            {
                qDebug() << output_info->name << sr->modes[j].name << j;

                jj++;
            }
        }

Upvotes: 2

Related Questions