Merge pull request #24 from kasmtech/bugfix/KASM-2108_mobile_ipc

KASM-2108 Update Kasm<->noVNC communication for mobile related features
This commit is contained in:
j-travis 2021-11-15 20:08:54 -05:00 committed by GitHub
commit 9383783efd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 22 deletions

View File

@ -30,14 +30,6 @@ window.updateSetting = (name, value) => {
}
}
window.showKeyboardControlsPanel = () => {
document.querySelector(".keyboard-controls").classList.add("is-visible");
}
window.hideKeyboardControlsPanel = () => {
document.querySelector(".keyboard-controls").classList.remove("is-visible");
}
import "core-js/stable";
import "regenerator-runtime/runtime";
import * as Log from '../core/util/logging.js';
@ -163,13 +155,22 @@ const UI = {
UI.openConnectPanel();
}
if ( !isWindows() && (
(window.parent.KASM_INITIAL_KEYBOARD_CONTROLS_MODE === "on") ||
(window.parent.KASM_INITIAL_KEYBOARD_CONTROLS_MODE === "auto" && isTouchDevice)
)
) {
showKeyboardControlsPanel();
}
window.parent.postMessage({
action: "noVNC_initialized",
value: null
}, "*");
window.addEventListener("message", (e) => {
if (typeof e.data !== "object" || !e.data.action) {
return;
}
if (e.data.action === "show_keyboard_controls") {
UI.showKeyboardControls();
} else if (e.data.action === "hide_keyboard_controls") {
UI.hideKeyboardControls();
}
});
return Promise.resolve(UI.rfb);
},
@ -1871,6 +1872,14 @@ const UI = {
UI.rfb.translateShortcuts = UI.getSetting('translate_shortcuts');
},
showKeyboardControls() {
document.querySelector(".keyboard-controls").classList.add("is-visible");
},
hideKeyboardControls() {
document.querySelector(".keyboard-controls").classList.remove("is-visible");
},
showVirtualKeyboard() {
const input = document.getElementById('noVNC_keyboardinput');

View File

@ -966,13 +966,14 @@ export default class RFB extends EventTargetMixin {
_focusCanvas(event) {
// Hack:
// On most mobile phones it's only possible to play audio
// only if it's triggered by a user action. Moreover, since it's also
// impossible to listen for touch events on child frames (only on mobile phones)
// we delegate the audio unlocking to the parent window.
if (window.parent && !window.parent.KASM_AUDIO_UNLOCKED) {
window.parent.unlockAudio && window.parent.unlockAudio();
}
// On most mobile phones it's possible to play audio
// only if it's triggered by user action. It's also
// impossible to listen for touch events on child frames (on mobile phones)
// so we catch those events here but forward the audio unlocking to the parent window
window.parent.postMessage({
action: "enable_audio",
value: null
}, "*");
if (!this.focusOnClick) {
return;