add scroll wheel support to remote desktop
This commit is contained in:
@@ -1318,6 +1318,14 @@ import { checkFeatureAccess } from "./feature-gate.js";
|
||||
canvas.addEventListener("contextmenu", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
canvas.addEventListener("wheel", function (e) {
|
||||
if (!mouseCtrl.checked) return;
|
||||
const pt = getCanvasPoint(e);
|
||||
if (!pt) return;
|
||||
const delta = Math.max(-120, Math.min(120, Math.round(-e.deltaY)));
|
||||
sendCmd("mouse_wheel", { delta, x: pt.x, y: pt.y });
|
||||
e.preventDefault();
|
||||
}, { passive: false });
|
||||
|
||||
canvas.setAttribute("tabindex", "0");
|
||||
canvas.addEventListener("click", function () {
|
||||
|
||||
@@ -497,6 +497,13 @@ export function handleRemoteDesktopViewerMessage(ws: ServerWebSocket<SocketData>
|
||||
sendDesktopCommandWithId(target, "desktop_mouse_up", { button: Number(payload.button) || 0 }, commandId);
|
||||
break;
|
||||
}
|
||||
case "mouse_wheel": {
|
||||
if (!state.isStreaming) break;
|
||||
const commandId = uuidv4();
|
||||
recordRdInput(commandId, clientId, "mouse_wheel");
|
||||
sendDesktopCommandWithId(target, "desktop_mouse_wheel", { delta: Number(payload.delta) || 0, x: Number((payload as any).x) || 0, y: Number((payload as any).y) || 0 }, commandId);
|
||||
break;
|
||||
}
|
||||
case "key_down": {
|
||||
if (!state.isStreaming) break;
|
||||
const commandId = uuidv4();
|
||||
|
||||
Reference in New Issue
Block a user