diff --git a/include/display.js b/include/display.js index 13e402a0..d20f9ba0 100644 --- a/include/display.js +++ b/include/display.js @@ -136,12 +136,10 @@ var Display; cr.y2 = vp.y + this._fb_height - 1; } - if (this._viewport) { + if (this.fbuClip()) { // clipping - vp.w = Math.min(this._fb_width, window.innerWidth); - var control_bar_h = $D('noVNC-control-bar').scrollHeight; - var max_vp_h = window.innerHeight - control_bar_h - 5; - vp.h = Math.min(this._fb_height, max_vp_h); + vp.w = window.innerWidth; + vp.h = window.innerHeight - $D('noVNC-control-bar').scrollHeight - 5; } else { // scrollbars vp.w = this._fb_width; @@ -477,6 +475,13 @@ var Display; 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 get_context: function () { return this._drawCtx; diff --git a/include/rfb.js b/include/rfb.js index ab028021..76587c02 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -971,8 +971,8 @@ var RFB; } 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._onFBResize(this, this._fb_width, this._fb_height); this._keyboard.grab(); this._mouse.grab(); @@ -1898,8 +1898,8 @@ var RFB; this._fb_width = this._FBU.width; 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._onFBResize(this, this._fb_width, this._fb_height); this._FBU.bytes = 0; this._FBU.rects -= 1; @@ -1911,8 +1911,8 @@ var RFB; Util.Debug(">> set_desktopsize"); this._fb_width = this._FBU.width; 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._onFBResize(this, this._fb_width, this._fb_height); this._timing.fbu_rt_start = (new Date()).getTime(); this._FBU.bytes = 0; diff --git a/include/ui.js b/include/ui.js index d172055c..32e4e3c0 100644 --- a/include/ui.js +++ b/include/ui.js @@ -122,6 +122,7 @@ var UI; 'onXvpInit': UI.updateXvpVisualState, 'onClipboard': UI.clipReceive, 'onFBUComplete': UI.FBUComplete, + 'onFBResize': UI.updateViewDragButton, 'onDesktopName': UI.updateDocumentTitle}); var autoconnect = WebUtil.getQueryVar('autoconnect', false); @@ -789,21 +790,16 @@ var UI; // Toggle/set/unset the viewport drag/move button setViewDrag: function(drag) { - var vmb = $D('noVNC_view_drag_button'); if (!UI.rfb) { return; } - if (UI.rfb_state === 'normal' && - UI.rfb.get_display().get_viewport()) { - vmb.style.display = "inline"; - } else { - vmb.style.display = "none"; - } + UI.updateViewDragButton(); if (typeof(drag) === "undefined" || typeof(drag) === "object") { // If not specified, then toggle drag = !UI.rfb.get_viewportDrag(); } + var vmb = $D('noVNC_view_drag_button'); if (drag) { vmb.className = "noVNC_status_button_selected"; 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 showKeyboard: function() { var kbi = $D('keyboardinput');