On Wed, 30 Oct 2019 04:22:27 -0700 (PDT) Iwbnwif Yiw wrote:
IY> Firstly, thank you for the fast reply again. OT, but one day you should
IY> write a self-help book on how to consistently stay with a project through
IY> thick and thin!!
I've made a special effort for 3.1.3 release and I'm still continuing by
inertia for now but, to be honest, I really ought to stop spending so much
time on wx stuff and concentrate more on my work instead. I.e. objectively
speaking I'm pretty sure the most *self*-helping answer would be to not do
this at all. Luckily, I was never one for following anybody's advice,
including my own.
IY> > IY> I think the intention is that GTK+3 has display scaling built in
IY> > IY> and so a 100,100 rectangle will be scaled by the appropriate
IY> > IY> amount and converted to (for example) 200,200 physical pixels if
IY> > IY> the display scaling is 2.
IY> >
IY> > Yes, indeed.
IY> >
IY>
IY> Thank you for this confirmation. It was my fundamental misunderstanding
IY> that Windows doesn't do this (I assumed it did).
I'm not sure how to interpret this but, to be clear, MSW doesn't do any
scaling at all for us automatically, which is why we need to do it
ourselves. Both Cocoa and GTK perform the scaling internally, i.e. they
work with logical pixels, but MSW always works with physical pixels.
IY> Also there is a discussion here that kind of implies that fonts are scaled
IY> automatically, but other things aren't:
IY>
IY>
https://wiki.archlinux.org/index.php/HiDPI#GDK_3_(GTK_3)
OTOH
https://developer.gnome.org/gtk3/stable/gtk-x11.html seems to imply
that GDK_DPI_SCALE is useful for "scale-unaware applications", which would
make sense.
IY> I have tried (and so far failed) to work out how wxDataViewCtrl appears
IY> about right, but wxTreeCtrl, wxSTC and wxPropertyGrid all get it wrong.
The difference is, of course, that wxDataViewCtrl is native, i.e. uses GTK
mechanisms for scaling, while the rest of these classes are not. So it's
not surprising per se, it just means that we have to fix wxTreeCtrl &c to
do the right thing under GTK.
IY> > IY> I think that gdk_screen_get_resolution returns the user set font DPI
IY> > IY> (in my case 125).
IY> >
IY> > It doesn't make any sense to use font DPI for screen resolution, but
IY> > this doesn't necessarily prevent GTK from doing this, of course...
IY>
IY> I think this is just badly named. The description in the GDK manual
IY> says it *"Sets the resolution for font handling on the screen."* here:
IY>
IY>
https://developer.gnome.org/gdk3/stable/GdkScreen.html#gdk-screen-get-resolution
Ah, I see, thanks. Somehow I've missed this, even though I must have read
these docs a dozen of times. So this does look like the function to use, as
it should take into account all kinds of scaling and can deal with
fractional scaling. Unfortunately it's also the only DPI-related GTK
functions our code does _not_ use right now :-(
IY> There is also some useful information in this thread:
IY>
IY>
https://bugs.eclipse.org/bugs/show_bug.cgi?id=489771
I got a bit lost here...
IY> > So what does gtk_widget_get_scale_factor() return in this case? Still 1?
IY> >
IY>
IY> Yes, but it more depends on the value set for the general display scaling
IY> (e.g. GDK_SCALE) rather than the font scale (e.g. GDK_DPI_SCALE). It can
IY> only return an integer and appears to be rounded down (not exhaustively
IY> tested by me but see this table
IY>
https://bugs.eclipse.org/bugs/show_bug.cgi?id=489771#c40).
... but this table seems to confirm that gdk_screen_get_resolution() is the
function to use.
Unfortunately there is one big problem here: I don't see any equivalent
for this function in GdkMonitor, so it simply can't be used with multiple
monitors. So finally I still have no idea about what to do.
IY> Eran of Codelite fame has a pretty good understanding and Codelite is
IY> starting it handle it quite well - at least on the two platforms I use
IY> (Windows and Ubuntu). Also, I will try to be more organised in building a
IY> repository of useful information links and continue with the testing.
We basically need a way to get the DPI/scaling values compatible with what
everybody else uses. I.e. it's less important for them to be "right" (which
they should currently be in wxGTK, as we really compute DPI by dividing the
number of dots by the number of inches), than to be the same as in all the
other applications on the system. Unfortunately I still have no idea about
how to do it with GTK API.
The good thing is that if native GTK apps work correctly for you even with
fractional scaling, this ought to be possible. We "just" need to find out
how.
Regards,
VZ