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

Conversation

whoactuallycares
Copy link
Contributor

When using shadow mode the window offset is incorrectly calculated causing the cursor position on the server to be off by quite a bit (depending on the XpraWindow's offset from the page's 0,0).
image
This is fixed by using the window div's position, instead of it's .x and .y fields

The next issue is that the cursor events are sent to the window even when the cursor isn't over the XpraWindow, this is fixed by checking if win is undefined while in shadow mode.

The final issue is that the drawn cursor image prevents events from propagating to the window, this is fixed by ignoring events on it.

@@ -1791,7 +1794,7 @@ class XpraClient {
}

on_mousescroll(e, win) {
if (this.server_readonly || this.mouse_grabbed || !this.connected) {
if (this.server_readonly || this.mouse_grabbed || !this.connecte || (!win && this.server_is_shadow)) {
Copy link
Collaborator

@totaam totaam Feb 10, 2025

Choose a reason for hiding this comment

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

connecte looks like a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here

@@ -330,7 +330,7 @@ class XpraClient {
const screen_element = jQuery("#screen");
screen_element.mousedown((e) => this.on_mousedown(e));
screen_element.mouseup((e) => this.on_mouseup(e));
document.getElementById("screen").addEventListener("mousemove", (e) => this.on_mousemove(e));
screen_element.mousemove((e) => this.on_mousemove(e))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was changed recently in 7287ce7 to support pointer lock: #335
It's probably best to ask @CorbinWunderlich why that is, to avoid breaking things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, it just didn't make sense to my why it was different when I came across it - not much point in the change other than that

Copy link
Collaborator

Choose a reason for hiding this comment

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

@whoactuallycares Can you undo this please?
@CorbinWunderlich does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undone here

Copy link
Collaborator

@totaam totaam left a comment

Choose a reason for hiding this comment

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

If all these checks do the same thing:

if (this.server_readonly || this.mouse_grabbed || !this.connected || (!win && this.server_is_shadow)) {

Then it may be clearer to move them to a utility method, which would make it clearer what it's doing.
Just skimming the code does not make it obvious to me, and I wrote most of it!

if (this.server_readonly || !this.connected) {
return window == undefined;
if (this.server_readonly || !this.connected || (!win && this.server_is_shadow)) {
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

@totaam
Copy link
Collaborator

totaam commented Feb 11, 2025

LGTM, can you squash the commits?
Ideally with only the return window == undefined; as separate commit.

@CorbinWunderlich
Copy link
Contributor

Please use server_resize_exact instead of always returning undefined

@totaam
Copy link
Collaborator

totaam commented Feb 11, 2025

@CorbinWunderlich sorry, I don't understand what you mean

@CorbinWunderlich
Copy link
Contributor

I took another look and it looks good to me.

@totaam
Copy link
Collaborator

totaam commented Feb 11, 2025

@CorbinWunderlich What about the screen_element.mousemove change? Is that safe? This reverts your previous commit on that line.

@CorbinWunderlich
Copy link
Contributor

@CorbinWunderlich What about the screen_element.mousemove change? Is that safe? This reverts your previous commit on that line.

I believe that was what was reverted

@CorbinWunderlich
Copy link
Contributor

Now just squash your commits, then it will be good too me

@totaam totaam merged commit ddc70c1 into Xpra-org:master Feb 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants