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

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit 150cc072d25e038c8c75a539df958ef2a85be4cf
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Nov 30 21:08:17 2026 -0600

    tests - restore a maximized X11 window that declares a shadow
    
    test_maximize_restore.c asks a Wayland client whose surface is bigger
    than its window whether it comes back from maximized at the size it
    had. E saves and restores that size in e_client.c, which the X11
    compositor shares, so the same question is now asked on X11, of a
    window that declares 16 pixels of shadow on each side with
    _GTK_FRAME_EXTENTS, as GTK does.
    
    The window is a bare ecore_x one: an elementary window puts its own
    size back when it is unmaximized, and the test passed with E restoring
    the wrong size. Saving a width 7 pixels too wide when maximizing makes
    this one fail, on one head and two. Run 20 times on each.
    
    Co-Authored-By: Claude Opus 5 <[email protected]>
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/tests/x11/meson.build             |  3 ++
 src/tests/x11/test_maximize_restore.c | 94 +++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/src/tests/x11/meson.build b/src/tests/x11/meson.build
index cf9d61cbf..e8661a432 100644
--- a/src/tests/x11/meson.build
+++ b/src/tests/x11/meson.build
@@ -20,6 +20,9 @@ if not config_h.has('HAVE_WAYLAND_ONLY')
     ['x11-iconify', executable('test_x11_iconify', 'test_iconify.c',
                                dependencies: x11_test_deps),
      {'ELM_TRANSITION_DURATION_FACTOR': '4'}],
+    ['x11-maximize-restore', executable('test_x11_maximize_restore',
+                                        'test_maximize_restore.c',
+                                        dependencies: x11_test_deps)],
     ['x11-key-binding', executable('test_x11_key_binding', 'test_key_binding.c',
                                    dependencies: x11_test_deps)],
   ]
diff --git a/src/tests/x11/test_maximize_restore.c b/src/tests/x11/test_maximize_restore.c
new file mode 100644
index 000000000..73404e26d
--- /dev/null
+++ b/src/tests/x11/test_maximize_restore.c
@@ -0,0 +1,94 @@
+/* A window whose X window is bigger than what the user sees, because part
+ * of it is shadow it declares with _GTK_FRAME_EXTENTS, as GTK does, must
+ * come back from maximized at the size it had before.
+ *
+ * The window is a bare ecore_x one: an elementary window puts its own size
+ * back when it is unmaximized, which would hide what E did. A GTK window
+ * leaves that to the window manager.
+ *
+ * The Wayland side of this is test_maximize_restore.c. Saving the size and
+ * restoring it happen in e_client.c, which both compositors share. */
+#include "x11_testkit.h"
+
+#define SHADOW 16
+#define W (400 + (2 * SHADOW))
+#define H (300 + (2 * SHADOW))
+
+static Eina_Bool
+_maximized_get(Ecore_X_Window win)
+{
+   Ecore_X_Window_State *states = NULL;
+   unsigned int num = 0, i;
+   int found = 0;
+
+   if (!ecore_x_netwm_window_state_get(win, &states, &num)) return EINA_FALSE;
+   for (i = 0; i < num; i++)
+     if ((states[i] == ECORE_X_WINDOW_STATE_MAXIMIZED_VERT) ||
+         (states[i] == ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ))
+       found++;
+   free(states);
+   return found == 2;
+}
+
+static void
+_maximize(Ecore_X_Window win, Eina_Bool on, const char *what)
+{
+   double end = ecore_time_get() + 10.0;
+
+   ecore_x_netwm_state_request_send(win, ecore_x_window_root_first_get(),
+                                    ECORE_X_WINDOW_STATE_MAXIMIZED_VERT,
+                                    ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ, on);
+   while (_maximized_get(win) != on)
+     {
+        if (ecore_time_get() > end) xtk_fail("%s never happened", what);
+        xtk_settle(0.05);
+     }
+   /* The state is set before the window is resized to match it. */
+   xtk_settle(0.5);
+}
+
+static void
+_size_get(Ecore_X_Window win, int *w, int *h)
+{
+   ecore_x_sync();
+   ecore_x_window_geometry_get(win, NULL, NULL, w, h);
+}
+
+int
+main(int argc, char **argv)
+{
+   unsigned int extents[4] = { SHADOW, SHADOW, SHADOW, SHADOW };
+   Ecore_X_Window win;
+   int w0, h0, mw, mh, w, h;
+
+   xtk_init(argc, argv, "test-x11-maximize-restore");
+   win = ecore_x_window_new(0, 100, 100, W, H);
+   ecore_x_icccm_title_set(win, "maximize restore");
+   /* Before the window is shown: E reads it when it starts managing it. */
+   ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_GTK_FRAME_EXTENTS,
+                                  extents, 4);
+   ecore_x_window_show(win);
+   xtk_settle(1.0);
+   _size_get(win, &w0, &h0);
+   if ((w0 != W) || (h0 != H))
+     xtk_fail("mapped at %dx%d, asked for %dx%d", w0, h0, W, H);
+
+   _maximize(win, EINA_TRUE, "maximizing");
+   _size_get(win, &mw, &mh);
+   if ((mw <= w0) || (mh <= h0))
+     xtk_fail("maximized to %dx%d, no bigger than the %dx%d it was",
+              mw, mh, w0, h0);
+
+   _maximize(win, EINA_FALSE, "unmaximizing");
+   _size_get(win, &w, &h);
+   if ((w != w0) || (h != h0))
+     xtk_fail("restored to %dx%d, it was %dx%d before maximizing, with %d "
+              "of shadow on each side", w, h, w0, h0, SHADOW);
+
+   printf("test-x11-maximize-restore: ok, %dx%d, %dx%d maximized\n",
+          w0, h0, mw, mh);
+   ecore_x_window_free(win);
+   ecore_x_shutdown();
+   elm_shutdown();
+   return 0;
+}

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

Reply via email to