diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-04-30 14:29:37 -0400 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-05-09 13:58:29 +0200 |
commit | bc990b011a928ab55b42361415c6eeb5cb9d172c (patch) | |
tree | f8e1cb980630e9696a3abf951944b84f0655722f /desktop/inc/lib | |
parent | fda7a716a782f95f89d8b2b980e0b67058d7fec8 (diff) |
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 <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit cf98799fff7ae999bd62cec6486c986bf44000cc)
Diffstat (limited to 'desktop/inc/lib')
-rw-r--r-- | desktop/inc/lib/init.hxx | 51 |
1 files changed, 51 insertions, 0 deletions
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<std::pair<int, std::string>> m_queue; std::map<int, std::string> m_states; |