Skip to content

Commit

Permalink
Merge pull request #137 from selkies-project/to_upstream/prevent_stuc…
Browse files Browse the repository at this point in the history
…k_keys

Prevent stuck keys (by sending keyup on blur)
  • Loading branch information
totaam authored Dec 31, 2021
2 parents 1cc8a1c + 4176697 commit 2568b64
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 @@ -1401,6 +1401,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 @@ -129,6 +129,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 @@ -934,7 +935,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 2568b64

Please sign in to comment.