Skip to content

fix(kvm): Map mouse to framebuffer via on-screen box, honour object fit - #1860

Open
michaelmadell wants to merge 1 commit into
device-management-toolkit:mainfrom
michaelmadell:main
Open

michaelmadell wants to merge 1 commit into
device-management-toolkit:mainfrom
michaelmadell:main

Conversation

@michaelmadell

@michaelmadell michaelmadell commented Oct 2, 2026 •

Copy link
Copy Markdown

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

PR Checklist

  • Unit Tests have been added for new changes
  • API tests have been updated if applicable
  • All commented code has been removed
  • If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.

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

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
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.

1 participant