Re: [PATCH app/xdpyinfo v3] Use XRANDR 1.2 extension for reporting dimensions and resolution per output

2018-05-07 Thread Pali Rohár
On Wednesday 18 April 2018 15:45:20 Giuseppe Bilotta wrote:
> On Wed, Apr 18, 2018 at 3:33 PM, Pali Rohár  wrote:
> > On Thursday 12 April 2018 16:34:15 Adam Jackson wrote:
> >> This should print the RANDR data in a separate stanza after the main
> >> output, like the other extensions do. Again: the purpose of the core of
> >> xdpyinfo is to tell you what the connection block says. Don't make it
> >> print something else.
> >
> > This patch does not change anything in the output when command line
> > option for RANDR is not used. Therefore you would get same output as
> > before (without applying patch).
> >
> > And when RANDR is explicitly requested then it outputs correct dimension
> > information. Yes, it hides what is reported by connection block, but the
> > main problem is that this tools is not already used like you said. Users
> > and also scripts expects that they would get correct monitor/output
> > dimension from xdpyinfo and not something which do not match with their
> > physical monitor device.
> >
> > As Giuseppe said, this seems like a good compromise. When no parameter
> > is specified then xdpyinfo reports exactly same data as without this
> > patch. And with this patch which adds support for optional RANDR
> > parameter, then it reports dimensions for each monitor/output correctly.
> > So users would see what they are already expecting and want.
> 
> 
> No, in the RANDR case you are still replacing the core output, which
> is not what I suggested. Instead, the RANDR information should be
> provided _separately_ and _in addition to_ the core output. So instead
> of defining a useless print_none_info, put the RANDR code in
> print_randr_info and add _that_ to the known_extensions array.

Ok. I will put both core and randr information into output. But still I
think that those dimension information should be at one place and not
separated to different parts. It is also hard to find them when reading
output or parse.

-- 
Pali Rohár
pali.ro...@gmail.com


signature.asc
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH app/xdpyinfo v3] Use XRANDR 1.2 extension for reporting dimensions and resolution per output

2018-04-18 Thread Giuseppe Bilotta
On Wed, Apr 18, 2018 at 3:33 PM, Pali Rohár  wrote:
> On Thursday 12 April 2018 16:34:15 Adam Jackson wrote:
>> This should print the RANDR data in a separate stanza after the main
>> output, like the other extensions do. Again: the purpose of the core of
>> xdpyinfo is to tell you what the connection block says. Don't make it
>> print something else.
>
> This patch does not change anything in the output when command line
> option for RANDR is not used. Therefore you would get same output as
> before (without applying patch).
>
> And when RANDR is explicitly requested then it outputs correct dimension
> information. Yes, it hides what is reported by connection block, but the
> main problem is that this tools is not already used like you said. Users
> and also scripts expects that they would get correct monitor/output
> dimension from xdpyinfo and not something which do not match with their
> physical monitor device.
>
> As Giuseppe said, this seems like a good compromise. When no parameter
> is specified then xdpyinfo reports exactly same data as without this
> patch. And with this patch which adds support for optional RANDR
> parameter, then it reports dimensions for each monitor/output correctly.
> So users would see what they are already expecting and want.


No, in the RANDR case you are still replacing the core output, which
is not what I suggested. Instead, the RANDR information should be
provided _separately_ and _in addition to_ the core output. So instead
of defining a useless print_none_info, put the RANDR code in
print_randr_info and add _that_ to the known_extensions array.

-- 
Giuseppe "Oblomov" Bilotta
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH app/xdpyinfo v3] Use XRANDR 1.2 extension for reporting dimensions and resolution per output

2018-04-18 Thread Pali Rohár
On Thursday 12 April 2018 16:34:15 Adam Jackson wrote:
> This should print the RANDR data in a separate stanza after the main
> output, like the other extensions do. Again: the purpose of the core of
> xdpyinfo is to tell you what the connection block says. Don't make it
> print something else.

This patch does not change anything in the output when command line
option for RANDR is not used. Therefore you would get same output as
before (without applying patch).

And when RANDR is explicitly requested then it outputs correct dimension
information. Yes, it hides what is reported by connection block, but the
main problem is that this tools is not already used like you said. Users
and also scripts expects that they would get correct monitor/output
dimension from xdpyinfo and not something which do not match with their
physical monitor device.

As Giuseppe said, this seems like a good compromise. When no parameter
is specified then xdpyinfo reports exactly same data as without this
patch. And with this patch which adds support for optional RANDR
parameter, then it reports dimensions for each monitor/output correctly.
So users would see what they are already expecting and want.

-- 
Pali Rohár
pali.ro...@gmail.com
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH app/xdpyinfo v3] Use XRANDR 1.2 extension for reporting dimensions and resolution per output

2018-04-12 Thread Adam Jackson
On Thu, 2018-04-12 at 20:47 +0200, Pali Rohár wrote:
> XServer with enabled XRANDR 1.2 extension does not provide correct
> dimensions from DisplayWidthMM() and DisplayHeightMM() calls anymore.
> Values are calculated from fixed DPI 96.
> 
> Therefore when XRANDR 1.2 extension is enabled, present and user requested
> for it, instead use XRRGetScreenResources() and XRRGetOutputInfo() calls to
> get correct dimensions and resolution information.
> 
> Otherwise when XRANDR 1.2 extension is enabled, present and user did not
> request for it (which is default), show note that printed dimension does
> not have to be correct and instruct user to run xdpyinfo with -ext RANDR.

This should print the RANDR data in a separate stanza after the main
output, like the other extensions do. Again: the purpose of the core of
xdpyinfo is to tell you what the connection block says. Don't make it
print something else.

