-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix screen grabbing zones coordinates when screen scaling is used #378
base: master
Are you sure you want to change the base?
Fix screen grabbing zones coordinates when screen scaling is used #378
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.
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
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: |
Oh, my bad. I've taken the ratio from the wrong place. Will fix. |
Hmm. Qt scaling works pretty similar on each platform. Does UI look properly scaled when you use it on high-DPI screens? |
Ah, got it. App does not use Qt scaling in your case. That's why |
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. |
probably |
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? |
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 |
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.