From d9b45d390be3c26b2d0938283fa3182556553b98 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 13 Sep 2025 00:00:13 +0200 Subject: [PATCH] Disable clipboard button with async clipboard With async clipboard available, the fallback clipboard textarea adds mostly confusion. If async clipboard is out right denied, users most likely don't want to see any clipboard activity. --- app/ui.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/ui.js b/app/ui.js index 2542e059..2b936c02 100644 --- a/app/ui.js +++ b/app/ui.js @@ -9,7 +9,7 @@ import * as Log from '../core/util/logging.js'; import _, { l10n } from './localization.js'; import { isTouchDevice, isMac, isIOS, isAndroid, isChromeOS, isSafari, - hasScrollbarGutter, dragThreshold } + hasScrollbarGutter, dragThreshold, browserAsyncClipboardSupport } from '../core/util/browser.js'; import { setCapture, getPointerEvent } from '../core/util/events.js'; import KeyTable from "../core/input/keysym.js"; @@ -1103,6 +1103,7 @@ const UI = { UI.rfb.showDotCursor = UI.getSetting('show_dot'); UI.updateViewOnly(); // requires UI.rfb + UI.updateClipboard(); }, disconnect() { @@ -1754,6 +1755,31 @@ const UI = { } }, + updateClipboard() { + browserAsyncClipboardSupport() + .then((support) => { + if (support === 'unsupported') { + // Use fallback clipboard panel + return; + } + if (support === 'denied' || support === 'available') { + UI.closeClipboardPanel(); + document.getElementById('noVNC_clipboard_button') + .classList.add('noVNC_hidden'); + document.getElementById('noVNC_clipboard_button') + .removeEventListener('click', UI.toggleClipboardPanel); + document.getElementById('noVNC_clipboard_text') + .removeEventListener('change', UI.clipboardSend); + if (UI.rfb) { + UI.rfb.removeEventListener('clipboard', UI.clipboardReceive); + } + } + }) + .catch(() => { + // Treat as unsupported + }); + }, + updateShowDotCursor() { if (!UI.rfb) return; UI.rfb.showDotCursor = UI.getSetting('show_dot');