loolwsd/ChildProcessSession.cpp | 47 ++++++++++++++++++++++++++++++++++++---- loolwsd/ChildProcessSession.hpp | 5 ++++ 2 files changed, 48 insertions(+), 4 deletions(-)
New commits: commit 3a4c02b71d4666e83bba141954fcfaa288b4b59b Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Apr 22 00:28:52 2016 -0400 loolwsd: track important notifications not sent to inactive clients These notifications are important to be sent once the user becomes active again to sync their view with the latest. Change-Id: Id8f9fff83eea888cdcc8d6ed1d4f12111de39a6e Reviewed-on: https://gerrit.libreoffice.org/24288 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp index a5529d7..ec9448a 100644 --- a/loolwsd/ChildProcessSession.cpp +++ b/loolwsd/ChildProcessSession.cpp @@ -90,8 +90,22 @@ public: } else if (!_session.isActive()) { - Log::trace("Skipping callback on inactive session " + _session.getName()); - return; + // Pass save notifications through. + if (nType != LOK_CALLBACK_UNO_COMMAND_RESULT || rPayload.find(".uno:Save") == std::string::npos) + { + Log::trace("Skipping callback on inactive session " + _session.getName()); + _session.setMissedUpdates(); + if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || + nType == LOK_CALLBACK_TEXT_SELECTION || + nType == LOK_CALLBACK_TEXT_SELECTION_START || + nType == LOK_CALLBACK_TEXT_SELECTION_END || + nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED) + { + _session.setMissedNotif(nType, rPayload); + } + + return; + } } switch (nType) @@ -269,6 +283,7 @@ ChildProcessSession::ChildProcessSession(const std::string& id, _jailId(jailId), _viewId(0), _clientPart(0), + _missedUpdates(false), _onLoad(onLoad), _onUnload(onUnload), _callbackWorker(new CallbackWorker(_callbackQueue, *this)) @@ -307,8 +322,9 @@ void ChildProcessSession::disconnect() bool ChildProcessSession::_handleInput(const char *buffer, int length) { - if (!isActive() && _loKitDocument != nullptr) + if (_missedUpdates && _loKitDocument != nullptr) { + _missedUpdates = false; Log::debug("Handling message after inactivity of " + std::to_string(getInactivityMS()) + "ms."); // Client is getting active again. @@ -331,7 +347,30 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length) " width=" + std::to_string(INT_MAX) + " height=" + std::to_string(INT_MAX)); - //TODO: Sync cursor. + for (const auto& pair : _missedNotif) + { + switch (pair.first) + { + case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: + sendTextFrame("invalidatecursor: " + pair.second); + break; + case LOK_CALLBACK_TEXT_SELECTION: + sendTextFrame("textselection: " + pair.second); + break; + case LOK_CALLBACK_TEXT_SELECTION_START: + sendTextFrame("textselectionstart: " + pair.second); + break; + case LOK_CALLBACK_TEXT_SELECTION_END: + sendTextFrame("textselectionend: " + pair.second); + break; + case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED: + getStatus("", 0); + getPartPageRectangles("", 0); + break; + } + } + + _missedNotif.clear(); } const std::string firstLine = getFirstLine(buffer, length); diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp index b7e0af6..6e4a233 100644 --- a/loolwsd/ChildProcessSession.hpp +++ b/loolwsd/ChildProcessSession.hpp @@ -60,6 +60,9 @@ public: std::unique_lock<std::recursive_mutex> getLock() { return std::unique_lock<std::recursive_mutex>(Mutex); } + void setMissedUpdates() { _missedUpdates = true; } + void setMissedNotif(const int type, const std::string& payload) { _missedNotif.emplace(type, payload); } + protected: virtual bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens) override; @@ -98,6 +101,8 @@ private: /// View ID, returned by createView() or 0 by default. int _viewId; int _clientPart; + bool _missedUpdates; + std::map<int, std::string> _missedNotif; std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, bool)> _onLoad; std::function<void(const std::string&)> _onUnload; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits