Skip to content

Commit

Permalink
#301 add clipboard sync to server button
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed May 14, 2024
1 parent 8f8de0d commit 2294088
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Binary file added html5/icons/clipboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@
data-icon="keyboard"
></a>
</li>
<li class="-hasSubmenu -noChevron">
<a
href="#"
id="clipboard_button"
title="Clipboard Copy"
data-icon="content_copy"
></a>
</li>
<li class="-hasSubmenu -noChevron">
<a
href="#"
Expand Down Expand Up @@ -1592,6 +1600,10 @@ <h2>Xpra Bug Report</h2>
toggle_keyboard();
});

$("#clipboard_button").on("click", function (e) {
client.read_clipboard(e);
});

// Configure Xpra tray window list right click behavior.
$("#open_windows_list")
.siblings("a")
Expand Down
11 changes: 10 additions & 1 deletion html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class XpraClient {
this.debug_categories = [];
this.start_new_session = null;
this.clipboard_enabled = false;
this.clipboard_poll = false;
this.file_transfer = false;
this.remote_file_size_limit = 0;
this.remote_file_chunks = 0;
Expand Down Expand Up @@ -1662,6 +1663,7 @@ class XpraClient {
selections = ["CLIPBOARD", "PRIMARY"];
this.log("legacy clipboard");
}
this.log("clipboard polling: ", this.clipboard_poll);
return {
"enabled" : this.clipboard_enabled,
"want_targets" : true,
Expand Down Expand Up @@ -2119,14 +2121,21 @@ class XpraClient {
}

_poll_clipboard(e) {
if (this.clipboard_enabled === false) {
if (!this.clipboard_poll) {
return;
}
//see if the clipboard contents have changed:
if (this.clipboard_pending) {
//we're still waiting to set the clipboard..
return false;
}
this.read_clipboard(e);
}

read_clipboard(e) {
if (this.clipboard_enabled === false) {
return;
}
if (navigator.clipboard && navigator.clipboard.clipboardData) {
this.debug("clipboard", "polling using", navigator.clipboard.clipboardData);
this.read_clipboard_data();
Expand Down

0 comments on commit 2294088

Please sign in to comment.