This is an automated email from the git hooks/post-receive script.

git pushed a commit to reference refs/pull/198/head
in repository enlightenment.

View the commit online.

commit f7c03babee4a9285db173b08272dee6808115768
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 21 12:37:36 2026 -0600

    e_comp_object - finish a minimise asked for during the show animation
    
    A window minimised while the theme's show animation was still running
    never left the screen. On Wayland it stayed drawn for good, minimised
    but visible; on X11 its WM_STATE stayed Normal, so pagers and taskbars
    never saw it minimised. Minimising right after mapping a window, or
    right after restoring one, is enough to hit it, and the animation is
    0.15s in the default theme.
    
    During the show animation _e_comp_intercept_hide() only signals the
    iconify and puts the hide off with defer_hide, without starting the
    theme's hide animation. The animation that ends next is therefore the
    show one, and _e_comp_object_done_defer() carries out a deferred hide
    only on the end of a hide animation or an effect, so the hide was
    dropped. Now the end of the show animation starts the hide that was
    put off, with its own animation. A restore before then clears
    defer_hide, as it already did, so it is not undone.
    
    _e_comp_object_done_defer() is shared and static; it is the callback
    for the theme's e,action,*,done signals and for visibility effects,
    and only the theme's show animation emits e,action,show,done. Tested
    on both backends: wl-client-iconify drives E's iconify action on
    Wayland, and x11-iconify has an EFL client ask with WM_CHANGE_STATE,
    on one head and on two. Both run with the theme's animations stretched
    by ELM_TRANSITION_DURATION_FACTOR so the request lands in the show
    animation. Without the change they fail every run, on Wayland with the
    window still visible and on X11 with WM_STATE Normal; with it they
    pass 20 runs out of 20, and the whole suite passes.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/bin/e_comp_object.c                 |   7 ++
 src/tests/wayland/e_wl_testkit.c        |  28 +++++++
 src/tests/wayland/e_wl_testkit.h        |   8 ++
 src/tests/wayland/meson.build           |  14 +++-
 src/tests/wayland/test_client_iconify.c |  42 +++++++++++
 src/tests/x11/meson.build               |  15 ++--
 src/tests/x11/test_iconify.c            | 126 ++++++++++++++++++++++++++++++++
 7 files changed, 233 insertions(+), 7 deletions(-)

