From 0b903af296d6b0626cee53a3b12b0e56d84b02d9 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Mon, 30 Jul 2018 10:02:44 +0200 Subject: [PATCH 1/3] Remove unnecessary code The enableDisableViewClip call in the fullscreen code didn't have any effect and should have been removed when the special case for clipping in IE and Safari fullscreen was removed in b18ef81. The setViewDrag call claimed to disable view drag on UI state change. The UI states are: init, connecting, connected, reconnecting, disconnecting, disconnected The only state where the called function didn't immediately return was "connected" and that's the only state where enabling view drag is possible. Thus it could never have been enabled when changing to the "connected" state. --- app/ui.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/ui.js b/app/ui.js index 4fe2a3fb..552ac287 100644 --- a/app/ui.js +++ b/app/ui.js @@ -432,11 +432,7 @@ const UI = { 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'); }, @@ -1204,7 +1200,6 @@ const UI = { document.body.msRequestFullscreen(); } } - UI.enableDisableViewClip(); UI.updateFullscreenButton(); }, From 2bbd15ccaf6e1cfa6dbfb8088e9f35f27a0f3e16 Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Mon, 30 Jul 2018 10:46:41 +0200 Subject: [PATCH 2/3] Remove setViewDrag function Unnecessary function only used in the toggle function above. --- app/ui.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/ui.js b/app/ui.js index 552ac287..083c8458 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1278,16 +1278,7 @@ const UI = { 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(); }, From 4ddcc7537fb00166a623b7e062496be4928a568d Mon Sep 17 00:00:00 2001 From: Samuel Mannehed Date: Mon, 30 Jul 2018 10:49:42 +0200 Subject: [PATCH 3/3] Merge enableDisableViewClip and updateViewClip Makes the code easier to follow and makes sure that viewDrag is properly disabled when scaling. Fixes #1110. --- app/ui.js | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/app/ui.js b/app/ui.js index 083c8458..f657a44c 100644 --- a/app/ui.js +++ b/app/ui.js @@ -340,8 +340,8 @@ const UI = { 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'); @@ -408,9 +408,9 @@ const UI = { return; } - UI.enableDisableViewClip(); - if (UI.connected) { + UI.updateViewClip(); + UI.disableSetting('encrypt'); UI.disableSetting('shared'); UI.disableSetting('host'); @@ -1236,20 +1236,25 @@ const UI = { * 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 @@ -1257,18 +1262,6 @@ const UI = { 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 * ==============