Bug 431520 - X11: painter passed to decoration doesn't have scaling information set properly on HiDPI screens
Summary: X11: painter passed to decoration doesn't have scaling information set proper...
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: decorations (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-12 21:53 UTC by Janet Blackquill
Modified: 2021-01-14 17:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janet Blackquill 2021-01-12 21:53:00 UTC
When a decoration gets painted on Wayland, it can query the painter->device()->devicePixelRatioF() to determine the device pixel ratio, which may be needed to properly support HiDPI when things like QImages are used internally within a decoration.

This is not the case on X11, where it seems to always return 1.0.

Testable with https://invent.kde.org/plasma/breeze/-/merge_requests/67.
Comment 1 Janet Blackquill 2021-01-12 22:07:28 UTC
Doing some digging, this looks like because the decoration queries the client for the scale which queries the Screens singleton for scale which queries the X11 output, which doesn't set the scale beyond m_backend->initialOutputScale(), which surprise surprise, doesn't change from its default of 1.0 on x11, only on Wayland.
Comment 2 Vlad Zahorodnii 2021-01-14 07:51:23 UTC
> This is not the case on X11, where it seems to always return 1.0.

That's correct. On X11, there is no concept of scale factors.
Comment 3 Janet Blackquill 2021-01-14 08:04:02 UTC
That doesn't make this not a bug. The rest of KWin's UI would be rendered at a different scale correctly as handled automatically by Qt, but fails to copy Qt's correct behaviour when using custom painting routines for UI elements. The image buffer physical size is already correctly adjusted by the scale factor; it simply doesn't have the correct scale information.
Comment 4 Vlad Zahorodnii 2021-01-14 08:15:47 UTC
> The image buffer physical size is already correctly adjusted by the scale factor

This is because the size of the buffer image is based on the font metrics. Screen scale factors should remain 1, otherwise we may break a lot of things. X11 was not designed with hidpi in mind.
Comment 5 Janet Blackquill 2021-01-14 08:45:49 UTC
Well, if you're insistent on not doing anything about this bug, I'll work around it in Breeze decorations then ¯\_(ツ)_/¯
Comment 6 Nate Graham 2021-01-14 17:20:47 UTC
But KScreen and Qt have a concept of scale factors on X11. Can't KWin just read from one of them?
Comment 7 Vlad Zahorodnii 2021-01-14 17:41:22 UTC
No, it's not that simple on X11 unfortunately. You are going to break a lot of things if you do that.