Aven on hiDPI screens

Wookey wookey at wookware.org
Wed Sep 8 15:56:02 BST 2021


On 2021-09-06 00:26 +0100, Olly Betts wrote:
> On Sun, Sep 05, 2021 at 10:44:50PM +0100, Wookey wrote:
> 
> > Has anyone found out how to make the aven text a readable size on such
> > displays? (menu items, icons, the survey tree and labels are all very
> > tiny).
> 
> IIRC before this, the survey pane was drawn at half the height and half
> the width (or presumably whatever fraction corresponds to the HiDPI-ness
> factor of your display), so while you probably had more readable text in
> menus, etc, around the edge of the window, the very important bit in the
> middle was rather broken.
> 
> > Ideally just setting the X DPI would make everything DTRT, but it
> > doesn't. Clearly far too many things are actually specified in pixels,
> > not sizes.
> 
> It's probably to do with the sizing and scaling of the OpenGL pane, but
> ideally it needs someone with an HiDPI display to sort it out.
> 
> See src/aven.cc for the current bodge:
> 
>     setenv("GDK_SCALE", "1", 1);
> 
> If you comment that out and rebuild, you'll hopefully see the problem.

I see. That explains why setting GDK_SCALE has no effect on aven.

So I can remove this nobble and see the issue (the main screen pane is 1/GDK_SCALE the size it should be). Some searching sugests that multiplying the pane size by GetContentScaleFactor() will fix things ( https://trac.wxwidgets.org/ticket/17391 ). However I have not been able to get this to build on stable without hitting:
aven.cc: In member function ‘virtual bool Aven::OnInit()’:
aven.cc:352:57: error: ‘GetContentScaleFactor’ was not declared in this scope

The docs (https://docs.wxwidgets.org/trunk/classwx_window.html) say that
#include <wx/window.h> should do the trick but it's not working for me.

grepping /usr/include/wx-3.0/ finds menations in
/usr/include/wx-3.0/wx/gtk/window.h
/usr/include/wx-3.0/wx/dc.h
/usr/include/wx-3.0/wx/window.h
so I tried #include <wx/dc.h> as well, but it didn't help.

(It also looks as if the function in wx/window.h just sets
GetContentScaleFactor to '1' anyway, but perhaps that is just a
default and it can be changed elsewhere?)

Below is my patch. Can anyone who groks C++ tell me what I'm doing
wrong in terms of scope?

So instead I tried just putting '2' as the scaling factor and it
doesn't seem to work either, so this may be the wrong approach.

Description: Arrange GL pane to be the right size
 Stop nobbling GDK_SCALE, and use GetContentScaleFactor() to request
pane of the right size.
Author: Wookey <wookey at debian.org>

---
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Last-Update: 2021-09-07

Index: survex-1.2.45/src/aven.cc
===================================================================
--- survex-1.2.45.orig/src/aven.cc
+++ survex-1.2.45/src/aven.cc
@@ -41,6 +41,8 @@
 
 #include <wx/confbase.h>
 #include <wx/image.h>
+#include <wx/window.h>
+#include <wx/dc.h>
 #if wxUSE_DISPLAY
 // wxDisplay was added in wx 2.5; but it may not be built for mingw (because
 // the header seems to be missing).
@@ -187,7 +189,7 @@ int main(int argc, char **argv)
     // FIXME: The OpenGL code needs work before scaling on hidpi displays will
     // work usefully, so for now disable such scaling (which simulates how
     // things are when using GTK2).
-    setenv("GDK_SCALE", "1", 1);
+    // setenv("GDK_SCALE", "1", 1);
 #endif
 #ifdef __WXMAC__
     // MacOS passes a magic -psn_XXXX command line argument in argv[1] which
@@ -347,7 +349,7 @@ bool Aven::OnInit()
     }
 
     // Create the main window.
-    m_Frame = new MainFrm(APP_NAME, pos, wxSize(width, height));
+    m_Frame = new MainFrm(APP_NAME, pos, wxSize(width * GetContentScaleFactor(), height * GetContentScaleFactor() ));
 
     // Select maximised if that's the saved state.
     if (maximized) {


Wookey
-- 
Principal hats:  Linaro, Debian, Wookware, ARM
http://wookware.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.survex.com/pipermail/survex/attachments/20210908/f6dde372/attachment.sig>


More information about the Survex mailing list