Skip to content

Commit

Permalink
Merge pull request Xpra-org#136 from selkies-project/to_upstream/fix_…
Browse files Browse the repository at this point in the history
…to-server_clipboard

Fix clipboard-related event handlers
  • Loading branch information
totaam authored and JanCVanB committed Jan 3, 2022
1 parent a49e96d commit 9a28092
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 10 additions & 1 deletion html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1387,11 +1387,20 @@ <h2>Xpra Bug Report</h2>
});
// disable right click menu:
window.oncontextmenu = function(e) {
client._poll_clipboard(e);
if (this.clipboard_direction === "to-client" || this.clipboard_direction === "both") {
client._poll_clipboard(e);
}
e.preventDefault();
e.stopPropagation();
return false;
}

// Send clipboard from browser on focus if client-to-server clipboard is enabled.
$(window).on("focus", (e) => {
if (this.clipboard_direction === "to-server" || this.clipboard_direction === "both") {
client._poll_clipboard(e);
}
});
}

window.inAltTab = false;
Expand Down
8 changes: 3 additions & 5 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ XpraClient.prototype.init_state = function(container) {
this.scroll_reverse_x = false;
this.scroll_reverse_y = false;
// clipboard
this.clipboard_direction = default_settings["clipboard_direction"] || "both";
this.clipboard_datatype = null;
this.clipboard_buffer = "";
this.clipboard_server_buffers = {};
Expand Down Expand Up @@ -878,11 +879,8 @@ XpraClient.prototype.do_keyb_process = function(pressed, event) {
unpress_now = true;
}

//if (keyname=="Control_L" || keyname=="Control_R")
this._poll_clipboard(event);

let allow_default = false;
if (this.clipboard_enabled) {
if (this.clipboard_enabled && client.clipboard_direction !== "to-server") {
//allow some key events that need to be seen by the browser
//for handling the clipboard:
let clipboard_modifier_keys = ["Control_L", "Control_R", "Shift_L", "Shift_R"];
Expand Down Expand Up @@ -1449,7 +1447,7 @@ XpraClient.prototype.do_window_mouse_click = function(e, window, pressed) {
return;
}
let send_delay = 0;
if (this._poll_clipboard(e)) {
if (client.clipboard_direction !== "to-server" && this._poll_clipboard(e)) {
send_delay = CLIPBOARD_EVENT_DELAY;
}
const mouse = this.getMouse(e, window),
Expand Down

0 comments on commit 9a28092

Please sign in to comment.