From 28053b3d74b572677132e3d525781c22630a11d3 Mon Sep 17 00:00:00 2001 From: Tobias Messner Date: Tue, 5 Nov 2024 15:59:03 +0100 Subject: [PATCH] fix: Increase OPEN_TIMEOUT and move injects to own file Closes #351 Closes #350 --- remote/Dockerfile | 15 +++------------ remote/client-inject.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 remote/client-inject.js diff --git a/remote/Dockerfile b/remote/Dockerfile index 4159f01e..994e3c69 100644 --- a/remote/Dockerfile +++ b/remote/Dockerfile @@ -47,20 +47,11 @@ RUN wget -qO /usr/share/keyrings/xpra.asc ${XPRA_REGISTRY}/xpra.asc && \ # Inject script to force focus on modal windows in xpra client # and remove the compressed index.html files because they don't contain our fix -RUN sed -i '/load_default_settings();/a \ -setInterval(() => {\ -for (const [id, win] of Object.entries(client.id_to_window).toReversed()) {\ - if (win.metadata.modal) {\ - if (client.topwindow !== parseInt(id)) {\ - console.log("Forcing focus on modal window", id);\ - client.set_focus(win);\ - }\ - break;\ - }\ -}\ -}, 100);' /usr/share/xpra/www/index.html \ +COPY client-inject.js /tmp/client-inject.js +RUN sed -i '/load_default_settings();/r /tmp/client-inject.js' /usr/share/xpra/www/index.html \ && rm /usr/share/xpra/www/index.html.gz \ && rm /usr/share/xpra/www/index.html.br + COPY rc.xml /etc/xdg/openbox/rc.xml COPY menu.xml /etc/xdg/openbox/menu.xml diff --git a/remote/client-inject.js b/remote/client-inject.js new file mode 100644 index 00000000..05d9da14 --- /dev/null +++ b/remote/client-inject.js @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +const injectInterval = setInterval(() => { + if (!client) return; + client.OPEN_TIMEOUT = 100_000; + + for (const [id, win] of Object.entries(client.id_to_window).toReversed()) { + if (win.metadata.modal) { + if (client.topwindow !== parseInt(id)) { + console.log("Forcing focus on modal window", id); + client.set_focus(win); + } + break; + } + } +}, 100); +console.log("Inject script running on interval", injectInterval);