Font size with 2 monitors on GTK3

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Font size with 2 monitors on GTK3

Frédéric
Hi,

A few months ago, my application worked well. Now I have some issues
and I cannot remember exactly when it started because I update from
time to time wxwidgets to the current master and I do not check in
details (halas) the part of my program that exhibits an issue.

My program draws a preview of a document in a window. For this to work
well with fonts, I need to scale the fonts according to the size of
the preview window so that everything scales proportionnaly when I
change the size of the window. In the calculation, I need to use the
DPI of the screen and up to now I have always used wxGetDisplayPPI().

My laptop has a display with 1920x1080 resolution and an external
display with 2560x1440 resolution plugged via HDMI.

What happens now is the following:
1. if the application runs on the laptop display with the external
monitor off AND unplugged, everything is fine.
2. if I plug the external monitor with the monitor on or off, whatever
screen the application runs on, the fonts are too large.

So my question is: has anything changed in the pas 6-8 months about
wxGetDisplayPPI()? I found on the list that some per-window DPI has
been introduced. I wonder if this is not the reason why I see those
troubles.

Kind regards,

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
On Mon, 8 Oct 2018 10:55:23 +0200 Frédéric wrote:

F> My laptop has a display with 1920x1080 resolution and an external
F> display with 2560x1440 resolution plugged via HDMI.
F>
F> What happens now is the following:
F> 1. if the application runs on the laptop display with the external
F> monitor off AND unplugged, everything is fine.
F> 2. if I plug the external monitor with the monitor on or off, whatever
F> screen the application runs on, the fonts are too large.

 To be honest, I'm not sure how could this happen, i.e. why would the
sole presence of another monitor affect anything happening on the main
one.

F> So my question is: has anything changed in the pas 6-8 months about
F> wxGetDisplayPPI()?

 Not AFAIK, but maybe some of my recent changes have done this
inadvertently. If so, this must have been done by the commit
c2162792cf24f2d59024bd06a921fd1ffde4f937 so you could try reverting it and
checking if it's really the case.

F> I found on the list that some per-window DPI has been introduced.

 It hasn't been introduced yet, although it's planned. And the first step
of it the addition of wxDisplay::GetPPI() which is done by this PR:

        https://github.com/wxWidgets/wxWidgets/pull/963

So I'd recommend applying it and checking if it changes anything for you
(normally it shouldn't) and also what does GetPPI() return for both of your
displays, to see if it works for you.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Font size with 2 monitors on GTK3

Frédéric
> F> So my question is: has anything changed in the pas 6-8 months about
> F> wxGetDisplayPPI()?
>
>  Not AFAIK, but maybe some of my recent changes have done this
> inadvertently. If so, this must have been done by the commit
> c2162792cf24f2d59024bd06a921fd1ffde4f937 so you could try reverting it and
> checking if it's really the case.

c2162792cf24f2d59024bd06a921fd1ffde4f937^ is good
(c98d504b6d636365fd7543d74bcb646eecfc5d17)
c2162792cf24f2d59024bd06a921fd1ffde4f937 is bad

so yes c2162792cf24f2d59024bd06a921fd1ffde4f937 is to be blamed.

Thanks,

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[2]: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
On Wed, 10 Oct 2018 06:41:59 +0200 Frédéric wrote:

F> > F> So my question is: has anything changed in the pas 6-8 months about
F> > F> wxGetDisplayPPI()?
F> >
F> >  Not AFAIK, but maybe some of my recent changes have done this
F> > inadvertently. If so, this must have been done by the commit
F> > c2162792cf24f2d59024bd06a921fd1ffde4f937 so you could try reverting it and
F> > checking if it's really the case.
F>
F> c2162792cf24f2d59024bd06a921fd1ffde4f937^ is good
F> (c98d504b6d636365fd7543d74bcb646eecfc5d17)
F> c2162792cf24f2d59024bd06a921fd1ffde4f937 is bad
F>
F> so yes c2162792cf24f2d59024bd06a921fd1ffde4f937 is to be blamed.

 Thanks for testing. As this commit didn't change wxGetDisplayPPI(), it's
the return value of wxGetDisplaySize() which must have changed. Previously
it used gdk_screen_{width,height}() functions while now it uses
gdk_screen_get_monitor_geometry(), so it would seem that the latter must
return different values somehow... Could you please run the display sample
on your system and check what does it return as resolution for both
displays? Is it really wrong?

 TIA,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: Font size with 2 monitors on GTK3

Frédéric
>  Thanks for testing. As this commit didn't change wxGetDisplayPPI(), it's
> the return value of wxGetDisplaySize() which must have changed. Previously
> it used gdk_screen_{width,height}() functions while now it uses
> gdk_screen_get_monitor_geometry(), so it would seem that the latter must
> return different values somehow... Could you please run the display sample
> on your system and check what does it return as resolution for both
> displays? Is it really wrong?

The display sample gives:
Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
1440)-(1920, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
0)-(2560, 1440), Primary: no, Current: (1920x1080, 24bpp, 60Hz)

So it seems all fine apart maybe for "Current" which is always the
same but I do not know what it represents. Note that the values are
the same if I run the sample on display 0 or 1.

If I run the sample with external display unplugged, so with only the
laptop display, I get something different:
Display 0: Origin: (0, 0), Size: (1920, 1080), Client area is (0,
0)-(1846, 1080), Current: (1920x1080, 24bpp, 60Hz)
So it is strange that the task bar is taken into account (I put it on
the right hand side) but wasn't with the 2 display version.

Kind regards,

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[4]: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
On Wed, 10 Oct 2018 17:02:25 +0200 Frédéric wrote:

F> >  Thanks for testing. As this commit didn't change wxGetDisplayPPI(), it's
F> > the return value of wxGetDisplaySize() which must have changed. Previously
F> > it used gdk_screen_{width,height}() functions while now it uses
F> > gdk_screen_get_monitor_geometry(), so it would seem that the latter must
F> > return different values somehow... Could you please run the display sample
F> > on your system and check what does it return as resolution for both
F> > displays? Is it really wrong?
F>
F> The display sample gives:
F> Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
F> 1440)-(1920, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
F> Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
F> 0)-(2560, 1440), Primary: no, Current: (1920x1080, 24bpp, 60Hz)
F>
F> So it seems all fine

 I'm a bit surprised by (320, 1440) origin, but if this is how your
monitors are actually positioned, then this indeed looks correct to me.

 You don't seem to be using the latest master, which is a pity as I'd like
to see if the PPI is correct for both monitors. Please let me know if you
can check this later.

F> apart maybe for "Current" which is always the same but I do not know
F> what it represents.

 "Current" shows the video mode (the sample also allows changing it) and
it's definitely wrong, but I guess retrieving or changing modes for
non-primary monitor is just not supported with X11-based ports.

F> Note that the values are the same if I run the sample on display 0 or 1.

 Yes, this is to be expected, the display numbers are fixed and don't
change just because you start the application on another monitor.

F> If I run the sample with external display unplugged, so with only the
F> laptop display, I get something different:
F> Display 0: Origin: (0, 0), Size: (1920, 1080), Client area is (0,
F> 0)-(1846, 1080), Current: (1920x1080, 24bpp, 60Hz)
F> So it is strange that the task bar is taken into account (I put it on
F> the right hand side) but wasn't with the 2 display version.

 Yes, this definitely seems wrong to me. Are these results with GTK+ 2 or
3?

 The real question is, however, why did wxGetDisplayPPI() return value
change for you. If the current results are correct, then the old ones must
have been wrong... Or are you testing with the pre-c216279 version?


 Ideally, I'd like to see the results with both c216279^ (i.e. before all
the recent changes) and the latest master, to see what has changed in your
setup.

 TIA,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re[4]: Font size with 2 monitors on GTK3

Frédéric
>  I'm a bit surprised by (320, 1440) origin, but if this is how your
> monitors are actually positioned, then this indeed looks correct to me.

Yes, the large monitor is on top of the laptop which is roughly centered below.

>  You don't seem to be using the latest master, which is a pity as I'd like
> to see if the PPI is correct for both monitors. Please let me know if you
> can check this later.

What I showed was with commit 613c686d73 so not quite the latest
master but post c216279

> F> If I run the sample with external display unplugged, so with only the
> F> laptop display, I get something different:
> F> Display 0: Origin: (0, 0), Size: (1920, 1080), Client area is (0,
> F> 0)-(1846, 1080), Current: (1920x1080, 24bpp, 60Hz)
> F> So it is strange that the task bar is taken into account (I put it on
> F> the right hand side) but wasn't with the 2 display version.
>
>  Yes, this definitely seems wrong to me. Are these results with GTK+ 2 or
> 3?

GTK+3: 3.22.30

>  The real question is, however, why did wxGetDisplayPPI() return value
> change for you. If the current results are correct, then the old ones must
> have been wrong... Or are you testing with the pre-c216279 version?

So no (see above).

>  Ideally, I'd like to see the results with both c216279^ (i.e. before all
> the recent changes) and the latest master, to see what has changed in your
> setup.

OK, I will rebuild c216279^

Thanks,

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[6]: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
On Wed, 10 Oct 2018 19:01:06 +0200 Frédéric wrote:

F> >  You don't seem to be using the latest master, which is a pity as I'd like
F> > to see if the PPI is correct for both monitors. Please let me know if you
F> > can check this later.
F>
F> What I showed was with commit 613c686d73 so not quite the latest
F> master but post c216279

 Unfortunately 613c686d73 predates 54ef52fbd9 which further changes the
same code. Ideal would be to retest with it or later commit.

 TIA,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re[6]: Font size with 2 monitors on GTK3

Frédéric
>  Unfortunately 613c686d73 predates 54ef52fbd9 which further changes the
> same code. Ideal would be to retest with it or later commit.

So here are the results:

* When both monitors are enabled:

- 2018-09-30: c98d504b6d (c216279^):
Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
1440)-(1920, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
0)-(2560, 1440), Primary: no, Current: (1920x1080, 24bpp, 60Hz)
wxDisplayPPI() gives 96*96

- 2018-10-10: b0c025e9fd (latest):
Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
1440)-(1920, 1080), Resolution: 72*41, Depth: 24, Primary: yes,
Current: (1920x1080, 24bpp, 60Hz)
Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
0)-(2560, 1440), Resolution: 118*118, Depth: 24, Primary: no, Current:
(1920x1080, 24bpp, 60Hz)
wxDisplayPPI() gives 72*41

So yes, the resultion seems bad (72*41) in the first display.

* When just the laptop monitor is enabled:

