// set manually
let port = window.location.port;
if (!port) {
- if (window.location.protocol.substring(0,5) == 'https') {
+ if (window.location.protocol.substring(0, 5) == 'https') {
port = 443;
- }
- else if (window.location.protocol.substring(0,4) == 'http') {
+ } else if (window.location.protocol.substring(0, 4) == 'http') {
port = 80;
}
}
UI.addSettingChangeHandler('encrypt');
UI.addSettingChangeHandler('resize');
- UI.addSettingChangeHandler('resize', UI.enableDisableViewClip);
UI.addSettingChangeHandler('resize', UI.applyResizeMode);
+ UI.addSettingChangeHandler('resize', UI.updateViewClip);
UI.addSettingChangeHandler('view_clip');
UI.addSettingChangeHandler('view_clip', UI.updateViewClip);
UI.addSettingChangeHandler('shared');
return;
}
- UI.enableDisableViewClip();
-
if (UI.connected) {
+ UI.updateViewClip();
+
UI.disableSetting('encrypt');
UI.disableSetting('shared');
UI.disableSetting('host');
UI.keepControlbar();
}
- // State change disables viewport dragging.
- // It is enabled (toggled) by direct click on the button
- UI.setViewDrag(false);
-
- // State change also closes the password dialog
+ // State change closes the password dialog
document.getElementById('noVNC_password_dlg')
.classList.remove('noVNC_open');
},
const ctrl = document.getElementById('noVNC_setting_' + name);
let val = WebUtil.readSetting(name);
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;
} else {
val = true;
},
clipboardReceive(e) {
- Log.Debug(">> UI.clipboardReceive: " + e.detail.text.substr(0,40) + "...");
+ Log.Debug(">> UI.clipboardReceive: " + e.detail.text.substr(0, 40) + "...");
document.getElementById('noVNC_clipboard_text').value = e.detail.text;
Log.Debug("<< UI.clipboardReceive");
},
clipboardSend() {
const text = document.getElementById('noVNC_clipboard_text').value;
- Log.Debug(">> UI.clipboardSend: " + text.substr(0,40) + "...");
+ Log.Debug(">> UI.clipboardSend: " + text.substr(0, 40) + "...");
UI.rfb.clipboardPasteFrom(text);
Log.Debug("<< UI.clipboardSend");
},
document.body.msRequestFullscreen();
}
}
- UI.enableDisableViewClip();
UI.updateFullscreenButton();
},
* VIEW CLIPPING
* ------v------*/
- // Update parameters that depend on the viewport clip setting
+ // Update viewport clipping property for the connection. The normal
+ // case is to get the value from the setting. There are special cases
+ // for when the viewport is scaled or when a touch device is used.
updateViewClip() {
if (!UI.rfb) return;
- const cur_clip = UI.rfb.clipViewport;
- let new_clip = UI.getSetting('view_clip');
+ const scaling = UI.getSetting('resize') === 'scale';
- if (isTouchDevice) {
+ if (scaling) {
+ // Can't be clipping if viewport is scaled to fit
+ UI.forceSetting('view_clip', false);
+ UI.rfb.clipViewport = false;
+ } else if (isTouchDevice) {
// Touch devices usually have shit scrollbars
- new_clip = true;
- }
-
- if (cur_clip !== new_clip) {
- UI.rfb.clipViewport = new_clip;
+ UI.forceSetting('view_clip', true);
+ UI.rfb.clipViewport = true;
+ } else {
+ UI.enableSetting('view_clip');
+ UI.rfb.clipViewport = UI.getSetting('view_clip');
}
// Changing the viewport may change the state of
UI.updateViewDrag();
},
- // Handle special cases where viewport clipping is locked
- enableDisableViewClip() {
- const resizeSetting = UI.getSetting('resize');
- if (isTouchDevice) {
- UI.forceSetting('view_clip', true);
- } else if (resizeSetting === 'scale') {
- UI.disableSetting('view_clip');
- } else {
- UI.enableSetting('view_clip');
- }
- },
-
/* ------^-------
* /VIEW CLIPPING
* ==============
toggleViewDrag() {
if (!UI.rfb) return;
- const drag = UI.rfb.dragViewport;
- UI.setViewDrag(!drag);
- },
-
- // Set the view drag mode which moves the viewport on mouse drags
- setViewDrag(drag) {
- if (!UI.rfb) return;
-
- UI.rfb.dragViewport = drag;
-
+ UI.rfb.dragViewport = !UI.rfb.dragViewport;
UI.updateViewDrag();
},
UI.rfb.touchButton = num;
}
- const blist = [0, 1,2,4];
+ const blist = [0, 1, 2, 4];
for (let b = 0; b < blist.length; b++) {
const button = document.getElementById('noVNC_mouse_button' +
blist[b]);