fix(kvm): Map mouse to framebuffer via on-screen box, honour object fit - #1860
Open
michaelmadell wants to merge 1 commit into
Open
michaelmadell wants to merge 1 commit into
michaelmadell wants to merge 1 commit into
Conversation
The pointer position sent to AMT was wrong whenever the canvas wasn't shown 1:1 at its layout position: - Fullscreen: browsers give a full-screen element `object-fit: contain`, so the picture is letterboxed inside a screen-sized element. The mapping ignored the bars, putting the remote cursor up and to the right (e.g. aiming at 700,500 of a 1024x768 desktop on a 1600x900 screen send 870,388). - X was scaled by the height ratio and Y by the width ratio, so any non-uniform stretch skewed both axes. - The cached largest bounding-rect top/left was added to every event, so scrolling the page shifted clicks by the scroll distance. Map clientX/clientY through getBoundingClientRect instead (handles scroll, CSS scaling and transforms), scale each axis by its own ratio, and account for object-fit contain/scale-down letterboxing. Coordinates are clamped to the framebuffer. resetOffsets() is kept as a no-op for API compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pointer position sent to AMT was wrong whenever the canvas wasn't shown 1:1 at its layout position:
object-fit: contain, so the picture is letterboxed inside a screen-sized element. The mapping ignored the bars, putting the remote cursor up and to the right (e.g. aiming at 700,500 of a 1024x768 desktop on a 1600x900 screen send 870,388).Map clientX/clientY through getBoundingClientRect instead (handles scroll, CSS scaling and transforms), scale each axis by its own ratio, and account for object-fit contain/scale-down letterboxing. Coordinates are clamped to the framebuffer. resetOffsets() is kept as a no-op for API compatibility
PR Checklist
What are you changing?
making the pointer position align when the canvas is full-screened or scaled to avoid the incorrect pointer position on the remote machine