- 2018-09-30: c98d504b6d (c216279^):
Display 0: Origin: (0, 0), Size: (1920, 1080), Client area: (0,
0)-(1846, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
wxDisplayPPI() gives 96*96

- 2018-10-10: b0c025e9fd (latest):
Display 0: Origin: (0, 0), Size: (1920, 1080), Client area: (0,
0)-(1846, 1080), Resolution: 96*96, Depth: 24, Primary: yes, Current:
(1920x1080, 24bpp, 60Hz)
wxDisplayPPI() gives 96*96

Does that help?

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[8]: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
On Wed, 10 Oct 2018 20:22:02 +0200 Frédéric wrote:

F> >  Unfortunately 613c686d73 predates 54ef52fbd9 which further changes the
F> > same code. Ideal would be to retest with it or later commit.
F>
F> So here are the results:
F>
F> * When both monitors are enabled:
F>
F> - 2018-09-30: c98d504b6d (c216279^):
F> Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
F> 1440)-(1920, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
F> Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
F> 0)-(2560, 1440), Primary: no, Current: (1920x1080, 24bpp, 60Hz)
F> wxDisplayPPI() gives 96*96
F>
F> - 2018-10-10: b0c025e9fd (latest):
F> Display 0: Origin: (320, 1440), Size: (1920, 1080), Client area: (320,
F> 1440)-(1920, 1080), Resolution: 72*41, Depth: 24, Primary: yes,

 OK, so this is totally wrong :-( I have no idea what's going on here and
even less why does the result change depending on whether the other display
is plugged in or not, but as we just use the results returned by the GDK
functions it seems that we have no choice but to revert to using the old
way for the primary display, as it was clearly more correct. I'll try to do
it soon.

F> Display 1: Origin: (0, 0), Size: (2560, 1440), Client area: (0,
F> 0)-(2560, 1440), Resolution: 118*118, Depth: 24, Primary: no

 This is also questionable... Is 118DPI correct (this would be scaling
factor of 1.23, so I suspect it isn't)?

F> * When just the laptop monitor is enabled:
F>
F> - 2018-09-30: c98d504b6d (c216279^):
F> Display 0: Origin: (0, 0), Size: (1920, 1080), Client area: (0,
F> 0)-(1846, 1080), Primary: yes, Current: (1920x1080, 24bpp, 60Hz)
F> wxDisplayPPI() gives 96*96
F>
F> - 2018-10-10: b0c025e9fd (latest):
F> Display 0: Origin: (0, 0), Size: (1920, 1080), Client area: (0,
F> 0)-(1846, 1080), Resolution: 96*96, Depth: 24, Primary: yes, Current:
F> (1920x1080, 24bpp, 60Hz)
F> wxDisplayPPI() gives 96*96
F>
F> Does that help?

 Yes, thank you, it helps to understand the problem. Unfortunately it
doesn't explain how to get the actual DPI using GDK API if the functions
apparently provided exactly for this return wrong results :-(

VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re[6]: Font size with 2 monitors on GTK3

Frédéric
In reply to this post by Frédéric
Le mer. 10 oct. 2018 à 20:22, Frédéric <[hidden email]> a écrit :
>
> >  Unfortunately 613c686d73 predates 54ef52fbd9 which further changes the
> > same code. Ideal would be to retest with it or later commit.

One more information: the physical dpi, if I measure the screen size is about:
Display 0: 1920 pixels / (34.55 cm/(2.54 cm/in)) = 141 pixels/in
Display 1: 2560 pixels / (55.3 cm/(2.54 cm/in)) = 118 pixels/in

If I calculate 1920/(55.3/2.54), I get 88 pixels/in, this is the problem.

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: Re[8]: Font size with 2 monitors on GTK3

Frédéric
In reply to this post by Vadim Zeitlin-4
>  OK, so this is totally wrong :-( I have no idea what's going on here

Please, look at the picture of the arrangement of my displays attached
and you will understand. To calculate the dpi, apparently, you use the
total physical width and total physical height of all the displays but
you keep the pixel numbers of the current display.

F

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users

display-location.png (9K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re[6]: Font size with 2 monitors on GTK3

Frédéric
In reply to this post by Frédéric
> If I calculate 1920/(55.3/2.54), I get 88 pixels/in, this is the problem.
and vertically, it would give:
1080/((34.55+55.3) cm/(2.54 cm/in)) = 31 pixels/in

so 88x31, that's not exactly 72x41 but its close, isn't it?

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[8]: Font size with 2 monitors on GTK3

Vadim Zeitlin-4
 Hello again,

 I've created https://github.com/wxWidgets/wxWidgets/pull/995 with some
fixes for the issues discussed in this thread.

 Just in case it can be useful, here is a small GTK+ program I used for
testing:

        https://gist.github.com/vadz/074d3059b35017f79c2edb754deaa25e

If you still see anything very wrong, please compile and run it and report
its results.

 Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment