Cimbali / pympress

Pympress is a simple yet powerful PDF reader designed for dual-screen presentations
https://cimbali.github.io/pympress/
GNU General Public License v2.0
1.18k stars 89 forks source link

Support proper Hi-DPI on Windows #302

Closed Cimbali closed 10 months ago

Cimbali commented 11 months ago

As discussed in https://github.com/Cimbali/pympress/discussions/300

Originally posted by innocenat November 22, 2023 Hello!

My situation is that, my Windows laptop is 1080p. I was presenting on a 2160p monitor, and the slides are really, really pixelated. I try looking through pympress.ini to see if there are any render resolution set but can't seem to find it. Am I missing anything?

Originally posted by innocenat December 1, 2023 […]

Basically it was a meeting room 80" 4K monitor, which default to 300% zoom on Windows. Hence, the blurriness/pixelated. When I changed the scaling to 100% the image is crisp.

While playing with scaling on Windows machine, I think the pympress is NOT considered high-DPI aware on Windows. Hence, Windows report post-scaled resolution to the software, causing the blurriness, as the presenter view also show the blurriness on the UI features when on scaled display.

It is possibly related to this unmerged Gtk PR. Workarounds to test:

  1. [x] limit scaling to strictly less than 200% (typically largest setting would be 175%) so we can get font scaling without graphical scaling
  2. [x] compare what happens when opening the window directly on the high-DPI monitor vs. moving the window there. pympress should remember window positions, so this is case of just closing and re-opening pympress when the bug is experienced.
  3. [x] compensate lack of scaling awareness by setting e.g. GDK_SCALE=0.5 GDK_DPI_SCALE=2 in the environment (presumably for 200% scaling, try 0.33 and 3 for 300%) as suggested in this superuser question

If the linked PR is indeed the root cause of the issue, possible fixes would be:

  1. patch gtk3 before building it (what gimp seems to have done?) since we distribute the library anyway
  2. find another way in which pympress can directly set the right Windows DPI-awareness setting
  3. if workaround 2 works, a hacky option would be to perform a content window opening + closing after detecting a mixed-DPI/high-DPI view, or – even hacker – to add a button to trigger this solution
Cimbali commented 11 months ago

Ok so I can reproduce the and:

I’ll try to investigate a build with a patched Gtk when I get the time.

Cimbali commented 10 months ago

The good news is it’s easy to patch gtk and the patch (from the Gtk PR linked above) fixes the issue. Now we just have to see if we get this merged upstream or need to maintain our own patched gtk3 for Windows.