This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit ec76be40b38e25222cd5389b5785b4a2446c3807
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 6 01:20:25 2026 -0600
elementary: theme,changed is emitted once the theme is applied
The layout emitted theme,changed from inside the theme setup, before the
theme version was parsed and before the table children were packed
again. A listener of the event that read theme_version got the old
value. Emit it from theme_apply, after both, exactly once per reload and
with the same payload. The other emitters (textbox, entry) are separate
classes and unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
data/elementary/objects/meson.build | 1 +
data/elementary/objects/test.edc | 10 ++++++
data/elementary/objects/test_theme_version.edc | 14 ++++++++
src/lib/elementary/efl_ui_layout.c | 36 +++++++++++++------
src/tests/elementary/efl_ui_test_layout.c | 49 ++++++++++++++++++++++++++
5 files changed, 99 insertions(+), 11 deletions(-)
diff --git a/data/elementary/objects/meson.build b/data/elementary/objects/meson.build
index 736e6a154d..f39243e99d 100644
--- a/data/elementary/objects/meson.build
+++ b/data/elementary/objects/meson.build
@@ -7,6 +7,7 @@ edc_files = [
'test_tooltip.edc',
'test_pager.edc',
'test_prefs.edc',
+ 'test_theme_version.edc',
'cursors.edc',
'font_preview.edc',
'multibuttonentry.edc',
diff --git a/data/elementary/objects/test.edc b/data/elementary/objects/test.edc
index 46c3edbdbb..5cfd70f071 100644
--- a/data/elementary/objects/test.edc
+++ b/data/elementary/objects/test.edc
@@ -856,6 +856,16 @@ collections {
}
}
}
+ group { "efl/version_test";
+ data.item: "version" "123";
+ parts {
+ part { "base";
+ type: RECT;
+ description { "default";
+ }
+ }
+ }
+ }
group { name: "font_overlay_layout";
styles {
style { name: "test_class_style";
diff --git a/data/elementary/objects/test_theme_version.edc b/data/elementary/objects/test_theme_version.edc
new file mode 100644
index 0000000000..e35ba8bc3c
--- /dev/null
+++ b/data/elementary/objects/test_theme_version.edc
@@ -0,0 +1,14 @@
+// A second theme file for tests: the same group as in test.edc, one theme
+// version later.
+collections {
+ group { "efl/version_test";
+ data.item: "version" "124";
+ parts {
+ part { "base";
+ type: RECT;
+ description { "default";
+ }
+ }
+ }
+ }
+}
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index acf911d65e..c0d5fdcbdf 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -523,7 +523,8 @@ _efl_ui_layout_base_efl_ui_widget_disabled_set(Eo *obj, Efl_Ui_Layout_Data *_pd
}
static Eina_Error
-_efl_ui_layout_theme_internal(Eo *obj, Efl_Ui_Layout_Data *sd, Elm_Widget_Smart_Data **widget_data)
+_efl_ui_layout_theme_internal(Eo *obj, Efl_Ui_Layout_Data *sd,
+ Elm_Widget_Smart_Data **widget_data, Eina_Bool *changed)
{
Eina_Error ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
@@ -540,13 +541,8 @@ _efl_ui_layout_theme_internal(Eo *obj, Efl_Ui_Layout_Data *sd, Elm_Widget_Smart_
elm_widget_theme_style_get(obj));
}
- if (ret != EFL_UI_THEME_APPLY_ERROR_GENERIC)
- {
- if (sd->cb_theme_changed)
- efl_event_callback_call(obj, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, NULL);
- if (elm_widget_is_legacy(obj))
- evas_object_smart_callback_call(obj, "theme,changed", NULL);
- }
+ // The event is for the caller to emit, once the version is known
+ *changed = (ret != EFL_UI_THEME_APPLY_ERROR_GENERIC);
if (!_visuals_refresh(obj, sd))
ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
@@ -574,8 +570,8 @@ _deferred_signals_emit(Efl_Ui_Layout_Data *pd)
eina_inarray_free(signals);
}
-EOLIAN static Eina_Error
-_efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
+static Eina_Error
+_efl_ui_layout_theme_apply_do(Eo *obj, Efl_Ui_Layout_Data *sd, Eina_Bool *changed)
{
Eina_Error theme_apply_ret, theme_apply_internal_ret;
Elm_Widget_Smart_Data *wd = NULL;
@@ -588,7 +584,7 @@ _efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
theme_apply_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
if (theme_apply_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return EFL_UI_THEME_APPLY_ERROR_GENERIC;
- theme_apply_internal_ret = _efl_ui_layout_theme_internal(obj, sd, &wd);
+ theme_apply_internal_ret = _efl_ui_layout_theme_internal(obj, sd, &wd, changed);
if (theme_apply_internal_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC)
return EFL_UI_THEME_APPLY_ERROR_GENERIC;
@@ -659,6 +655,24 @@ _efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
return EFL_UI_THEME_APPLY_ERROR_NONE;
}
+// theme,changed is emitted once the theme is applied: the version is parsed
+// and the children are packed again, so a listener reads the new state.
+EOLIAN static Eina_Error
+_efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
+{
+ Eina_Bool changed = EINA_FALSE;
+ Eina_Error ret = _efl_ui_layout_theme_apply_do(obj, sd, &changed);
+
+ if (changed)
+ {
+ if (sd->cb_theme_changed)
+ efl_event_callback_call(obj, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, NULL);
+ if (elm_widget_is_legacy(obj))
+ evas_object_smart_callback_call(obj, "theme,changed", NULL);
+ }
+ return ret;
+}
+
EOLIAN static int
_efl_ui_layout_base_theme_version_get(const Eo *obj EINA_UNUSED, Efl_Ui_Layout_Data *pd)
{
diff --git a/src/tests/elementary/efl_ui_test_layout.c b/src/tests/elementary/efl_ui_test_layout.c
index cf175db265..3126bdb917 100644
--- a/src/tests/elementary/efl_ui_test_layout.c
+++ b/src/tests/elementary/efl_ui_test_layout.c
@@ -112,6 +112,54 @@ EFL_START_TEST(efl_ui_layout_test_property_bind_provider)
}
EFL_END_TEST
+static unsigned int _theme_changed_count;
+static int _theme_changed_version;
+
+static void
+_theme_changed_cb(void *data, const Efl_Event *ev)
+{
+ Eo *ly = data;
+
+ EINA_SAFETY_ON_FALSE_RETURN(ev->object == ly);
+ _theme_changed_count++;
+ _theme_changed_version = efl_ui_layout_theme_version_get(ly);
+}
+
+// theme,changed is emitted once the theme is applied, so a listener that
+// reads the theme version sees the one of the theme just loaded.
+EFL_START_TEST(efl_ui_layout_test_theme_changed_sees_new_version)
+{
+ Eo *win, *ly, *def;
+ char first[PATH_MAX], second[PATH_MAX];
+
+ snprintf(first, sizeof(first), "%s/objects/test.edj", ELM_TEST_DATA_DIR);
+ snprintf(second, sizeof(second), "%s/objects/test_theme_version.edj", ELM_TEST_DATA_DIR);
+ def = efl_ui_theme_default_get();
+ efl_ui_theme_extension_add(def, first);
+
+ win = win_add(NULL, "layout", EFL_UI_WIN_TYPE_BASIC);
+ ly = efl_add(EFL_UI_LAYOUT_CLASS, win,
+ efl_ui_layout_theme_set(efl_added, "version_test", NULL, NULL));
+ ck_assert_int_eq(efl_ui_layout_theme_version_get(ly), 123);
+
+ _theme_changed_count = 0;
+ _theme_changed_version = 0;
+ efl_event_callback_add(ly, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, _theme_changed_cb, ly);
+
+ // The overlay answers before the extension: the same group, a version
+ // later. Widgets apply their theme again when the theme changes.
+ efl_ui_theme_overlay_add(def, second);
+
+ ck_assert_uint_eq(_theme_changed_count, 1);
+ ck_assert_int_eq(_theme_changed_version, 124);
+ ck_assert_int_eq(efl_ui_layout_theme_version_get(ly), 124);
+
+ efl_event_callback_del(ly, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, _theme_changed_cb, ly);
+ efl_ui_theme_overlay_del(def, second);
+ efl_ui_theme_extension_del(def, first);
+}
+EFL_END_TEST
+
EFL_START_TEST(efl_ui_layout_test_layout_api_size_min)
{
Evas_Object *win;
@@ -534,6 +582,7 @@ void efl_ui_test_layout(TCase *tc)
tcase_add_test(tc, efl_ui_layout_text_set_while_building);
tcase_add_test(tc, efl_ui_layout_content_set_while_building);
tcase_add_test(tc, efl_ui_layout_test_property_bind);
+ tcase_add_test(tc, efl_ui_layout_test_theme_changed_sees_new_version);
tcase_add_test(tc, efl_ui_layout_test_layout_api_size_min);
tcase_add_test(tc, efl_ui_layout_test_layout_api_update_hints);
tcase_add_test(tc, efl_ui_layout_test_layout_force);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.