kit/ChildSession.cpp | 50 ++++++++++++++++++++++++++++++++------------------ kit/ChildSession.hpp | 12 ++++++++++++ 2 files changed, 44 insertions(+), 18 deletions(-)
New commits: commit c36e619d24d9a5b063db648e65daf2e43aae3df8 Author: Jan Holesovsky <ke...@collabora.com> Date: Mon Apr 24 19:19:18 2017 +0200 inactive: Invalidate tiles when we return back to the active state. Change-Id: Ib97d6463c52ecf153d3c19ab7efc47d99b71ce9b diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 373d451f..8b01a517 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -117,15 +117,24 @@ bool ChildSession::_handleInput(const char *buffer, int length) sendTextFrame("setpart: part=" + std::to_string(curPart)); } + // Invalidate if we have to + // TODO instead just a "_invalidate" flag, we should remember / grow + // the rectangle to invalidate; invalidating everything is sub-optimal + if (_stateRecorder._invalidate) + { + std::string payload = "0, 0, " + std::to_string(INT_MAX) + ", " + std::to_string(INT_MAX) + ", " + std::to_string(curPart); + loKitCallback(LOK_CALLBACK_INVALIDATE_TILES, payload); + } + for (const auto& viewPair : _stateRecorder._recordedViewEvents) { - for (const auto& eventPair : viewPair.second) - { - const RecordedEvent& event = eventPair.second; - LOG_TRC("Replaying missed view event: " << viewPair.first << " " << LOKitHelper::kitCallbackTypeToString(event._type) - << ": " << event._payload); - loKitCallback(event._type, event._payload); - } + for (const auto& eventPair : viewPair.second) + { + const RecordedEvent& event = eventPair.second; + LOG_TRC("Replaying missed view event: " << viewPair.first << " " << LOKitHelper::kitCallbackTypeToString(event._type) + << ": " << event._payload); + loKitCallback(event._type, event._payload); + } } for (const auto& eventPair : _stateRecorder._recordedEvents) @@ -971,16 +980,21 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const std::ve */ void ChildSession::rememberEventsForInactiveUser(const int type, const std::string& payload) { - if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || - type == LOK_CALLBACK_CURSOR_VISIBLE || - type == LOK_CALLBACK_TEXT_SELECTION || - type == LOK_CALLBACK_TEXT_SELECTION_START || - type == LOK_CALLBACK_TEXT_SELECTION_END || - type == LOK_CALLBACK_CELL_FORMULA || - type == LOK_CALLBACK_CELL_CURSOR || - type == LOK_CALLBACK_GRAPHIC_SELECTION || - type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED || - type == LOK_CALLBACK_INVALIDATE_HEADER) + if (type == LOK_CALLBACK_INVALIDATE_TILES) + { + auto lock(getLock()); + _stateRecorder.recordInvalidate(); // TODO remember the area, not just a bool ('true' invalidates everything) + } + else if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || + type == LOK_CALLBACK_CURSOR_VISIBLE || + type == LOK_CALLBACK_TEXT_SELECTION || + type == LOK_CALLBACK_TEXT_SELECTION_START || + type == LOK_CALLBACK_TEXT_SELECTION_END || + type == LOK_CALLBACK_CELL_FORMULA || + type == LOK_CALLBACK_CELL_CURSOR || + type == LOK_CALLBACK_GRAPHIC_SELECTION || + type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED || + type == LOK_CALLBACK_INVALIDATE_HEADER) { auto lock(getLock()); _stateRecorder.recordEvent(type, payload); diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index ce47ed4c..c0279488 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -66,13 +66,23 @@ struct RecordedEvent std::string _payload; }; +/// When the session is inactive, we need to record its state for a replay. class StateRecorder { public: + bool _invalidate; std::unordered_map<std::string, std::string> _recordedStates; std::unordered_map<int, std::unordered_map<int, RecordedEvent>> _recordedViewEvents; std::unordered_map<int, RecordedEvent> _recordedEvents; + StateRecorder() : _invalidate(false) {} + + // TODO Remember the maximal area we need to invalidate - grow it step by step. + void recordInvalidate() + { + _invalidate = true; + } + void recordEvent(const int type, const std::string& payload) { _recordedEvents[type] = {type, payload}; @@ -90,8 +100,10 @@ public: void clear() { + _invalidate = false; _recordedEvents.clear(); _recordedViewEvents.clear(); + _recordedStates.clear(); } }; commit e78c862c4799804e0627cb98d99d021a636fab80 Author: Jan Holesovsky <ke...@collabora.com> Date: Mon Apr 24 18:37:03 2017 +0200 inactive: Replay the state payload, not the only the value. We need to replay 'client-0054 statechanged: .uno:StateWordCount=5 words, 30 characters', not 'client-0054 statechanged: 5 words, 30 characters'. Change-Id: Ifd1fc7d6d567bcf209dffdd826400f5a5248aa7e diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 97a384a7..373d451f 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -1006,7 +1006,7 @@ void ChildSession::rememberEventsForInactiveUser(const int type, const std::stri if (LOOLProtocol::parseNameValuePair(payload, name, value, '=')) { auto lock(getLock()); - _stateRecorder.recordState(name, value); + _stateRecorder.recordState(name, payload); } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits