Skip to content

Commit 6e50da8

Browse files
committed
Merge pull request #94931 from KoBeWi/1_window_1_hack
Use legacy color picking in single window mode
2 parents 4aa0b52 + 3852843 commit 6e50da8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

scene/gui/color_picker.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ void ColorPicker::_notification(int p_what) {
5454
_update_color();
5555
} break;
5656

57+
case NOTIFICATION_READY: {
58+
// FIXME: The embedding check is needed to fix a bug in single-window mode (GH-93718).
59+
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SCREEN_CAPTURE) && !get_tree()->get_root()->is_embedding_subwindows()) {
60+
btn_pick->set_tooltip_text(ETR("Pick a color from the screen."));
61+
btn_pick->connect(SceneStringName(pressed), callable_mp(this, &ColorPicker::_pick_button_pressed));
62+
} else {
63+
// On unsupported platforms, use a legacy method for color picking.
64+
btn_pick->set_tooltip_text(ETR("Pick a color from the application window."));
65+
btn_pick->connect(SceneStringName(pressed), callable_mp(this, &ColorPicker::_pick_button_pressed_legacy));
66+
}
67+
} break;
68+
5769
case NOTIFICATION_TRANSLATION_CHANGED: {
5870
List<BaseButton *> buttons;
5971
preset_group->get_buttons(&buttons);
@@ -1834,14 +1846,6 @@ ColorPicker::ColorPicker() {
18341846

18351847
btn_pick = memnew(Button);
18361848
sample_hbc->add_child(btn_pick);
1837-
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_SCREEN_CAPTURE)) {
1838-
btn_pick->set_tooltip_text(ETR("Pick a color from the screen."));
1839-
btn_pick->connect(SceneStringName(pressed), callable_mp(this, &ColorPicker::_pick_button_pressed));
1840-
} else {
1841-
// On unsupported platforms, use a legacy method for color picking.
1842-
btn_pick->set_tooltip_text(ETR("Pick a color from the application window."));
1843-
btn_pick->connect(SceneStringName(pressed), callable_mp(this, &ColorPicker::_pick_button_pressed_legacy));
1844-
}
18451849

18461850
sample = memnew(TextureRect);
18471851
sample_hbc->add_child(sample);

0 commit comments

Comments
 (0)