KASM-1881 Add MacOs cmd+wheel zoom support

This commit is contained in:
Mariusz Marciniak 2021-08-30 21:28:06 +02:00
parent ba40cacce0
commit 8453916f9c
2 changed files with 14 additions and 1 deletions

View File

@ -40,6 +40,13 @@ export default class Keyboard {
if (down) {
this._keyDownList[code] = keysym;
} else {
// On MacOs zoom and shortcut actions are CMD based so we need to
// let the remote know that it should unselect the CTRL key instead
if (browser.isMac() && code === "MetaLeft" && this._keyDownList["ControlLeft"]) {
keysym = KeyTable.XK_Control_L;
code = "ControlLeft";
}
// Do we really think this key is down?
if (!(code in this._keyDownList)) {
return;

View File

@ -10,7 +10,7 @@
import { toUnsigned32bit, toSigned32bit } from './util/int.js';
import * as Log from './util/logging.js';
import { encodeUTF8, decodeUTF8 } from './util/strings.js';
import { dragThreshold, supportsCursorURIs, isTouchDevice } from './util/browser.js';
import { dragThreshold, supportsCursorURIs, isTouchDevice, isMac } from './util/browser.js';
import { clientToElement } from './util/element.js';
import { setCapture } from './util/events.js';
import EventTargetMixin from './util/eventtarget.js';
@ -1340,6 +1340,12 @@ export default class RFB extends EventTargetMixin {
this._accumulatedWheelDeltaX += dX;
this._accumulatedWheelDeltaY += dY;
// On MacOs we need to translate zooming CMD+wheel to CTRL+wheel
if (isMac() && this._keyboard._keyDownList["MetaLeft"]) {
this._keyboard._sendKeyEvent(this._keyboard._keyDownList["MetaLeft"], "MetaLeft", false);
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
}
// Generate a mouse wheel step event when the accumulated delta
// for one of the axes is large enough.
if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) {