[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/inc desktop/qa

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun May 8 16:16:18 UTC 2016


 desktop/inc/lib/init.hxx                    |   25 +++++++++++++++++--------
 desktop/qa/desktop_lib/test_desktop_lib.cxx |    7 ++-----
 2 files changed, 19 insertions(+), 13 deletions(-)

New commits:
commit 7cdfe080432f69c2247cc7ff28316b653bd654ff
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 8 12:02:54 2016 -0400

    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 at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index e581493..82a01b2 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 0f8be8f..13382ac 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++]));
 


More information about the Libreoffice-commits mailing list