+ viewportChangeSize: function(width, height) {
+
+ if (!this._viewport ||
+ typeof(width) === "undefined" || typeof(height) === "undefined") {
+
+ Util.Debug("Setting viewport to full display region");
+ width = this._fb_width;
+ height = this._fb_height;
+ }
+
+ var vp = this._viewportLoc;
+ if (vp.w !== width || vp.h !== height) {
+
+ var cr = this._cleanRect;
+
+ if (width < vp.w && cr.x2 > vp.x + width - 1) {
+ cr.x2 = vp.x + width - 1;
+ }
+
+ if (height < vp.h && cr.y2 > vp.y + height - 1) {
+ cr.y2 = vp.y + height - 1;
+ }
+
+ if (this.fbuClip()) {
+ // clipping
+ vp.w = window.innerWidth;
+ var cb = document.getElementById('noVNC-control-bar');
+ var controlbar_h = (cb !== null) ? cb.offsetHeight : 0;
+ vp.h = window.innerHeight - controlbar_h - 5;
+ } else {
+ // scrollbars
+ vp.w = width;
+ vp.h = height;
+ }
+
+ var saveImg = null;
+ var canvas = this._target;
+ if (vp.w > 0 && vp.h > 0 && canvas.width > 0 && canvas.height > 0) {
+ var img_width = canvas.width < vp.w ? canvas.width : vp.w;
+ var img_height = canvas.height < vp.h ? canvas.height : vp.h;
+ saveImg = this._drawCtx.getImageData(0, 0, img_width, img_height);
+ }
+
+ canvas.width = vp.w;
+ canvas.height = vp.h;
+
+ if (saveImg) {
+ this._drawCtx.putImageData(saveImg, 0, 0);
+ }
+ }
+ },
+