Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const UI = {
UI.initSetting('bell', 'on');
UI.initSetting('view_only', false);
UI.initSetting('show_dot', false);
UI.initSetting('notify_clipboard_received', false);
UI.initSetting('path', 'websockify');
UI.initSetting('repeaterID', '');
UI.initSetting('reconnect', false);
Expand Down Expand Up @@ -371,6 +372,8 @@ const UI = {
UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
UI.addSettingChangeHandler('show_dot');
UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor);
UI.addSettingChangeHandler('notify_clipboard_received');
UI.addSettingChangeHandler('notify_clipboard_received', UI.updateNotifyClipboardReceived);
UI.addSettingChangeHandler('host');
UI.addSettingChangeHandler('port');
UI.addSettingChangeHandler('path');
Expand Down Expand Up @@ -892,6 +895,7 @@ const UI = {
UI.updateSetting('logging');
UI.updateSetting('reconnect');
UI.updateSetting('reconnect_delay');
UI.updateSetting('notify_clipboard_received');

document.getElementById('noVNC_settings')
.classList.add("noVNC_open");
Expand Down Expand Up @@ -994,6 +998,13 @@ const UI = {
}
},

notifyClipboardReceived() {
// When enabled with setting 'notify_clipboard_received', shows
// notification when a 'clipboard-received'-event is fired by
// the RFB instance.
UI.showStatus(_('Clipboard updated'), 3000);
},

clipboardReceive(e) {
Log.Debug(">> UI.clipboardReceive: " + e.detail.text.substr(0, 40) + "...");
document.getElementById('noVNC_clipboard_text').value = e.detail.text;
Expand Down Expand Up @@ -1104,6 +1115,7 @@ const UI = {

UI.updateViewOnly(); // requires UI.rfb
UI.updateClipboard();
UI.updateNotifyClipboardReceived();
},

disconnect() {
Expand Down Expand Up @@ -1809,6 +1821,14 @@ const UI = {
UI.rfb.showDotCursor = UI.getSetting('show_dot');
},

updateNotifyClipboardReceived() {
if (!UI.rfb) return;
UI.rfb.removeEventListener('clipboardreceived', UI.notifyClipboardReceived);
if (UI.getSetting('notify_clipboard_received')) {
UI.rfb.addEventListener('clipboardreceived', UI.notifyClipboardReceived);
}
},

updateLogging() {
WebUtil.initLogging(UI.getSetting('logging'));
},
Expand Down
12 changes: 7 additions & 5 deletions core/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2335,11 +2335,13 @@ export default class RFB extends EventTargetMixin {

_writeClipboard(text) {
if (this._viewOnly) return;
if (this._asyncClipboard.writeClipboard(text)) return;
// Fallback clipboard
this.dispatchEvent(
new CustomEvent("clipboard", {detail: {text: text}})
);
if (!(this._asyncClipboard.writeClipboard(text))) {
// Fallback clipboard
this.dispatchEvent(
new CustomEvent("clipboard", {detail: {text: text}})
);
}
this.dispatchEvent(new CustomEvent("clipboardreceived"));
}

_handleServerCutText() {
Expand Down
6 changes: 6 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ protocol stream.
- The `clipboard` event is fired when clipboard data is received from
the server.

['clipboardreceived'](#clipboardreceived)
- The `clipboardreceived` event is fired after the `clipboard` event
or after the clipboard has been updated through the
[Clipboard module](API-internal.md#11-module-list). The copied text
has already been written to the system clipboard or the clipboard panel.

[`clippingviewport`](#clippingviewport)
- The `clippingviewport` event is fired when `RFB.clippingViewport` is
updated.
Expand Down
7 changes: 7 additions & 0 deletions vnc.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
Show dot when no cursor
</label>
</li>
<li>
<label>
<input id="noVNC_setting_notify_clipboard_received" type="checkbox"
class="toggle">
Show clipboard notification
</label>
</li>
<li><hr></li>
<!-- Logging selection dropdown -->
<li>
Expand Down