Skip to content

Commit a0a1bb6

Browse files
committed
just a test
1 parent d44f7e0 commit a0a1bb6

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

app/ui.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ const UI = {
185185
UI.initSetting('bell', 'on');
186186
UI.initSetting('view_only', false);
187187
UI.initSetting('show_dot', false);
188+
UI.initSetting('notify_clipboard_received', false);
188189
UI.initSetting('path', 'websockify');
189190
UI.initSetting('repeaterID', '');
190191
UI.initSetting('reconnect', false);
@@ -371,6 +372,8 @@ const UI = {
371372
UI.addSettingChangeHandler('view_only', UI.updateViewOnly);
372373
UI.addSettingChangeHandler('show_dot');
373374
UI.addSettingChangeHandler('show_dot', UI.updateShowDotCursor);
375+
UI.addSettingChangeHandler('notify_clipboard_received');
376+
UI.addSettingChangeHandler('notify_clipboard_received', UI.updateNotifyClipboardReceived);
374377
UI.addSettingChangeHandler('host');
375378
UI.addSettingChangeHandler('port');
376379
UI.addSettingChangeHandler('path');
@@ -892,6 +895,7 @@ const UI = {
892895
UI.updateSetting('logging');
893896
UI.updateSetting('reconnect');
894897
UI.updateSetting('reconnect_delay');
898+
UI.updateSetting('notify_clipboard_received');
895899

896900
document.getElementById('noVNC_settings')
897901
.classList.add("noVNC_open");
@@ -994,6 +998,13 @@ const UI = {
994998
}
995999
},
9961000

1001+
notifyClipboardReceived() {
1002+
// When enabled with setting 'notify_clipboard_received', shows
1003+
// notification when a 'clipboard-received'-event is fired by
1004+
// the RFB instance.
1005+
UI.showStatus(_('Clipboard updated'), 3000);
1006+
},
1007+
9971008
clipboardReceive(e) {
9981009
Log.Debug(">> UI.clipboardReceive: " + e.detail.text.substr(0, 40) + "...");
9991010
document.getElementById('noVNC_clipboard_text').value = e.detail.text;
@@ -1104,6 +1115,7 @@ const UI = {
11041115

11051116
UI.updateViewOnly(); // requires UI.rfb
11061117
UI.updateClipboard();
1118+
UI.updateNotifyClipboardReceived();
11071119
},
11081120

11091121
disconnect() {
@@ -1809,6 +1821,14 @@ const UI = {
18091821
UI.rfb.showDotCursor = UI.getSetting('show_dot');
18101822
},
18111823

1824+
updateNotifyClipboardReceived() {
1825+
if (!UI.rfb) return;
1826+
UI.rfb.removeEventListener('clipboardreceived', UI.notifyClipboardReceived);
1827+
if (UI.getSetting('notify_clipboard_received')) {
1828+
UI.rfb.addEventListener('clipboardreceived', UI.notifyClipboardReceived);
1829+
}
1830+
},
1831+
18121832
updateLogging() {
18131833
WebUtil.initLogging(UI.getSetting('logging'));
18141834
},

core/rfb.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,11 +2335,13 @@ export default class RFB extends EventTargetMixin {
23352335

23362336
_writeClipboard(text) {
23372337
if (this._viewOnly) return;
2338-
if (this._asyncClipboard.writeClipboard(text)) return;
2339-
// Fallback clipboard
2340-
this.dispatchEvent(
2341-
new CustomEvent("clipboard", {detail: {text: text}})
2342-
);
2338+
if (!(this._asyncClipboard.writeClipboard(text))) {
2339+
// Fallback clipboard
2340+
this.dispatchEvent(
2341+
new CustomEvent("clipboard", {detail: {text: text}})
2342+
);
2343+
}
2344+
this.dispatchEvent(new CustomEvent("clipboardreceived"));
23432345
}
23442346

23452347
_handleServerCutText() {

vnc.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ <h1 class="noVNC_logo" translate="no"><span>no</span><br>VNC</h1>
296296
Show dot when no cursor
297297
</label>
298298
</li>
299+
<li>
300+
<label>
301+
<input id="noVNC_setting_notify_clipboard_received" type="checkbox"
302+
class="toggle">
303+
Show clipboard notification
304+
</label>
305+
</li>
299306
<li><hr></li>
300307
<!-- Logging selection dropdown -->
301308
<li>

0 commit comments

Comments
 (0)