Skip to content

DPI scaling policy should use PassThrough on Windows to support common fractional scale factors #243

@b4shful

Description

@b4shful

Problem

I run a high DPI display (2560x1600 on a 16 inch laptop), on Windows my OS-wide display scaling is set to 150% (which is Windows' "Recommended" scale factor for this display).

When I run qFlipper, by default it appears a little "too small" for the screen:

Image

If I set QT_SCALE_FACTOR=1.5 and then launch qFlipper, the scaling is perfect:

Image

Both images are screenshots of the full screen, with the Settings window maximised in the background to help give an idea of proportions/scale

Potential cause/fix

On modern Windows systems, fractional scaling factors in increments of 25%/0.25 are very common, and in many cases set by default without the user having to change it.

Currently, qFlipper sets the High DPI scale factor rounding policy to RoundPreferFloor in application/main.cpp:

QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);

I note this was added in 701ffe5 "Improve GUI scaling behaviour".

Qt supports a scale factor rounding policy PassThrough, which would respect the scale factors set by Windows, including for non-integer values.

Windows has a well-defined system-wide DPI scaling factor, so PassThrough should work consistently and reliably. But I'm aware this would probably not be the preferred option on Linux, due to not having a single standard for DPI scaling... fragmented configuration... toolkits looking at different environment variables etc.

So to avoid drawbacks on other platforms, you could do something like:

#ifdef Q_OS_WIN
    QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#else
    QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor);
#endif

That way, on Windows, it would be correctly scaled out of the box with no additional workarounds required.

I will do some further testing to see if this would be the correct fix, but wanted to post as an issue rather than a PR to facilitate discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions