From 2000ba7aed8bde5fd39f97fa70dd9f9263c3e924 Mon Sep 17 00:00:00 2001 From: Tommy Walker Date: Mon, 10 Feb 2025 12:51:49 +0100 Subject: [PATCH 1/2] Fix wrong cursor offset while in shadow mode --- html5/css/client.css | 1 + html5/js/Client.js | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/html5/css/client.css b/html5/css/client.css index ea40e0f7..a2864c26 100644 --- a/html5/css/client.css +++ b/html5/css/client.css @@ -449,6 +449,7 @@ div.windowinfocus div.windowhead { border: 1px; z-index: 100000; display: none; + pointer-events: none; } table#sessiondata { diff --git a/html5/js/Client.js b/html5/js/Client.js index 5b33d539..26ab88f6 100644 --- a/html5/js/Client.js +++ b/html5/js/Client.js @@ -1651,7 +1651,8 @@ class XpraClient { return true; } - if (this.server_readonly || !this.connected) { + // Ignore events when server is readonly, disconnected or if the event is not over the screen while in shadow mode + if (this.server_readonly || !this.connected || (!win && this.server_is_shadow)) { return window == undefined; } const mouse = this.getMouse(e); @@ -1665,8 +1666,9 @@ class XpraClient { if (win) { wid = win.wid; // add relative coordinates: - coords.push(Math.round(mouse.x - win.x)); - coords.push(Math.round(mouse.y - win.y)); + const pos = jQuery(win.div).position() + coords.push(Math.round(mouse.x - pos.left)); + coords.push(Math.round(mouse.y - pos.top)); e.preventDefault(); } this.send([PACKET_TYPES.pointer_position, wid, coords, modifiers, buttons]); @@ -1684,8 +1686,9 @@ class XpraClient { if (win) { wid = win.wid; // add relative coordinates: - coords.push(Math.round(mouse.x - win.x)); - coords.push(Math.round(mouse.y - win.y)); + const pos = jQuery(win.div).position() + coords.push(Math.round(mouse.x - pos.left)); + coords.push(Math.round(mouse.y - pos.right)); } for (const button of this.buttons_pressed) { this.send_button_action(wid, button, pressed, coords, modifiers); @@ -1696,7 +1699,9 @@ class XpraClient { if (win) { e.preventDefault(); } - if (this.server_readonly || this.mouse_grabbed || !this.connected) { + + // Ignore events when server is readonly, disconnected or if the event is not over the screen while in shadow mode + if (this.server_readonly || this.mouse_grabbed || !this.connected || (!win && this.server_is_shadow)) { return; } // Skip processing if clicked on float menu @@ -1720,8 +1725,9 @@ class XpraClient { if (win) { wid = win.wid; // add relative coordinates: - coords.push(Math.round(mouse.x - win.x)); - coords.push(Math.round(mouse.y - win.y)); + const pos = jQuery(win.div).position() + coords.push(Math.round(mouse.x - pos.left)); + coords.push(Math.round(mouse.y - pos.top)); e.preventDefault(); } // dont call set focus unless the focus has actually changed @@ -1791,7 +1797,8 @@ class XpraClient { } on_mousescroll(e, win) { - if (this.server_readonly || this.mouse_grabbed || !this.connected) { + // Ignore events when server is readonly, disconnected or if the event is not over the screen while in shadow mode + if (this.server_readonly || this.mouse_grabbed || !this.connected || (!win && this.server_is_shadow)) { return false; } const mouse = this.getMouse(e); @@ -3223,8 +3230,9 @@ class XpraClient { const win = this.id_to_window[wid]; //we can use window relative coordinates: if (packet.length >= 6 && win) { - x = win.x + packet[4]; - y = win.y + packet[5]; + const pos = jQuery(win.div).position() + x = pos.left + packet[4]; + y = pos.top + packet[5]; } const shadow_pointer = document.querySelector("#shadow_pointer"); const style = shadow_pointer.style; From 54083e1827e9b9d6d347bf73fad70040b479d888 Mon Sep 17 00:00:00 2001 From: Tommy Walker Date: Wed, 12 Feb 2025 12:23:56 +0100 Subject: [PATCH 2/2] Fix typo --- html5/js/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html5/js/Client.js b/html5/js/Client.js index 26ab88f6..43daa389 100644 --- a/html5/js/Client.js +++ b/html5/js/Client.js @@ -1653,7 +1653,7 @@ class XpraClient { // Ignore events when server is readonly, disconnected or if the event is not over the screen while in shadow mode if (this.server_readonly || !this.connected || (!win && this.server_is_shadow)) { - return window == undefined; + return win == undefined; } const mouse = this.getMouse(e); const x = Math.round(mouse.x);