Hello, this is still not acceptable. _Do not alter the main section output_, and move the XRANDR-specific information into its own extension-dedicated output function, instead of hacking around it with the print_none_info function.
On Mon, May 7, 2018 at 11:34 PM Pali Rohár <[email protected]> wrote: > - xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / > - ((double) DisplayWidthMM(dpy,scr))); > - yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) / > - ((double) DisplayHeightMM(dpy,scr))); > - > printf ("\n"); > printf ("screen #%d:\n", scr); > - printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n", > - XDisplayWidth (dpy, scr), XDisplayHeight (dpy, scr), > - XDisplayWidthMM(dpy, scr), XDisplayHeightMM (dpy, scr)); > - printf (" resolution: %dx%d dots per inch\n", > - (int) (xres + 0.5), (int) (yres + 0.5)); > + > +#ifdef XRANDR > + if (XRRQueryExtension (dpy, &event_base, &error_base) && > + XRRQueryVersion (dpy, &major, &minor) && > + (major > 1 || (major == 1 && minor >= 2))) > + has_xrandr = True; > +#endif > + > +#ifdef XRANDR > + if (has_xrandr && print_xrandr) > + { > + res = XRRGetScreenResources (dpy, RootWindow (dpy, scr)); > + if (res) { > + for (i = 0; i < res->noutput; ++i) { > + output = XRRGetOutputInfo (dpy, res, res->outputs[i]); > + if (!output || !output->crtc || output->connection != > RR_Connected) > + continue; > + > + crtc = XRRGetCrtcInfo (dpy, res, output->crtc); > + if (!crtc) { > + XRRFreeOutputInfo (output); > + continue; > + } > + > + /* width and height is reported according to rotation, but > mm_width and mm_height not */ > + if (crtc->rotation == RR_Rotate_0 || crtc->rotation == > RR_Rotate_180) { > + width = crtc->width; > + height = crtc->height; > + } else { > + width = crtc->height; > + height = crtc->width; > + } > + > + printf (" output: %s\n", output->name); > + printf (" dimensions: %ux%u pixels (%lux%lu > millimeters)\n", > + width, height, output->mm_width, output->mm_height); > + > + if (output->mm_width && output->mm_height) { > + xres = ((((double) width) * 25.4) / ((double) > output->mm_width)); > + yres = ((((double) height) * 25.4) / ((double) > output->mm_height)); > + } else { > + xres = 0; > + yres = 0; > + } > + printf (" resolution: %dx%d dots per inch\n", > + (int) (xres + 0.5), (int) (yres + 0.5)); > + > + XRRFreeCrtcInfo (crtc); > + XRRFreeOutputInfo (output); > + } > + XRRFreeScreenResources (res); > + } > + > + printf (" screen output: (union of all configured monitors)\n"); > + printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n", > + DisplayWidth (dpy, scr), DisplayHeight (dpy, scr), > + DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr)); > + > + xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / > + ((double) DisplayWidthMM(dpy,scr))); > + yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) / > + ((double) DisplayHeightMM(dpy,scr))); > + printf (" resolution: %dx%d dots per inch\n", > + (int) (xres + 0.5), (int) (yres + 0.5)); > + } > + else > +#endif > + { > + printf (" dimensions: %dx%d pixels (%dx%d millimeters)\n", > + DisplayWidth (dpy, scr), DisplayHeight (dpy, scr), > + DisplayWidthMM(dpy, scr), DisplayHeightMM (dpy, scr)); > + > + xres = ((((double) DisplayWidth(dpy,scr)) * 25.4) / > + ((double) DisplayWidthMM(dpy,scr))); > + yres = ((((double) DisplayHeight(dpy,scr)) * 25.4) / > + ((double) DisplayHeightMM(dpy,scr))); > + printf (" resolution: %dx%d dots per inch\n", > + (int) (xres + 0.5), (int) (yres + 0.5)); > + > + if (has_xrandr) > + printf (" NOTE: above information is obsoleted and may be > incorrect\n" > + " instead run `%s -ext RANDR' for correct > output\n\n", > + ProgramName); > + } > + > depths = XListDepths (dpy, scr, &ndepths); > if (!depths) ndepths = 0; > printf (" depths (%d): ", ndepths); > @@ -1316,6 +1410,10 @@ static int print_dmx_info(Display *dpy, const char > *extname) > > #endif /* DMX */ > > +#ifdef XRANDR > +static int print_none_info(Display *dpy, const char *extname) { return 1; } > +#endif > + > /* utilities to manage the list of recognized extensions */ > > > @@ -1369,6 +1467,9 @@ static ExtensionPrintInfo known_extensions[] = > #ifdef DMX > {"DMX", print_dmx_info, False}, > #endif > +#ifdef XRANDR > + {RANDR_NAME, print_none_info, False}, > +#endif > /* add new extensions here */ > }; > > @@ -1397,8 +1498,16 @@ mark_extension_for_printing(const char *extname) > { > int i; > > +#ifdef XRANDR > + if (strcmp(extname, RANDR_NAME) == 0) > + print_xrandr = True; > +#endif > + > if (strcmp(extname, "all") == 0) > { > +#ifdef XRANDR > + print_xrandr = True; > +#endif > for (i = 0; i < num_known_extensions; i++) > known_extensions[i].printit = True; > } > -- > 2.11.0 > -- Giuseppe "Oblomov" Bilotta _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
