Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cursor glitching and offset when using shadow mode #363

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions html5/css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ div.windowinfocus div.windowhead {
border: 1px;
z-index: 100000;
display: none;
pointer-events: none;
}

table#sessiondata {
Expand Down
32 changes: 20 additions & 12 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1651,8 +1651,9 @@ class XpraClient {
return true;
}

if (this.server_readonly || !this.connected) {
return window == undefined;
// 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)) {
totaam marked this conversation as resolved.
Show resolved Hide resolved
return win == undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a separate bug fix, is it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw that window wasn't defined while win was, so I assumed it's a typo

}
const mouse = this.getMouse(e);
const x = Math.round(mouse.x);
Expand All @@ -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]);
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down