This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch headless-session
in repository enlightenment.
View the commit online.
commit 08b653fba303b5d3d573f79c8c2d2bdfe33efc8e
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Dec 1 22:20:27 2026 -0600
tests - keep a frame listener fed through the screensaver and fullscreen
A remote desktop server reads the screen through a frame listener on the
headless backend, and depends on two things E does to rendering on
other backends.
The screensaver stops E rendering. With a listener attached and a
client that keeps committing, no frame is delivered once the screensaver
has blanked the screen, and client commits alone do not wake it. Input
injected through e_comp_wl_input_inject_pointer_motion() and _key()
does: the screensaver goes off and the frames show what the client
committed meanwhile. E stops drawing a second after the screensaver's
fade ends, on a timer, so the test commits until three commits in a row
produce no frame, and fails only at the wait limit. It runs with
ELM_TRANSITION_DURATION_FACTOR=0.1, which shortens the fade.
A fullscreen client must not make E stop rendering. On X11 an opaque
client covering the output makes E hide its canvas (nocomp, started from
_e_comp_cb_update() after a second). Two things keep it from starting on
Wayland. e_comp_util_client_is_fullscreen(), which
_e_comp_fullscreen_check() calls, wants !ec->argb, and e_comp_wl.c marks
every client argb. And _e_comp_fullscreen_check() wants nothing visible
above the client, which E's own cursor is: e_pointer_object_set() puts
it on the canvas above the clients, and the buffer backend draws it. A
client that hides its cursor, as a video player does, takes it away. The
test client hides its cursor on pointer enter and paints an opaque XRGB
buffer over the whole output for longer than the delay, reading its
colour through the frames, in fullscreen and after it. It runs with the
default e_comp configuration (nocomp_fs on), as a user has, the tests
starting E with a private HOME.
Both pass on the existing code. They fail when the behaviour is broken:
with the screensaver's fade, signals and manual render removed the
first reports that E is still rendering, and with only ec->argb cleared
the second reads a frozen black pixel. A key or a pointer motion that
does not reset the idle timer fails the first at the wake.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/tests/wayland/e_wl_framekit.h | 169 +++++++++++++++++++++++
src/tests/wayland/meson.build | 3 +
src/tests/wayland/test_headless_fullscreen.c | 198 +++++++++++++++++++++++++++
src/tests/wayland/test_headless_saver.c | 172 +++++++++++++++++++++++
4 files changed, 542 insertions(+)
diff --git a/src/tests/wayland/e_wl_framekit.h b/src/tests/wayland/e_wl_framekit.h
new file mode 100644
index 000000000..7fe21507a
--- /dev/null
+++ b/src/tests/wayland/e_wl_framekit.h
@@ -0,0 +1,169 @@
+/* What the tests of a session with a frame listener share: a window the
+ * client paints in one colour, and a listener that reads that colour back
+ * through the frames E renders. A wait is a round trip through the
+ * compositor's main loop, repeated until the state wanted is reached, and
+ * fails after TK_WAIT_SECONDS. Needs _GNU_SOURCE for memfd_create. */
+#ifndef E_WL_FRAMEKIT_H
+#define E_WL_FRAMEKIT_H
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/mman.h>
+
+#include "e_wl_testkit.h"
+
+#define FK_WL_TEST_VERSION 17
+
+typedef struct
+{
+ Tk *tk;
+ struct wl_test *tester;
+ struct wl_shm *shm;
+ int answered;
+ unsigned int count;
+ unsigned int argb;
+ int pixels_w, pixels_h;
+ /* The last answer to get_screensaver, -1 if none. */
+ int saver;
+} Fk;
+
+/* A buffer the client repaints in place and commits again. */
+typedef struct
+{
+ struct wl_buffer *buffer;
+ uint32_t *pixels;
+ int w, h;
+} Fk_Buffer;
+
+static void
+_fk_frames(void *data, struct wl_test *t __attribute__((unused)),
+ uint32_t id __attribute__((unused)),
+ uint32_t zone __attribute__((unused)), uint32_t count,
+ int32_t x __attribute__((unused)), int32_t y __attribute__((unused)),
+ int32_t w __attribute__((unused)), int32_t h __attribute__((unused)),
+ uint32_t pixels_ok __attribute__((unused)), int32_t pixels_w,
+ int32_t pixels_h, int32_t pixels_stride __attribute__((unused)),
+ uint32_t argb)
+{
+ Fk *fk = data;
+
+ fk->count = count;
+ fk->argb = argb;
+ fk->pixels_w = pixels_w;
+ fk->pixels_h = pixels_h;
+ fk->answered = 1;
+}
+
+static void
+_fk_screensaver(void *data, struct wl_test *t __attribute__((unused)),
+ uint32_t on)
+{
+ Fk *fk = data;
+
+ fk->saver = !!on;
+}
+
+static const struct wl_test_listener _fk_listener =
+{
+ .frames = _fk_frames,
+ .screensaver = _fk_screensaver
+};
+
+static void
+fk_init(Fk *fk, Tk *tk)
+{
+ memset(fk, 0, sizeof(*fk));
+ fk->tk = tk;
+ fk->tester = tk_bind(tk, &wl_test_interface, FK_WL_TEST_VERSION);
+ if (!fk->tester) tk_fail(tk, "no wl_test version %d", FK_WL_TEST_VERSION);
+ wl_test_add_listener(fk->tester, &_fk_listener, fk);
+ fk->shm = tk_bind(tk, &wl_shm_interface, 1);
+ if (!fk->shm) tk_fail(tk, "no wl_shm");
+}
+
+/* A listener reading the pixel x,y of the screen. */
+static void
+fk_listen(Fk *fk, unsigned int id, int x, int y)
+{
+ wl_test_frame_listen(fk->tester, id, 0, x, y);
+ tk_sync(fk->tk);
+}
+
+/* What the listener saw so far: the frame count and the pixel it reads. */
+static void
+fk_frames_get(Fk *fk, unsigned int id)
+{
+ fk->answered = 0;
+ wl_test_get_frames(fk->tester, id, 0);
+ tk_sync(fk->tk);
+ if (!fk->answered) tk_fail(fk->tk, "no answer to get_frames(%u)", id);
+}
+
+/* Until the listener has read this pixel through a frame. */
+static void
+fk_argb_wait(Fk *fk, unsigned int id, unsigned int want, const char *what)
+{
+ double end = tk_now() + tk_wait_seconds();
+
+ for (;;)
+ {
+ fk_frames_get(fk, id);
+ if (fk->argb == want) return;
+ if (tk_now() > end)
+ tk_fail(fk->tk, "%s: listener %u read %#x, wanted %#x after %u "
+ "frames", what, id, fk->argb, want, fk->count);
+ }
+}
+
+static void
+fk_buffer_new(Fk *fk, Fk_Buffer *buf, int w, int h, uint32_t format)
+{
+ struct wl_shm_pool *pool;
+ int fd, size = w * h * 4;
+
+ fd = memfd_create("framekit", MFD_CLOEXEC);
+ if ((fd < 0) || (ftruncate(fd, size) < 0))
+ tk_fail(fk->tk, "cannot make a %dx%d buffer", w, h);
+ buf->pixels = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (buf->pixels == MAP_FAILED) tk_fail(fk->tk, "cannot map a buffer");
+ pool = wl_shm_create_pool(fk->shm, fd, size);
+ buf->buffer = wl_shm_pool_create_buffer(pool, 0, w, h, w * 4, format);
+ wl_shm_pool_destroy(pool);
+ close(fd);
+ buf->w = w;
+ buf->h = h;
+}
+
+/* Fill the buffer with one colour and commit it, all of it damaged. */
+static void
+fk_paint(struct wl_surface *surface, Fk_Buffer *buf, unsigned int argb)
+{
+ int i;
+
+ for (i = 0; i < buf->w * buf->h; i++) buf->pixels[i] = argb;
+ wl_surface_attach(surface, buf->buffer, 0, 0);
+ wl_surface_damage(surface, 0, 0, buf->w, buf->h);
+ wl_surface_commit(surface);
+}
+
+/* Wait a moment for an answer there is no event to wait on. */
+static void
+fk_pause(int msec)
+{
+ struct timespec step = { 0, msec * 1000000L };
+
+ nanosleep(&step, NULL);
+}
+
+/* A colour that is a new one each time, opaque. */
+static unsigned int
+fk_colour_next(unsigned int *seed)
+{
+ *seed += 1;
+ return 0xff000000 | ((*seed * 0x0b1d27) & 0xffffff) | 0x101010;
+}
+
+#endif
diff --git a/src/tests/wayland/meson.build b/src/tests/wayland/meson.build
index 3477daaf2..92b787fe1 100644
--- a/src/tests/wayland/meson.build
+++ b/src/tests/wayland/meson.build
@@ -137,6 +137,9 @@ wl_protocol_tests = [
['input-inject', 'test_input_inject.c'],
['frame-listener', 'test_frame_listener.c'],
['frame-listener-zones', 'test_frame_listener_zones.c'],
+ ['headless-fullscreen', 'test_headless_fullscreen.c'],
+ ['headless-saver', 'test_headless_saver.c',
+ {'ELM_TRANSITION_DURATION_FACTOR': '0.1'}],
]
tk_src = files('e_wl_testkit.c')
diff --git a/src/tests/wayland/test_headless_fullscreen.c b/src/tests/wayland/test_headless_fullscreen.c
new file mode 100644
index 000000000..7baae0693
--- /dev/null
+++ b/src/tests/wayland/test_headless_fullscreen.c
@@ -0,0 +1,198 @@
+/* A fullscreen client that covers the output does not stop E rendering: a
+ * frame listener, such as a remote desktop server, keeps getting frames
+ * that show the client's latest colour, in fullscreen and after it. On X11
+ * E hides its canvas then (nocomp), which a headless session cannot do.
+ *
+ * Two things keep nocomp from starting on Wayland, and the client here
+ * clears neither on its own account but the second:
+ * - e_comp_util_client_is_fullscreen(), called by _e_comp_fullscreen_check(),
+ * wants !ec->argb, and e_comp_wl.c marks every client argb;
+ * - _e_comp_fullscreen_check() wants nothing visible above the client, and
+ * E's own cursor is: the buffer backend draws it on the canvas, at a layer
+ * above the clients. A client that hides its cursor, as a video player
+ * does, takes it away.
+ * So the client hides its cursor, and the test pins the outcome, not the
+ * mechanism. */
+#define _GNU_SOURCE 1
+#include "e_wl_framekit.h"
+
+#define PROG "test-headless-fullscreen"
+#define APP_ID "e.test.headless-fullscreen"
+#define WIN_W 400
+#define WIN_H 300
+#define WIN_X 200
+#define WIN_Y 150
+/* E starts nocomp one second after a client is found to cover the output,
+ * on a timer: only painting for longer shows it did not. */
+#define NOCOMP_SECONDS 2.5
+#define PAINT_PERIOD_MSEC 20
+
+static Fk fk;
+static int entered;
+
+/* A video player hides the cursor over its window. */
+static void
+_pointer_enter(void *data __attribute__((unused)),
+ struct wl_pointer *pointer, uint32_t serial,
+ struct wl_surface *surface __attribute__((unused)),
+ wl_fixed_t sx __attribute__((unused)),
+ wl_fixed_t sy __attribute__((unused)))
+{
+ wl_pointer_set_cursor(pointer, serial, NULL, 0, 0);
+ entered++;
+}
+
+static void
+_pointer_leave(void *data __attribute__((unused)),
+ struct wl_pointer *pointer __attribute__((unused)),
+ uint32_t serial __attribute__((unused)),
+ struct wl_surface *surface __attribute__((unused)))
+{
+}
+
+static void
+_pointer_motion(void *data __attribute__((unused)),
+ struct wl_pointer *pointer __attribute__((unused)),
+ uint32_t time __attribute__((unused)),
+ wl_fixed_t sx __attribute__((unused)),
+ wl_fixed_t sy __attribute__((unused)))
+{
+}
+
+static void
+_pointer_button(void *data __attribute__((unused)),
+ struct wl_pointer *pointer __attribute__((unused)),
+ uint32_t serial __attribute__((unused)),
+ uint32_t time __attribute__((unused)),
+ uint32_t button __attribute__((unused)),
+ uint32_t state __attribute__((unused)))
+{
+}
+
+static void
+_pointer_axis(void *data __attribute__((unused)),
+ struct wl_pointer *pointer __attribute__((unused)),
+ uint32_t time __attribute__((unused)),
+ uint32_t axis __attribute__((unused)),
+ wl_fixed_t value __attribute__((unused)))
+{
+}
+
+static const struct wl_pointer_listener _pointer_listener =
+{
+ .enter = _pointer_enter,
+ .leave = _pointer_leave,
+ .motion = _pointer_motion,
+ .button = _pointer_button,
+ .axis = _pointer_axis
+};
+
+/* A pointer that hides the cursor on each enter. */
+static void
+_cursor_watch(void)
+{
+ struct wl_seat *seat = tk_bind(fk.tk, &wl_seat_interface, 1);
+
+ if (!seat) tk_fail(fk.tk, "no wl_seat");
+ wl_pointer_add_listener(wl_seat_get_pointer(seat), &_pointer_listener,
+ NULL);
+}
+
+/* Put the pointer over the window and wait for its enter, which is where
+ * the cursor gets hidden. */
+static void
+_cursor_hide(int x, int y)
+{
+ double end = tk_now() + tk_wait_seconds();
+
+ tk_pointer_warp(fk.tk, x, y);
+ while (!entered)
+ {
+ tk_sync(fk.tk);
+ if (tk_now() > end)
+ tk_fail(fk.tk, "the pointer never entered the window at %d,%d",
+ x, y);
+ }
+}
+
+/* Paint new colours for NOCOMP_SECONDS, each of which has to reach the
+ * listener through a frame. */
+static void
+_follow(struct wl_surface *surface, Fk_Buffer *buf, unsigned int id,
+ unsigned int *seed, const char *what)
+{
+ double end = tk_now() + NOCOMP_SECONDS;
+ unsigned int colour;
+
+ while (tk_now() < end)
+ {
+ colour = fk_colour_next(seed);
+ fk_paint(surface, buf, colour);
+ fk_argb_wait(&fk, id, colour, what);
+ fk_pause(PAINT_PERIOD_MSEC);
+ }
+}
+
+static void
+_size_wait(Tk_Toplevel *top, int w, int h, const char *what)
+{
+ double end = tk_now() + tk_wait_seconds();
+ int cw = 0, ch = 0;
+
+ for (;;)
+ {
+ tk_sync(fk.tk);
+ tk_toplevel_configured(top, &cw, &ch, NULL);
+ if ((cw == w) && (ch == h)) return;
+ if (tk_now() > end)
+ tk_fail(fk.tk, "%s: configured %dx%d, wanted %dx%d", what, cw, ch,
+ w, h);
+ }
+}
+
+int
+main(void)
+{
+ Fk_Buffer window, screen;
+ Tk_Toplevel *top;
+ struct wl_surface *surface;
+ unsigned int seed = 0, colour;
+ int x, y;
+
+ fk.tk = tk_connect(PROG);
+ fk_init(&fk, fk.tk);
+ _cursor_watch();
+ top = tk_toplevel_new(fk.tk, APP_ID, "fullscreen", WIN_W, WIN_H);
+ surface = tk_toplevel_surface(top);
+ wl_test_move_surface(fk.tester, surface, WIN_X, WIN_Y);
+ tk_settle(fk.tk);
+ tk_surface_geometry(fk.tk, surface, &x, &y, NULL, NULL);
+
+ _cursor_hide(x + (WIN_W / 2), y + (WIN_H / 2));
+
+ /* Opaque, as a video player's window is: a client that draws alpha is
+ * never taken for a fullscreen one. */
+ fk_buffer_new(&fk, &window, WIN_W, WIN_H, WL_SHM_FORMAT_XRGB8888);
+ fk_listen(&fk, 1, x + (WIN_W / 2), y + (WIN_H / 2));
+ colour = fk_colour_next(&seed);
+ fk_paint(surface, &window, colour);
+ fk_argb_wait(&fk, 1, colour, "the window before fullscreen");
+ if ((fk.pixels_w < WIN_X + WIN_W) || (fk.pixels_h < WIN_Y + WIN_H))
+ tk_fail(fk.tk, "the output is %dx%d", fk.pixels_w, fk.pixels_h);
+
+ fk_buffer_new(&fk, &screen, fk.pixels_w, fk.pixels_h,
+ WL_SHM_FORMAT_XRGB8888);
+ fk_listen(&fk, 2, fk.pixels_w / 2, fk.pixels_h / 2);
+ xdg_toplevel_set_fullscreen(tk_toplevel_xdg(top), NULL);
+ _size_wait(top, screen.w, screen.h, "going fullscreen");
+ _follow(surface, &screen, 2, &seed, "fullscreen");
+
+ xdg_toplevel_unset_fullscreen(tk_toplevel_xdg(top));
+ _size_wait(top, WIN_W, WIN_H, "leaving fullscreen");
+ _follow(surface, &window, 1, &seed, "after fullscreen");
+
+ tk_toplevel_del(top);
+ tk_disconnect(fk.tk);
+ printf(PROG ": ok\n");
+ return 0;
+}
diff --git a/src/tests/wayland/test_headless_saver.c b/src/tests/wayland/test_headless_saver.c
new file mode 100644
index 000000000..f6c16fe28
--- /dev/null
+++ b/src/tests/wayland/test_headless_saver.c
@@ -0,0 +1,172 @@
+/* With a frame listener attached, E stops rendering once the screensaver
+ * is on, whatever the client commits, and starts again when input
+ * arrives through the injectors a remote desktop server uses: the frames
+ * then show the latest content. */
+#define _GNU_SOURCE 1
+#include <linux/input-event-codes.h>
+#include "e_wl_framekit.h"
+
+#define PROG "test-headless-saver"
+#define APP_ID "e.test.headless-saver"
+#define WIN_W 400
+#define WIN_H 300
+#define WIN_X 200
+#define WIN_Y 150
+#define TIMEOUT 1
+/* E freezes its canvas a second after the screensaver's fade ends, on a
+ * timer: a commit is not drawn only from then on. */
+#define SETTLE_MSEC 150
+#define FROZEN_COMMITS 3
+
+typedef struct
+{
+ struct wl_surface *surface;
+ Fk_Buffer buffer;
+ unsigned int seed;
+ unsigned int latest;
+} Saver;
+
+static Fk fk;
+static Saver saver;
+
+static int
+_saver_get(void)
+{
+ fk.saver = -1;
+ wl_test_get_screensaver(fk.tester);
+ tk_sync(fk.tk);
+ if (fk.saver < 0) tk_fail(fk.tk, "no answer to get_screensaver");
+ return fk.saver;
+}
+
+static void
+_saver_wait(int on, const char *what)
+{
+ double end = tk_now() + tk_wait_seconds();
+
+ while (_saver_get() != on)
+ {
+ if (tk_now() > end)
+ tk_fail(fk.tk, "screensaver still %s: %s", on ? "off" : "on", what);
+ fk_pause(50);
+ }
+}
+
+static void
+_commit(void)
+{
+ saver.latest = fk_colour_next(&saver.seed);
+ fk_paint(saver.surface, &saver.buffer, saver.latest);
+}
+
+/* Whether E renders a frame within a moment. There is no event for a frame
+ * that never comes. */
+static int
+_rendered_within(unsigned int count, int msec)
+{
+ double end = tk_now() + (msec / 1000.0);
+
+ for (;;)
+ {
+ fk_frames_get(&fk, 1);
+ if (fk.count != count) return 1;
+ if (tk_now() > end) return 0;
+ fk_pause(10);
+ }
+}
+
+/* A commit E does not render, with the screensaver on. While it fades the
+ * screen the frames show a dimmed picture, so what counts is whether a
+ * frame comes, not what is in it. */
+static int
+_commit_rendered(void)
+{
+ unsigned int count;
+
+ fk_frames_get(&fk, 1);
+ count = fk.count;
+ _commit();
+ return _rendered_within(count, SETTLE_MSEC);
+}
+
+/* Keep committing until FROZEN_COMMITS in a row are not rendered. A frame
+ * starts the count again: a commit drawn late is the canvas not frozen
+ * yet. A build that never freezes is caught at the deadline. */
+static void
+_frozen_wait(const char *what)
+{
+ double end = tk_now() + tk_wait_seconds();
+ int quiet = 0;
+
+ _saver_wait(1, what);
+ while (quiet < FROZEN_COMMITS)
+ {
+ if (_commit_rendered()) quiet = 0;
+ else quiet++;
+ if ((quiet < FROZEN_COMMITS) && (tk_now() > end))
+ tk_fail(fk.tk, "%s: still rendering %d seconds after the "
+ "screensaver came on", what, tk_wait_seconds());
+ }
+}
+
+/* The screensaver is on: commits are not drawn, and do not wake it. */
+static void
+_frozen_check(const char *what)
+{
+ int i;
+
+ for (i = 0; i < 3; i++)
+ if (_commit_rendered())
+ tk_fail(fk.tk, "%s: a commit was drawn with the screensaver on", what);
+ if (!_saver_get())
+ tk_fail(fk.tk, "%s: client commits woke the screensaver", what);
+}
+
+/* Input has woken E: the frames show what the client committed while it
+ * was frozen. */
+static void
+_woken_check(const char *what)
+{
+ _saver_wait(0, what);
+ fk_argb_wait(&fk, 1, saver.latest, what);
+}
+
+int
+main(void)
+{
+ Tk_Toplevel *top;
+ int x, y;
+
+ fk.tk = tk_connect(PROG);
+ fk_init(&fk, fk.tk);
+ top = tk_toplevel_new(fk.tk, APP_ID, "saver", WIN_W, WIN_H);
+ saver.surface = tk_toplevel_surface(top);
+ wl_test_move_surface(fk.tester, saver.surface, WIN_X, WIN_Y);
+ tk_settle(fk.tk);
+ tk_surface_geometry(fk.tk, saver.surface, &x, &y, NULL, NULL);
+
+ fk_buffer_new(&fk, &saver.buffer, WIN_W, WIN_H, WL_SHM_FORMAT_XRGB8888);
+ fk_listen(&fk, 1, x + (WIN_W / 2), y + (WIN_H / 2));
+ _commit();
+ fk_argb_wait(&fk, 1, saver.latest, "before the screensaver");
+
+ wl_test_screensaver_configure(fk.tester, TIMEOUT);
+ _frozen_wait("the screensaver comes on");
+ _frozen_check("the screensaver comes on");
+
+ tk_pointer_move(fk.tk, 1, 0);
+ _woken_check("a pointer motion");
+
+ _frozen_wait("the screensaver comes on again");
+ _frozen_check("the screensaver comes on again");
+ wl_test_key_code(fk.tester, KEY_LEFTSHIFT, 1);
+ tk_sync(fk.tk);
+ _woken_check("a key press");
+ wl_test_key_code(fk.tester, KEY_LEFTSHIFT, 0);
+ tk_sync(fk.tk);
+
+ tk_toplevel_del(top);
+ tk_disconnect(fk.tk);
+ printf(PROG ": ok\n");
+ return 0;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.