]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Change clippingDisplay() to a property
authorPierre Ossman <ossman@cendio.se>
Fri, 20 Oct 2017 11:03:50 +0000 (13:03 +0200)
committerPierre Ossman <ossman@cendio.se>
Thu, 9 Nov 2017 12:13:41 +0000 (13:13 +0100)
It fits much better as a property given that it only tells what the
current state of things are.

app/ui.js
core/display.js
core/rfb.js
docs/API-internal.md
docs/API.md
tests/test.display.js

index 626b5f465e7e7287baf3feaf02a4b0294bd3d6a8..20a8912d488a66dcd9508ea38b4001cdeeca55eb 100644 (file)
--- a/app/ui.js
+++ b/app/ui.js
@@ -1377,8 +1377,7 @@ var UI = {
 
         // Check if viewport drag is possible. It is only possible
         // if the remote display is clipping the client display.
-        if (UI.rfb.viewport &&
-            UI.rfb.clippingDisplay()) {
+        if (UI.rfb.viewport && UI.rfb.isClipped) {
             clipping = true;
         }
 
index 07d4ef5b79574fe45113d7234e57a3c65cd8fa99..13d47773fc80c228ac3dba198487a7c337aa0ead 100644 (file)
@@ -106,6 +106,11 @@ Display.prototype = {
         return this._fb_height;
     },
 
+    get isClipped() {
+        var vp = this._viewportLoc;
+        return this._fb_width > vp.w || this._fb_height > vp.h;
+    },
+
     logo: null,
 
     // ===== EVENT HANDLERS =====
@@ -512,11 +517,6 @@ Display.prototype = {
         this._target.style.cursor = "none";
     },
 
-    clippingDisplay: function () {
-        var vp = this._viewportLoc;
-        return this._fb_width > vp.w || this._fb_height > vp.h;
-    },
-
     autoscale: function (containerWidth, containerHeight, downscaleOnly) {
         var vp = this._viewportLoc;
         var targetAspectRatio = containerWidth / containerHeight;
index 2767e53c1ec8bd2bfe6e8c87b70069c4909fb341..3ab3bcad7f633b395ce37286e425e7887912ec9f 100644 (file)
@@ -268,6 +268,8 @@ RFB.prototype = {
     get viewport() { return this._display.viewport; },
     set viewport(viewport) { this._display.viewport = viewport; },
 
+    get isClipped() { return this._display.isClipped; },
+
     // ===== EVENT HANDLERS =====
 
     onupdatestate: function () {},  // onupdatestate(rfb, state, oldstate): connection state change
@@ -380,11 +382,6 @@ RFB.prototype = {
         this._display.viewportChangeSize(width, height);
     },
 
-    clippingDisplay: function () {
-        if (this._rfb_connection_state !== 'connected') { return false; }
-        return this._display.clippingDisplay();
-    },
-
     // Requests a change of remote desktop size. This message is an extension
     // and may only be sent if we have received an ExtendedDesktopSize message
     requestDesktopSize: function (width, height) {
index 6a45d38f939d7cf4a86b59cd0e7ba7a2babbdf20..21741dc74caf1570221d504d72b258dccee60c3e 100644 (file)
@@ -89,6 +89,7 @@ None
 | viewport    | bool  | RW   | false   | Use viewport clipping
 | width       | int   | RO   |         | Display area width
 | height      | int   | RO   |         | Display area height
+| isClipped   | bool  | RO   |         | Is the remote display is larger than the client display
 
 ### 2.3.2 Methods
 
@@ -116,7 +117,6 @@ None
 | changeCursor       | (pixels, mask, hotx, hoty, w, h)                        | Change cursor appearance
 | defaultCursor      | ()                                                      | Restore default cursor appearance
 | disableLocalCursor | ()                                                      | Disable local (client-side) cursor
-| clippingDisplay    | ()                                                      | Check if the remote display is larger than the client display
 | autoscale          | (containerWidth, containerHeight, downscaleOnly)        | Scale the display
 
 ### 2.3.3 Callbacks
index ad16990ad700fdc17f82c6fb53126d55db772a51..6c948a53b83fbc308635af8a84531d74c55829bd 100644 (file)
@@ -46,6 +46,10 @@ protocol stream.
     relative position of a clipped canvas. Only relevant if `viewport`
     is enabled. Disabled by default.
 
+`isClipped` *Read only*
+  - Is a `boolean` indicating if the framebuffer is larger than the
+    current canvas, i.e. it is being clipped.
+
 `disconnectTimeout`
   - Is a `long` indicating how many seconds to wait for a disconnect
     request to complete. Is set to `3` by default.
@@ -128,10 +132,6 @@ protocol stream.
 [`RFB.autoscale()`](#rfbautoscale)
   - Set `RFB.scale` so that the framebuffer fits a specified container.
 
-[`RFB.clippingDisplay()`](#rfbclippingDisplay)
-  - Returns `true` if the framebuffer is larger than what is currently
-    displayed on the canvas.
-
 [`RFB.requestDesktopSize()`](#rfbrequestDesktopSize)
   - Send a request to change the remote desktop size.
 
@@ -426,21 +426,6 @@ The `RFB.autoscale()` method is used to automatically adjust
 **`downscaleOnly`**
   - A `boolean` specifying if the scale must be kept below `1.0`.
 
-#### RFB.clippingDisplay()
-
-The `RFB.clippingDisplay()` method is used to determine if the
-framebuffer is larger than the current canvas, i.e. it is being
-clipped.
-
-##### Syntax
-
-    RFB.clippingDisplay( );
-
-###### Return value
-
-Returns a `boolean` indicating if the framebuffer is currently being
-clipped.
-
 #### RFB.requestDesktopSize()
 
 The `RFB.requestDesktopSize()` method is used to request a change of
index 675b43d7a5a72e72692ddb1187c2c98a1a8ab291..33ff8f1238cf761da8c31074604ffc6a54bd267d 100644 (file)
@@ -92,14 +92,12 @@ describe('Display/Canvas Helper', function () {
         });
 
         it('should report clipping when framebuffer > viewport', function () {
-            var clipping = display.clippingDisplay();
-            expect(clipping).to.be.true;
+            expect(display.isClipped).to.be.true;
         });
 
         it('should report not clipping when framebuffer = viewport', function () {
             display.viewportChangeSize(5, 5);
-            var clipping = display.clippingDisplay();
-            expect(clipping).to.be.false;
+            expect(display.isClipped).to.be.false;
         });
 
         it('should show the entire framebuffer when disabling the viewport', function() {