Qt: Fractional scaling on X11 with Nvidia proprietary driver
It seems that on x11, if Nvidia proprietary driver is used, Qt applications which use fractional scaling becomes visually broken. I know that this is not caused by VLC itself, so I'm marking this as "incident" instead of issue. Below, you can find some notes on the matter.
- Some desktop environments, such as KDE Plasma, seem to set environment variable
QT_SCREEN_SCALE_FACTORS, to adjust application's scaling. However, this usage is incorrect as according to Qt docs this is reserved for debugging purposes. According to my experiment, Qt uses it as final value and does not apply newly addedQApplication::setHighDpiScaleFactorRoundingPolicy(), which allows rounding fractional scaling.- One solution might be to "unset" this environment variable unconditionally so that Qt gets the scaling factor naturally, and then applies the rounding. I'm not sure if it is feasible to override the environment variable, though because Qt might not be able to get the intended scaling for the screen.
- Another solution might be to construct a temporary
QApplicationto get the device pixel ratio to see if it is fractional, and then apply own rounding. This might be a good way to resolve for Qt versions < 5.14 sinceQApplication::setHighDpiScaleFactorRoundingPolicy()is added in 5.14. OrQT_SCREEN_SCALE_FACTORScan be parsed before Qt does and be edited, probably. - Disabling high DPI scaling altogether is also a solution. But it seems to be necessary, at least for the native part of the user interface.
- KWin + X11 + Nvidia driver + Fractional scaling + Compositor integration enabled, makes resizing to freeze the application.
- According to my experiment, this is not caused by VLC. This happens when a child widget that is a native window has size policy to expand to parent widget. One solution to this might be using
QWidgetinstead ofQMainWindow+setCentralWidget(), and handle the resize manually instead of using the central layout by taking the pixel ratio into account. - I have seen some relevant issues about Qt platform integration not making use of
_NET_WM_SYNC_REQUESTproperly in this configuration during resizing, so that some compositors can not handle the application window as intended.
- According to my experiment, this is not caused by VLC. This happens when a child widget that is a native window has size policy to expand to parent widget. One solution to this might be using
- Fractional scaling + X11 + Nvidia driver, causes alignment and rendering issues. Possibly related with the driver. Maybe force rounding if Nvidia is compositing?