Hide the view_drag_button (the hand) when the display area is the same or smaller than the remote session size.

This commit is contained in:
samhed 2015-01-22 14:09:29 +01:00
parent dd54a45436
commit 1f57d1e731
3 changed files with 27 additions and 15 deletions

View File

@ -136,12 +136,10 @@ var Display;
cr.y2 = vp.y + this._fb_height - 1; cr.y2 = vp.y + this._fb_height - 1;
} }
if (this._viewport) { if (this.fbuClip()) {
// clipping // clipping
vp.w = Math.min(this._fb_width, window.innerWidth); vp.w = window.innerWidth;
var control_bar_h = $D('noVNC-control-bar').scrollHeight; vp.h = window.innerHeight - $D('noVNC-control-bar').scrollHeight - 5;
var max_vp_h = window.innerHeight - control_bar_h - 5;
vp.h = Math.min(this._fb_height, max_vp_h);
} else { } else {
// scrollbars // scrollbars
vp.w = this._fb_width; vp.w = this._fb_width;
@ -477,6 +475,13 @@ var Display;
this._target.style.cursor = "none"; this._target.style.cursor = "none";
}, },
fbuClip: function () {
var control_bar_h = $D('noVNC-control-bar').scrollHeight;
var max_vp_h = window.innerHeight - control_bar_h - 5;
return (this._viewport &&
(this._fb_width > window.innerWidth || this._fb_height > max_vp_h));
},
// Overridden getters/setters // Overridden getters/setters
get_context: function () { get_context: function () {
return this._drawCtx; return this._drawCtx;

View File

@ -971,8 +971,8 @@ var RFB;
} }
this._display.set_true_color(this._true_color); this._display.set_true_color(this._true_color);
this._onFBResize(this, this._fb_width, this._fb_height);
this._display.resize(this._fb_width, this._fb_height); this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
this._keyboard.grab(); this._keyboard.grab();
this._mouse.grab(); this._mouse.grab();
@ -1898,8 +1898,8 @@ var RFB;
this._fb_width = this._FBU.width; this._fb_width = this._FBU.width;
this._fb_height = this._FBU.height; this._fb_height = this._FBU.height;
this._onFBResize(this, this._fb_width, this._fb_height);
this._display.resize(this._fb_width, this._fb_height); this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
this._FBU.bytes = 0; this._FBU.bytes = 0;
this._FBU.rects -= 1; this._FBU.rects -= 1;
@ -1911,8 +1911,8 @@ var RFB;
Util.Debug(">> set_desktopsize"); Util.Debug(">> set_desktopsize");
this._fb_width = this._FBU.width; this._fb_width = this._FBU.width;
this._fb_height = this._FBU.height; this._fb_height = this._FBU.height;
this._onFBResize(this, this._fb_width, this._fb_height);
this._display.resize(this._fb_width, this._fb_height); this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
this._timing.fbu_rt_start = (new Date()).getTime(); this._timing.fbu_rt_start = (new Date()).getTime();
this._FBU.bytes = 0; this._FBU.bytes = 0;

View File

@ -122,6 +122,7 @@ var UI;
'onXvpInit': UI.updateXvpVisualState, 'onXvpInit': UI.updateXvpVisualState,
'onClipboard': UI.clipReceive, 'onClipboard': UI.clipReceive,
'onFBUComplete': UI.FBUComplete, 'onFBUComplete': UI.FBUComplete,
'onFBResize': UI.updateViewDragButton,
'onDesktopName': UI.updateDocumentTitle}); 'onDesktopName': UI.updateDocumentTitle});
var autoconnect = WebUtil.getQueryVar('autoconnect', false); var autoconnect = WebUtil.getQueryVar('autoconnect', false);
@ -789,21 +790,16 @@ var UI;
// 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.updateViewDragButton();
UI.rfb.get_display().get_viewport()) {
vmb.style.display = "inline";
} else {
vmb.style.display = "none";
}
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);
@ -813,6 +809,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');