Index: webaccess/noVNC/include/rfb.js =================================================================== --- webaccess/noVNC/include/rfb.js (revision 27526) +++ webaccess/noVNC/include/rfb.js (working copy) @@ -63,7 +63,8 @@ //['JPEG_quality_hi', -23 ], //['compress_lo', -255 ], ['compress_hi', -247 ], - ['last_rect', -224 ] + ['last_rect', -224 ], + ['ext_desktop_size', -308 ] ], encHandlers = {}, @@ -120,6 +121,10 @@ test_mode = false, + supportsSetDesktopSize = false, + screen_id = 0, + screen_flags = 0, + def_con_timeout = Websock_native ? 2 : 5, /* Mouse state */ @@ -1589,6 +1594,45 @@ return true; }; +encHandlers.ext_desktop_size = function () { + //Util.Debug(">> ext_desktop_size"); + if (ws.rQwait("ext_desktop_size", 4)) { return false; } + + var number_of_screens = ws.rQshift8(); + + ws.rQshift8(); // padding + ws.rQshift16(); // padding + + for (var i=0; i> set_desktopsize"); fb_width = FBU.width; @@ -1851,6 +1895,31 @@ //Util.Debug("<< clipboardPasteFrom"); }; +that.setDesktopSize = function(width, height) { + if (rfb_state !== "normal") { return; } + + if (supportsSetDesktopSize) { + + var arr = [251]; // msg-type + arr.push8(0); // padding + arr.push16(width); // width + arr.push16(height); // height + + arr.push8(1); // number-of-screens + arr.push8(0); // padding + + // screen array + arr.push32(screen_id); // id + arr.push16(0); // x-position + arr.push16(0); // y-position + arr.push16(width); // width + arr.push16(height); // height + arr.push32(screen_flags); // flags + + ws.send(arr); + } +}; + // Override internal functions for testing that.testMode = function(override_send, data_mode) { test_mode = true; Index: webaccess/noVNC/include/ui.js =================================================================== --- webaccess/noVNC/include/ui.js (revision 27526) +++ webaccess/noVNC/include/ui.js (working copy) @@ -10,8 +10,12 @@ /*jslint white: false, browser: true */ /*global window, $D, Util, WebUtil, RFB, Display */ +var resizeTimeout; + // Load supporting scripts window.onscriptsload = function () { UI.load(); }; +window.onresize = function () { UI.onresize(); }; + Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js", "input.js", "display.js", "jsunzip.js", "rfb.js"]); @@ -29,6 +33,19 @@ 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); +}, + // Render default UI and initialize settings menu start: function(callback) { var html = '', i, sheet, sheets, llevels, port; @@ -447,6 +464,11 @@ 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':