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
...@@ -37,24 +37,24 @@ var RFB; ...@@ -37,24 +37,24 @@ var RFB;
// In preference order // In preference order
this._encodings = [ this._encodings = [
['COPYRECT', 0x01 ], ['COPYRECT', 0x01 ],
['TIGHT', 0x07 ], ['TIGHT', 0x07 ],
['TIGHT_PNG', -260 ], ['TIGHT_PNG', -260 ],
['HEXTILE', 0x05 ], ['HEXTILE', 0x05 ],
['RRE', 0x02 ], ['RRE', 0x02 ],
['RAW', 0x00 ], ['RAW', 0x00 ],
['DesktopSize', -223 ], ['DesktopSize', -223 ],
['Cursor', -239 ], ['Cursor', -239 ],
// Psuedo-encoding settings // Psuedo-encoding settings
//['JPEG_quality_lo', -32 ], //['JPEG_quality_lo', -32 ],
['JPEG_quality_med', -26 ], ['JPEG_quality_med', -26 ],
//['JPEG_quality_hi', -23 ], //['JPEG_quality_hi', -23 ],
//['compress_lo', -255 ], //['compress_lo', -255 ],
['compress_hi', -247 ], ['compress_hi', -247 ],
['last_rect', -224 ], ['last_rect', -224 ],
['xvp', -309 ], ['xvp', -309 ],
['ext_desktop_size', -308 ] ['ExtendedDesktopSize', -308 ]
]; ];
this._encHandlers = {}; this._encHandlers = {};
...@@ -1871,15 +1871,27 @@ var RFB; ...@@ -1871,15 +1871,27 @@ var RFB;
return true; 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; 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; this._supportsSetDesktopSize = true;
var number_of_screens = this._sock.rQpeek8(); var number_of_screens = this._sock.rQpeek8();
this._FBU.bytes = 4 + (number_of_screens * 16); 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(1); // number-of-screens
this._sock.rQskipBytes(3); // padding this._sock.rQskipBytes(3); // padding
...@@ -1898,31 +1910,42 @@ var RFB; ...@@ -1898,31 +1910,42 @@ var RFB;
} }
} }
if (this._FBU.x == 0 && this._FBU.y != 0) { return true; } /*
* The x-position indicates the reason for the change:
this._fb_width = this._FBU.width; *
this._fb_height = this._FBU.height; * 0 - server resized on its own
this._display.resize(this._fb_width, this._fb_height); * 1 - this client requested the resize
this._onFBResize(this, this._fb_width, this._fb_height); * 2 - another client requested the resize
*/
this._FBU.bytes = 0; // We need to handle errors when we requested the resize.
this._FBU.rects -= 1; 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; return true;
}, },
DesktopSize: function () { DesktopSize: function () {
Util.Debug(">> set_desktopsize"); this._encHandlers.handle_FB_resize();
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");
return true; return true;
}, },
......
...@@ -1584,7 +1584,7 @@ describe('Remote Frame Buffer Protocol Client', function() { ...@@ -1584,7 +1584,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
}); });
it('should not handle a failed request', 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 var status_code = 1; // Resize is administratively prohibited
send_fbu_msg([{ x: reason_for_change, y: status_code, 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