diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-04-23 14:06:22 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2016-05-09 02:40:38 +0000 |
commit | 3d27afd26f7b85c46a7c7d08498000b9dbcea1c8 (patch) | |
tree | 6d0db56701fe588ea7eec64ac3db3bf835219a56 /desktop | |
parent | 0ab7ad3bb0138c2614f66dba8af39cabe760f910 (diff) |
Desktop compresses text selection start/end notifications
Change-Id: Ia85ded04d0eaf9d9b846fab6d86a44a758fccb69
Reviewed-on: https://gerrit.libreoffice.org/24320
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit 45037438d84485356a5ceb820ecc3e0bae4b112e)
Reviewed-on: https://gerrit.libreoffice.org/24380
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/lib/init.hxx | 9 | ||||
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 28 |
2 files changed, 36 insertions, 1 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index df065d767dca..7cf81e33b629 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -39,6 +39,8 @@ namespace desktop { // Add the states that are safe to skip duplicates on, // even when not consequent. + 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_INVALIDATE_VISIBLE_CURSOR, "NIL"); m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL"); @@ -94,6 +96,13 @@ namespace desktop { return; } + if (type == LOK_CALLBACK_TEXT_SELECTION && payload.empty()) + { + // Removing text selection invalidates the start and end as well. + m_states[LOK_CALLBACK_TEXT_SELECTION_START] = ""; + m_states[LOK_CALLBACK_TEXT_SELECTION_END] = ""; + } + m_queue.emplace_back(type, payload); lock.unlock(); diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f6e3d91632e4..86ca392c8626 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1289,10 +1289,18 @@ void DesktopLOKTest::testNotificationCompression() handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 8 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Should be dropped. handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // Should be dropped. + handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 9 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 10 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // 11 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // Should be dropped. + handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // Should be dropped. + handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 12 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 13 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 14 Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(9), notifs.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(15), notifs.size()); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[0])); CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[0])); @@ -1320,6 +1328,24 @@ void DesktopLOKTest::testNotificationCompression() CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[8])); CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[8])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[9])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[9])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[10])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[10])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[11])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[11])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[12])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[12])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[13])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[13])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[14])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[14])); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); |