This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/291/head
in repository efl.
View the commit online.
commit 16034098e37573dd1979166364a6d6cc1ea73aa8
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 19:01:51 2026 -0600
elementary: a window measures the spacers of its frame once
A window that draws its own frame, as every window does on wayland,
finds out how much room the frame takes by resizing the frame to
1000x1000, reading the opaque and the content spacers, and resizing it
back. It did so three times for every update of the frame: once for
the content spacer and twice for the opaque one. The content of the
window is swallowed in the frame, so each of these laid the whole
window out twice, at 1000x1000 and at its real size, and an update
runs on every resize. In a profile of terminology being resized by a
compositor, about half of its CPU time was spent there.
Both spacers are now read in one measurement and the result is kept.
What they measure does not depend on the size of the window, only on
the layout of the frame, so it is dropped when that changes:
* when the frame's edje object sends its recalc event, which it does
for a state change, a change in the hints of what it swallows, a
text, a size or color class, and not for a plain resize; a
calculation the frame still owes is run first, so that a change not
laid out yet is reported before the kept value is trusted
* when the window gets its theme applied, as on a new scale or theme:
edje_scale_set() forces the calculation and sends no recalc.
An application that calls edje_scale_set() itself, without going
through elementary's configuration, is not seen until one of the two
happens.
Measured with terminology on a Pinebook Pro (RK3399), driven through
40 interactive resize steps of 48x36 pixels by Enlightenment's wayland
test harness, as the time from the configure to the commit that
answers it, taken from WAYLAND_DEBUG timestamps. libelementary built
from this tree before and after with the same flags (buildtype plain),
the rest of the EFL as installed; median of 40 steps, two runs each:
before after
software, E on its buffer backend 70.0 71.0 ms 38.9 32.4 ms
GL (wayland_egl), E nested with GL 70.3 67.6 ms 32.7 32.4 ms
With both libraries terminology sends the same sequence of configure
acks, window geometries, opaque and input regions and buffer sizes
through a run that maximizes it, takes it fullscreen and back and
resizes it in between.
The new test checks the room the frame takes through resizes, a
borderless window and a change of scale. It passes before the change,
and fails when either of the two ways the kept value is dropped is
taken out. The main menu, which changes the frame through the hints
of a swallowed object, is not in it: it only enters the frame after
the D-Bus menu registration has answered. elementary-suite and
efl-ui-suite pass.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/lib/elementary/efl_ui_win.c | 112 +++++++++++++++++++++++++-----------
src/tests/elementary/elm_test_win.c | 69 ++++++++++++++++++++++
2 files changed, 149 insertions(+), 32 deletions(-)
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index bc3a400e4d..03e951a535 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -263,6 +263,10 @@ struct _Efl_Ui_Win_Data
Eina_Bool cur_unresizable : 1;
Eina_Bool cur_indicator : 1;
Eina_Bool wayland : 1;
+ /* The spacers of the frame, as _elm_win_frame_spacers_measure() last
+ * found them, until the frame says its layout changed. */
+ Eina_Rect spacer_opaque, spacer_content;
+ Eina_Bool spacers_measured : 1;
} csd;
struct {
@@ -1635,30 +1639,65 @@ _elm_win_profile_update(Efl_Ui_Win_Data *sd)
efl_event_callback_legacy_call(sd->obj, EFL_UI_WIN_EVENT_PROFILE_CHANGED, NULL);
}
-static inline void
-_elm_win_frame_geometry_adjust(Efl_Ui_Win_Data *sd)
+/* Edje only sends this when something other than the size of the frame
+ * changed its layout: a state, the hints of what it swallows, a text, the
+ * scale. */
+static void
+_elm_win_frame_obj_recalc(void *data, const Efl_Event *ev EINA_UNUSED)
{
- int l = 0, t = 0, r = 0, b = 0;
+ Efl_Ui_Win_Data *sd = data;
- if (sd->frame_obj && sd->csd.need && !sd->fullscreen)
+ sd->csd.spacers_measured = EINA_FALSE;
+}
+
+/* Where the frame puts its opaque and its content spacers, measured on a
+ * 1000x1000 frame so that the size of the window does not get in the way.
+ * Resizing the frame lays out everything it swallows, the whole content of
+ * the window, on the way there and on the way back: the result is kept
+ * until _elm_win_frame_obj_recalc() says the layout changed. */
+static void
+_elm_win_frame_spacers_measure(Efl_Ui_Win_Data *sd, Eina_Rect *opaque, Eina_Rect *content)
+{
+ Eina_Bool legacy = elm_widget_is_legacy(sd->obj);
+ int fw, fh;
+
+ /* A change the frame has not laid out yet has not been reported yet. */
+ if (evas_object_smart_need_recalculate_get(sd->frame_obj))
+ evas_object_smart_calculate(sd->frame_obj);
+ if (!sd->csd.spacers_measured)
{
- int fw, fh, ox, oy, ow, oh;
evas_object_geometry_get(sd->frame_obj, NULL, NULL, &fw, &fh);
sd->ignore_frame_resize++;
evas_object_resize(sd->frame_obj, 1000, 1000);
- if (elm_widget_is_legacy(sd->obj))
- edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
- &ox, &oy, &ow, &oh);
- else
- edje_object_part_geometry_get(sd->frame_obj, "efl.spacer.opaque",
- &ox, &oy, &ow, &oh);
+ edje_object_part_geometry_get(sd->frame_obj,
+ legacy ? "elm.spacer.opaque" : "efl.spacer.opaque",
+ &sd->csd.spacer_opaque.x, &sd->csd.spacer_opaque.y,
+ &sd->csd.spacer_opaque.w, &sd->csd.spacer_opaque.h);
+ edje_object_part_geometry_get(sd->frame_obj,
+ legacy ? "elm.spacer.content" : "efl.spacer.content",
+ &sd->csd.spacer_content.x, &sd->csd.spacer_content.y,
+ &sd->csd.spacer_content.w, &sd->csd.spacer_content.h);
+ sd->csd.spacers_measured = EINA_TRUE;
evas_object_resize(sd->frame_obj, fw, fh);
sd->ignore_frame_resize--;
- fw = 1000; fh = 1000;
- l = ox;
- t = oy;
- r = fw - ow - l;
- b = fh - oh - t;
+ }
+ if (opaque) *opaque = sd->csd.spacer_opaque;
+ if (content) *content = sd->csd.spacer_content;
+}
+
+/* The shadow is what the frame draws around its opaque spacer, as measured
+ * by _elm_win_frame_spacers_measure(); none without one. */
+static void
+_elm_win_frame_shadow_set(Efl_Ui_Win_Data *sd, const Eina_Rect *opaque)
+{
+ int l = 0, t = 0, r = 0, b = 0;
+
+ if (opaque)
+ {
+ l = opaque->x;
+ t = opaque->y;
+ r = 1000 - opaque->w - l;
+ b = 1000 - opaque->h - t;
if (l < 0) l = 0;
if (r < 0) r = 0;
if (t < 0) t = 0;
@@ -1667,6 +1706,20 @@ _elm_win_frame_geometry_adjust(Efl_Ui_Win_Data *sd)
ecore_evas_shadow_geometry_set(sd->ee, l, r, t, b);
}
+static inline void
+_elm_win_frame_geometry_adjust(Efl_Ui_Win_Data *sd)
+{
+ Eina_Rect opaque;
+
+ if (sd->frame_obj && sd->csd.need && !sd->fullscreen)
+ {
+ _elm_win_frame_spacers_measure(sd, &opaque, NULL);
+ _elm_win_frame_shadow_set(sd, &opaque);
+ }
+ else
+ _elm_win_frame_shadow_set(sd, NULL);
+}
+
static inline Eina_Bool
_elm_win_framespace_set(Efl_Ui_Win_Data *sd, int x, int y, int w, int h)
{
@@ -1682,26 +1735,16 @@ _elm_win_framespace_set(Efl_Ui_Win_Data *sd, int x, int y, int w, int h)
static void
_elm_win_frame_obj_update(Efl_Ui_Win_Data *sd, Eina_Bool force)
{
- int ox, oy, ow, oh;
- int cx, cy, cw, ch;
+ Eina_Rect opaque, content;
int w, h;
- int l, r, t, b;
if (!sd->frame_obj) return;
if (!sd->csd.need) return;
- _elm_win_frame_geometry_adjust(sd);
- ecore_evas_shadow_geometry_get(sd->ee, &l, &r, &t, &b);
- sd->ignore_frame_resize++;
- evas_object_geometry_get(sd->frame_obj, &ox, &oy, &ow, &oh);
- evas_object_resize(sd->frame_obj, 1000, 1000);
- if (elm_widget_is_legacy(sd->obj))
- edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.content", &cx, &cy, &cw, &ch);
- else
- edje_object_part_geometry_get(sd->frame_obj, "efl.spacer.content", &cx, &cy, &cw, &ch);
- evas_object_resize(sd->frame_obj, ow, oh);
- sd->ignore_frame_resize--;
- if (!_elm_win_framespace_set(sd, cx, cy, 1000 - cw, 1000 - ch) && (!force)) return;
- _elm_win_frame_geometry_adjust(sd);
+ _elm_win_frame_spacers_measure(sd, &opaque, &content);
+ _elm_win_frame_shadow_set(sd, sd->fullscreen ? NULL : &opaque);
+ if (!_elm_win_framespace_set(sd, content.x, content.y,
+ 1000 - content.w, 1000 - content.h) && (!force))
+ return;
if (!sd->first_draw) return;
@@ -4556,6 +4599,8 @@ _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *element, const char *style)
if (sd->frame_obj) return;
sd->frame_obj = edje_object_add(sd->evas);
+ efl_event_callback_add(sd->frame_obj, EFL_LAYOUT_EVENT_RECALC,
+ _elm_win_frame_obj_recalc, sd);
// Verify theme version. Border requires an exact theme API.
version = elm_theme_data_get(elm_widget_theme_get(sd->obj), "version");
@@ -7116,6 +7161,9 @@ _efl_ui_win_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Win_Data *sd)
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
+ /* A new scale or theme lays the frame out again without the frame saying
+ * so: edje_scale_set() forces the calculation and sends no recalc. */
+ sd->csd.spacers_measured = EINA_FALSE;
sd->focus_highlight.theme_changed = EINA_TRUE;
int_ret = _elm_win_theme_internal(obj, sd) & int_ret;
diff --git a/src/tests/elementary/elm_test_win.c b/src/tests/elementary/elm_test_win.c
index e80a351616..e29cc3c57d 100644
--- a/src/tests/elementary/elm_test_win.c
+++ b/src/tests/elementary/elm_test_win.c
@@ -499,6 +499,74 @@ EFL_START_TEST(elm_win_test_default_type)
}
EFL_END_TEST
+typedef struct _Framespace
+{
+ int x, y, w, h;
+} Framespace;
+
+static Framespace
+_framespace_get(Evas_Object *win)
+{
+ Framespace fs;
+
+ force_render(win);
+ evas_output_framespace_get(evas_object_evas_get(win), &fs.x, &fs.y, &fs.w, &fs.h);
+ return fs;
+}
+
+static void
+_framespace_eq(Framespace a, Framespace b)
+{
+ ck_assert_int_eq(a.x, b.x);
+ ck_assert_int_eq(a.y, b.y);
+ ck_assert_int_eq(a.w, b.w);
+ ck_assert_int_eq(a.h, b.h);
+}
+
+/* The room a window's own frame takes around its content depends on the
+ * layout of the frame, not on the size of the window: it has to follow
+ * whatever changes that layout, and nothing else. */
+EFL_START_TEST(elm_win_test_frame_space)
+{
+ Evas_Object *win;
+ Framespace framed, bare, scaled;
+ double scale;
+
+ setenv("EFL_WIN_FRAME_MODE", "on", 1);
+ win = elm_win_add(NULL, "win", ELM_WIN_BASIC);
+ unsetenv("EFL_WIN_FRAME_MODE");
+ evas_object_resize(win, 300, 200);
+ evas_object_show(win);
+
+ framed = _framespace_get(win);
+ ck_assert_int_gt(framed.w, 0);
+ ck_assert_int_gt(framed.h, 0);
+
+ evas_object_resize(win, 640, 480);
+ _framespace_eq(_framespace_get(win), framed);
+ evas_object_resize(win, 120, 90);
+ _framespace_eq(_framespace_get(win), framed);
+
+ elm_win_borderless_set(win, EINA_TRUE);
+ bare = _framespace_get(win);
+ ck_assert_int_lt(bare.w, framed.w);
+ ck_assert_int_lt(bare.h, framed.h);
+ evas_object_resize(win, 300, 200);
+ _framespace_eq(_framespace_get(win), bare);
+ elm_win_borderless_set(win, EINA_FALSE);
+ _framespace_eq(_framespace_get(win), framed);
+
+ scale = elm_config_scale_get();
+ elm_config_scale_set(scale * 2.0);
+ evas_object_resize(win, 320, 240);
+ scaled = _framespace_get(win);
+ ck_assert_int_gt(scaled.h, framed.h);
+ elm_config_scale_set(scale);
+ evas_object_resize(win, 300, 200);
+ _framespace_eq(_framespace_get(win), framed);
+}
+EFL_END_TEST
+
void elm_test_win(TCase *tc)
{
tcase_add_test(tc, elm_win_legacy_type_check);
@@ -511,6 +579,7 @@ void elm_test_win(TCase *tc)
tcase_add_test(tc, efl_ui_win_multi_touch_inputs);
tcase_add_test(tc, elm_win_test_rotation);
tcase_add_test(tc, elm_win_test_default_type);
+ tcase_add_test(tc, elm_win_test_frame_space);
#ifdef HAVE_ELEMENTARY_X
tcase_add_test(tc, elm_win_autohide);
tcase_add_test(tc, elm_win_autohide_and_policy_quit_last_window_hidden);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.