mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Add wayland support for testing
This commit is contained in:
6
Makefile
6
Makefile
@@ -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
|
||||||
|
|||||||
16
README.md
16
README.md
@@ -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
|
||||||
|
```
|
||||||
|
|||||||
@@ -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
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
49
src/main/shell/run-electron-app-in-wayland
Executable file
49
src/main/shell/run-electron-app-in-wayland
Executable 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
|
||||||
Reference in New Issue
Block a user