diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-15 08:43:23 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-24 01:40:45 +0200 |
commit | 273a25c796fca9afa0dfadac57dc3f336831221c (patch) | |
tree | 3efb1e505e27164bcdb2c164c59a48c814221ffe /include/sfx2 | |
parent | 667c2499d861cfcd26935fc0512cb5aaf602c4c5 (diff) |
change some LOK internal updates to be pull model instead of push
Some LOK messages may get called very often, such as updates about
cursor position. And since only the last one matters, they get
generated every time, which costs some time, and then later except
for one they get all discard again from CallbackFlushHandler queue,
which again costs time.
Change the model to instead only set an 'updated' flag, and
CallbackFlushHandler will request the actual message payload only
before flushing.
This commit changes LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR and
LOK_CALLBACK_INVALIDATE_VIEW_CURSOR to work this way.
Change-Id: I376be63176c0b4b5cb492fbf529c21ed01b35481
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124083
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'include/sfx2')
-rw-r--r-- | include/sfx2/lokcallback.hxx | 11 | ||||
-rw-r--r-- | include/sfx2/lokhelper.hxx | 18 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 5 |
3 files changed, 32 insertions, 2 deletions
diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx index d01e7203205e..6f59402d0cec 100644 --- a/include/sfx2/lokcallback.hxx +++ b/include/sfx2/lokcallback.hxx @@ -11,6 +11,8 @@ #include <sal/types.h> +#include <vector> + namespace tools { class Rectangle; @@ -37,6 +39,15 @@ public: // comphelper::LibreOfficeKit::isPartInInvalidation() is not set virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) = 0; + // A message of the given type should be sent, for performance purpose only a notification + // is given here, details about the message should be queried from SfxViewShell when necessary. + // This is used for messages that are generated often but only the last one is needed. + virtual void libreOfficeKitViewUpdatedCallback(int nType) = 0; + // Like libreOfficeKitViewUpdatedCallback(), but a last message is needed for each nViewId value. + // SfxViewShell:getLOKPayload() will be called on nSourceViewId view. + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, + int nSourceViewId) + = 0; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index cf2c1c9c72bb..4ac50a19cc69 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -110,14 +110,28 @@ public: static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable* pDoc, bool bInvalidateAll = true); /// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed. static void notifyInvalidation(SfxViewShell const* pThisView, tools::Rectangle const *); - /// Emits a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, but tweaks it according to setOptionalFeatures() if needed. - static void notifyVisCursorInvalidation(OutlinerViewShell const* pThisView, const OString& rRectangle, bool bMispelledWord = false, const OString& rHyperlink = ""); /// Notifies all views with the given type and payload. static void notifyAllViews(int nType, const OString& rPayload); /// Notify about the editing context change. static void notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext); + // Notify about the given type needing an update. + static void notifyUpdate(SfxViewShell const* pViewShell, int nType); + // Notify about the given type needing a per-viewid update. + static void notifyUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + /// Same as notifyUpdatePerViewId(), pTargetShell will be notified, relevant viewId in pViewShell, + /// pSourceView->getLOKPayload() will be called to get the data. + static void notifyUpdatePerViewId(SfxViewShell const* pTargetShell, SfxViewShell const* pViewShell, + SfxViewShell const* pSourceShell, int nType); + // Notify other views about the given type needing a per-viewid update. + static void notifyOtherViewsUpdatePerViewId(SfxViewShell const* pViewShell, int nType); + + static OString makePayloadJSON(const SfxViewShell* pThisView, int nViewId, std::string_view rKey, const OString& rPayload); + /// Makes a LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR payload, but tweaks it according to setOptionalFeatures() if needed. + static OString makeVisCursorInvalidation(int nViewId, const OString& rRectangle, + bool bMispelledWord = false, const OString& rHyperlink = ""); + /// Helper for posting async key event static void postKeyEventAsync(const VclPtr<vcl::Window> &xWindow, int nType, int nCharCode, int nKeyCode, int nRepeat = 0); diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 89c9cd6c0c7c..e35c6848c9e1 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -343,6 +343,11 @@ public: virtual void libreOfficeKitViewInvalidateTilesCallback(const tools::Rectangle* pRect, int nPart) const override; // Performs any pending calls to libreOfficeKitViewInvalidateTilesCallback() as necessary. virtual void flushPendingLOKInvalidateTiles(); + virtual void libreOfficeKitViewUpdatedCallback(int nType) const override; + virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId) const override; + // Returns current payload for nType, after libreOfficeKitViewUpdatedCallback() or + // libreOfficeKitViewUpdatedCallbackPerViewId() were called. + virtual OString getLOKPayload(int nType, int nViewId) const; /// Set if we are doing tiled searching. void setTiledSearching(bool bTiledSearching); |