diff --git a/src/bin/e_comp_object.c b/src/bin/e_comp_object.c
index 8cf747b0c..0cabfd742 100644
--- a/src/bin/e_comp_object.c
+++ b/src/bin/e_comp_object.c
@@ -810,6 +810,13 @@ _e_comp_object_done_defer(void *data, Evas_Object *obj EINA_UNUSED, const char *
    /* hide only after animation finishes to guarantee a full run of the animation */
    if (cw->defer_hide && ((!strcmp(emission, "e,action,hide,done")) || (!strcmp(emission, "e,action,done"))))
      evas_object_hide(cw->smart_obj);
+   else if (cw->defer_hide && (!strcmp(emission, "e,action,show,done")))
+     {
+        /* An iconify during the show animation only put the hide off, and
+         * the hide animation never started: start it now. */
+        cw->defer_hide = 0;
+        evas_object_hide(cw->smart_obj);
+     }
    else if (!cw->deleted)
      {
         e_comp_shape_queue();
diff --git a/src/tests/wayland/e_wl_testkit.c b/src/tests/wayland/e_wl_testkit.c
index aaf6d8654..9aa09c0b4 100644
--- a/src/tests/wayland/e_wl_testkit.c
+++ b/src/tests/wayland/e_wl_testkit.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
 
@@ -654,6 +655,33 @@ tk_expect(Tk *tk, const char *app_id)
    return c;
 }
 
+static double
+_tk_now(void)
+{
+   struct timespec ts;
+
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+   return ts.tv_sec + (ts.tv_nsec / 1e9);
+}
+
+Tk_Client *
+tk_wait_states(Tk *tk, const char *app_id, unsigned int mask,
+               unsigned int want, const char *what)
+{
+   double deadline = _tk_now() + TK_WAIT_SECONDS;
+   Tk_Client *c;
+
+   for (;;)
+     {
+        c = tk_expect(tk, app_id);
+        if ((c->states & mask) == want) return c;
+        if (_tk_now() > deadline) break;
+        tk_sync(tk);
+     }
+   tk_fail(tk, "%s: states still 0x%x after %ds, waiting for 0x%x in 0x%x",
+           what, c->states, TK_WAIT_SECONDS, want, mask);
+}
+
 void
 tk_action(Tk *tk, unsigned int id, const char *name, const char *params)
 {
diff --git a/src/tests/wayland/e_wl_testkit.h b/src/tests/wayland/e_wl_testkit.h
index 538526d00..56169bfed 100644
--- a/src/tests/wayland/e_wl_testkit.h
+++ b/src/tests/wayland/e_wl_testkit.h
@@ -136,6 +136,14 @@ Tk_Client *tk_find(Tk *tk, const char *app_id);
 /* Like tk_find, but a miss is a failure rather than a NULL to check. */
 Tk_Client *tk_expect(Tk *tk, const char *app_id);
 
+/* Some of what E does to a window is animated by the theme. Waits, one
+ * compositor main loop iteration at a time, until the window's states
+ * masked by mask are want, and fails saying what it waited for if that
+ * takes more than TK_WAIT_SECONDS. */
+#define TK_WAIT_SECONDS 10
+Tk_Client *tk_wait_states(Tk *tk, const char *app_id, unsigned int mask,
+                          unsigned int want, const char *what);
+
 /* Run one of E's own actions on a window. Empty or NULL params means none. */
 void tk_action(Tk *tk, unsigned int id, const char *name, const char *params);
 
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 31f493a96..3c28733fa 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -43,7 +43,8 @@ test('wl-globals',
 )
 
 # Protocol tests. Each is a plain wayland-client program that exits non-zero
-# with an explanatory message; run-nested.sh supplies the compositor.
+# with an explanatory message; run-nested.sh supplies the compositor. A
+# third element adds to the environment the compositor runs in.
 wl_protocol_tests = [
   ['test-module', 'test_wl_test.c'],
   ['xdg-defunct-surfaces', 'test_xdg_defunct.c'],
@@ -69,6 +70,8 @@ wl_protocol_tests = [
   ['maximize-restore', 'test_maximize_restore.c'],
   ['xdg-decoration', 'test_xdg_decoration.c'],
   ['shm-truncate', 'test_shm_truncate.c'],
+  ['client-iconify', 'test_client_iconify.c',
+   {'ELM_TRANSITION_DURATION_FACTOR': '4'}],
 ]
 
 tk_src = files('e_wl_testkit.c')
@@ -78,10 +81,17 @@ foreach t: wl_protocol_tests
     [t[1], tk_src, test_proto_src],
     dependencies: [dependency('wayland-client')],
   )
+  env = wl_test_env
+  if t.length() > 2
+    env = environment({'E_TEST_COMPOSITOR': e_test_compositor})
+    foreach k, v: t[2]
+      env.set(k, v)
+    endforeach
+  endif
   test('wl-' + t[0],
     find_program('run-nested.sh'),
     args: [exe],
-    env: wl_test_env,
+    env: env,
     timeout: 120,
   )
 endforeach
diff --git a/src/tests/wayland/test_client_iconify.c b/src/tests/wayland/test_client_iconify.c
new file mode 100644
index 000000000..2d71a5e66
--- /dev/null
+++ b/src/tests/wayland/test_client_iconify.c
@@ -0,0 +1,42 @@
+/* Minimise a window through E's own action while the theme's show
+ * animation still runs for it, then get it back. The minimised window has
+ * to leave the screen once the animations are over, and the restored one
+ * to come back. meson stretches the theme's animations for this test, so
+ * that the action is sure to land in the show animation. */
+#include <stdio.h>
+
+#include "e_wl_testkit.h"
+
+#define PROG "test-client-iconify"
+#define APP_ID "e.test.client_iconify"
+#define W 320
+#define H 240
+
+#define MASK (WL_TEST_CLIENT_STATE_ICONIFIED | WL_TEST_CLIENT_STATE_VISIBLE)
+
+int
+main(void)
+{
+   Tk *tk;
+   unsigned int id;
+   int i;
+
+   tk = tk_connect(PROG);
+   tk_toplevel_new(tk, APP_ID, "iconify under test", W, H);
+   id = tk_expect(tk, APP_ID)->id;
+
+   /* Twice: restoring runs the show animation again. */
+   for (i = 0; i < 2; i++)
+     {
+        tk_action(tk, id, "window_iconic_toggle", NULL);
+        tk_wait_states(tk, APP_ID, MASK, WL_TEST_CLIENT_STATE_ICONIFIED,
+                       "minimised while being shown");
+        tk_action(tk, id, "window_iconic_toggle", NULL);
+        tk_wait_states(tk, APP_ID, MASK, WL_TEST_CLIENT_STATE_VISIBLE,
+                       "restored");
+     }
+
+   printf(PROG ": ok\n");
+   tk_disconnect(tk);
+   return 0;
+}
diff --git a/src/tests/x11/meson.build b/src/tests/x11/meson.build
index e61f23b25..66ab716ff 100644
--- a/src/tests/x11/meson.build
+++ b/src/tests/x11/meson.build
@@ -11,23 +11,28 @@
 # The windows under test are elementary ones, drawing their own decorations
 # on X11, and ecore_x drives the pointer. Not in a Wayland-only build.
 if not config_h.has('HAVE_WAYLAND_ONLY')
-  x11_test_env = environment()
-  x11_test_env.set('E_TEST_COMPOSITOR', e_test_compositor)
-
   x11_test_deps = [dep_elementary, dep_ecore_x]
   x11_tests = [
     ['x11-csd-move', executable('test_x11_csd_move', 'test_csd_move.c',
                                 dependencies: x11_test_deps)],
     ['x11-csd-resize', executable('test_x11_csd_resize', 'test_csd_resize.c',
                                   dependencies: x11_test_deps)],
+    ['x11-iconify', executable('test_x11_iconify', 'test_iconify.c',
+                               dependencies: x11_test_deps),
+     {'ELM_TRANSITION_DURATION_FACTOR': '4'}],
   ]
 
   # Two heads as well: a window on the right-hand screen is far from 0,0,
   # which is where a drag that lost its starting point puts it.
   foreach t: x11_tests
     foreach heads: ['1', '2']
-      env = x11_test_env
-      env.set('E_TEST_HEADS', heads)
+      env = environment({'E_TEST_COMPOSITOR': e_test_compositor,
+                         'E_TEST_HEADS': heads})
+      if t.length() > 2
+        foreach k, v: t[2]
+          env.set(k, v)
+        endforeach
+      endif
       test(heads == '1' ? t[0] : t[0] + '-2heads',
         files('run-x11.sh'),
         args: [t[1]],
diff --git a/src/tests/x11/test_iconify.c b/src/tests/x11/test_iconify.c
new file mode 100644
index 000000000..4df630769
--- /dev/null
+++ b/src/tests/x11/test_iconify.c
@@ -0,0 +1,126 @@
+/* Minimise a window, as a client asks with ICCCM's WM_CHANGE_STATE: it
+ * must end up Iconic and gone from the screen, whether it is asked once
+ * the window is shown or while E is still showing it. What is on the
+ * screen is read back from the root window, where E composites, with each
+ * window filled with a colour nothing else on the screen has.
+ *
+ * Getting the window back is not tested here: elementary asks for it with
+ * _NET_ACTIVE_WINDOW, which the test profile's activation policy ignores,
+ * and E keeps an iconified window mapped, so mapping it again does not ask
+ * either. */
+#include "x11_testkit.h"
+
+#define W 300
+#define H 200
+#define MARK 0xff00ff
+
+static unsigned int
+_screen_pixel(int x, int y)
+{
+   Ecore_X_Display *disp = ecore_x_display_get();
+   Ecore_X_Screen *screen = ecore_x_default_screen_get();
+   Ecore_X_Image *im;
+   unsigned int *data, pixel;
+   int bpl, rows, bpp;
+
+   ecore_x_sync();
+   im = ecore_x_image_new(1, 1, ecore_x_default_visual_get(disp, screen),
+                          ecore_x_default_depth_get(disp, screen));
+   if (!im) xtk_fail("cannot make an image to read the screen into");
+   if (!ecore_x_image_get(im, ecore_x_window_root_first_get(), x, y,
+                          0, 0, 1, 1))
+     xtk_fail("cannot read the screen at %d,%d", x, y);
+   data = "" &bpl, &rows, &bpp);
+   pixel = data[0] & 0xffffff;
+   ecore_x_image_free(im);
+   return pixel;
+}
+
+/* A window filled with MARK at x,y, not shown yet. */
+static Evas_Object *
+_marked_window_add(int x, int y, const char *title)
+{
+   Evas_Object *win, *mark;
+
+   win = elm_win_add(NULL, title, ELM_WIN_BASIC);
+   elm_win_title_set(win, title);
+   elm_win_autodel_set(win, EINA_FALSE);
+   mark = evas_object_rectangle_add(evas_object_evas_get(win));
+   evas_object_color_set(mark, 255, 0, 255, 255);
+   evas_object_size_hint_weight_set(mark, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, mark);
+   evas_object_data_set(win, "xtk_bg", mark);
+   evas_object_show(mark);
+   evas_object_resize(win, W, H);
+   evas_object_move(win, x, y);
+   /* Placed where it asks, as a session restore would have it. */
+   ecore_x_icccm_size_pos_hints_set(elm_win_xwindow_get(win), EINA_TRUE,
+                                    ECORE_X_GRAVITY_NW, 0, 0, 0, 0,
+                                    0, 0, 1, 1, 0.0, 0.0);
+   return win;
+}
+
+/* Shows a new window and minimises it as soon as E starts drawing it,
+ * while the theme's show animation runs: meson stretches the theme's
+ * animations for this test, so that the request lands in it. x,y is
+ * where to look for it on the screen. */
+static Evas_Object *
+_iconify_while_showing(int *x, int *y)
+{
+   Evas_Object *win = _marked_window_add(450, 50, "iconify while showing");
+   unsigned int before;
+
+   evas_object_show(win);
+   while (!ecore_x_window_visible_get(elm_win_xwindow_get(win)))
+     ecore_main_loop_iterate();
+   xtk_content_point(win, W / 2, H / 2, x, y);
+   before = _screen_pixel(*x, *y);
+   while (_screen_pixel(*x, *y) == before)
+     {
+        if (before == MARK)
+          xtk_fail("the window was shown before it could be minimised");
+        ecore_main_loop_iterate();
+     }
+   elm_win_iconified_set(win, EINA_TRUE);
+   return win;
+}
+
+static void
+_expect_iconic(Evas_Object *win, int x, int y, const char *what)
+{
+   int state = ecore_x_icccm_state_get(elm_win_xwindow_get(win));
+
+   if (state != ECORE_X_WINDOW_STATE_HINT_ICONIC)
+     xtk_fail("a window minimised %s has WM_STATE %d, not Iconic", what,
+              state);
+   if (_screen_pixel(x, y) == MARK)
+     xtk_fail("a window minimised %s is still on the screen", what);
+}
+
+int
+main(int argc, char **argv)
+{
+   Evas_Object *shown, *showing;
+   int px, py, qx, qy;
+
+   xtk_init(argc, argv, "test-x11-iconify");
+   shown = _marked_window_add(50, 50, "iconify once shown");
+   evas_object_show(shown);
+   xtk_settle(1.0);
+   xtk_content_point(shown, W / 2, H / 2, &px, &py);
+   if (_screen_pixel(px, py) != MARK)
+     xtk_fail("the window is not on the screen before minimising: 0x%06x",
+              _screen_pixel(px, py));
+
+   elm_win_iconified_set(shown, EINA_TRUE);
+   showing = _iconify_while_showing(&qx, &qy);
+   xtk_settle(3.0);
+
+   _expect_iconic(shown, px, py, "once shown");
+   _expect_iconic(showing, qx, qy, "while being shown");
+
+   printf("test-x11-iconify: ok\n");
+   evas_object_del(showing);
+   xtk_shutdown(shown);
+   return 0;
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to