diff options
author | samhed <samuel@cendio.se> | 2015-03-05 14:56:47 +0100 |
---|---|---|
committer | samhed <samuel@cendio.se> | 2015-03-05 14:56:47 +0100 |
commit | 798340b98d097afd7e7cd949d9256dcf2a74eef4 (patch) | |
tree | 2bee62c61dc9fe44a86b2ea699e6eb03873d3cd3 | |
parent | 3b8ec46fd26d644e6edbea4f46e630929297e448 (diff) | |
download | novnc-798340b98d097afd7e7cd949d9256dcf2a74eef4.tar.gz |
* 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
-rw-r--r-- | include/rfb.js | 99 | ||||
-rw-r--r-- | tests/test.rfb.js | 2 |
2 files changed, 62 insertions, 39 deletions
diff --git a/include/rfb.js b/include/rfb.js index 909112d..6fcdab6 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -37,24 +37,24 @@ var RFB; // In preference order this._encodings = [ - ['COPYRECT', 0x01 ], - ['TIGHT', 0x07 ], - ['TIGHT_PNG', -260 ], - ['HEXTILE', 0x05 ], - ['RRE', 0x02 ], - ['RAW', 0x00 ], - ['DesktopSize', -223 ], - ['Cursor', -239 ], + ['COPYRECT', 0x01 ], + ['TIGHT', 0x07 ], + ['TIGHT_PNG', -260 ], + ['HEXTILE', 0x05 ], + ['RRE', 0x02 ], + ['RAW', 0x00 ], + ['DesktopSize', -223 ], + ['Cursor', -239 ], // Psuedo-encoding settings - //['JPEG_quality_lo', -32 ], - ['JPEG_quality_med', -26 ], - //['JPEG_quality_hi', -23 ], - //['compress_lo', -255 ], - ['compress_hi', -247 ], - ['last_rect', -224 ], - ['xvp', -309 ], - ['ext_desktop_size', -308 ] + //['JPEG_quality_lo', -32 ], + ['JPEG_quality_med', -26 ], + //['JPEG_quality_hi', -23 ], + //['compress_lo', -255 ], + ['compress_hi', -247 ], + ['last_rect', -224 ], + ['xvp', -309 ], + ['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; }, diff --git a/tests/test.rfb.js b/tests/test.rfb.js index 444e42c..006b5fa 100644 --- a/tests/test.rfb.js +++ b/tests/test.rfb.js @@ -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, |