Explorar o código

Clarified enableDisableClip (now called enableDisableViewClip) and
moved it to where the other clipping functions are.

samhed %!s(int64=10) %!d(string=hai) anos
pai
achega
30bfff81d9
Modificáronse 1 ficheiros con 17 adicións e 16 borrados
  1. 17 16
      include/ui.js

+ 17 - 16
include/ui.js

@@ -220,7 +220,7 @@ var UI;
 
             $D("noVNC_resize").onchange = function () {
                 var connected = UI.rfb && UI.rfb_state === 'normal';
-                UI.enableDisableClip(connected);
+                UI.enableDisableViewClip(connected);
             };
         },
 
@@ -685,7 +685,7 @@ var UI;
                 $D('noVNC_cursor').disabled = true;
             }
 
-            UI.enableDisableClip(connected);
+            UI.enableDisableViewClip(connected);
             $D('noVNC_resize').disabled = connected;
             $D('noVNC_shared').disabled = connected;
             $D('noVNC_view_only').disabled = connected;
@@ -747,19 +747,6 @@ var UI;
             }
         },
 
-        enableDisableClip: function (connected) {
-            var resizeElem = $D('noVNC_resize');
-            if (resizeElem.value === 'downscale' || resizeElem.value === 'scale') {
-                UI.forceSetting('clip', false);
-                $D('noVNC_clip').disabled = true;
-            } else {
-                $D('noVNC_clip').disabled = connected || UI.isTouchDevice;
-                if (UI.isTouchDevice) {
-                    UI.forceSetting('clip', true);
-                }
-            }
-        },
-
         // 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
@@ -849,7 +836,7 @@ var UI;
             Util.Debug("<< UI.clipSend");
         },
 
-        // Enable/disable and configure viewport clipping
+        // Set and configure viewport clipping
         setViewClip: function(clip) {
             var display;
             if (UI.rfb) {
@@ -900,6 +887,20 @@ var UI;
             }
         },
 
+        // Handle special cases where clipping is forced on/off or locked
+        enableDisableViewClip: function (connected) {
+            var resizeElem = $D('noVNC_resize');
+            if (resizeElem.value === 'downscale' || resizeElem.value === 'scale') {
+                UI.forceSetting('clip', false);
+                $D('noVNC_clip').disabled = true;
+            } else {
+                $D('noVNC_clip').disabled = connected || UI.isTouchDevice;
+                if (UI.isTouchDevice) {
+                    UI.forceSetting('clip', true);
+                }
+            }
+        },
+
         // Update the viewport drag/move button
         updateViewDrag: function(drag) {
             if (!UI.rfb) return;