<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 3/27/21 4:35 AM, re.mcclue wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:UTI7QlTcxClhUI9_nVYjRU-8M0cNOAVQEuhv-RXNtAcUQ2BzH3G2CE9OWvHFkjbYhMtAqSQJKGHpkX4GlbFeurI7kT0xIwOC3hwOjeT38Zo=@protonmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div>A <code>XRRScreenResources</code> contains multiple <code>XRRModeInfo</code>
        and <code>RROutput</code> (which with <code>XRRGetOutputInfo()</code>
        effectively means <code>XRROutputInfo</code>). Therefore, a
        screen can have many outputs which in turn, can have many
        modes. I can restrict myself to only <code>(XRROutputInfo
          *)->connection == RR_Connected</code> outputs, however this
        still leaves many possible modes. The, rate is a property of the
        mode. Because of this many-to-many
        relationship, how can I determine what the active rate is?</div>
      <div>In other words:<br>
      </div>
      <p><br>
      </p>
      <pre><code>  XRRScreenResources *res = XRRGetScreenResources(display, default_root_window);
  for (int i = 0; i < res->nmode; ++i) {
    XRRModeInfo *mode_info = &res->modes[i];
    // How do you verify this is the active rate?
    double rate = (double)mode_info->dotClock / ((double)mode_info->hTotal * (double)mode_info->vTotal));
  }
</code>
</pre>
      <div><br>
      </div>
    </blockquote>
    <p>An Output is active if there is a CRTC driving it. The active
      mode for a CRTC is returned in the <a moz-do-not-send="true"
href="https://gitlab.freedesktop.org/xorg/proto/xorgproto/blob/master/randrproto.txt#L1062">RRGetCrtcInfo
        reply</a>. This reply also tells you which outputs are currently
      being driven by that CRTC.</p>
    <p>Note that even if an Output is connected (i.e. <code>(XRROutputInfo
        *)->connection == RR_Connected</code>) it's not necessarily
      actually turned on. Conversely, it's possible for a CRTC to be
      driving an Output with a mode even if no monitor is actually
      connected to that Output. So if you just want to figure out which
      display heads (CRTCs) are active and what their refresh rates are,
      I would recommend ignoring the <code>connection</code> state
      completely and only look at the states of the CRTCs.<br>
    </p>
    <p>-- Aaron</p>
  </body>
</html>