summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel <samuel@cendio.se>2016-06-02 22:37:52 +0200
committerSamuel <samuel@cendio.se>2016-06-02 22:37:52 +0200
commitae11605141f345d38bf1e5fcf8fb85c42c771145 (patch)
tree70b865bef8a65391c853bd9140127eb4cde3dfab
parentf52105bc88ebd18d5cb3fba817173e99600cdc3f (diff)
downloadnovnc-ae11605141f345d38bf1e5fcf8fb85c42c771145.tar.gz
Split the setDesktopSize function (#618)
In order to follow the surrounding coding-standards, the setDesktopSize client message is split from the public function which now is called requestDesktopSize().
-rw-r--r--include/rfb.js58
-rw-r--r--include/ui.js4
-rw-r--r--tests/test.rfb.js8
-rw-r--r--vnc_auto.html2
4 files changed, 46 insertions, 26 deletions
diff --git a/include/rfb.js b/include/rfb.js
index 48fa5a8..7340fad 100644
--- a/include/rfb.js
+++ b/include/rfb.js
@@ -311,28 +311,13 @@ var RFB;
this._sock.flush();
},
- setDesktopSize: function (width, height) {
+ requestDesktopSize: 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);
+ RFB.messages.setDesktopSize(this._sock, width, height,
+ this._screen_id, this._screen_flags);
+ this._sock.flush();
}
},
@@ -1340,6 +1325,41 @@ var RFB;
sock._sQlen += 8 + n;
},
+ setDesktopSize: function (sock, width, height, id, flags) {
+ var buff = sock._sQ;
+ var offset = sock._sQlen;
+
+ buff[offset] = 251; // msg-type
+ buff[offset + 1] = 0; // padding
+ buff[offset + 2] = width >> 8; // width
+ buff[offset + 3] = width;
+ buff[offset + 4] = height >> 8; // height
+ buff[offset + 5] = height;
+
+ buff[offset + 6] = 1; // number-of-screens
+ buff[offset + 7] = 0; // padding
+
+ // screen array
+ buff[offset + 8] = id >> 24; // id
+ buff[offset + 9] = id >> 16;
+ buff[offset + 10] = id >> 8;
+ buff[offset + 11] = id;
+ buff[offset + 12] = 0; // x-position
+ buff[offset + 13] = 0;
+ buff[offset + 14] = 0; // y-position
+ buff[offset + 15] = 0;
+ buff[offset + 16] = width >> 8; // width
+ buff[offset + 17] = width;
+ buff[offset + 18] = height >> 8; // height
+ buff[offset + 19] = height;
+ buff[offset + 20] = flags >> 24; // flags
+ buff[offset + 21] = flags >> 16;
+ buff[offset + 22] = flags >> 8;
+ buff[offset + 23] = flags;
+
+ sock._sQlen += 24;
+ },
+
pixelFormat: function (sock, bpp, depth, true_color) {
var buff = sock._sQ;
var offset = sock._sQlen;
diff --git a/include/ui.js b/include/ui.js
index cfdedb3..95bc135 100644
--- a/include/ui.js
+++ b/include/ui.js
@@ -263,9 +263,9 @@ var UI;
UI.resizeTimeout = setTimeout(function(){
display.set_maxWidth(size.w);
display.set_maxHeight(size.h);
- Util.Debug('Attempting setDesktopSize(' +
+ Util.Debug('Attempting requestDesktopSize(' +
size.w + ', ' + size.h + ')');
- UI.rfb.setDesktopSize(size.w, size.h);
+ UI.rfb.requestDesktopSize(size.w, size.h);
}, 500);
} else if (scaleType === 'scale' || scaleType === 'downscale') {
// use local scaling
diff --git a/tests/test.rfb.js b/tests/test.rfb.js
index 1b73986..a0f2fa7 100644
--- a/tests/test.rfb.js
+++ b/tests/test.rfb.js
@@ -219,7 +219,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
});
});
- describe("#setDesktopSize", function () {
+ describe("#requestDesktopSize", function () {
beforeEach(function() {
client._sock = new Websock();
client._sock.open('ws://', 'binary');
@@ -244,19 +244,19 @@ describe('Remote Frame Buffer Protocol Client', function() {
expected.push16(2); // height
expected.push32(0); // flags
- client.setDesktopSize(1, 2);
+ client.requestDesktopSize(1, 2);
expect(client._sock).to.have.sent(new Uint8Array(expected));
});
it('should not send the request if the client has not recieved a ExtendedDesktopSize rectangle', function () {
client._supportsSetDesktopSize = false;
- client.setDesktopSize(1,2);
+ client.requestDesktopSize(1,2);
expect(client._sock.flush).to.not.have.been.called;
});
it('should not send the request if we are not in a normal state', function () {
client._rfb_state = "broken";
- client.setDesktopSize(1,2);
+ client.requestDesktopSize(1,2);
expect(client._sock.flush).to.not.have.been.called;
});
});
diff --git a/vnc_auto.html b/vnc_auto.html
index 7317471..bbf94d7 100644
--- a/vnc_auto.html
+++ b/vnc_auto.html
@@ -92,7 +92,7 @@
var controlbarH = $D('noVNC_status_bar').offsetHeight;
var padding = 5;
if (innerW !== undefined && innerH !== undefined)
- rfb.setDesktopSize(innerW, innerH - controlbarH - padding);
+ rfb.requestDesktopSize(innerW, innerH - controlbarH - padding);
}
}
function FBUComplete(rfb, fbu) {