- ajax
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH app/xdpyinfo v3] Use XRANDR 1.2 extension for reporting dimensions and resolution per output

2018-04-12 Thread Pali Rohár
XServer with enabled XRANDR 1.2 extension does not provide correct
dimensions from DisplayWidthMM() and DisplayHeightMM() calls anymore.
Values are calculated from fixed DPI 96.

Therefore when XRANDR 1.2 extension is enabled, present and user requested
for it, instead use XRRGetScreenResources() and XRRGetOutputInfo() calls to
get correct dimensions and resolution information.

Otherwise when XRANDR 1.2 extension is enabled, present and user did not
request for it (which is default), show note that printed dimension does
not have to be correct and instruct user to run xdpyinfo with -ext RANDR.

Also update manual page and add information that xdpyinfo does not provide
correct information about DPI.

Signed-off-by: Pali Rohár 
---
Changes since v2:
* Fixed dimensions calculation when rotation is active
* Show XRANDR output only when explicitly requested
* Update manpage

Changes since v1:
* Fixed detection of presence of XRANDR 1.2
* Fixed resolution calculation when dimensions are zero
---
 Makefile.am  |   2 +
 configure.ac |  12 ++
 man/xdpyinfo.man |   7 
 xdpyinfo.c   | 117 ++-
 4 files changed, 128 insertions(+), 10 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 2f21dda..496094e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,6 +35,7 @@ AM_CFLAGS = \
$(DPY_XCOMPOSITE_CFLAGS) \
$(DPY_XINERAMA_CFLAGS) \
$(DPY_DMX_CFLAGS) \
+   $(DPY_XRANDR_CFLAGS) \
$(DPY_XTST_CFLAGS)
 
 xdpyinfo_LDADD = \
@@ -49,6 +50,7 @@ xdpyinfo_LDADD = \
$(DPY_XCOMPOSITE_LIBS) \
$(DPY_XINERAMA_LIBS) \
$(DPY_DMX_LIBS) \
+   $(DPY_XRANDR_LIBS) \
$(DPY_XTST_LIBS)
 
 xdpyinfo_SOURCES = \
diff --git a/configure.ac b/configure.ac
index 73dce26..4473faa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,6 +132,18 @@ else
echo "without dmx"
 fi
 
+AC_ARG_WITH(xrandr, AS_HELP_STRING([--without-xrandr],[Disable xrandr 1.2 
support.]),
+   [USE_XRANDR="$withval"], [USE_XRANDR="yes"])
+if test "x$USE_XRANDR" != "xno" ; then
+   PKG_CHECK_MODULES(DPY_XRANDR, xrandr >= 1.2,
+   [SAVE_CPPFLAGS="$CPPFLAGS"
+   CPPFLAGS="$CPPFLAGS $DPY_XRANDR_CFLAGS $DPY_X11_CFLAGS"
+   AC_CHECK_HEADERS([X11/extensions/Xrandr.h],,,[#include 
])
+   CPPFLAGS="$SAVE_CPPFLAGS"],[echo "not found"])
+else
+   echo "without xrandr 1.2"
+fi
+
 PKG_CHECK_MODULES(DPY_XTST, xtst,
[SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $DPY_XTST_CFLAGS $DPY_X11_CFLAGS"
diff --git a/man/xdpyinfo.man b/man/xdpyinfo.man
index c3d5c6d..5df44ea 100644
--- a/man/xdpyinfo.man
+++ b/man/xdpyinfo.man
@@ -51,6 +51,13 @@ Detailed information about a particular extension is 
displayed with the
 \fBall\fP, information about all extensions supported by both \fIxdpyinfo\fP
 and the server is displayed.
 .PP
+Do not use this utility for determining dimensions of monitor when XRANDR 1.2+
+extension is enabled for X screen, because it does not provide them. For
+determining physical dimensions or DPI of particular monitor use either
+.IR xrandr (__appmansuffix__)
+utility or call xdpyinfo with parameter \fB\-ext RANDR\fP (supported since
+xdpyinfo version 1.3.3).
+.PP
 If \fB-version\fP is specified, xdpyinfo prints its version and exits, without
 contacting the X server.
 .SH ENVIRONMENT
diff --git a/xdpyinfo.c b/xdpyinfo.c
index 152e32c..ac2526f 100644
--- a/xdpyinfo.c
+++ b/xdpyinfo.c
@@ -76,6 +76,10 @@ in this Software without prior written authorization from 
The Open Group.
 #  define DMX
 # endif
 
+# if HAVE_X11_EXTENSIONS_XRANDR_H
+#  define XRANDR
+# endif
+
 #endif
 
 #ifdef WIN32
@@ -137,6 +141,9 @@ in this Software without prior written authorization from 
The Open Group.
 #ifdef DMX
 #include 
 #endif
+#ifdef XRANDR
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -442,6 +449,10 @@ print_visual_info(XVisualInfo *vip)
vip->bits_per_rgb);
 }
 
+#ifdef XRANDR
+static Bool print_xrandr = False;
+#endif
+
 static void
 print_screen_info(Display *dpy, int scr)
 {
@@ -455,6 +466,14 @@ print_screen_info(Display *dpy, int scr)
 double xres, yres;
 int ndepths = 0, *depths = NULL;
 unsigned int width, height;
+Bool has_xrandr = False;
+#ifdef XRANDR
+int event_base, error_base;
+int major, minor;
+XRRScreenResources *res;
+XRROutputInfo *output;
+XRRCrtcInfo *crtc;
+#endif
 
 /*
  * there are 2.54 centimeters to an inch; so there are 25.4 millimeters.
@@ -464,18 +483,81 @@ print_screen_info(Display *dpy, int scr)
  * = N * 25.4 pixels / M inch
  */
 
-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: