|
@@ -15,6 +15,8 @@ var UI;
|
|
(function () {
|
|
(function () {
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
|
+ var resizeTimeout;
|
|
|
|
+
|
|
// Load supporting scripts
|
|
// Load supporting scripts
|
|
window.onscriptsload = function () { UI.load(); };
|
|
window.onscriptsload = function () { UI.load(); };
|
|
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
|
|
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
|
|
@@ -43,6 +45,19 @@ var UI;
|
|
WebUtil.initSettings(UI.start, callback);
|
|
WebUtil.initSettings(UI.start, callback);
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ onresize: function (callback) {
|
|
|
|
+ if (UI.getSetting('resize')) {
|
|
|
|
+ var innerW = window.innerWidth;
|
|
|
|
+ var innerH = window.innerHeight;
|
|
|
|
+ var controlbarH = $D('noVNC-control-bar').offsetHeight;
|
|
|
|
+ // For some unknown reason the container is higher than the canvas,
|
|
|
|
+ // 5px higher in Firefox and 4px higher in Chrome
|
|
|
|
+ var padding = 5;
|
|
|
|
+ if (innerW !== undefined && innerH !== undefined)
|
|
|
|
+ UI.rfb.setDesktopSize(innerW, innerH - controlbarH - padding);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
// Render default UI and initialize settings menu
|
|
// Render default UI and initialize settings menu
|
|
start: function(callback) {
|
|
start: function(callback) {
|
|
UI.isTouchDevice = 'ontouchstart' in document.documentElement;
|
|
UI.isTouchDevice = 'ontouchstart' in document.documentElement;
|
|
@@ -89,6 +104,7 @@ var UI;
|
|
UI.initSetting('encrypt', (window.location.protocol === "https:"));
|
|
UI.initSetting('encrypt', (window.location.protocol === "https:"));
|
|
UI.initSetting('true_color', true);
|
|
UI.initSetting('true_color', true);
|
|
UI.initSetting('cursor', !UI.isTouchDevice);
|
|
UI.initSetting('cursor', !UI.isTouchDevice);
|
|
|
|
+ UI.initSetting('resize', false);
|
|
UI.initSetting('shared', true);
|
|
UI.initSetting('shared', true);
|
|
UI.initSetting('view_only', false);
|
|
UI.initSetting('view_only', false);
|
|
UI.initSetting('path', 'websockify');
|
|
UI.initSetting('path', 'websockify');
|
|
@@ -98,6 +114,8 @@ var UI;
|
|
'onUpdateState': UI.updateState,
|
|
'onUpdateState': UI.updateState,
|
|
'onXvpInit': UI.updateXvpVisualState,
|
|
'onXvpInit': UI.updateXvpVisualState,
|
|
'onClipboard': UI.clipReceive,
|
|
'onClipboard': UI.clipReceive,
|
|
|
|
+ 'onFBUComplete': UI.FBUComplete,
|
|
|
|
+ 'onFBResize': UI.updateViewDragButton,
|
|
'onDesktopName': UI.updateDocumentTitle});
|
|
'onDesktopName': UI.updateDocumentTitle});
|
|
|
|
|
|
var autoconnect = WebUtil.getQueryVar('autoconnect', false);
|
|
var autoconnect = WebUtil.getQueryVar('autoconnect', false);
|
|
@@ -118,7 +136,6 @@ var UI;
|
|
// Remove the address bar
|
|
// Remove the address bar
|
|
setTimeout(function() { window.scrollTo(0, 1); }, 100);
|
|
setTimeout(function() { window.scrollTo(0, 1); }, 100);
|
|
UI.forceSetting('clip', true);
|
|
UI.forceSetting('clip', true);
|
|
- $D('noVNC_clip').disabled = true;
|
|
|
|
} else {
|
|
} else {
|
|
UI.initSetting('clip', false);
|
|
UI.initSetting('clip', false);
|
|
}
|
|
}
|
|
@@ -136,7 +153,17 @@ var UI;
|
|
$D('noVNC_host').focus();
|
|
$D('noVNC_host').focus();
|
|
|
|
|
|
UI.setViewClip();
|
|
UI.setViewClip();
|
|
- Util.addEvent(window, 'resize', UI.setViewClip);
|
|
|
|
|
|
+
|
|
|
|
+ Util.addEvent(window, 'resize', function () {
|
|
|
|
+ UI.setViewClip();
|
|
|
|
+ // When the window has been resized, wait until the size remains
|
|
|
|
+ // the same for 0.5 seconds before sending the request for changing
|
|
|
|
+ // the resolution of the session
|
|
|
|
+ clearTimeout(resizeTimeout);
|
|
|
|
+ resizeTimeout = setTimeout(function(){
|
|
|
|
+ UI.onresize();
|
|
|
|
+ }, 500);
|
|
|
|
+ } );
|
|
|
|
|
|
Util.addEvent(window, 'load', UI.keyboardinputReset);
|
|
Util.addEvent(window, 'load', UI.keyboardinputReset);
|
|
|
|
|
|
@@ -212,7 +239,7 @@ var UI;
|
|
getSetting: function(name) {
|
|
getSetting: function(name) {
|
|
var ctrl = $D('noVNC_' + name);
|
|
var ctrl = $D('noVNC_' + name);
|
|
var val = WebUtil.readSetting(name);
|
|
var val = WebUtil.readSetting(name);
|
|
- if (val !== null && ctrl.type === 'checkbox') {
|
|
|
|
|
|
+ if (typeof val !== 'undefined' && val !== null && ctrl.type === 'checkbox') {
|
|
if (val.toString().toLowerCase() in {'0':1, 'no':1, 'false':1}) {
|
|
if (val.toString().toLowerCase() in {'0':1, 'no':1, 'false':1}) {
|
|
val = false;
|
|
val = false;
|
|
} else {
|
|
} else {
|
|
@@ -427,6 +454,7 @@ var UI;
|
|
$D('noVNC_cursor').disabled = true;
|
|
$D('noVNC_cursor').disabled = true;
|
|
}
|
|
}
|
|
UI.updateSetting('clip');
|
|
UI.updateSetting('clip');
|
|
|
|
+ UI.updateSetting('resize');
|
|
UI.updateSetting('shared');
|
|
UI.updateSetting('shared');
|
|
UI.updateSetting('view_only');
|
|
UI.updateSetting('view_only');
|
|
UI.updateSetting('path');
|
|
UI.updateSetting('path');
|
|
@@ -479,6 +507,7 @@ var UI;
|
|
UI.saveSetting('cursor');
|
|
UI.saveSetting('cursor');
|
|
}
|
|
}
|
|
UI.saveSetting('clip');
|
|
UI.saveSetting('clip');
|
|
|
|
+ UI.saveSetting('resize');
|
|
UI.saveSetting('shared');
|
|
UI.saveSetting('shared');
|
|
UI.saveSetting('view_only');
|
|
UI.saveSetting('view_only');
|
|
UI.saveSetting('path');
|
|
UI.saveSetting('path');
|
|
@@ -595,6 +624,8 @@ var UI;
|
|
UI.updateSetting('cursor', !UI.isTouchDevice);
|
|
UI.updateSetting('cursor', !UI.isTouchDevice);
|
|
$D('noVNC_cursor').disabled = true;
|
|
$D('noVNC_cursor').disabled = true;
|
|
}
|
|
}
|
|
|
|
+ $D('noVNC_clip').disabled = connected || UI.isTouchDevice;
|
|
|
|
+ $D('noVNC_resize').disabled = connected;
|
|
$D('noVNC_shared').disabled = connected;
|
|
$D('noVNC_shared').disabled = connected;
|
|
$D('noVNC_view_only').disabled = connected;
|
|
$D('noVNC_view_only').disabled = connected;
|
|
$D('noVNC_path').disabled = connected;
|
|
$D('noVNC_path').disabled = connected;
|
|
@@ -650,6 +681,16 @@ var UI;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // This resize can not be done until we know from the first Frame Buffer Update
|
|
|
|
+ // if it is supported or not.
|
|
|
|
+ // The resize is needed to make sure the server desktop size is updated to the
|
|
|
|
+ // corresponding size of the current local window when reconnecting to an
|
|
|
|
+ // existing session.
|
|
|
|
+ FBUComplete: function(rfb, fbu) {
|
|
|
|
+ UI.onresize();
|
|
|
|
+ UI.rfb.set_onFBUComplete(function() { });
|
|
|
|
+ },
|
|
|
|
+
|
|
// Display the desktop name in the document title
|
|
// Display the desktop name in the document title
|
|
updateDocumentTitle: function(rfb, name) {
|
|
updateDocumentTitle: function(rfb, name) {
|
|
document.title = name + " - noVNC";
|
|
document.title = name + " - noVNC";
|
|
@@ -691,6 +732,9 @@ var UI;
|
|
UI.closeSettingsMenu();
|
|
UI.closeSettingsMenu();
|
|
UI.rfb.disconnect();
|
|
UI.rfb.disconnect();
|
|
|
|
|
|
|
|
+ // Restore the callback used for initial resize
|
|
|
|
+ UI.rfb.set_onFBUComplete(UI.FBUComplete);
|
|
|
|
+
|
|
$D('noVNC_logo').style.display = "block";
|
|
$D('noVNC_logo').style.display = "block";
|
|
UI.connSettingsOpen = false;
|
|
UI.connSettingsOpen = false;
|
|
UI.toggleConnectPanel();
|
|
UI.toggleConnectPanel();
|
|
@@ -742,7 +786,7 @@ var UI;
|
|
UI.updateSetting('clip', false);
|
|
UI.updateSetting('clip', false);
|
|
display.set_viewport(false);
|
|
display.set_viewport(false);
|
|
$D('noVNC_canvas').style.position = 'static';
|
|
$D('noVNC_canvas').style.position = 'static';
|
|
- display.viewportChange();
|
|
|
|
|
|
+ display.viewportChangeSize();
|
|
}
|
|
}
|
|
if (UI.getSetting('clip')) {
|
|
if (UI.getSetting('clip')) {
|
|
// If clipping, update clipping settings
|
|
// If clipping, update clipping settings
|
|
@@ -751,27 +795,22 @@ var UI;
|
|
var new_w = window.innerWidth - pos.x;
|
|
var new_w = window.innerWidth - pos.x;
|
|
var new_h = window.innerHeight - pos.y;
|
|
var new_h = window.innerHeight - pos.y;
|
|
display.set_viewport(true);
|
|
display.set_viewport(true);
|
|
- display.viewportChange(0, 0, new_w, new_h);
|
|
|
|
|
|
+ display.viewportChangeSize(new_w, new_h);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
// Toggle/set/unset the viewport drag/move button
|
|
// Toggle/set/unset the viewport drag/move button
|
|
setViewDrag: function(drag) {
|
|
setViewDrag: function(drag) {
|
|
- var vmb = $D('noVNC_view_drag_button');
|
|
|
|
if (!UI.rfb) { return; }
|
|
if (!UI.rfb) { return; }
|
|
|
|
|
|
- if (UI.rfb_state === 'normal' &&
|
|
|
|
- UI.rfb.get_display().get_viewport()) {
|
|
|
|
- vmb.style.display = "inline";
|
|
|
|
- } else {
|
|
|
|
- vmb.style.display = "none";
|
|
|
|
- }
|
|
|
|
|
|
+ UI.updateViewDragButton();
|
|
|
|
|
|
if (typeof(drag) === "undefined" ||
|
|
if (typeof(drag) === "undefined" ||
|
|
typeof(drag) === "object") {
|
|
typeof(drag) === "object") {
|
|
// If not specified, then toggle
|
|
// If not specified, then toggle
|
|
drag = !UI.rfb.get_viewportDrag();
|
|
drag = !UI.rfb.get_viewportDrag();
|
|
}
|
|
}
|
|
|
|
+ var vmb = $D('noVNC_view_drag_button');
|
|
if (drag) {
|
|
if (drag) {
|
|
vmb.className = "noVNC_status_button_selected";
|
|
vmb.className = "noVNC_status_button_selected";
|
|
UI.rfb.set_viewportDrag(true);
|
|
UI.rfb.set_viewportDrag(true);
|
|
@@ -781,6 +820,17 @@ var UI;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ updateViewDragButton: function() {
|
|
|
|
+ var vmb = $D('noVNC_view_drag_button');
|
|
|
|
+ if (UI.rfb_state === 'normal' &&
|
|
|
|
+ UI.rfb.get_display().get_viewport() &&
|
|
|
|
+ UI.rfb.get_display().fbuClip()) {
|
|
|
|
+ vmb.style.display = "inline";
|
|
|
|
+ } else {
|
|
|
|
+ vmb.style.display = "none";
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
// On touch devices, show the OS keyboard
|
|
// On touch devices, show the OS keyboard
|
|
showKeyboard: function() {
|
|
showKeyboard: function() {
|
|
var kbi = $D('keyboardinput');
|
|
var kbi = $D('keyboardinput');
|