Bug 454942

Summary: Provide devicePixelRatio in KDecoration2
Product: [Plasma] kwin Reporter: Paul McAuley <kde>
Component: decorationsAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: nate, xaver.hugl
Priority: NOR    
Version First Reported In: 5.24.90   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.3
Sentry Crash Report:

Description Paul McAuley 2022-06-06 19:15:22 UTC
This is a feature request for an additional parameter in the KDecoration2 API.

Currently, in KDecoration you can only access devicePixelRatioF() (of the current screen which the window exists) within the Decoration::paint method via painter->device()->devicePixelRatioF(). 

However, in my own C++ window decoration I also paint some elements outside the  Decoration::paint method (for example, a window outline in the shadow, and a separator under the titlebar). For these I would like access to devicePixelRatioF() for more precise painting (e.g. with a cosmetic brush) and alignment under Wayland.

Vlad Zahorodnii also mentioned this as a possibility in an old merge request at https://invent.kde.org/plasma/breeze/-/merge_requests/75 :

"Vlad Zahorodnii @vladz ยท 1 year ago
Developer

KWin is the true source of device pixel ratio information. If such information is needed, it can be added in KDecoration2 library, e.g. a devicePixelRatio getter and a signal."
Comment 1 Zamundaaa 2024-12-13 17:35:42 UTC
This has been added in KDecoration3