[Libreoffice-commits] online.git: 4 commits - loleaflet/src loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/tsqueue.h
Mihai Varga
mihai.varga at collabora.com
Tue Jul 21 01:09:13 PDT 2015
loleaflet/src/layer/tile/TileLayer.js | 34 ++++++++++++++++++++++++----------
loleaflet/src/map/Map.js | 10 ++++++++--
loolwsd/LOOLSession.cpp | 6 ++++--
loolwsd/LOOLWSD.cpp | 2 +-
loolwsd/tsqueue.h | 9 +++++++++
5 files changed, 46 insertions(+), 15 deletions(-)
New commits:
commit 8f48dabf28076fc448ff76ec5da1cdd59990c5b1
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Tue Jul 21 11:08:08 2015 +0300
loolwsd: discard requests that are in the queue already
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 0670876..4bccf72 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -243,7 +243,7 @@ public:
// Also forward the "canceltiles" to the child process, if any
session->handleInput(buffer, n);
}
- else
+ else if (!queue.alreadyInQueue(firstLine))
{
queue.put(firstLine);
}
diff --git a/loolwsd/tsqueue.h b/loolwsd/tsqueue.h
index 9511efb..25c2ac2 100644
--- a/loolwsd/tsqueue.h
+++ b/loolwsd/tsqueue.h
@@ -54,6 +54,15 @@ public:
_queue.end());
}
+ bool alreadyInQueue(std::string cmd) {
+ for (auto it = _queue.cbegin(); it != _queue.cend(); ++it) {
+ if (cmd == *it) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private:
std::mutex _mutex;
std::condition_variable _cv;
commit 47790d9d5dc5b5131a0934080086f94845ef51a9
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Mon Jul 20 20:10:13 2015 +0300
loolwsd: use the new invalidate x y widht height command
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 69dccc7..cddf845 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -682,7 +682,6 @@ extern "C"
{
int curPart = srv->_loKitDocument->pClass->getPart(srv->_loKitDocument);
srv->sendTextFrame("curpart: part=" + std::to_string(curPart));
- srv->sendTextFrame("invalidatetiles: " + std::string(pPayload));
StringTokenizer tokens(std::string(pPayload), " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
if (tokens.count() == 4)
{
@@ -690,13 +689,16 @@ extern "C"
int y(std::stoi(tokens[1]));
int width(std::stoi(tokens[2]));
int height(std::stoi(tokens[3]));
- srv->sendTextFrame("invalidate:"
+ srv->sendTextFrame("invalidatetiles:"
" part=" + std::to_string(curPart) +
" x=" + std::to_string(x) +
" y=" + std::to_string(y) +
" width=" + std::to_string(width) +
" height=" + std::to_string(height));
}
+ else {
+ srv->sendTextFrame("invalidatetiles: " + std::string(pPayload));
+ }
}
break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
commit 596ee77d5a267ebcc39da09d9f603713c5bdbefb
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Mon Jul 20 20:09:37 2015 +0300
loleaflet: use the new invalidate x y widht height command
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index ba76534..b4d8024 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -249,18 +249,26 @@ L.TileLayer = L.GridLayer.extend({
this._onUpdateGraphicSelection();
}
else if (textMsg.startsWith('invalidatetiles:') && !textMsg.match('EMPTY')) {
- strTwips = textMsg.match(/\d+/g);
- topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
- offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
+ command = this._parseServerCmd(textMsg);
+ if (command.x === undefined || command.y === undefined || command.part === undefined) {
+ strTwips = textMsg.match(/\d+/g);
+ command.x = parseInt(strTwips[0]);
+ command.y = parseInt(strTwips[1]);
+ command.width = parseInt(strTwips[2]);
+ command.height = parseInt(strTwips[3]);
+ command.part = this._currentPart;
+ }
+ topLeftTwips = new L.Point(command.x, command.y);
+ offset = new L.Point(command.width, command.height);
bottomRightTwips = topLeftTwips.add(offset);
var invalidBounds = new L.Bounds(topLeftTwips, bottomRightTwips);
for (var key in this._tiles) {
var coords = this._tiles[key].coords;
- var point1 = this._coordsToTwips(coords);
- var point2 = new L.Point(point1.x + this._tileWidthTwips, point1.y + this._tileHeightTwips);
- var bounds = new L.Bounds(point1, point2);
- if (invalidBounds.intersects(bounds)) {
+ var tileTopLeft = this._coordsToTwips(coords);
+ var tileBottomRight = new L.Point(this._tileWidthTwips, this._tileHeightTwips);
+ var bounds = new L.Bounds(tileTopLeft, tileTopLeft.add(tileBottomRight));
+ if (invalidBounds.intersects(bounds) && coords.part === command.part) {
if (this._tiles[key]._invalidCount) {
this._tiles[key]._invalidCount += 1;
}
@@ -271,8 +279,8 @@ L.TileLayer = L.GridLayer.extend({
'part=' + coords.part + ' ' +
'width=' + this._tileSize + ' ' +
'height=' + this._tileSize + ' ' +
- 'tileposx=' + point1.x + ' ' +
- 'tileposy=' + point1.y + ' ' +
+ 'tileposx=' + tileTopLeft.x + ' ' +
+ 'tileposy=' + tileTopLeft.y + ' ' +
'tilewidth=' + this._tileWidthTwips + ' ' +
'tileheight=' + this._tileHeightTwips, key);
}
@@ -281,7 +289,7 @@ L.TileLayer = L.GridLayer.extend({
// compute the rectangle that each tile covers in the document based
// on the zoom level
coords = this._keyToTileCoords(key);
- if (coords.part !== this._currentPart) {
+ if (coords.part !== command.part) {
continue;
}
var scale = this._map.getZoomScale(coords.z);
@@ -476,6 +484,12 @@ L.TileLayer = L.GridLayer.extend({
else if (tokens[i].substring(0, 9) === 'tileposy=') {
command.y = parseInt(tokens[i].substring(9));
}
+ else if (tokens[i].substring(0, 2) === 'x=') {
+ command.x = parseInt(tokens[i].substring(2));
+ }
+ else if (tokens[i].substring(0, 2) === 'y=') {
+ command.y = parseInt(tokens[i].substring(2));
+ }
else if (tokens[i].substring(0, 10) === 'tilewidth=') {
command.tileWidth = parseInt(tokens[i].substring(10));
}
commit 7fe1c2707fc7b6ddba50abf8a71bdf320791b4a9
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Mon Jul 20 12:59:33 2015 +0300
loleaflet: notify when the connection dropped
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3e299f9..d47c8d7 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -443,7 +443,8 @@ L.Map = L.Evented.extend({
vex.dialog.alert('Socket connection error');
return;
}
- this.socket.onerror = L.bind(this._socketError, this);
+ this.socket.onerror = L.bind(this._onSocketError, this);
+ this.socket.onclose = L.bind(this._onSocketClose, this);
this.socket.binaryType = 'arraybuffer';
},
@@ -756,9 +757,14 @@ L.Map = L.Evented.extend({
return Math.max(min, Math.min(max, zoom));
},
- _socketError: function (e) {
+ _onSocketError: function (e) {
console.log(e);
vex.dialog.alert('Socket connection error');
+ },
+
+ _onSocketClose: function (e) {
+ console.log(e);
+ vex.dialog.alert('Socket connection closed');
}
});
More information about the Libreoffice-commits
mailing list