From e8e230b2dbb9bc3e691f1b6257275a4532b9c6ab Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Fri, 27 Mar 2026 22:29:27 +0100 Subject: [PATCH] wayland: add WMAKER_USE_WAYLAND backend selector and split smoke tests - startup.c: include wl_backend.h when USE_WAYLAND_BACKEND is defined; select wl_backend when WMAKER_USE_WAYLAND env var is set, otherwise fall back to x11_backend (no-op for non-Wayland builds) - tests/smoke-test.sh renamed to tests/x11-smoke-test.sh (X11-only path) - tests/wl-smoke-test.sh: new Wayland smoke test; currently verifies wl_backend symbol presence and wlroots linkage; headless compositor tests will be added as vtable slots are implemented Co-Authored-By: Claude Sonnet 4.6 --- src/startup.c | 10 +++++- tests/wl-smoke-test.sh | 41 ++++++++++++++++++++++ tests/{smoke-test.sh => x11-smoke-test.sh} | 0 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 tests/wl-smoke-test.sh rename tests/{smoke-test.sh => x11-smoke-test.sh} (100%) diff --git a/src/startup.c b/src/startup.c index e86e3f1..d32495a 100644 --- a/src/startup.c +++ b/src/startup.c @@ -49,6 +49,9 @@ #include "session.h" #include "defaults.h" #include "backend/x11/x11_backend.h" +#ifdef USE_WAYLAND_BACKEND +#include "backend/wayland/wl_backend.h" +#endif #include "properties.h" #include "dialog.h" #include "wmspec.h" @@ -520,7 +523,12 @@ void StartUp(Bool defaultScreenOnly) w_global.screen_count = 0; /* Select the display backend before any screen is initialized. */ - wm_backend = &x11_backend; +#ifdef USE_WAYLAND_BACKEND + if (getenv("WMAKER_USE_WAYLAND")) + wm_backend = &wl_backend; + else +#endif + wm_backend = &x11_backend; /* Check if TIFF images are supported */ formats = RSupportedFileFormats(); diff --git a/tests/wl-smoke-test.sh b/tests/wl-smoke-test.sh new file mode 100755 index 0000000..1fb0fee --- /dev/null +++ b/tests/wl-smoke-test.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# tests/wl-smoke-test.sh +# +# Wayland backend smoke test for Window Maker. +# Uses the wlroots headless compositor (no display hardware needed). +# +# Currently verifies: +# 1. wmaker was built with Wayland backend support (symbol present) +# 2. wmaker links against wlroots +# +# This test grows as wl_backend vtable slots are implemented. +# When the compositor can open a headless display, tests for window +# management, EWMH properties, etc. will be added here in the same +# style as tests/x11-smoke-test.sh. +# +# Exit 0 = PASS, non-zero = FAIL. + +set -e + +# Use the real ELF binary (src/wmaker is a libtool wrapper script) +WMAKER=src/.libs/wmaker +[ -x "$WMAKER" ] || WMAKER=src/wmaker + +die() { + echo "FAIL: $*" >&2 + exit 1 +} + +# -- 1. Build check: wl_backend symbol must be present -------------------- +[ -x "$WMAKER" ] || die "wmaker binary not found (tried src/.libs/wmaker and src/wmaker)" + +nm "$WMAKER" 2>/dev/null | grep -q 'wl_backend' \ + || die "wl_backend symbol not found in $WMAKER (built without --enable-wayland-backend?)" + +# -- 2. Link check: wlroots library must be linked in --------------------- +ldd "$WMAKER" 2>/dev/null | grep -qi 'wlroots\|libwlr' \ + || die "wmaker does not link against wlroots" + +# -- Done (headless compositor tests to be added as vtable is implemented) -- +echo "PASS (wl_backend symbol + wlroots link verified; full headless tests pending)" +exit 0 diff --git a/tests/smoke-test.sh b/tests/x11-smoke-test.sh similarity index 100% rename from tests/smoke-test.sh rename to tests/x11-smoke-test.sh