[Libreoffice-commits] core.git: desktop/inc

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sat May 28 20:39:06 UTC 2016


 desktop/inc/lib/init.hxx |   39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

New commits:
commit 692863ac3880c16c127250e5ba590406298b39ab
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 15 14:23:47 2016 -0400

    LOK: improved event handling and fixes
    
    During painting, when notifications are disabled, we could still
    receive notifications that are imporatant and cannot be suppressed.
    So certain events are let through during painting.
    A comment describes this better in the code.
    
    Some widgets (notably postit/comment control) emits events in
    relative (local) coordinates instead of absolute. This is patched
    in many cases but some cases still exist that are rather hard
    to patch due to the complex interaction with other parts of the code.
    These supurious local coordinate updates (notably cursor invalidation)
    are supressed to avoid the bad side-effects they cause in LOOL.
    
    Change-Id: Ie22a316d54ea163c6976ed04314d6ced8247824c
    Reviewed-on: https://gerrit.libreoffice.org/25013
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit b5c2a3fdbbf4161b0699ba515f63f98d7607ddf2)
    Reviewed-on: https://gerrit.libreoffice.org/25424
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index c0a4462..d337eaa 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -80,13 +80,36 @@ namespace desktop {
 
         void queue(const int type, const char* data)
         {
+            const std::string payload(data ? data : "(nil)");
             if (m_bPartTilePainting)
             {
-                // We drop notifications when this is set.
+                // We drop notifications when this is set, except for important ones.
+                // When we issue a complex command (such as .uno:InsertAnnotation)
+                // there will be multiple notifications. On the first invalidation
+                // we will start painting, but other events will get fired
+                // while the complex command in question executes.
+                // We don't want to supress everything here on the wrong assumption
+                // that no new events are fired during painting.
+                if (type != LOK_CALLBACK_STATE_CHANGED &&
+                    type != LOK_CALLBACK_INVALIDATE_TILES)
+                {
+                    //SAL_WARN("lokevt", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "].");
+                    return;
+                }
+            }
+
+            // Supress invalid payloads.
+            if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR &&
+                payload.find(", 0, 0, ") != std::string::npos)
+            {
+                // The cursor position is often the relative coordinates of the widget
+                // issueing it, instead of the absolute one that we expect.
+                // This is temporary however, and, once the control is created and initialized
+                // correctly, it eventually emits the correct absolute coordinates.
+                //SAL_WARN("lokevt", "Skipping invalid event [" + std::to_string(type) + "]: [" + payload + "].");
                 return;
             }
 
-            const std::string payload(data ? data : "(nil)");
             std::unique_lock<std::mutex> lock(m_mutex);
 
             const auto stateIt = m_states.find(type);
@@ -95,19 +118,13 @@ namespace desktop {
                 // If the state didn't change, it's safe to ignore.
                 if (stateIt->second == payload)
                 {
+                    //SAL_WARN("lokevt", "Skipping duplicate [" + std::to_string(type) + "]: [" + payload + "].");
                     return;
                 }
 
                 stateIt->second = payload;
             }
 
-            if (type == LOK_CALLBACK_INVALIDATE_TILES &&
-                !m_queue.empty() && m_queue.back().first == type && m_queue.back().second == payload)
-            {
-                // Supress duplicate invalidation only when they are in sequence.
-                return;
-            }
-
             if (type == LOK_CALLBACK_TEXT_SELECTION && payload.empty())
             {
                 // Removing text selection invalidates the start and end as well.
@@ -186,7 +203,7 @@ namespace desktop {
                 if (m_queue[i].first == type)
                 {
                     payload = m_queue[i].second;
-                    //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "].");
+                    //SAL_WARN("lokevt", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "].");
                     break;
                 }
             }
@@ -196,7 +213,7 @@ namespace desktop {
                 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) + ": " + m_queue[i].second + "].");
+                    //SAL_WARN("lokevt", "Removing [" + std::to_string(type) + "] at " + std::to_string(i) + ": " + m_queue[i].second + "].");
                     m_queue.erase(m_queue.begin() + i);
                 }
             }


More information about the Libreoffice-commits mailing list