summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-05-08 12:02:54 -0400
committerAshod Nakashian <ashnakash@gmail.com>2016-05-08 16:15:54 +0000
commit7cdfe080432f69c2247cc7ff28316b653bd654ff (patch)
tree65905ad8df8537c4ac22593f3a7bf6ddffef773b
parentbd55be7ec88b1b8af3eb0b3b98be4f73453f9f89 (diff)
LOK: drop identical invalidation notifications
And drop duplicate GRAPHIC_SELECTION notifications. Change-Id: I0c372efa9a58620e24cea219d82479cdc9dff359 Reviewed-on: https://gerrit.libreoffice.org/24771 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--desktop/inc/lib/init.hxx25
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx7
2 files changed, 19 insertions, 13 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index e581493e22ab..82a01b27b297 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -43,6 +43,7 @@ namespace desktop {
m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_START, "NIL");
m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_END, "NIL");
m_states.emplace(LOK_CALLBACK_TEXT_SELECTION, "NIL");
+ m_states.emplace(LOK_CALLBACK_GRAPHIC_SELECTION, "NIL");
m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "NIL");
m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL");
m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL");
@@ -85,7 +86,6 @@ namespace desktop {
return;
}
-
const std::string payload(data ? data : "(nil)");
std::unique_lock<std::mutex> lock(m_mutex);
@@ -124,13 +124,14 @@ namespace desktop {
case LOK_CALLBACK_TEXT_SELECTION_START:
case LOK_CALLBACK_TEXT_SELECTION_END:
case LOK_CALLBACK_TEXT_SELECTION:
+ case LOK_CALLBACK_GRAPHIC_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);
+ removeAllButLast(type, false);
break;
// These come with rects, so drop earlier
@@ -139,10 +140,15 @@ namespace desktop {
case LOK_CALLBACK_INVALIDATE_TILES:
if (payload.empty())
{
- // Invalidating everything means previous
+ // Invalidating everything means previously
// invalidated tiles can be dropped.
- removeAllButLast(type);
+ removeAllButLast(type, false);
+ }
+ else
+ {
+ removeAllButLast(type, true);
}
+
break;
}
@@ -171,23 +177,26 @@ namespace desktop {
}
}
- void removeAllButLast(const int type)
+ void removeAllButLast(const int type, const bool identical)
{
int i = m_queue.size() - 1;
+ std::string payload;
for (; i >= 0; --i)
{
if (m_queue[i].first == type)
{
- //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i));
+ payload = m_queue[i].second;
+ //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "].");
break;
}
}
for (--i; i >= 0; --i)
{
- if (m_queue[i].first == type)
+ if (m_queue[i].first == type &&
+ (!identical || m_queue[i].second == payload))
{
- //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i));
+ //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i) + ": " + m_queue[i].second + "].");
m_queue.erase(m_queue.begin() + i);
}
}
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 0f8be8fbf6d3..13382acb4d56 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -812,7 +812,7 @@ void DesktopLOKTest::testNotificationCompression()
handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0
handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded.
handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // Should be dropped.
- handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 1
+ handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Superseeded.
handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Should be dropped.
handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // Superseeded.
handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 2
@@ -841,15 +841,12 @@ void DesktopLOKTest::testNotificationCompression()
Scheduler::ProcessEventsToIdle();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), notifs.size());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(13), notifs.size());
size_t i = 0;
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++]));
- CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[i]));
- CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++]));
-
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++]));