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:
parent
b0871c124e
commit
bcf3b08447
|
|
@ -1592,13 +1592,16 @@ encHandlers.last_rect = function last_rect() {
|
||||||
};
|
};
|
||||||
|
|
||||||
encHandlers.ext_desktop_size = function () {
|
encHandlers.ext_desktop_size = function () {
|
||||||
//Util.Debug(">> ext_desktop_size");
|
FBU.bytes = 1;
|
||||||
if (ws.rQwait("ext_desktop_size", 4)) { return false; }
|
if (ws.rQwait("ext_desktop_size", FBU.bytes)) { return false; }
|
||||||
|
|
||||||
supportsSetDesktopSize = true;
|
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.rQshift8(); // padding
|
||||||
ws.rQshift16(); // 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_width = FBU.width;
|
||||||
fb_height = FBU.height;
|
fb_height = FBU.height;
|
||||||
conf.onFBResize(that, fb_width, fb_height);
|
conf.onFBResize(that, fb_width, fb_height);
|
||||||
display.resize(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.bytes = 0;
|
||||||
FBU.rects -= 1;
|
FBU.rects -= 1;
|
||||||
|
|
||||||
//Util.Debug("<< ext_desktop_size");
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,15 @@ var resizeTimeout;
|
||||||
|
|
||||||
// Load supporting scripts
|
// Load supporting scripts
|
||||||
window.onscriptsload = function () { UI.load(); };
|
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",
|
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
|
||||||
"input.js", "display.js", "jsunzip.js", "rfb.js"]);
|
"input.js", "display.js", "jsunzip.js", "rfb.js"]);
|
||||||
|
|
@ -34,17 +42,11 @@ load: function (callback) {
|
||||||
WebUtil.initSettings(UI.start, 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) {
|
onresize: function (callback) {
|
||||||
clearTimeout(resizeTimeout);
|
// Control-bar height: 44px +
|
||||||
resizeTimeout = setTimeout(function(){
|
// Status-bar height: 24px +
|
||||||
// Control-bar height: 44px +
|
// border height: 5px = 73px to be deducted from the height
|
||||||
// Status-bar height: 24px +
|
UI.rfb.setDesktopSize(window.innerWidth, window.innerHeight - 73);
|
||||||
// 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
|
// Render default UI and initialize settings menu
|
||||||
|
|
@ -100,7 +102,8 @@ start: function(callback) {
|
||||||
|
|
||||||
UI.rfb = RFB({'target': $D('noVNC_canvas'),
|
UI.rfb = RFB({'target': $D('noVNC_canvas'),
|
||||||
'onUpdateState': UI.updateState,
|
'onUpdateState': UI.updateState,
|
||||||
'onClipboard': UI.clipReceive});
|
'onClipboard': UI.clipReceive,
|
||||||
|
'onFBUComplete': UI.FBUComplete});
|
||||||
UI.updateVisualState();
|
UI.updateVisualState();
|
||||||
|
|
||||||
// Unfocus clipboard when over the VNC area
|
// Unfocus clipboard when over the VNC area
|
||||||
|
|
@ -463,11 +466,6 @@ updateState: function(rfb, state, oldstate, msg) {
|
||||||
klass = "noVNC_status_error";
|
klass = "noVNC_status_error";
|
||||||
break;
|
break;
|
||||||
case 'normal':
|
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";
|
klass = "noVNC_status_normal";
|
||||||
break;
|
break;
|
||||||
case 'disconnected':
|
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) {
|
clipReceive: function(rfb, text) {
|
||||||
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
Util.Debug(">> UI.clipReceive: " + text.substr(0,40) + "...");
|
||||||
$D('noVNC_clipboard_text').value = text;
|
$D('noVNC_clipboard_text').value = text;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue