From 0acb4d027d9a20b0be807dd883a25da4f005e8de Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Thu, 10 Oct 2024 15:55:38 +0200 Subject: [PATCH] feat: Use Xpra in desktop mode with Openbox Compared to using the Xpra HTML5 client in window mode, the desktop mode features much better window management thanks to the battle-proven Openbox WM. The two most noticable improvements are: 1. The Capella main window automatically is fullscreened, removing the unneeded window decorations and making it always follow the browser window size, just like for Xrdp based sessions. 2. Modal dialogs (like the "New Project" or "Properties" dialogs) now properly stay on top of the Capella main window. Previously, they could disappear behind the main window. This avoids the awkward situations where a hidden modal dialog prevents interaction with the main window, making it appear completely frozen. The Xvfb instance spawned by Xpra is configured to use 96 DPI. This avoid issues with Openbox seeing a way too high resolution during early startup, before the client has connected, and assuming a HighDPI display. Scaling is actually done client-side by the browser (by reporting a downscaled resolution to Xpra), and Openbox applying its own scaling settings would result in irritating issues like oversized mouse cursors. Setting the DPI happens in a small wrapper script, which is called by Xpra instead of the actual `openbox-session` executable. This allows the setting to be applied early enough to also affect Openbox itself, instead of only the Capella instance started by its autostart script. --- remote/Dockerfile | 2 ++ remote/openbox-launcher.sh | 10 ++++++++++ remote/supervisord.xpra.conf | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 remote/openbox-launcher.sh diff --git a/remote/Dockerfile b/remote/Dockerfile index 36ba9019..6d7a5a79 100644 --- a/remote/Dockerfile +++ b/remote/Dockerfile @@ -45,8 +45,10 @@ RUN wget -qO /usr/share/keyrings/xpra.asc ${XPRA_REGISTRY}/xpra.asc && \ nginx && \ rm -rf /var/lib/apt/lists/* +COPY openbox-launcher.sh /usr/local/bin/openbox-launcher.sh COPY rc.xml /etc/xdg/openbox/rc.xml COPY menu.xml /etc/xdg/openbox/menu.xml +RUN printf '\nGTK_IM_MODULE=ibus\n' >> /etc/environment # Setup Nitrogen (Desktop background) COPY wallpaper.png /tmp/wallpaper.png diff --git a/remote/openbox-launcher.sh b/remote/openbox-launcher.sh new file mode 100755 index 00000000..30e900c1 --- /dev/null +++ b/remote/openbox-launcher.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: Apache-2.0 + +xrdb -merge <<\EOF +Xft.dpi: 96 +EOF + +exec openbox-session diff --git a/remote/supervisord.xpra.conf b/remote/supervisord.xpra.conf index e43d4a4a..1d0ccc9a 100644 --- a/remote/supervisord.xpra.conf +++ b/remote/supervisord.xpra.conf @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 [program:xpra] -command=xpra start :10 --start=/home/techuser/.config/openbox/autostart --start-env=GTK_IM_MODULE=ibus --attach=yes --daemon=no --bind-tcp=0.0.0.0:10001 --min-quality=70 +command=xpra start-desktop :10 --start=/usr/local/bin/openbox-launcher.sh --attach=yes --daemon=no --bind-tcp=0.0.0.0:10001 --min-quality=70 user=techuser autorestart=true environment=DISPLAY=":10",XPRA_DEFAULT_CONTENT_TYPE="text",XPRA_DEFAULT_VFB_RESOLUTION="1920x1080"