loleaflet/src/control/Parts.js | 11 ++++++++--- loleaflet/src/layer/tile/CalcTileLayer.js | 2 +- loleaflet/src/layer/tile/ImpressTileLayer.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 624380089e193870bc8b1fb37fd19800a3377a2a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Apr 16 22:56:26 2017 -0400 loleaflet: don't send setclientpart when the server sets part Client now sends setclientpart only when it wants to change the current part number, but not when it is updating the current part when it receives setpart from the server. When switching parts (either by the keyboard or mouse) LoKit sends a notification of the current part and invalidates tiles. As a reaction to that the client cancels its tiles and requests new tiles for the new part. In addition, it sends setclientpart back with the new part number. This works fine, except when the client switches between parts quickly (as when randomly pressing page-up and page-down quickly in impress), by the time LoKit receives the second request the client would have reacted to switching the first by sending setclientpart for the first. This will result in a resonance back and forth ad infinitum (or when the client goes inactive). The client shouldn't echo back the part number which the LoKit has told it (it should only send it to explicitly set it itself). But the server should be smart enough to remove duplicate setpart notifications from the client queue. This reduces the chances of an ocillation like that to happen. Change-Id: Ia8a1bb25e427ab910129340ce599e3743983463b Reviewed-on: https://gerrit.libreoffice.org/36598 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js index a7e4fd5b..1071db03 100644 --- a/loleaflet/src/control/Parts.js +++ b/loleaflet/src/control/Parts.js @@ -2,7 +2,7 @@ * Document parts switching handler */ L.Map.include({ - setPart: function (part) { + setPart: function (part, external) { var docLayer = this._docLayer; docLayer._prevSelectedPart = docLayer._selectedPart; if (part === 'prev') { @@ -30,7 +30,12 @@ L.Map.include({ parts: docLayer._parts, docType: docLayer._docType }); - this._socket.sendMessage('setclientpart part=' + docLayer._selectedPart); + + // If this wasn't triggered from the server, + // then notify the server of the change. + if (!external) { + this._socket.sendMessage('setclientpart part=' + docLayer._selectedPart); + } docLayer.eachView(docLayer._viewCursors, docLayer._onUpdateViewCursor, docLayer); docLayer.eachView(docLayer._cellViewCursors, docLayer._onUpdateCellViewCursor, docLayer); docLayer.eachView(docLayer._graphicViewMarkers, docLayer._onUpdateGraphicViewSelection, docLayer); @@ -260,7 +265,7 @@ L.Map.include({ }; this._socket.sendMessage('uno .uno:Name ' + JSON.stringify(command)); - this.setPart(this._docLayer, nPos); + this.setPart(this._docLayer); } }, diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js index 9fba31fc..d0e300bf 100644 --- a/loleaflet/src/layer/tile/CalcTileLayer.js +++ b/loleaflet/src/layer/tile/CalcTileLayer.js @@ -334,7 +334,7 @@ L.CalcTileLayer = L.TileLayer.extend({ _onSetPartMsg: function (textMsg) { var part = parseInt(textMsg.match(/\d+/g)[0]); if (part !== this._selectedPart) { - this._map.setPart(part); + this._map.setPart(part, true); this._map.fire('setpart', {selectedPart: this._selectedPart}); // TODO: test it! this._map.fire('updaterowcolumnheaders'); diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js index 09015cbf..09f8707f 100644 --- a/loleaflet/src/layer/tile/ImpressTileLayer.js +++ b/loleaflet/src/layer/tile/ImpressTileLayer.js @@ -343,7 +343,7 @@ L.ImpressTileLayer = L.TileLayer.extend({ _onSetPartMsg: function (textMsg) { var part = parseInt(textMsg.match(/\d+/g)[0]); if (part !== this._selectedPart) { - this._map.setPart(part); + this._map.setPart(part, true); this._map.fire('setpart', {selectedPart: this._selectedPart}); } }, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits