Commit 31ddaa1c authored by samhed's avatar samhed

Clarify code with regards to the viewport drag functionality

* Fixes #502 so that the viewport drag functionality can't get stuck
parent 29a0e6a8
...@@ -127,7 +127,7 @@ var UI; ...@@ -127,7 +127,7 @@ var UI;
Util.addEvent(window, 'resize', function () { Util.addEvent(window, 'resize', function () {
UI.onresize(); UI.onresize();
UI.setViewClip(); UI.setViewClip();
UI.updateViewDragButton(); UI.updateViewDrag();
UI.setBarPosition(); UI.setBarPosition();
} ); } );
...@@ -165,7 +165,7 @@ var UI; ...@@ -165,7 +165,7 @@ var UI;
'onXvpInit': UI.updateXvpVisualState, 'onXvpInit': UI.updateXvpVisualState,
'onClipboard': UI.clipReceive, 'onClipboard': UI.clipReceive,
'onFBUComplete': UI.FBUComplete, 'onFBUComplete': UI.FBUComplete,
'onFBResize': UI.updateViewDragButton, 'onFBResize': UI.updateViewDrag,
'onDesktopName': UI.updateDocumentTitle}); 'onDesktopName': UI.updateDocumentTitle});
return true; return true;
} catch (exc) { } catch (exc) {
...@@ -176,7 +176,7 @@ var UI; ...@@ -176,7 +176,7 @@ var UI;
addMouseHandlers: function() { addMouseHandlers: function() {
// Setup interface handlers that can't be inline // Setup interface handlers that can't be inline
$D("noVNC_view_drag_button").onclick = UI.setViewDrag; $D("noVNC_view_drag_button").onclick = UI.toggleViewDrag;
$D("noVNC_mouse_button0").onclick = function () { UI.setMouseButton(1); }; $D("noVNC_mouse_button0").onclick = function () { UI.setMouseButton(1); };
$D("noVNC_mouse_button1").onclick = function () { UI.setMouseButton(2); }; $D("noVNC_mouse_button1").onclick = function () { UI.setMouseButton(2); };
$D("noVNC_mouse_button2").onclick = function () { UI.setMouseButton(4); }; $D("noVNC_mouse_button2").onclick = function () { UI.setMouseButton(4); };
...@@ -565,7 +565,7 @@ var UI; ...@@ -565,7 +565,7 @@ var UI;
WebUtil.selectStylesheet(UI.getSetting('stylesheet')); WebUtil.selectStylesheet(UI.getSetting('stylesheet'));
WebUtil.init_logging(UI.getSetting('logging')); WebUtil.init_logging(UI.getSetting('logging'));
UI.setViewClip(); UI.setViewClip();
UI.setViewDrag(UI.rfb && UI.rfb.get_viewportDrag()); UI.updateViewDrag();
//Util.Debug("<< settingsApply"); //Util.Debug("<< settingsApply");
}, },
...@@ -696,8 +696,7 @@ var UI; ...@@ -696,8 +696,7 @@ var UI;
// State change disables viewport dragging. // State change disables viewport dragging.
// It is enabled (toggled) by direct click on the button // It is enabled (toggled) by direct click on the button
UI.setViewDrag(false); UI.updateViewDrag(false);
UI.updateViewDragButton();
switch (UI.rfb_state) { switch (UI.rfb_state) {
case 'fatal': case 'fatal':
...@@ -859,6 +858,7 @@ var UI; ...@@ -859,6 +858,7 @@ var UI;
// Turn clipping off // Turn clipping off
UI.updateSetting('clip', false); UI.updateSetting('clip', false);
display.set_viewport(false); display.set_viewport(false);
// Disable max dimensions
display.set_maxWidth(0); display.set_maxWidth(0);
display.set_maxHeight(0); display.set_maxHeight(0);
display.viewportChangeSize(); display.viewportChangeSize();
...@@ -886,43 +886,64 @@ var UI; ...@@ -886,43 +886,64 @@ var UI;
} }
}, },
// Toggle/set/unset the viewport drag/move button // Update the viewport drag/move button
setViewDrag: function(drag) { updateViewDrag: function(drag) {
if (!UI.rfb) return; if (!UI.rfb) return;
if (typeof(drag) === "undefined" ||
typeof(drag) === "object") {
// If not specified, then toggle
drag = !UI.rfb.get_viewportDrag();
}
var vmb = $D('noVNC_view_drag_button'); var vmb = $D('noVNC_view_drag_button');
if (drag) {
vmb.className = "noVNC_status_button_selected";
UI.rfb.set_viewportDrag(true);
} else {
vmb.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false);
}
},
updateViewDragButton: function() { // Check if viewport drag is possible
var vmb = $D('noVNC_view_drag_button');
if (UI.rfb_state === 'normal' && if (UI.rfb_state === 'normal' &&
UI.rfb.get_display().get_viewport() && UI.rfb.get_display().get_viewport() &&
UI.rfb.get_display().clippingDisplay()) { UI.rfb.get_display().clippingDisplay()) {
// Enable the viewport drag button
// Show and enable the drag button
vmb.style.display = "inline"; vmb.style.display = "inline";
vmb.disabled = false; vmb.disabled = false;
} else if (UI.rfb_state === 'normal' && } else {
UI.isTouchDevice) { // The VNC content is the same size as
// Disable the viewport drag button // or smaller than the display
vmb.style.display = "inline";
vmb.disabled = true; if (UI.rfb.get_viewportDrag) {
// Turn off viewport drag when it's
// active since it can't be used here
vmb.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false);
}
// Disable or hide the drag button
if (UI.rfb_state === 'normal' && UI.isTouchDevice) {
vmb.style.display = "inline";
vmb.disabled = true;
} else {
vmb.style.display = "none";
}
return;
}
if (typeof(drag) !== "undefined" &&
typeof(drag) !== "object") {
if (drag) {
vmb.className = "noVNC_status_button_selected";
UI.rfb.set_viewportDrag(true);
} else {
vmb.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false);
}
}
},
toggleViewDrag: function() {
if (!UI.rfb) return;
var vmb = $D('noVNC_view_drag_button');
if (UI.rfb.get_viewportDrag()) {
vmb.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false);
} else { } else {
// Hide the viewport drag button vmb.className = "noVNC_status_button_selected";
vmb.style.display = "none"; UI.rfb.set_viewportDrag(true);
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment