diff --git a/include/rfb.js b/include/rfb.js index 08fdee75..e98aa477 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1592,13 +1592,16 @@ encHandlers.last_rect = function last_rect() { }; encHandlers.ext_desktop_size = function () { - //Util.Debug(">> ext_desktop_size"); - if (ws.rQwait("ext_desktop_size", 4)) { return false; } + FBU.bytes = 1; + if (ws.rQwait("ext_desktop_size", FBU.bytes)) { return false; } supportsSetDesktopSize = true; + var number_of_screens = ws.rQpeek8(); - var number_of_screens = ws.rQshift8(); - + FBU.bytes = 4 + (number_of_screens * 16); + if (ws.rQwait("ext_desktop_size", FBU.bytes)) { return false; } + + ws.rQshift8(); // number-of-screens ws.rQshift8(); // padding ws.rQshift16(); // padding @@ -1616,20 +1619,16 @@ encHandlers.ext_desktop_size = function () { } } - if (FBU.x == 0 && FBU.y != 0) { return false; } + if (FBU.x == 0 && FBU.y != 0) { return true; } fb_width = FBU.width; fb_height = FBU.height; conf.onFBResize(that, fb_width, fb_height); display.resize(fb_width, fb_height); - timing.fbu_rt_start = (new Date()).getTime(); - // Send a new non-incremental request - ws.send(fbUpdateRequests()); FBU.bytes = 0; FBU.rects -= 1; - //Util.Debug("<< ext_desktop_size"); return true; }; diff --git a/include/ui.js b/include/ui.js index 75914c1c..7cf7a542 100644 --- a/include/ui.js +++ b/include/ui.js @@ -15,7 +15,15 @@ var resizeTimeout; // Load supporting scripts window.onscriptsload = function () { UI.load(); }; -window.onresize = function () { UI.onresize(); }; +window.onresize = function () { + // When the window has been resized, wait until the size remains + // the same for 0.5 seconds before sending the request for changing + // the resolution of the session + clearTimeout(resizeTimeout); + resizeTimeout = setTimeout(function(){ + UI.onresize(); + }, 500); +}; Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", "input.js", "display.js", "jsunzip.js", "rfb.js"]); @@ -34,17 +42,11 @@ load: function (callback) { WebUtil.initSettings(UI.start, callback); }, -// When the window has been resized, wait until the size remains -// the same for 0.5 seconds before sending the request for changing -// the resolution of the session onresize: function (callback) { - clearTimeout(resizeTimeout); - resizeTimeout = setTimeout(function(){ - // Control-bar height: 44px + - // Status-bar height: 24px + - // border height: 5px = 73px to be deducted from the height - UI.rfb.setDesktopSize(window.innerWidth, window.innerHeight - 73); - }, 500); + // Control-bar height: 44px + + // Status-bar height: 24px + + // border height: 5px = 73px to be deducted from the height + UI.rfb.setDesktopSize(window.innerWidth, window.innerHeight - 73); }, // Render default UI and initialize settings menu @@ -100,7 +102,8 @@ start: function(callback) { UI.rfb = RFB({'target': $D('noVNC_canvas'), 'onUpdateState': UI.updateState, - 'onClipboard': UI.clipReceive}); + 'onClipboard': UI.clipReceive, + 'onFBUComplete': UI.FBUComplete}); UI.updateVisualState(); // Unfocus clipboard when over the VNC area @@ -463,11 +466,6 @@ updateState: function(rfb, state, oldstate, msg) { klass = "noVNC_status_error"; break; case 'normal': - // When reconnecting to an existing session, - // make sure the resolution is updated to the window size - if (oldstate === 'ServerInitialisation') { - onresize(); - } klass = "noVNC_status_normal"; break; case 'disconnected': @@ -553,6 +551,17 @@ updateVisualState: function() { }, +// 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 +// corresponding size of the current local window when reconnecting to an +// existing session. +FBUComplete: function(rfb, fbu) { + onresize(); + UI.rfb.set_onFBUComplete(function() { }); +}, + + clipReceive: function(rfb, text) { Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "..."); $D('noVNC_clipboard_text').value = text;