[Libreoffice-commits] online.git: loleaflet/src loolwsd/ChildSession.cpp loolwsd/protocol.txt

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Aug 15 03:15:19 UTC 2016


 loleaflet/src/layer/tile/TileLayer.js |   40 ++++++++++++++++++++++++++++++++++
 loolwsd/ChildSession.cpp              |    3 ++
 loolwsd/protocol.txt                  |    7 +++++
 3 files changed, 50 insertions(+)

New commits:
commit fbcce1b8031636456759251f41ed4ef8faabcbf4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Aug 14 11:57:17 2016 -0400

    loleaflet+loolwsd: new commands addview and remview
    
    The new commands help the UI update the cursors and other
    visual elements that track views and clients.
    
    Currently, when remview is received loleaflet removes
    the associated cursor from the screen.
    
    Change-Id: I03e2f9e3485166adae31de84ae7ac6bd1c85b05d
    Reviewed-on: https://gerrit.libreoffice.org/28131
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 62c2f1b..1d6f5d6 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -357,6 +357,12 @@ L.TileLayer = L.GridLayer.extend({
 		else if (textMsg.startsWith('viewcursorvisible:')) {
 			this._onViewCursorVisibleMsg(textMsg);
 		}
+		else if (textMsg.startsWith('addview:')) {
+			this._onAddViewMsg(textMsg);
+		}
+		else if (textMsg.startsWith('remview:')) {
+			this._onRemViewMsg(textMsg);
+		}
 	},
 
 	_onCommandValuesMsg: function (textMsg) {
@@ -562,6 +568,40 @@ L.TileLayer = L.GridLayer.extend({
 		this._onUpdateViewCursor(viewId);
 	},
 
+	_onAddViewMsg: function(textMsg) {
+		textMsg = textMsg.substring('addview:'.length + 1);
+		var viewId = parseInt(textMsg);
+
+		// Ignore if viewid is same as ours
+		if (viewId === this._viewId) {
+			return;
+		}
+
+		//TODO: We can initialize color and other properties here.
+		if (typeof this._viewCursors[viewId] !== 'undefined') {
+			this._viewCursors[viewId] = {};
+		}
+
+		this._onUpdateViewCursor(viewId);
+	},
+
+	_onRemViewMsg: function(textMsg) {
+		textMsg = textMsg.substring('remview:'.length + 1);
+		var viewId = parseInt(textMsg);
+
+		// Ignore if viewid is same as ours
+		if (viewId === this._viewId) {
+			return;
+		}
+
+		// Just remove the view and update (to refresh as needed).
+		if (typeof this._viewCursors[viewId] !== 'undefined') {
+			this._viewCursors[viewId].visible = false;
+			this._onUpdateViewCursor(viewId);
+			delete this._viewCursors[viewId];
+		}
+	},
+
 	_onPartPageRectanglesMsg: function (textMsg) {
 		textMsg = textMsg.substring(19);
 		var pages = textMsg.split(';');
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 3cda3ff..07d57ff 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -60,6 +60,8 @@ void ChildSession::disconnect()
     {
         std::unique_lock<std::recursive_mutex> lock(Mutex);
 
+        sendTextFrame("remview: " + std::to_string(_viewId));
+
         if (_multiView && _loKitDocument)
             _loKitDocument->setView(_viewId);
 
@@ -342,6 +344,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
     if (_multiView)
     {
         _viewId = _loKitDocument->getView();
+        sendTextFrame("addview: " + std::to_string(_viewId));
     }
 
     _docType = LOKitHelper::getDocumentTypeAsString(_loKitDocument->get());
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 9eaceae..02940f5 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -332,6 +332,13 @@ viewlock:
 
     Per-view lock rectangle. JSON payload.
 
+addview: <viewId>
+
+    New view with the given viewId is created.
+
+remview: <viewId>
+
+    The view with the given viewId has been destroyed.
 
 child -> parent
 ===============


More information about the Libreoffice-commits mailing list