diff --git a/remote/Dockerfile b/remote/Dockerfile index cc15cb55..78177cb2 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);