diff options
author | Devaev Maxim <[email protected]> | 2020-11-05 10:48:11 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-11-05 10:48:11 +0300 |
commit | dc3259c169a4b1602ee1c7810d67aef16edd9f57 (patch) | |
tree | 5b4751f1cf6aec2e5605980d85ce49d7d1e78640 /web/share/js/kvm/mouse.js | |
parent | c37c17d29fe5d7c82b96a255d723fb76890cfafa (diff) |
delayed relative events
Diffstat (limited to 'web/share/js/kvm/mouse.js')
-rw-r--r-- | web/share/js/kvm/mouse.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index 32ab1ba4..37de6226 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -43,6 +43,7 @@ export function Mouse(record_callback) { var __current_pos = {x: 0, y:0}; var __sent_pos = {x: 0, y:0}; var __wheel_delta = {x: 0, y: 0}; + var __relative_deltas = []; var __stream_hovered = false; @@ -62,7 +63,7 @@ export function Mouse(record_callback) { $("stream-box").onwheel = __streamWheelHandler; $("stream-box").ontouchstart = (event) => __streamTouchMoveHandler(event); - setInterval(__sendMove, 100); // Only for absolute + setInterval(__sendMove, 100); }; /************************************************************************/ @@ -176,8 +177,7 @@ export function Mouse(record_callback) { x: Math.min(Math.max(-127, event.movementX), 127), y: Math.min(Math.max(-127, event.movementY), 127), }; - tools.debug("Mouse: relative:", delta); - __sendEvent("mouse_relative", {"delta": delta}); + __relative_deltas.push(delta); } }; @@ -201,6 +201,10 @@ export function Mouse(record_callback) { __sendEvent("mouse_move", {"to": to}); __sent_pos = pos; } + } else if (__relative_deltas) { + tools.debug("Mouse: relative:", __relative_deltas); + __sendEvent("mouse_relative", {"delta": __relative_deltas}); + __relative_deltas = []; } }; |