[Development] Respecting QGuiApplication::highDpiScaleFactorRoundingPolicy on Wayland

Morten Sørvig Morten.Sorvig at qt.io
Fri Sep 13 11:20:14 CEST 2024



> On 11 Sep 2024, at 12:38, Ilya Fedin <fedin-ilja2010 at ya.ru> wrote:
> 
> On Mon, 9 Sep 2024 11:03:04 +0400
> Ilya Fedin <fedin-ilja2010 at ya.ru> wrote:
> 
>> While most platforms seem to have fractional scaling via
>> QHighDpiScaling, Wayland is the first (and the only right now)
>> platform that got fractional devicePixelRatio on QPA level.
>> QHighDpiScaling doesn't handle that and the Wayland QPA just disables
>> fractional scaling support when it sees the policy is not PassThrough.
>> 
>> It's good that it does that at least but I believe this could be done
>> better. I have patches that make High DPI rounding policy to behave on
>> Wayland the same as on other platforms, allowing applications using a
>> rounding policy to render 1:1 with crsip fonts (currently the
>> compositor downscales as QPA disables fractional scaling support) and
>> actually respect the policy (downscaling means it's effectively always
>> Ceil).
>> 
>> Is there any interest in those changes?
>> 
>> The code changes are quite small actually: the main patch changing
>> mostly qhighdpiscaling.cpp is 179 lines long. The auxiliary qtwayland
>> patch to provide fractional QWaylandScreen::devicePixelRatio
>> (currently it provides only fractional
>> QWaylandWindow::devicePixelRatio) is 111 lines long.
> 
> Anyone? Morten Sørvig? Or is mailing list not the right place to discuss
> this?

Yes, though my SLA is sometimes measured in days, here.

It looks like there are two topics here (at least?)

- Should we expand the use of the QHighDpiScaling machinery and public API to also
handle QPA level DPR? So far this is only in use when Qt Gui is actually applying an UI
scale factor.

Strictly speaking, the Wayland platform plugin should not use the highDpiScaleFactorRoundingPolicy
property: that property controls how the Qt Gui UI scale factor is rounded. The
Wayland platform plugin provides a DPR value to Qt, not a UI scale factor.

Qt for WebAssembly is another platform with fractional devicePixelRatio on the QPA
level. So we want to keep these two platforms (and any other relevant platform) in sync
with regards to which settings they react to.

- How do we support applications which need DPR rounding

The options for rounding to int DPR are:

1) display the UI different (incorrect) visual size, but crisp.
2) display the UI at the correct visual size, downscaled.

I think you are suggesting implementing option 1) also for "native DPR” platforms?

Here my preference is for option 2): always present the UI at the correct size for the
user (not doing so is confusing), downscale if needed/possible.

This ties in with the QT_WIDGETS_HIGHDPI_DOWNSCALE feature currently
in development for widgets.

One challenge here is that support is somewhat fragmented if we want to provide
a cross-platform setting to opt out of fractional DPR by downscale: Qt only supports
it for hw accelerated widgets (requires QT_WIDGETS_RHI), and not all platforms
support it natively.

- Morten









More information about the Development mailing list