[Libreoffice-commits] online.git: loolwsd/MessageQueue.cpp loolwsd/MessageQueue.hpp
Jan Holesovsky
kendy at collabora.com
Mon Sep 26 02:49:08 UTC 2016
loolwsd/MessageQueue.cpp | 7 +++----
loolwsd/MessageQueue.hpp | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
New commits:
commit 4e7ba53a2b0c91c35d93f11e114a9e56dc467555
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Sep 23 10:37:33 2016 +0200
Prioritize the views where the cursor moved the most recently.
Even the order of the views matters when the editing is happening.
Change-Id: Id0868a8198f9fa955512fccba57fa063eab46e8c
Reviewed-on: https://gerrit.libreoffice.org/29284
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index 2f46e10..01f06ac 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -175,12 +175,11 @@ bool TileQueue::priority(const std::string& tileMsg)
auto tile = TileDesc::parse(tileMsg); //FIXME: Expensive, avoid.
- for (auto& pair : _cursorPositions)
+ for (int view : _viewOrder)
{
- if (tile.intersectsWithRect(pair.second.X, pair.second.Y, pair.second.Width, pair.second.Height))
- {
+ auto& cursor = _cursorPositions[view];
+ if (tile.intersectsWithRect(cursor.X, cursor.Y, cursor.Width, cursor.Height))
return true;
- }
}
return false;
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index 89d314e..11bad5f 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -10,6 +10,7 @@
#ifndef INCLUDED_MESSAGEQUEUE_HPP
#define INCLUDED_MESSAGEQUEUE_HPP
+#include <algorithm>
#include <condition_variable>
#include <deque>
#include <map>
@@ -112,10 +113,24 @@ public:
{
_cursorPositions[viewId] = cursorPosition;
}
+
+ auto view = std::find(_viewOrder.begin(), _viewOrder.end(), viewId);
+ if (view != _viewOrder.end())
+ {
+ std::swap(_viewOrder.front(), *view);
+ }
+ else
+ {
+ _viewOrder.push_front(viewId);
+ }
}
void removeCursorPosition(int viewId)
{
+ auto it = std::find(_viewOrder.begin(), _viewOrder.end(), viewId);
+ if (it != _viewOrder.end())
+ _viewOrder.erase(it);
+
_cursorPositions.erase(viewId);
}
@@ -131,6 +146,10 @@ private:
private:
std::map<int, CursorPosition> _cursorPositions;
+
+ /// Check the views in the order of how the editing (cursor movement) has
+ /// been happening.
+ std::deque<int> _viewOrder;
};
#endif
More information about the Libreoffice-commits
mailing list