Bug 357022

Summary: Rectangular Region selection screen does not take into account device pixel ratio
Product: [Applications] Spectacle Reporter: Kai Uwe Broulik <kde>
Component: GeneralAssignee: Boudhayan Gupta <me>
Status: RESOLVED FIXED    
Severity: normal CC: adam, ishitatsuyuki, meven29, miso, nate, null, peter, wengxt
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 16.04.1
Sentry Crash Report:
Attachments: spectacle-rectangle-hidpi.png

Description Kai Uwe Broulik 2015-12-21 23:07:25 UTC
Run spectable with QT_DEVICE_PIXEL_RATIO=2 and the region selection screen will be scaled 2x

Reproducible: Always

Steps to Reproduce:
1. Run QT_DEVICE_PIXEL_RATIO=2 spectacle
2. Take a "Rectangular Region" screenshot
3.

Actual Results:  
The region selector is scaled up and only a quarter of the screen is visible

Expected Results:  
The entire screen is visible
Comment 1 Boudhayan Gupta 2015-12-22 08:49:32 UTC
Does it work properly on an actual HiDPI screen? I don't want to fix QT_DPR support on non-HiDPI screens - I just want it to work on real HiDPI hardware.
Comment 2 Kai Uwe Broulik 2015-12-22 08:50:35 UTC
I have a high dpi screen which is why I use this option.
Comment 3 Kai Uwe Broulik 2015-12-23 09:54:09 UTC
Git commit 3484b8fb09872a0c9a4754c473e11b46544e847e by Kai Uwe Broulik.
Committed on 23/12/2015 at 09:52.
Pushed by broulik into branch 'Applications/15.12'.

Properly support QT_DEVICE_PIXEL_RATIO

This fixes the region grabber when running spectacle with QT_DEVICE_PIXEL_RATIO>1.
It fixes rendering the grabbed image, selecting it, the help overlays as well as the
preview of the high dpi pixmap.

REVIEW: 126479
FIXED-IN: 15.12.1

M  +1    -1    src/Gui/KSImageWidget.cpp
M  +23   -11   src/Gui/ScreenClipper.cpp

http://commits.kde.org/kscreengenie/3484b8fb09872a0c9a4754c473e11b46544e847e
Comment 4 Weng Xuetian 2015-12-24 21:11:39 UTC
*** Bug 356765 has been marked as a duplicate of this bug. ***
Comment 5 Weng Xuetian 2016-04-15 17:11:38 UTC
Now I'm on 16.03.90 (with Qt 5.6.0 KF 5.21), I notice that "Rectangle region" had the this problem again. It only shows the left top 1/4 part of the screen.
Comment 6 Weng Xuetian 2016-04-15 17:13:49 UTC
I have no problem with 15.12.3 if I downgrade only spectacle.
Comment 7 Boudhayan Gupta 2016-04-15 19:02:15 UTC
But we specifically tested with QT_DEVICE_PIXEL_RATIO=2 and confirmed the new implementation was working. We even made minor corrections to the code to fix edge cases.

Kai, if you have some free time could you verify this bug?
Comment 8 Kai Uwe Broulik 2016-04-15 19:12:13 UTC
Just encountered it yesterday, I can confirm that with the new QML-UI it's broken, I reverted back 15.12 branch and there it works.
Comment 9 Boudhayan Gupta 2016-04-15 19:50:22 UTC
Right, I'll try and fix this tomorrow
Comment 10 Boudhayan Gupta 2016-04-15 20:00:22 UTC
I can confirm that I've reproduced this bug on my computer. I strongly suspect this is a Qt 5.6 problem.
Comment 11 Boudhayan Gupta 2016-04-25 17:52:40 UTC
Fixed in 16.04 git now, should be out with 16.04.1
Comment 12 Weng Xuetian 2016-05-02 18:33:39 UTC
I'm afraid this is not completely fixed yet.

If I use region selection, the actual selected image is not the correct one. It's clipped to 1/4 of the top-left of selected region on my screen setup. Can you check it again? I think the clip region also need to be scaled.
Comment 13 Weng Xuetian 2016-05-02 18:34:21 UTC
Comment 12 is based on Applications/16.04 branch.
Comment 14 Weng Xuetian 2016-05-08 16:12:16 UTC
Git commit 38804556588e977aaaea5f50115363d9f4dc379d by Weng Xuetian.
Committed on 08/05/2016 at 16:11.
Pushed by xuetianweng into branch 'Applications/16.04'.

Fix high dpi region selection.

Coordinates need to be scaled to native pixel before clip.

REVIEW: 127814

M  +8    -2    src/QuickEditor/EditorRoot.qml

http://commits.kde.org/kscreengenie/38804556588e977aaaea5f50115363d9f4dc379d
Comment 15 Peter Wu 2016-10-12 20:24:38 UTC
*** Bug 362653 has been marked as a duplicate of this bug. ***
Comment 16 Peter Wu 2016-10-15 13:49:08 UTC
I found one remaining edge case where the fullscreen picture is displayed at the wrong location.

Consider a laptop screen on the left (primary) with an external, larger screen on the right with resolutions 1920x1080 and 2560x1440 respectively and QT_SCALE_FACTOR=2. The bottom sides are aligned such that you can move a pointer between the bottoms without a jumping cursor. This means that the origin of the laptop screen is no longer at (0, 0), but (0,360).

When the image is scaled by 2, the translated origin of the laptop screen becomes (0,180). But Qt expects screen coordinates in native pixels and is still painting from the (0,360), resulting in an upward shift of the image and loss of the bottom half!

Adding a margin should work, but maybe you can think of other edge cases? (Two different resolutions below each other? Others?)

(I have also reported the lack of documentation on the origin at https://bugreports.qt.io/browse/QTBUG-56555)
Comment 17 Peter Wu 2016-10-20 20:47:48 UTC
Git commit 1244980882382639f35925cef1d4cf3eeb3c240c by Peter Wu.
Committed on 20/10/2016 at 20:40.
Pushed by peterwu into branch 'master'.

Fix initial region location for High DPI screens

QML dimensions are measured in device-independent pixels, be sure to
make appropriate conversions. Also make sure that the new selection
size feature displays the correct dimensions.

Tested with: QT_SCALE_FACTOR=2 src/spectacle and dragging the region.

REVIEW: 129190

M  +1    -1    src/QuickEditor/EditorRoot.qml
M  +5    -4    src/QuickEditor/QuickEditor.cpp

http://commits.kde.org/spectacle/1244980882382639f35925cef1d4cf3eeb3c240c
Comment 18 Adam Dymitruk 2017-01-17 05:43:48 UTC
rectangle area also shows dimensions with fraction errors like 24.0000000001 X 35.000000000001
Comment 19 null 2018-01-28 23:19:49 UTC
Created attachment 110192 [details]
spectacle-rectangle-hidpi.png

The new QML UI still has issues in HiDPI mode, even though the pixmap itself seems fine now (see screenshot). In src/QuickEditor/EditorRoot.qml, this mostly concerns "ctx" / Context2D.

I wonder whether this is related to https://bugreports.qt.io/browse/QTBUG-37095, although with Qt 5.10.0 it's still problematic for me.
Comment 20 Méven Car 2020-04-30 07:29:39 UTC
I believe this issue has been fixed for some time.
Tested on Wayland and X (including the issue reported by xchain about the text in box not being scaled).
Comment 21 Nate Graham 2020-04-30 17:04:39 UTC
Indeed.