KASM-1890 Add MacOS shortcut translation
This commit is contained in:
parent
7cd55562f0
commit
f509f5231a
22
app/ui.js
22
app/ui.js
|
@ -20,6 +20,16 @@ window.addEventListener("load", function() {
|
|||
}
|
||||
});
|
||||
|
||||
window.updateSetting = (name, value) => {
|
||||
WebUtil.writeSetting(name, value);
|
||||
|
||||
switch (name) {
|
||||
case "translate_shortcuts":
|
||||
UI.updateShortcutTranslation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
import * as Log from '../core/util/logging.js';
|
||||
import _, { l10n } from './localization.js';
|
||||
import { isTouchDevice, isSafari, hasScrollbarGutter, dragThreshold }
|
||||
|
@ -190,6 +200,7 @@ const UI = {
|
|||
UI.initSetting('quality', 6);
|
||||
UI.initSetting('dynamic_quality_min', 3);
|
||||
UI.initSetting('dynamic_quality_max', 9);
|
||||
UI.initSetting('translate_shortcuts', true);
|
||||
UI.initSetting('treat_lossless', 7);
|
||||
UI.initSetting('jpeg_video_quality', 5);
|
||||
UI.initSetting('webp_video_quality', 5);
|
||||
|
@ -411,6 +422,8 @@ const UI = {
|
|||
UI.addSettingChangeHandler('dynamic_quality_min', UI.updateQuality);
|
||||
UI.addSettingChangeHandler('dynamic_quality_max');
|
||||
UI.addSettingChangeHandler('dynamic_quality_max', UI.updateQuality);
|
||||
UI.addSettingChangeHandler('translate_shortcuts');
|
||||
UI.addSettingChangeHandler('translate_shortcuts', UI.updateShortcutTranslation);
|
||||
UI.addSettingChangeHandler('treat_lossless');
|
||||
UI.addSettingChangeHandler('treat_lossless', UI.updateQuality);
|
||||
UI.addSettingChangeHandler('anti_aliasing');
|
||||
|
@ -1266,6 +1279,7 @@ const UI = {
|
|||
document.addEventListener('mousedown', UI.mouseDownVNC);
|
||||
UI.rfb.addEventListener("bell", UI.bell);
|
||||
UI.rfb.addEventListener("desktopname", UI.updateDesktopName);
|
||||
UI.rfb.translateShortcuts = UI.getSetting('translate_shortcuts');
|
||||
UI.rfb.clipViewport = UI.getSetting('view_clip');
|
||||
UI.rfb.scaleViewport = UI.getSetting('resize') === 'scale';
|
||||
UI.rfb.resizeSession = UI.getSetting('resize') === 'remote';
|
||||
|
@ -1731,12 +1745,18 @@ const UI = {
|
|||
UI.rfb.compressionLevel = parseInt(UI.getSetting('compression'));
|
||||
},
|
||||
|
||||
|
||||
|
||||
/* ------^-------
|
||||
* /COMPRESSION
|
||||
* ==============
|
||||
* KEYBOARD
|
||||
* MOUSE AND KEYBOARD
|
||||
* ------v------*/
|
||||
|
||||
updateShortcutTranslation() {
|
||||
UI.rfb.translateShortcuts = UI.getSetting('translate_shortcuts');
|
||||
},
|
||||
|
||||
showVirtualKeyboard() {
|
||||
if (!isTouchDevice) return;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { stopEvent } from '../util/events.js';
|
|||
import * as KeyboardUtil from "./util.js";
|
||||
import KeyTable from "./keysym.js";
|
||||
import * as browser from "../util/browser.js";
|
||||
import UI from '../../app/ui.js';
|
||||
|
||||
//
|
||||
// Keyboard event handler
|
||||
|
@ -133,6 +134,15 @@ export default class Keyboard {
|
|||
return;
|
||||
}
|
||||
|
||||
// Translate MacOs CMD based shortcuts to their CTRL based counterpart
|
||||
if (browser.isMac() && UI.rfb.translateShortcuts && code !== "MetaLeft" && e.metaKey && !e.ctrlKey && !e.altKey) {
|
||||
this._sendKeyEvent(this._keyDownList["MetaLeft"], "MetaLeft", false);
|
||||
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
this._sendKeyEvent(keysym, code, true);
|
||||
stopEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
// Alt behaves more like AltGraph on macOS, so shuffle the
|
||||
// keys around a bit to make things more sane for the remote
|
||||
// server. This method is used by RealVNC and TigerVNC (and
|
||||
|
|
|
@ -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, isMac } from './util/browser.js';
|
||||
import { dragThreshold, supportsCursorURIs, isTouchDevice, isWindows, isMac } from './util/browser.js';
|
||||
import { clientToElement } from './util/element.js';
|
||||
import { setCapture } from './util/events.js';
|
||||
import EventTargetMixin from './util/eventtarget.js';
|
||||
|
|
9
vnc.html
9
vnc.html
|
@ -190,7 +190,14 @@
|
|||
<li>
|
||||
<label><input id="noVNC_setting_clipboard_seamless" type="checkbox" /> Clipboard Seamless</label></li>
|
||||
<li>
|
||||
<label><input id="noVNC_setting_prefer_local_cursor" type="checkbox" /> Prefer Local Cursor</label></li>
|
||||
<label><input id="noVNC_setting_prefer_local_cursor" type="checkbox" /> Prefer Local Cursor</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<input id="noVNC_setting_translate_shortcuts" type="checkbox" />Translate keyboard shurtcuts
|
||||
</label>
|
||||
</li>
|
||||
</li>
|
||||
<li>
|
||||
<label><input id="noVNC_setting_enable_webp" type="checkbox" /> Enable WebP Compression</label></li>
|
||||
<li>
|
||||
|
|
Loading…
Reference in New Issue