-
Notifications
You must be signed in to change notification settings - Fork 60
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
Conversation
html5/js/Client.js
Outdated
@@ -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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
html5/js/Client.js
Outdated
@@ -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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undone here
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
LGTM, can you squash the commits? |
Please use server_resize_exact instead of always returning undefined |
@CorbinWunderlich sorry, I don't understand what you mean |
I took another look and it looks good to me. |
@CorbinWunderlich What about the |
I believe that was what was reverted |
Now just squash your commits, then it will be good too me |
c65b63b
to
54083e1
Compare
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](https://private-user-images.githubusercontent.com/77851258/411545603-246f4693-4c46-4571-a1af-32c5c36f5a6f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MzM0MDEsIm5iZiI6MTczOTUzMzEwMSwicGF0aCI6Ii83Nzg1MTI1OC80MTE1NDU2MDMtMjQ2ZjQ2OTMtNGM0Ni00NTcxLWExYWYtMzJjNWMzNmY1YTZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDExMzgyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJhNTAxMTBmNjNjNmRlZTA3Y2Q0ZDlmMzc1Zjc2Mjc3YzU0ZjVmZjJjZWJhMDAxNDJlMWMzMTc4MzAzYWY5YTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.4Ml4Xb4FLpRSiWcZ3rVI7800eKj6m0C-i0LSnXOJUw4)
This is fixed by using the window div's position, instead of it's
.x
and.y
fieldsThe 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.