Additional fixes for the code in my previous commits:

* Implemented correct use of the FBU.bytes variable.
 * Removed the non-incremental update from ext_desktop_size to prevent the
   server from sending extra ExtendedDesktopSize rectangles.
 * The code is now using the 'onFBUComplete' callback from rfb to resize
   the session on reconnect instead of a timer.
This commit is contained in:
Samuel Mannehed 2013-07-02 15:08:36 +02:00
parent b0871c124e
commit bcf3b08447
2 changed files with 34 additions and 26 deletions

View File

@ -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;
};

View File

@ -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;