Adjust cursor coordinates by hotspot.
This commit is contained in:
parent
6175985967
commit
2c11e27a4a
11
core/rfb.js
11
core/rfb.js
|
|
@ -1532,7 +1532,11 @@ export default class RFB extends EventTargetMixin {
|
||||||
// Finally, translate the coordinates to those relative to the
|
// Finally, translate the coordinates to those relative to the
|
||||||
// canvas and send the pointer move event to the remote machine.
|
// canvas and send the pointer move event to the remote machine.
|
||||||
const posFromCanvas = clientToElement(safeX, safeY, this._canvas);
|
const posFromCanvas = clientToElement(safeX, safeY, this._canvas);
|
||||||
this._sendMouse(posFromCanvas.x, posFromCanvas.y, this._mouseButtonMask);
|
const hotspot = this._cursor.hotspot;
|
||||||
|
this._sendMouse(
|
||||||
|
posFromCanvas.x + hotspot.x,
|
||||||
|
posFromCanvas.y + hotspot.y,
|
||||||
|
this._mouseButtonMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleTouchpadOneTapEvent() {
|
_handleTouchpadOneTapEvent() {
|
||||||
|
|
@ -1616,7 +1620,10 @@ export default class RFB extends EventTargetMixin {
|
||||||
* @returns {{x: number, y: number}}
|
* @returns {{x: number, y: number}}
|
||||||
*/
|
*/
|
||||||
_getCursorPositionToCanvas() {
|
_getCursorPositionToCanvas() {
|
||||||
const cursorPos = this._cursor.position;
|
const cursorPos = {
|
||||||
|
x: this._cursor.position.x + this._cursor.hotspot.x,
|
||||||
|
y: this._cursor.position.y + this._cursor.hotspot.y
|
||||||
|
};
|
||||||
return clientToElement(cursorPos.x, cursorPos.y, this._canvas);
|
return clientToElement(cursorPos.x, cursorPos.y, this._canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,13 @@ export default class Cursor {
|
||||||
get position() {
|
get position() {
|
||||||
return this._position;
|
return this._position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {{ x: number, y: number }}
|
||||||
|
*/
|
||||||
|
get hotspot() {
|
||||||
|
return this._hotSpot;
|
||||||
|
}
|
||||||
|
|
||||||
attach(target) {
|
attach(target) {
|
||||||
if (this._target) {
|
if (this._target) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue