Fix computing display geometry on multi-monitor HiDPI setups on X11

Authored by printesoi on May 9 2020, 4:54 PM.


Group Reviewers

KWindowSystem::workArea() and KWindowSystem::workArea(QList<WId>()) should return the same value, but the second call returned an incorrect value on multi-monitor HiDPI setups. The cause is that the former uses NETRootInfo::workArea() whereas the second one uses displayGeometr() to compuse base work area. displayGeometry() on X11 platform did not take into account the device pixel ratio.

Diff Detail

R278 KWindowSystem
Lint Skipped
Unit Tests Skipped
printesoi created this revision.May 9 2020, 4:54 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 9 2020, 4:54 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
printesoi requested review of this revision.May 9 2020, 4:54 PM
printesoi added reviewers: davidedmundson, KWin.

I would like to add some more details about my setup: I have a laptop with a 4K display and I use a second 4K external monitor. I have enabled the 200% scalling and xrandr -q | grep -E '\bconnected' gives

DP-0 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 609mm x 349mm
DP-2 connected primary 3840x2160+0+2160 (normal left inverted right x axis y axis) 344mm x 193mm

ie: the external monitor is set at 0,0 (on top) and the laptop monitor is set at 0,2160 (on bottom)

I created a minimal project that shows the problem in this setup and without the patch the results I get from the code above is (I have a 32px panel on the bottom of the primary (laptop) screen):

QRect KWindowSystemPrivateX11::workArea(int desktop): QRect(0,0 1920x2128)
QRect KWindowSystemPrivateX11::workArea(const QList<WId> &exclude, int desktop): QRect(0,0 960x1588)
zzag accepted this revision.EditedMay 14 2020, 8:46 AM

In general, it's better to use QScreen::availableGeometry() instead of KWindowSystem::workArea().

This revision is now accepted and ready to land.May 14 2020, 8:46 AM

@zzag yes, but as per the, it does not work on setups with multiple displays :)