KASM-2108 Update Kasm<->noVNC communication for mobile related features
This commit is contained in:
parent
170cb81f6f
commit
c20db143a0
39
app/ui.js
39
app/ui.js
|
@ -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 "core-js/stable";
|
||||||
import "regenerator-runtime/runtime";
|
import "regenerator-runtime/runtime";
|
||||||
import * as Log from '../core/util/logging.js';
|
import * as Log from '../core/util/logging.js';
|
||||||
|
@ -163,13 +155,22 @@ const UI = {
|
||||||
UI.openConnectPanel();
|
UI.openConnectPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !isWindows() && (
|
window.parent.postMessage({
|
||||||
(window.parent.KASM_INITIAL_KEYBOARD_CONTROLS_MODE === "on") ||
|
action: "noVNC_initialized",
|
||||||
(window.parent.KASM_INITIAL_KEYBOARD_CONTROLS_MODE === "auto" && isTouchDevice)
|
value: null
|
||||||
)
|
}, "*");
|
||||||
) {
|
|
||||||
showKeyboardControlsPanel();
|
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);
|
return Promise.resolve(UI.rfb);
|
||||||
},
|
},
|
||||||
|
@ -1871,6 +1872,14 @@ const UI = {
|
||||||
UI.rfb.translateShortcuts = UI.getSetting('translate_shortcuts');
|
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() {
|
showVirtualKeyboard() {
|
||||||
const input = document.getElementById('noVNC_keyboardinput');
|
const input = document.getElementById('noVNC_keyboardinput');
|
||||||
|
|
||||||
|
|
15
core/rfb.js
15
core/rfb.js
|
@ -966,13 +966,14 @@ export default class RFB extends EventTargetMixin {
|
||||||
|
|
||||||
_focusCanvas(event) {
|
_focusCanvas(event) {
|
||||||
// Hack:
|
// Hack:
|
||||||
// On most mobile phones it's only possible to play audio
|
// On most mobile phones it's possible to play audio
|
||||||
// only if it's triggered by a user action. Moreover, since it's also
|
// only if it's triggered by user action. It's also
|
||||||
// impossible to listen for touch events on child frames (only on mobile phones)
|
// impossible to listen for touch events on child frames (on mobile phones)
|
||||||
// we delegate the audio unlocking to the parent window.
|
// so we catch those events here but forward the audio unlocking to the parent window
|
||||||
if (window.parent && !window.parent.KASM_AUDIO_UNLOCKED) {
|
window.parent.postMessage({
|
||||||
window.parent.unlockAudio && window.parent.unlockAudio();
|
action: "enable_audio",
|
||||||
}
|
value: null
|
||||||
|
}, "*");
|
||||||
|
|
||||||
if (!this.focusOnClick) {
|
if (!this.focusOnClick) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue