diff options
author | samhed <samuel@cendio.se> | 2015-02-06 17:06:48 +0100 |
---|---|---|
committer | samhed <samuel@cendio.se> | 2015-02-06 17:06:48 +0100 |
commit | b0ec6509f11469569c438e5f5e4300e6a1ce4dad (patch) | |
tree | d0e2d4714e67820cacd8e3d3bb9257459cb0c2a0 | |
parent | 636be753b2c2769e06ec27665fbeb652a060481a (diff) | |
download | novnc-b0ec6509f11469569c438e5f5e4300e6a1ce4dad.tar.gz |
Support automatic resize [Part 2/4]: rfb.js
* Support sending the setDesktopSize encoding (client -> server)
* Support recieving the ExtendedDesktopSize encoding (server <- client)
-rw-r--r-- | include/rfb.js | 79 |
1 files changed, 75 insertions, 4 deletions
diff --git a/include/rfb.js b/include/rfb.js index 559eccb..03d4b81 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -53,7 +53,8 @@ var RFB; //['compress_lo', -255 ], ['compress_hi', -247 ], ['last_rect', -224 ], - ['xvp', -309 ] + ['xvp', -309 ], + ['ext_desktop_size', -308 ] ]; this._encHandlers = {}; @@ -106,6 +107,10 @@ var RFB; pixels: 0 }; + this._supportsSetDesktopSize = false; + this._screen_id = 0; + this._screen_flags = 0; + // Mouse state this._mouse_buttonMask = 0; this._mouse_arr = []; @@ -305,6 +310,32 @@ var RFB; this._sock.send(RFB.messages.clientCutText(text)); }, + setDesktopSize: function (width, height) { + if (this._rfb_state !== "normal") { return; } + + if (this._supportsSetDesktopSize) { + + var arr = [251]; // msg-type + arr.push8(0); // padding + arr.push16(width); // width + arr.push16(height); // height + + arr.push8(1); // number-of-screens + arr.push8(0); // padding + + // screen array + arr.push32(this._screen_id); // id + arr.push16(0); // x-position + arr.push16(0); // y-position + arr.push16(width); // width + arr.push16(height); // height + arr.push32(this._screen_flags); // flags + + this._sock.send(arr); + } + }, + + // Private methods _connect: function () { @@ -585,7 +616,7 @@ var RFB; var deltaY = this._viewportDragPos.y - y; this._viewportDragPos = {'x': x, 'y': y}; - this._display.viewportChange(deltaX, deltaY); + this._display.viewportChangePos(deltaX, deltaY); // Skip sending mouse events return; @@ -944,8 +975,8 @@ var RFB; } this._display.set_true_color(this._true_color); - this._onFBResize(this, this._fb_width, this._fb_height); this._display.resize(this._fb_width, this._fb_height); + this._onFBResize(this, this._fb_width, this._fb_height); this._keyboard.grab(); this._mouse.grab(); @@ -1839,12 +1870,52 @@ var RFB; return true; }, + ext_desktop_size: function () { + this._FBU.bytes = 1; + if (this._sock.rQwait("ext_desktop_size", 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; } + + this._sock.rQskipBytes(1); // number-of-screens + this._sock.rQskipBytes(3); // padding + + for (var i=0; i<number_of_screens; i += 1) { + // Save the id and flags of the first screen + if (i == 0) { + this._screen_id = this._sock.rQshiftBytes(4); // id + this._sock.rQskipBytes(2); // x-position + this._sock.rQskipBytes(2); // y-position + this._sock.rQskipBytes(2); // width + this._sock.rQskipBytes(2); // height + this._screen_flags = this._sock.rQshiftBytes(4); // flags + } else { + this._sock.rQskipBytes(16); + } + } + + 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); + + this._FBU.bytes = 0; + this._FBU.rects -= 1; + + return true; + }, + DesktopSize: function () { Util.Debug(">> set_desktopsize"); this._fb_width = this._FBU.width; this._fb_height = this._FBU.height; - this._onFBResize(this, this._fb_width, this._fb_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; |