Skip to content

Commit

Permalink
Merge pull request Xpra-org#137 from selkies-project/to_upstream/prev…
Browse files Browse the repository at this point in the history
…ent_stuck_keys

Prevent stuck keys (by sending keyup on blur)
  • Loading branch information
totaam authored and JanCVanB committed Jan 3, 2022
1 parent 41279be commit bc27af6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,18 @@ <h2>Xpra Bug Report</h2>
client._poll_clipboard(e);
}
});

// Prevent stuck keys.
$(window).on("blur", (e) => {
if (client.last_key_packet.length > 2 && client.last_keycode_pressed > 0) {
console.log("clearing keycode: " + client.last_keycode_pressed);
key_packet = client.last_key_packet;
// Set pressed = false to indicate key up.
key_packet[3] = false;
client.send(key_packet);
client.last_key_packet = [];
}
});
}

window.inAltTab = false;
Expand Down
5 changes: 4 additions & 1 deletion html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ XpraClient.prototype.init_state = function(container) {
this.browser_language_change_embargo_time = 0;
this.key_layout = null;
this.last_keycode_pressed = 0;
this.last_key_packet = [];
// mouse
this.last_button_event = [-1, false, -1, -1];
this.mousedown_event = null;
Expand Down Expand Up @@ -926,7 +927,9 @@ XpraClient.prototype.do_keyb_process = function(pressed, event) {
const me = this;
setTimeout(function () {
while (me.key_packets.length>0) {
me.send(me.key_packets.shift());
var key_packet = me.key_packets.shift();
me.last_key_packet = key_packet;
me.send(key_packet);
}
}, delay);
}
Expand Down

0 comments on commit bc27af6

Please sign in to comment.