Bug 446627

Summary: Pager does not show correct size when PLASMA_USE_QT_SCALING=1 is set on X11
Product: [Plasma] plasmashell Reporter: Luke Horwell <code>
Component: PagerAssignee: Fushan Wen <qydwhotmail>
Status: RESOLVED FIXED    
Severity: normal CC: nate, plasma-bugs, qydwhotmail, rapiteanu.catalin
Priority: NOR    
Version: 5.23.4   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.27.8
Bug Depends on:    
Bug Blocks: 356446    
Attachments: X11 desktop at 100%, 200% and with variable set

Description Luke Horwell 2021-12-07 15:47:50 UTC
Created attachment 144305 [details]
X11 desktop at 100%, 200% and with variable set

SUMMARY

On X11 desktops, when the environment variable `PLASMA_USE_QT_SCALING=1` is set, the Pager widget only shows the first quarter of the desktop (in the case of 200% scaling).

When the variable is not present, the pager works correctly when Plasma's global scale set to 100% and 200%.

Wayland is not affected and works as expected, even with the variable set.

Perhaps there needs to be a condition to divide the global scale (e.g. 200% = 2) when X11 is in use and the environment variable is present?

STEPS TO REPRODUCE
A HiDPI display is useful, but not required.

1. Set the global scale to 200%.
2. echo "PLASMA_USE_QT_SCALING=1" >> .bash_profile
3. Log out and back in
4. Observe the Pager widget on the panel and open some windows in the top-left and bottom-right regions.

OBSERVED RESULT
On X11 desktops, the window outlines on the widget are not accurately shown when PLASMA_USE_QT_SCALING is set.

EXPECTED RESULT
The pager shows the correct position/size of windows for a virtual desktop.

SOFTWARE/OS VERSIONS
OS: Arch Linux
KDE Plasma Version: 5.23.4
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
See attachments for screenshots.
Comment 1 Nate Graham 2021-12-07 21:17:23 UTC
Can confirm.
Comment 2 Nate Graham 2022-01-21 05:12:40 UTC
The thing this is a blocker for (Bug 356446) is closed now, and doing this was never supported anyway.

Unfortunately I think we have to close this. Folks who want a decent hidpi experience will have to use Wayland and look forward to upcoming changes to improve the experience for XWayland apps in particular.

Sorry everyone. :(
Comment 3 Nate Graham 2022-01-23 19:27:02 UTC
*** Bug 448967 has been marked as a duplicate of this bug. ***
Comment 4 Fushan Wen 2022-02-17 11:36:28 UTC
Can reproduce
Comment 5 Nate Graham 2022-02-17 15:10:45 UTC
PLASMA_USE_QT_SCALING=1 is still not supported, so these kinds of issues when using it on X11 can be expected.

If you'd like to re-open and fix this, we should re-open the parent bug and all the other blockers too, and implement your proposed UI to let the user choose what kind of scaling they want in the KScreen KCM on X11.

Would you like to start on that?
Comment 6 Fushan Wen 2022-02-17 15:49:13 UTC
(In reply to Nate Graham from comment #5)
> PLASMA_USE_QT_SCALING=1 is still not supported, so these kinds of issues
> when using it on X11 can be expected.
> 
> If you'd like to re-open and fix this, we should re-open the parent bug and
> all the other blockers too, and implement your proposed UI to let the user
> choose what kind of scaling they want in the KScreen KCM on X11.
> 
> Would you like to start on that?

The bug seems to be fixable within my knowledge level and  I am working on this. 

I can't say other blockers can be fixed but at least I will take this bug. Marked it as LATER now.
Comment 8 Nate Graham 2022-02-21 18:13:48 UTC
Git commit 16d44ae2cb5e680f03a7414afe94f92d49fdcb37 by Nate Graham, on behalf of Fushan Wen.
Committed on 21/02/2022 at 18:13.
Pushed by ngraham into branch 'master'.

applet/pager: Divide window size by devicePixelRatio on X11 when it's >1

KWindowInfoPrivateX11::frameGeometry() returns the true geometry of
a window, so dividing the window size by devicePixelRatio is needed to
get the correct size when it's greater than 1.
FIXED-IN: 5.24.2

M  +18   -12   applets/pager/plugin/windowmodel.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/16d44ae2cb5e680f03a7414afe94f92d49fdcb37
Comment 9 Nate Graham 2022-02-21 18:16:24 UTC
Git commit 78b1d26134647d890ee55e1ad7607cbd77e538be by Nate Graham, on behalf of Fushan Wen.
Committed on 21/02/2022 at 18:16.
Pushed by ngraham into branch 'Plasma/5.24'.

applet/pager: Divide window size by devicePixelRatio on X11 when it's >1

KWindowInfoPrivateX11::frameGeometry() returns the true geometry of
a window, so dividing the window size by devicePixelRatio is needed to
get the correct size when it's greater than 1.
FIXED-IN: 5.24.2


(cherry picked from commit 16d44ae2cb5e680f03a7414afe94f92d49fdcb37)

M  +18   -12   applets/pager/plugin/windowmodel.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/78b1d26134647d890ee55e1ad7607cbd77e538be
Comment 10 Bug Janitor Service 2023-08-19 16:32:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1674
Comment 11 Bug Janitor Service 2023-08-21 01:03:49 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/1676
Comment 12 Fushan Wen 2023-08-23 01:04:18 UTC
Git commit 18b91601b3ded2e6359ce51b7e983717cd49df12 by Fushan Wen.
Committed on 22/08/2023 at 07:05.
Pushed by fusionfuture into branch 'master'.

applets/pager: fix window/screen size/position when using Qt scaling

On X11, the rect returned from QScreen::virtualGeometry cannot be used
as the whole screen rect. Instead, compute the whole screen rect
manually, and map all windows/screens to the non-scaled coordinate
system on X11 to make windows show in right positions in the pager applet.
FIXED-IN: 5.27.8

M  +38   -20   applets/pager/plugin/pagermodel.cpp
M  +3    -0    applets/pager/plugin/pagermodel.h
M  +13   -13   applets/pager/plugin/windowmodel.cpp
M  +5    -0    applets/pager/plugin/windowmodel.h

https://invent.kde.org/plasma/plasma-desktop/-/commit/18b91601b3ded2e6359ce51b7e983717cd49df12
Comment 13 Fushan Wen 2023-08-23 01:11:09 UTC
Git commit 879492370e9b8193dc76b59a266fbdc410a7c45a by Fushan Wen.
Committed on 23/08/2023 at 02:49.
Pushed by fusionfuture into branch 'Plasma/5.27'.

applets/pager: fix window/screen size/position when using Qt scaling

On X11, the rect returned from QScreen::virtualGeometry cannot be used
as the whole screen rect. Instead, compute the whole screen rect
manually, and map all windows/screens to the non-scaled coordinate
system on X11 to make windows show in right positions in the pager applet.
FIXED-IN: 5.27.8

(cherry picked from commit 18b91601b3ded2e6359ce51b7e983717cd49df12)

M  +39   -20   applets/pager/plugin/pagermodel.cpp
M  +3    -0    applets/pager/plugin/pagermodel.h
M  +15   -25   applets/pager/plugin/windowmodel.cpp
M  +3    -0    applets/pager/plugin/windowmodel.h

https://invent.kde.org/plasma/plasma-desktop/-/commit/879492370e9b8193dc76b59a266fbdc410a7c45a