[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sfx2/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 25 12:38:31 UTC 2019


 sfx2/source/sidebar/SidebarDockingWindow.cxx |   45 +++++++++++++++++++--------
 1 file changed, 33 insertions(+), 12 deletions(-)

New commits:
commit e8a2d9f3ff86f53d6ace6f81a324c0c28dca50f3
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Nov 24 09:56:02 2019 -0500
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Mon Nov 25 13:37:46 2019 +0100

    sidebar: do not emit unnecessary created notifications
    
    This also breaks a potentially recursive cycle where
    each 'created' notification requests a re-rendering,
    which triggers view change (when more than one view
    is open on the doc), which triggers a frame change,
    which resets the sidebar, causing a 'created'
    notification, thereby starting the cycle anew.
    
    Change-Id: I1aafe7f45871748afb393fa55c357037215e6c33
    Reviewed-on: https://gerrit.libreoffice.org/83629
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index b40f47eb4bad..0b7ee183f5c1 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -39,19 +39,23 @@ namespace sfx2 { namespace sidebar {
 
 class SidebarNotifyIdle : public Idle
 {
-    SidebarDockingWindow &mrSidebarDockingWin;
+    SidebarDockingWindow& m_rSidebarDockingWin;
+    std::string m_LastNotificationMessage;
+    vcl::LOKWindowId m_LastLOKWindowId;
 
 public:
     SidebarNotifyIdle(SidebarDockingWindow &rSidebarDockingWin) :
         Idle("Sidebar notify"),
-        mrSidebarDockingWin(rSidebarDockingWin)
+        m_rSidebarDockingWin(rSidebarDockingWin),
+        m_LastNotificationMessage(),
+        m_LastLOKWindowId(0)
     {
         SetPriority(TaskPriority::POST_PAINT);
     }
 
     void Invoke() override
     {
-        auto pNotifier = mrSidebarDockingWin.GetLOKNotifier();
+        auto pNotifier = m_rSidebarDockingWin.GetLOKNotifier();
         if (!pNotifier || !comphelper::LibreOfficeKit::isActive())
             return;
 
@@ -61,19 +65,36 @@ public:
             {
                 // Mobile.
                 std::stringstream aStream;
-                boost::property_tree::write_json(aStream, mrSidebarDockingWin.DumpAsPropertyTree());
-                pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aStream.str().c_str());
+                boost::property_tree::write_json(aStream, m_rSidebarDockingWin.DumpAsPropertyTree());
+                const std::string message = aStream.str();
+                if (message != m_LastNotificationMessage)
+                {
+                    m_LastNotificationMessage = message;
+                    pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+                }
             }
             else
             {
                 // On desktop use the classic notifications.
-                std::vector<vcl::LOKPayloadItem> aItems;
-                aItems.emplace_back("type", "deck");
-                const Point pos = Point(mrSidebarDockingWin.GetOutOffXPixel(),
-                                        mrSidebarDockingWin.GetOutOffYPixel());
-                aItems.emplace_back("position", pos.toString());
-                aItems.emplace_back("size", mrSidebarDockingWin.GetSizePixel().toString());
-                pNotifier->notifyWindow(mrSidebarDockingWin.GetLOKWindowId(), "created", aItems);
+                const Point pos = Point(m_rSidebarDockingWin.GetOutOffXPixel(),
+                                        m_rSidebarDockingWin.GetOutOffYPixel());
+                const OString posMessage = pos.toString();
+                const OString sizeMessage = m_rSidebarDockingWin.GetSizePixel().toString();
+
+                const std::string message = OString(posMessage + sizeMessage).getStr();
+                const vcl::LOKWindowId lokWindowId = m_rSidebarDockingWin.GetLOKWindowId();
+
+                if (lokWindowId != m_LastLOKWindowId || message != m_LastNotificationMessage)
+                {
+                    m_LastLOKWindowId = lokWindowId;
+                    m_LastNotificationMessage = message;
+
+                    std::vector<vcl::LOKPayloadItem> aItems;
+                    aItems.emplace_back("type", "deck");
+                    aItems.emplace_back("position", posMessage);
+                    aItems.emplace_back("size", sizeMessage);
+                    pNotifier->notifyWindow(lokWindowId, "created", aItems);
+                }
             }
         }
         catch (boost::property_tree::json_parser::json_parser_error& rError)


More information about the Libreoffice-commits mailing list