bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 8 +++++- kit/Kit.cpp | 24 ++++++++++++++++--- loleaflet/src/layer/tile/TileLayer.js | 11 +++++--- test/httpwstest.cpp | 8 +++++- 4 files changed, 42 insertions(+), 9 deletions(-)
New commits: commit ef63d9480c4eadb0eda8d60e2a67f7025f963f05 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Sun Apr 8 00:00:53 2018 +0200 Writer: View jumps to cursor position even if it is moved by an other view. Need to get the viewid which moved our visible cursor, so we can check whether it positioned changed by the owner of the cursor or not. Change-Id: Ie7b1fafc8d8f11fba0c0b0d5f02d755e15284514 Reviewed-on: https://gerrit.libreoffice.org/52571 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> (cherry picked from commit ffd7151443ee360c7764aaa77f9e7fe5f5d64eee) Reviewed-on: https://gerrit.libreoffice.org/52703 diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h index d1ac3b3d4..bec5d0d7e 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -84,7 +84,13 @@ typedef enum /** * Enable range based header data */ - LOK_FEATURE_RANGE_HEADERS = (1ULL << 4) + LOK_FEATURE_RANGE_HEADERS = (1ULL << 4), + + /** + * Request to have the active view's Id as the 1st value in the + * LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload. + */ + LOK_FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK = (1ULL << 5) } LibreOfficeKitOptionalFeatures; diff --git a/kit/Kit.cpp b/kit/Kit.cpp index e99ba4782..779deb151 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -1125,8 +1125,7 @@ public: // when we examine the content of the JSON std::string targetViewId; - if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || - type == LOK_CALLBACK_CELL_CURSOR) + if (type == LOK_CALLBACK_CELL_CURSOR) { Poco::StringTokenizer tokens(payload, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); // Payload may be 'EMPTY'. @@ -1140,6 +1139,24 @@ public: tileQueue->updateCursorPosition(0, 0, cursorX, cursorY, cursorWidth, cursorHeight); } } + else if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR) + { + Poco::JSON::Parser parser; + const Poco::Dynamic::Var result = parser.parse(payload); + const auto& command = result.extract<Poco::JSON::Object::Ptr>(); + std::string rectangle = command->get("rectangle").toString(); + Poco::StringTokenizer tokens(rectangle, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + // Payload may be 'EMPTY'. + if (tokens.count() == 4) + { + int cursorX = std::stoi(tokens[0]); + int cursorY = std::stoi(tokens[1]); + int cursorWidth = std::stoi(tokens[2]); + int cursorHeight = std::stoi(tokens[3]); + + tileQueue->updateCursorPosition(0, 0, cursorX, cursorY, cursorWidth, cursorHeight); + } + } else if (type == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR || type == LOK_CALLBACK_CELL_VIEW_CURSOR) { @@ -1486,7 +1503,8 @@ private: | LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY | LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK | LOK_FEATURE_NO_TILED_ANNOTATIONS - | LOK_FEATURE_RANGE_HEADERS; + | LOK_FEATURE_RANGE_HEADERS + | LOK_FEATURE_VIEWID_IN_VISCURSOR_INVALIDATION_CALLBACK; _loKit->setOptionalFeatures(flags); // Save the provided password with us and the jailed url diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 28444a7a0..c5c8bf413 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -749,7 +749,10 @@ L.TileLayer = L.GridLayer.extend({ _onInvalidateCursorMsg: function (textMsg) { var docLayer = this._map._docLayer; - var strTwips = textMsg.match(/\d+/g); + textMsg = textMsg.substring('invalidatecursor:'.length + 1); + var obj = JSON.parse(textMsg); + var modifierViewId = parseInt(obj.viewId); + var strTwips = obj.rectangle.match(/\d+/g); var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1])); var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3])); var bottomRightTwips = topLeftTwips.add(offset); @@ -762,7 +765,7 @@ L.TileLayer = L.GridLayer.extend({ this._map.fire('setFollowOff'); } this._map.lastActionByUser = false; - this._onUpdateCursor(); + this._onUpdateCursor(this._viewId === modifierViewId); }, _updateEditor: function(textMsg) { @@ -1451,11 +1454,11 @@ L.TileLayer = L.GridLayer.extend({ }, // Update cursor layer (blinking cursor). - _onUpdateCursor: function (e) { + _onUpdateCursor: function (scroll) { var cursorPos = this._visibleCursor.getNorthWest(); var docLayer = this._map._docLayer; - if (!e && !this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible) { + if ((scroll !== false) && !this._map.getBounds().contains(this._visibleCursor) && this._isCursorVisible) { var center = this._map.project(cursorPos); center = center.subtract(this._map.getSize().divideBy(2)); center.x = Math.round(center.x < 0 ? 0 : center.x); diff --git a/test/httpwstest.cpp b/test/httpwstest.cpp index dee2e160d..ef1c8876a 100644 --- a/test/httpwstest.cpp +++ b/test/httpwstest.cpp @@ -2508,7 +2508,13 @@ void HTTPWSTest::testCursorPosition() // receive cursor position response = getResponseString(socket0, "invalidatecursor:", testname); - Poco::StringTokenizer cursorTokens(response.substr(17), ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + + Poco::JSON::Parser parser0; + const Poco::Dynamic::Var result0 = parser0.parse(response.substr(17)); + const auto& command0 = result0.extract<Poco::JSON::Object::Ptr>(); + CPPUNIT_ASSERT_MESSAGE("missing property rectangle", command0->has("rectangle")); + + Poco::StringTokenizer cursorTokens(command0->get("rectangle").toString(), ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), cursorTokens.count()); // Create second view _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits