Add wayland support for testing

This commit is contained in:
2026-01-08 16:33:39 +01:00
parent 9e5d53e530
commit a2827573fd
4 changed files with 74 additions and 4 deletions

View File

@@ -53,10 +53,14 @@ package:
run-client: run-client:
IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels $(ELECTRON) ./src/main/node/app.js IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels $(ELECTRON) ./src/main/node/app.js
.PHONY: runx .PHONY: run-client-x
run-client-x: run-client-x:
IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels ./src/main/shell/run-electron-app-in-xorg $(ELECTRON) IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels ./src/main/shell/run-electron-app-in-xorg $(ELECTRON)
.PHONY: run-client-wl
run-client-wl:
IMGFLOAT_CHANNELS_URL=http://localhost:8080/channels ./src/main/shell/run-electron-app-in-xorg $(ELECTRON)
.PHONY: fix .PHONY: fix
fix: node_modules fix: node_modules
./node_modules/.bin/prettier --write src ./node_modules/.bin/prettier --write src

View File

@@ -79,11 +79,11 @@ This automatically re-compiles the project when source files change. `entr` is r
### Running the electron client ### Running the electron client
There are two methods of running the electron app during development. Both methods require access to an Xorg server. There are two methods of running the electron app during development.
#### Running in the current X server #### Running in the current display server
This spawns the window in your current Xorg server. This spawns the window in your current display server.
```sh ```sh
$ make run-client $ make run-client
@@ -100,3 +100,13 @@ $ make run-client-x
... ...
^C ^C
``` ```
#### Running in a sandboxed wayland server
This method spawns an Xorg server with `Xephyr` and `openbox` to ensure a floating window manager, which will more accurately reflect the common user environment. Killing either the Xephyr or electron process shuts both down.
```sh
$ make run-client-x
...
^C
```

View File

@@ -4,12 +4,19 @@ pkgs.mkShell {
packages = [ packages = [
pkgs.electron pkgs.electron
pkgs.jdt-language-server pkgs.jdt-language-server
pkgs.libxkbcommon
pkgs.maven pkgs.maven
pkgs.mesa
pkgs.nodePackages.prettier pkgs.nodePackages.prettier
pkgs.nodejs pkgs.nodejs
pkgs.nss pkgs.nss
pkgs.openbox pkgs.openbox
pkgs.openjdk pkgs.openjdk
pkgs.vulkan-loader
pkgs.wayland
pkgs.wayland-protocols
pkgs.weston
pkgs.xorg.xorgserver pkgs.xorg.xorgserver
pkgs.xwayland
]; ];
} }

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env sh
set -eu
ELECTRON="$1"
APP_ENTRY="src/main/node/app.js"
SIZE="1280x800"
RUNTIME="${XDG_RUNTIME_DIR:-/tmp}"
# Find free WAYLAND_DISPLAY
for d in 1 2 3 4 5; do
if [ ! -S "$RUNTIME/wayland-$d" ]; then
WAYLAND_NUM="$d"
break
fi
done
[ -n "${WAYLAND_NUM:-}" ] || {
echo "No free WAYLAND_DISPLAY found" >&2
exit 1
}
export WAYLAND_DISPLAY="wayland-$WAYLAND_NUM"
export XDG_RUNTIME_DIR="$RUNTIME"
cleanup() {
kill "$ELECTRON_PID" "$WESTON_PID" 2>/dev/null || true
}
trap cleanup EXIT INT TERM
weston \
--backend=wayland-backend.so \
--width="${SIZE%x*}" \
--height="${SIZE#*x}" \
--xwayland \
--socket="$WAYLAND_DISPLAY" &
WESTON_PID=$!
sleep 1
WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
DISPLAY="" \
"${ELECTRON}" "$APP_ENTRY" &
ELECTRON_PID=$!
while :; do
kill -0 "$ELECTRON_PID" 2>/dev/null || break
kill -0 "$WESTON_PID" 2>/dev/null || break
sleep 0.5
done