loolwsd/DocumentBroker.cpp | 28 ++++++++++++++++++++++++---- loolwsd/MasterProcessSession.cpp | 21 ++++++++++++++++++++- loolwsd/MasterProcessSession.hpp | 8 +++++--- 3 files changed, 49 insertions(+), 8 deletions(-)
New commits: commit 55a85ddb33854ef18f950ba63a656eb5e15b04ed Author: Pranav Kant <pran...@collabora.com> Date: Tue May 10 19:07:42 2016 +0530 bccu#1776: Fake double click after auto-saving ... just so that if we have the cursor before auto-saving, we have it after save too (calc). Change-Id: I3e6b1e41006c8fd9105d370b62ead4f45e50848c diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 9a4db8a..31be2ce 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -54,6 +54,16 @@ std::string getCachePath(const std::string& uri) Poco::DigestEngine::digestToHex(digestEngine.digest()).insert(3, "/").insert(2, "/").insert(1, "/")); } +/// Return mouse commands +std::string getMouseCommand(std::string type, long posX, long posY, int count) +{ + return std::string("mouse type=" + type + + " x=" + std::to_string(posX) + + " y=" + std::to_string(posY) + + " count=" + std::to_string(count) + + " buttons=1 modifier=0"); +} + } Poco::URI DocumentBroker::sanitizeURI(const std::string& uri) @@ -284,13 +294,23 @@ bool DocumentBroker::sendUnoSave() // Invalidate the timestamp to force persisting. _lastFileModifiedTime.fromEpochTime(0); + // Store the cursor position before saving, if visible + long posX = -1; + long posY = -1; + if (sessionIt.second->isCursorVisible()) + { + sessionIt.second->getCursorPos(posX, posY); + } + queue->put("uno .uno:Save"); - // Set calc cell mode back to edit mode - // if we were in edit before save - if (sessionIt.second->isCursorVisible()) + // Restore the cursor position, if visible, by a fake double click + if (posX != -1 && posY != -1) { - queue->put("uno .uno:SetInputMode"); + queue->put(getMouseCommand("buttondown", posX, posY, 1)); + queue->put(getMouseCommand("buttonup", posX, posY, 1)); + queue->put(getMouseCommand("buttondown", posX, posY, 2)); + queue->put(getMouseCommand("buttonup", posX, posY, 2)); } return true; diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index 3d5ee3c..87be145 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -175,9 +175,16 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length) } } } + else if (tokens.count() == 5 && tokens[0] == "invalidatecursor:") + { + peer->setCursorPos(std::stoi(tokens[1]), std::stoi(tokens[2])); + } else if (tokens.count() == 2 && tokens[0] == "cursorvisible:") { - peer->setCursorVisible(tokens[1] == "true"); + if (tokens[1] == "false") + { + peer->setCursorPos(-1, -1); + } } } @@ -654,4 +661,16 @@ bool MasterProcessSession::shutdownPeer(Poco::UInt16 statusCode, const std::stri return peer != nullptr; } +void MasterProcessSession::setCursorPos(long posX, long posY) +{ + _cursorPosX = posX; + _cursorPosY = posY; +} + +void MasterProcessSession::getCursorPos(long& posX, long& posY) +{ + posX = _cursorPosX; + posY = _cursorPosY; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/loolwsd/MasterProcessSession.hpp b/loolwsd/MasterProcessSession.hpp index 2472eb5..d2227e7 100644 --- a/loolwsd/MasterProcessSession.hpp +++ b/loolwsd/MasterProcessSession.hpp @@ -50,8 +50,9 @@ class MasterProcessSession final : public LOOLSession, public std::enable_shared void setEditLock(const bool value); void markEditLock(const bool value) { _bEditLock = value; } bool isEditLocked() const { return _bEditLock; } - void setCursorVisible(const bool value) { _isCursorVisible = value; } - bool isCursorVisible() { return _isCursorVisible; } + void setCursorPos(const long posX, const long posY); + void getCursorPos(long& posX, long& posY); + bool isCursorVisible() { return _cursorPosX != -1 && _cursorPosY != -1; } bool shutdownPeer(Poco::UInt16 statusCode, const std::string& message); @@ -88,7 +89,8 @@ public: int _curPart; int _loadPart; - bool _isCursorVisible; + long _cursorPosX; + long _cursorPosY; /// Kind::ToClient instances store URLs of completed 'save as' documents. MessageQueue _saveAsQueue; std::shared_ptr<DocumentBroker> _docBroker; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits