From 2e5262baedd5e5b43d88a98429c92343ac94b3f7 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Thu, 10 Oct 2024 15:37:43 +0200 Subject: [PATCH 1/8] fix: Only fullscreen the Capella main window in Openbox --- remote/rc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/rc.xml b/remote/rc.xml index 8fa1c637..75d0cb74 100644 --- a/remote/rc.xml +++ b/remote/rc.xml @@ -750,7 +750,7 @@ # end of the example --> - + yes From a1cd66bcc7863afac08c38e9d790899e7680d1bc Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Thu, 10 Oct 2024 15:55:38 +0200 Subject: [PATCH 2/8] 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. --- capella/setup/provisioning.py | 5 ++--- remote/Dockerfile | 4 +++- remote/openbox-launcher.sh | 10 ++++++++++ remote/supervisord.xpra.conf | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100755 remote/openbox-launcher.sh diff --git a/capella/setup/provisioning.py b/capella/setup/provisioning.py index 7d2c12e5..1ea6bd8b 100644 --- a/capella/setup/provisioning.py +++ b/capella/setup/provisioning.py @@ -165,9 +165,8 @@ def provide_project_dirs_to_capella_plugin( projects: list[_ProjectDict], ) -> None: locations = ":".join([str(project["location"]) for project in projects]) - pathlib.Path("/etc/environment").write_text( - f"export MODEL_INBOX_DIRECTORIES={locations}\n", encoding="utf-8" - ) + with open("/etc/environment", "a", encoding="utf-8") as f: + f.write(f"export MODEL_INBOX_DIRECTORIES={locations}\n") log.info( "Set environment variable MODEL_INBOX_DIRECTORIES to '%s'", locations ) diff --git a/remote/Dockerfile b/remote/Dockerfile index 57727c53..bef2759f 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 echo 'export GTK_IM_MODULE=ibus' >> /etc/environment # Setup Nitrogen (Desktop background) COPY wallpaper.png /tmp/wallpaper.png @@ -73,7 +75,7 @@ RUN mkdir -p /run/xrdp/sockdir && \ chown techuser /var/log && \ chown techuser /etc/supervisord.conf /var/log/nginx /var/log/nginx/* && \ chown techuser /etc/nginx && \ - touch /etc/environment && chown techuser /etc/environment + chown techuser /etc/environment WORKDIR /home/techuser 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" From dfb1b553ecf964e69eefabbd607cb593053e77d9 Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Fri, 11 Oct 2024 14:28:20 +0200 Subject: [PATCH 3/8] chore: Remove nitrogen from remote docker image It hasn't been working for a while anyways. (This might have to do with the wallpaper file being empty.) --- capella/autostart | 4 +++- remote/Dockerfile | 6 +----- remote/bg-saved.cfg | 7 ------- remote/wallpaper.png | 0 4 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 remote/bg-saved.cfg delete mode 100644 remote/wallpaper.png diff --git a/capella/autostart b/capella/autostart index fc41979e..5e3993f9 100755 --- a/capella/autostart +++ b/capella/autostart @@ -8,7 +8,9 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # Load environment variables from /etc/environment source /etc/environment -nitrogen --restore & +if command -v nitrogen > /dev/null; then + nitrogen --restore & +fi if [ "$AUTOSTART_CAPELLA" = "1" ]; then diff --git a/remote/Dockerfile b/remote/Dockerfile index bef2759f..97c8d04a 100644 --- a/remote/Dockerfile +++ b/remote/Dockerfile @@ -27,7 +27,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-reco obconf \ gettext-base \ xprintidle \ - nitrogen && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* ARG XPRA_REGISTRY=https://xpra.org @@ -50,10 +50,6 @@ COPY rc.xml /etc/xdg/openbox/rc.xml COPY menu.xml /etc/xdg/openbox/menu.xml RUN echo 'export GTK_IM_MODULE=ibus' >> /etc/environment -# Setup Nitrogen (Desktop background) -COPY wallpaper.png /tmp/wallpaper.png -COPY bg-saved.cfg /home/techuser/.config/nitrogen/bg-saved.cfg - # Copy Supervisor Configuration RUN pip install --no-cache-dir supervisor==4.2.5 COPY supervisord.conf /etc/supervisord.conf diff --git a/remote/bg-saved.cfg b/remote/bg-saved.cfg deleted file mode 100644 index 72f2f872..00000000 --- a/remote/bg-saved.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors -# SPDX-License-Identifier: Apache-2.0 - -[xin_-1] -file=/tmp/wallpaper.png -mode=4 -bgcolor=#000000 diff --git a/remote/wallpaper.png b/remote/wallpaper.png deleted file mode 100644 index e69de29b..00000000 From 78c59372a2f169a6994f7f100e4808fe7555159e Mon Sep 17 00:00:00 2001 From: Martin Lehmann Date: Mon, 14 Oct 2024 11:40:24 +0200 Subject: [PATCH 4/8] feat: Add a maximize button to non-fullscreen windows --- remote/rc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/rc.xml b/remote/rc.xml index 75d0cb74..e3314972 100644 --- a/remote/rc.xml +++ b/remote/rc.xml @@ -52,7 +52,7 @@ Clearlooks - NLC + NLMC + + 5050 + yes