-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
(nut-tree/nut.js/183) Determine scale factor ifor high DPI displays i… #59
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@dscho You‘re welcome! Thanks for providing @git-for-windows! |
Thank you!!! |
Hi @bertyhell 👋 First of all: You don’t have to perform any custom install. Every change merged to
Thank you, that’s one of my main goals with nut.js! Regarding your issue, this is actually expected behavior. This means that the graphics content of your screen is Screen space is what’s relevant for mouse movement etc., so it’s absolutely correct that your bottom right point is The main goal I wanted to achieve with this PR was to establish the mapping from image space back to screen space to enable template matching with scaling applied. I hope this sheds some light on the purpose of this PR! Best regards Simon |
…n Windows
Recent Windows versions allow to change the "Scale" factor of the display. This is particularly useful on high DPI devices, where displaying windows in the regular pixel size would make it really hard to read (think: 3240x2160 resolution on a regular laptop, where the Scale factor would default to 200%). (Basically the same behavior as with retina displays)
To maintain compatibility with scale-unaware software, this is an opt-in feature, where applications have to specify via their manifest that they are aware of it. Otherwise, Windows will pretend that the resolution is actually lower.
However, this leads to a problem where calling
screen.capture()
thinks that the resolution on above-mentioned laptop is actually 1620x1080, yet when capturing a 1620X1080 rectangle at 0x0, it only captures the upper left quadrant!This PR calculates the scale factor by comparing desktop sizes to the size of the actual screen bitmap. This way it’s possible to capture the whole screen and report the correct image size so
nut.js
is able to apply its scale invariant image search.Please note that this PR does not contain a test. Changing display DPI requires a logout cycle, so I don’t see a way of running it on CI.
A manual test has been carried out successfully by both me and @dscho