From bc990b011a928ab55b42361415c6eeb5cb9d172c Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sat, 30 Apr 2016 14:29:37 -0400 Subject: Some LOK notifications are dropped if they are superseeded by later ones Change-Id: I323e46a2a6c60b200b182b89199945f99a7f384a Reviewed-on: https://gerrit.libreoffice.org/24567 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian (cherry picked from commit cf98799fff7ae999bd62cec6486c986bf44000cc) --- desktop/inc/lib/init.hxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'desktop/inc') diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 66811e40a51c..315f566b0568 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -109,6 +109,35 @@ namespace desktop { m_queue.emplace_back(type, payload); + // These are safe to use the latest state and ignore previous + // ones (if any) since the last overrides previous ones. + switch (type) + { + case LOK_CALLBACK_TEXT_SELECTION_START: + case LOK_CALLBACK_TEXT_SELECTION_END: + case LOK_CALLBACK_TEXT_SELECTION: + case LOK_CALLBACK_MOUSE_POINTER: + case LOK_CALLBACK_CELL_CURSOR: + case LOK_CALLBACK_CELL_FORMULA: + case LOK_CALLBACK_CURSOR_VISIBLE: + case LOK_CALLBACK_SET_PART: + case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: + removeAllButLast(type); + break; + + // These come with rects, so drop earlier + // only when the latter includes former ones. + case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: + case LOK_CALLBACK_INVALIDATE_TILES: + if (payload.empty()) + { + // Invalidating everything means previous + // invalidated tiles can be dropped. + removeAllButLast(type); + } + break; + } + lock.unlock(); if (!IsActive()) { @@ -131,6 +160,28 @@ namespace desktop { } } + void removeAllButLast(const int type) + { + int i = m_queue.size() - 1; + for (; i >= 0; --i) + { + if (m_queue[i].first == type) + { + SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i)); + break; + } + } + + for (--i; i >= 0; --i) + { + if (m_queue[i].first == type) + { + SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i)); + m_queue.erase(m_queue.begin() + i); + } + } + } + private: std::vector> m_queue; std::map m_states; -- cgit