Commit 798340b9 authored by samhed's avatar samhed

* Change name of ext_desktop_size to the proper ExtendedDesktopSize

* Added better error handling in ExtendedDesktopSize
* Added helper function to share code with DesktopSize
* Update test.rfb.js to only check for error handling if we were the
  ones requesting the resize
parent 3b8ec46f
......@@ -54,7 +54,7 @@ var RFB;
['compress_hi', -247 ],
['last_rect', -224 ],
['xvp', -309 ],
['ext_desktop_size', -308 ]
['ExtendedDesktopSize', -308 ]
];
this._encHandlers = {};
......@@ -1871,15 +1871,27 @@ var RFB;
return true;
},
ext_desktop_size: function () {
handle_FB_resize: function () {
this._fb_width = this._FBU.width;
this._fb_height = this._FBU.height;
this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
this._timing.fbu_rt_start = (new Date()).getTime();
this._FBU.bytes = 0;
this._FBU.rects -= 1;
return true;
},
ExtendedDesktopSize: function () {
this._FBU.bytes = 1;
if (this._sock.rQwait("ext_desktop_size", this._FBU.bytes)) { return false; }
if (this._sock.rQwait("ExtendedDesktopSize", this._FBU.bytes)) { return false; }
this._supportsSetDesktopSize = true;
var number_of_screens = this._sock.rQpeek8();
this._FBU.bytes = 4 + (number_of_screens * 16);
if (this._sock.rQwait("ext_desktop_size", this._FBU.bytes)) { return false; }
if (this._sock.rQwait("ExtendedDesktopSize", this._FBU.bytes)) { return false; }
this._sock.rQskipBytes(1); // number-of-screens
this._sock.rQskipBytes(3); // padding
......@@ -1898,31 +1910,42 @@ var RFB;
}
}
if (this._FBU.x == 0 && this._FBU.y != 0) { return true; }
this._fb_width = this._FBU.width;
this._fb_height = this._FBU.height;
this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
/*
* The x-position indicates the reason for the change:
*
* 0 - server resized on its own
* 1 - this client requested the resize
* 2 - another client requested the resize
*/
this._FBU.bytes = 0;
this._FBU.rects -= 1;
// We need to handle errors when we requested the resize.
if (this._FBU.x == 1 && this._FBU.y != 0) {
var msg = "";
// The y-position indicates the status code from the server
switch (this._FBU.y) {
case 1:
msg = "Resize is administratively prohibited";
break;
case 2:
msg = "Out of resources";
break;
case 3:
msg = "Invalid screen layout";
break;
default:
msg = "Unknown reason";
break;
}
Util.Info("Server did not accept the resize request: " + msg);
return true;
}
this._encHandlers.handle_FB_resize();
return true;
},
DesktopSize: function () {
Util.Debug(">> set_desktopsize");
this._fb_width = this._FBU.width;
this._fb_height = this._FBU.height;
this._display.resize(this._fb_width, this._fb_height);
this._onFBResize(this, this._fb_width, this._fb_height);
this._timing.fbu_rt_start = (new Date()).getTime();
this._FBU.bytes = 0;
this._FBU.rects--;
Util.Debug("<< set_desktopsize");
this._encHandlers.handle_FB_resize();
return true;
},
......
......@@ -1584,7 +1584,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
});
it('should not handle a failed request', function () {
var reason_for_change = 0; // non-incremental
var reason_for_change = 1; // requested by this client
var status_code = 1; // Resize is administratively prohibited
send_fbu_msg([{ x: reason_for_change, y: status_code,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment