summaryrefslogtreecommitdiff
path: root/web/share/js/kvm/mouse.js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2021-04-12 15:26:32 +0300
committerGitHub <[email protected]>2021-04-12 15:26:32 +0300
commit3af4a8b852019993ee31becd5651734377da6ec9 (patch)
tree499b77bfaa0c6f939175ea167d5ccb3956be95f0 /web/share/js/kvm/mouse.js
parent8158941833bd8a50278b61967e00d23522e633d7 (diff)
Rework of #39 (#40)
* Rework of #39 patch from @arykov (thanks) * styled resize corner * fixed squashing of resizaable window on moving * keep window size and opsition after full screen * not necessary * attempt to fix desktop overflow * improved * ios fixes * refactoring
Diffstat (limited to 'web/share/js/kvm/mouse.js')
-rw-r--r--web/share/js/kvm/mouse.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js
index 3ac7935e..2893a5ae 100644
--- a/web/share/js/kvm/mouse.js
+++ b/web/share/js/kvm/mouse.js
@@ -40,8 +40,8 @@ export function Mouse(record_callback) {
var __keypad = null;
- var __current_pos = {x: 0, y:0};
- var __sent_pos = {x: 0, y:0};
+ var __current_pos = {x: 0, y: 0};
+ var __sent_pos = {x: 0, y: 0};
var __wheel_delta = {x: 0, y: 0};
var __relative_deltas = [];
@@ -210,15 +210,16 @@ export function Mouse(record_callback) {
if (__absolute) {
let pos = __current_pos;
if (pos.x !== __sent_pos.x || pos.y !== __sent_pos.y) {
- let el_stream_image = $("stream-image");
- let to = {
- x: __translate(pos.x, 0, el_stream_image.clientWidth, -32768, 32767),
- y: __translate(pos.y, 0, el_stream_image.clientHeight, -32768, 32767),
- };
-
- tools.debug("Mouse: moved:", to);
- __sendEvent("mouse_move", {"to": to});
- __sent_pos = pos;
+ let geometry = $("stream-box").stream_geometry;
+ if (geometry) {
+ let to = {
+ x: __translate(pos.x, geometry.x, geometry.width, -32768, 32767),
+ y: __translate(pos.y, geometry.y, geometry.height, -32768, 32767),
+ };
+ tools.debug("Mouse: moved:", to);
+ __sendEvent("mouse_move", {"to": to});
+ __sent_pos = pos;
+ }
}
} else if (__relative_deltas.length) {
tools.debug("Mouse: relative:", __relative_deltas);
@@ -228,7 +229,13 @@ export function Mouse(record_callback) {
};
var __translate = function(x, a, b, c, d) {
- return Math.round((x - a) / (b - a) * (d - c) + c);
+ let translated = Math.round((x - a) / b * (d - c) + c);
+ if (translated < c) {
+ return c;
+ } else if (translated > d) {
+ return d;
+ }
+ return translated;
};
var __streamWheelHandler = function(event) {