-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Improve color picking #74962
Improve color picking #74962
Conversation
I noticed, that this PR will remove picking for non-desktop-platforms like Android. Perhaps the previous method should be kept for these platforms? |
I tested on Android and it seems to be working 🤔 |
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.
I used a little hack suggested by @Sauermann to detect clicks outside the main window. I spawn a tiny 1x1 popup and wait until it disappears (which happens when you click anywhere).
There's an issue with this approach, other apps can receive click and take focus when picking color, but I'm not sure how to solve it. On Windows, the global input hook used to close popups will consume the click event, but on other platforms it's only works with other windows of the same app.
Ok I restored the old method of color picking. It replaces the new one on unsupported platforms.
I wouldn't worry about that too much. GIMP for example has the same issue. |
bbd5d50
to
02e8537
Compare
02e8537
to
b76dded
Compare
Thanks! |
This PR makes use of the new
screen_get_pixel()
method for ColorPicker. It allows to pick the color anywhere on the screen(s), with a caveat that it only works on supported platforms (unsupported have the picking button disabled).I used a little hack suggested by @Sauermann to detect clicks outside the main window. I spawn a tiny 1x1 popup and wait until it disappears (which happens when you click anywhere). The color reading is done inside internal process. Pressing Escape will cancel picking and restore previous color.
Fixes #74048
EDIT:
After some feedback, I left the old picking code for platforms that don't support screen capture. It works e.g. on Android, so no reason to remove it I guess.