Fix screen grabbing zones coordinates when screen scaling is used - #378
Fix screen grabbing zones coordinates when screen scaling is used#378kdsx wants to merge 1 commit into
Conversation
When the app is running on a system which uses screen scaling factor other than "1.0", then grabber widget logical coordinates will differ from physical coordinates. Physical coordinates could be calculated by multiplying logical coordinates to a device pixel ratio.
psieg-jenkins
commented
Aug 3, 2020
Can one of the admins verify this patch? |
1 similar comment
psieg-jenkins
commented
Aug 3, 2020
Can one of the admins verify this patch? |
psieg
commented
Aug 8, 2020
Thanks for the PR! Which OS are you testing on? On windows this value seems to be always 1 even when using scaling. ok to test |
When device pixel ratio is 1, then probably everything should work as expected, shouldn't it? In my case it was Linux/KDE and screen scaling was set to 2 manually in KDE settings. Also please note that I haven't tested it on multi-screen multi-DPI environment. BTW does Lightpack support such configurations properly? |
Oh yes, I didn't mean to imply this would break something.
SG. I'm not familiar with scaling on linux, but I assume that's the standard way people would change the scaling.
At least on windows, Prismatik is kind of scaling agnostic. It uses desktop coordinates for the widgets and those match with the screenshot coordinates when adjusting for the screen position. The windows scaling doesn't change the resolution. In your case different screens could have different ratios I assume, so rather than using the QApp's ratio, you should use the ratio given by the Window, i.e. the Widget: |
kdsx
commented
Aug 8, 2020
Oh, my bad. I've taken the ratio from the wrong place. Will fix. |
kdsx
commented
Aug 8, 2020
Hmm. Qt scaling works pretty similar on each platform. Does UI look properly scaled when you use it on high-DPI screens? |
kdsx
commented
Aug 8, 2020
Ah, got it. App does not use Qt scaling in your case. That's why |
psieg
commented
Aug 8, 2020
I'm pretty sure it's not the case that windows scales the app. If that were the case, proportions of the elements in the UI would remain the same, but I guess that's not really relevant for this change. |
zomfg
commented
Aug 8, 2020
probably |
kdsx
commented
Aug 8, 2020
I'll try to check it there. |
Docs for QGuiApplication: "Use this function only when you don't know which window you are targeting. If you do know the target window, use QWindow::devicePixelRatio() instead." The widget's method should be preferred IIUC.
Indeed, docs: "Common values are 1.0 on normal displays and 2.0 on Apple "retina" displays." I believe it's currently working on MacOS because we're adjusting for the pixel ratio in the grabber. We might want to do the same for the X grabber instead of changing the maths here, WDYT? |
zomfg
commented
Aug 9, 2020
I just tested
macOS allows (in some cases?) for intermediate values (with some blurriness), I don't know if Qt returns the right values now, I used the native api at the time
the scale is used in mac grabber so we capture a 1x image (since the capture allows almost any target scaling), but the scale returned to |
psieg
commented
Apr 12, 2024
Qt6 has changed the coordinate system to a scaling dependent one, so things need to be adjusted. I did that on master meanwhile but could use help testing this on Mac on Linux systems |

When the app is running on a system which uses screen scaling factor other
than "1.0", then grabber widget logical coordinates will differ from physical
coordinates. Physical coordinates could be calculated by multiplying logical
coordinates to a device pixel ratio.