-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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 legacy color picker crash. #101513
Fix legacy color picker crash. #101513
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
I confirm this fixes the issue for me with X11/XWayland, multi-window on Fedora 41 KDE Wayland. There's still room for improvement possibly (weird resizing of the window with black bars on top and bottom, and the preview is either a black or white square with just a tiny preview of the actual color), but these predate #101266. It looks the same in 4.4.dev7. For comparison, here's how it looks like in 4.3.stable: |
What bug? Legacy picker is a working by picking pixels from pre-rendered texture, so there's no need to hide zoom preview, it can't obstruct anything. The #101266 only relevant for picking pixels from screen, which is never happening when this branch is used. |
This comment was marked as resolved.
This comment was marked as resolved.
It's not reverting it, only a tiny part that was wrong (legacy picker). Fix for real X11 is still there. |
Sorry, I was confused, forgot that i have added it in two places :') |
There seems to be an effect to the code being removed on my config (XWayland multi window, which is likely the most common configuration nowadays as most distros now default to Wayland and we default to X11 multi window). If I just do what @WhalesState suggests, I get: Which seems to be marginally better than what I have with this PR. diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index f5be4c59a9..affbd7270a 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -1982,9 +1982,11 @@ void ColorPicker::_picker_texture_input(const Ref<InputEvent> &p_event) {
picker_preview_style_box_color->set_bg_color(picker_color);
picker_preview_style_box->set_bg_color(picker_color.get_luminance() < 0.5 ? Color(1.0f, 1.0f, 1.0f) : Color(0.0f, 0.0f, 0.0f));
- Ref<AtlasTexture> atlas = picker_texture_zoom->get_texture();
- if (atlas.is_valid()) {
- atlas->set_region(Rect2i(ofs.x - 8, ofs.y - 8, 17, 17));
+ if (picker_texture_zoom) {
+ Ref<AtlasTexture> atlas = picker_texture_zoom->get_texture();
+ if (atlas.is_valid()) {
+ atlas->set_region(Rect2i(ofs.x - 8, ofs.y - 8, 17, 17));
+ }
}
}
} It's still imperfect, as the preview square is weirdly offset to the bottom right of the pointer, but it's better. I think we're starting to get confused by the terminology of legacy, single/multi window, embedded, and |
93c8fc4
to
886d519
Compare
Added missing part for XWayland (different texture setup branch from embedded legacy picker). |
That works great on XWayland multi-window: My last nitpick is that there's still an unexpected shrinking of the window with a black bar at the bottom (the window was full screen before). The top black bar is understandable, that's where the window decorations would be, to compare with: In 4.3 as shown above, I'm not getting this shrinking. But that's outside the scope of this PR. I'll test XWayland single-window, Wayland single-window, and real X11 multi/single-window. |
For reference there are the following cases:
|
There's one minor issue though, when clicking the picker button, a full size copy of the editor window is instantiated as a new window. When moving the cursor, it then disappears and is replaced by the proper preview picker with zoom. Here's an example of what it looks like: Maybe we should send a small mouse event to update the window contents?
Switching to X11 to test the other cases. |
Before doing a cleanup, I have those two PRs that fixes other Picker issues |
886d519
to
34ebefd
Compare
I can't reproduce it, but I see what can cause it. Added |
Tested the last two commits (886d519 and 34ebefd).
simplescreenrecorder-2025-01-14_00.15.17.mp4That last bug also seems to exist in 4.4.dev7, albeit in a worst form where the full size preview with zoom flickers black and white rapidly (epilepsy warning if you test). Edit: That seems to be #100797. |
X11 flicker bug is what #101485 should fix. |
Indeed, removing this line solves #100797 on native X11 multi-window: I'd suggest adding it in this PR so it can fix #101412, #100797 and #101328 altogether. It's going to conflict with #101485 anyway so we may as well keep that PR only for code style improvements and fix the known bugs here. diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 6024ea7b96..d1cff07a40 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -159,7 +159,6 @@ void ColorPicker::_notification(int p_what) {
}
DisplayServer *ds = DisplayServer::get_singleton();
Vector2 ofs = ds->mouse_get_position();
- picker_window->set_position(ofs - Vector2(28, 28));
Color c = DisplayServer::get_singleton()->screen_get_pixel(ofs); With this change, the only remaining issues I've seen, for future issues/PRs:
|
34ebefd
to
730495c
Compare
Done. Also added initial position to the picker for single-window and changed native X11 preview to always have same offset from cursor except for the bottom and right border of the screen. |
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.
Tested successfully on Linux with all combinations (on Fedora 41 KDE):
- Native X11 single-window
- Native X11 multi-window
- XWayland single-window
- XWayland multi-window
- Wayland single-window
Thanks! |
For the reference, native portal picker (#101546) should work much better on XWayland and Wayland (also probably the only way to make screen wide color selection on Wayland). |
ColorPicker
This line is redundant. #101328