]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Split the setDesktopSize function (#618)
authorSamuel <samuel@cendio.se>
Thu, 2 Jun 2016 20:37:52 +0000 (22:37 +0200)
committerSamuel <samuel@cendio.se>
Thu, 2 Jun 2016 20:37:52 +0000 (22:37 +0200)
In order to follow the surrounding coding-standards, the
setDesktopSize client message is split from the public function which
now is called requestDesktopSize().

include/rfb.js
include/ui.js
tests/test.rfb.js
vnc_auto.html

index 48fa5a8c5450e4330fc8c4eeb7b873ab9cbe3485..7340fad2f43a0d7f81de8ac7e309dd79b4455b5e 100644 (file)
@@ -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;
index cfdedb3ae7e439a05e6b7573b65392f39cb23b08..95bc1356685c1b54441e7db2ede1cc774382818e 100644 (file)
@@ -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
index 1b73986f24e841c6769dd0fd8fbd23d0aaaf156b..a0f2fa705ae86781ce120afdcf866cf4d77de71d 100644 (file)
@@ -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;
             });
         });
index 73174713dda2d8a4a895ce81b0fdb2efd6e3bf66..bbf94d7b4c2247664019c54c1da744e903b069da 100644 (file)
@@ -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) {