Refresh, attach, detach cursor on API-calls and mouse events

This commit is contained in:
Daniel Hammerschmidt 2025-09-17 04:17:01 +02:00
parent 3b79d45f6a
commit 68a2db4da5
1 changed files with 23 additions and 1 deletions

View File

@ -323,8 +323,10 @@ export default class RFB extends EventTargetMixin {
this._rfbConnectionState === "connected") {
if (viewOnly) {
this._keyboard.ungrab();
this._refreshCursor();
} else {
this._keyboard.grab();
this._refreshCursor();
}
}
}
@ -353,6 +355,7 @@ export default class RFB extends EventTargetMixin {
get dragViewport() { return this._dragViewport; }
set dragViewport(dragViewport) {
this._dragViewport = dragViewport;
this._refreshCursor();
}
get scaleViewport() { return this._scaleViewport; }
@ -399,6 +402,11 @@ export default class RFB extends EventTargetMixin {
dragCursor && (this._localCursors.drag = dragCursor);
draggingCursor && (this._localCursors.dragging = draggingCursor);
emptyCursor && (this._localCursors.empty = emptyCursor);
this._cursor.detach();
this._cursor.attach(this._canvas, {
showLocalCursor: this._showLocalCursor,
});
this._refreshCursor();
}
get background() { return this._screen.style.background; }
@ -605,7 +613,9 @@ export default class RFB extends EventTargetMixin {
this._gestures.attach(this._canvas);
this._cursor.attach(this._canvas);
this._cursor.attach(this._canvas, {
showLocalCursor: this._showLocalCursor
});
this._refreshCursor();
// Monitor size changes of the screen element
@ -1154,6 +1164,11 @@ export default class RFB extends EventTargetMixin {
this._viewportDragPos = {'x': pos.x, 'y': pos.y};
this._viewportHasMoved = false;
if (this._showLocalCursor) {
this._refreshCursor();
this._cursor.detach();
}
this._flushMouseMoveTimer(pos.x, pos.y);
// Skip sending mouse events, instead save the current
@ -1163,6 +1178,13 @@ export default class RFB extends EventTargetMixin {
} else {
this._viewportDragging = false;
if (this._showLocalCursor) {
this._cursor.attach(this._canvas, {
showLocalCursor: this._showLocalCursor,
});
this._refreshCursor();
}
// If we actually performed a drag then we are done
// here and should not send any mouse events
if (this._viewportHasMoved) {