summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-05-08 12:02:54 -0400
committerJan Holesovsky <kendy@collabora.com>2016-05-09 13:58:30 +0200
commit81d866a78d33dfc483b004b0cfc783a3d9005592 (patch)
treeaa8880532423f74f37eeffbdcd6ca3f0c392a456 /desktop
parente394a8eab65c65e5ce377950ccaad8964ca6bdc3 (diff)
LOK: drop identical invalidation notifications
And drop duplicate GRAPHIC_SELECTION notifications. (cherry picked from commit 7cdfe080432f69c2247cc7ff28316b653bd654ff) Change-Id: I0c372efa9a58620e24cea219d82479cdc9dff359 Reviewed-on: https://gerrit.libreoffice.org/24771 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'desktop')
-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 933b9e669a2d..c0a4462543e0 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 f20835db5472..905325d35751 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1279,7 +1279,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
@@ -1308,15 +1308,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++]));