[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/vcl vcl/jsdialog
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Wed May 20 09:33:34 UTC 2020
include/vcl/jsdialog/jsdialogbuilder.hxx | 17 ++++++++++--
vcl/jsdialog/jsdialogbuilder.cxx | 43 +++++++++++++++++++++++--------
2 files changed, 46 insertions(+), 14 deletions(-)
New commits:
commit 26a2c330c5a170d947fd3e33b07d396874a28925
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Mar 31 15:42:28 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed May 20 11:33:02 2020 +0200
jsdialog: use Idle timer to send updates
Change-Id: Ib4f18bab1279c622b576dca53169b40c4a2526bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94482
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx
index 32b279dea66d..be00372827c5 100644
--- a/include/vcl/jsdialog/jsdialogbuilder.hxx
+++ b/include/vcl/jsdialog/jsdialogbuilder.hxx
@@ -13,13 +13,24 @@
typedef std::map<OString, weld::Widget*> WidgetMap;
-class JSDialogSender
+class JSDialogNotifyIdle : public Idle
{
- VclPtr<vcl::Window> m_aOwnedToplevel;
+ VclPtr<vcl::Window> m_aWindow;
+ std::string m_LastNotificationMessage;
+
+public:
+ JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow);
+
+ void Invoke() override;
+};
+
+class VCL_DLLPUBLIC JSDialogSender
+{
+ std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify;
public:
JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel)
- : m_aOwnedToplevel(aOwnedToplevel)
+ : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel))
{
}
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 9246bda13b86..f247965e5e3d 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -7,23 +7,44 @@
using namespace weld;
-void JSDialogSender::notifyDialogState()
+JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow)
+ : Idle("JSDialog notify")
+ , m_aWindow(aWindow)
+ , m_LastNotificationMessage()
{
- if (!m_aOwnedToplevel)
- return;
+ SetPriority(TaskPriority::POST_PAINT);
+}
- const vcl::ILibreOfficeKitNotifier* pNotifier = m_aOwnedToplevel->GetLOKNotifier();
- if (pNotifier)
+void JSDialogNotifyIdle::Invoke()
+{
+ try
{
- std::stringstream aStream;
- boost::property_tree::ptree aTree = m_aOwnedToplevel->DumpAsPropertyTree();
- aTree.put("id", m_aOwnedToplevel->GetLOKWindowId());
- boost::property_tree::write_json(aStream, aTree);
- const std::string message = aStream.str();
- pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+ if (!m_aWindow)
+ return;
+
+ const vcl::ILibreOfficeKitNotifier* pNotifier = m_aWindow->GetLOKNotifier();
+ if (pNotifier)
+ {
+ std::stringstream aStream;
+ boost::property_tree::ptree aTree = m_aWindow->DumpAsPropertyTree();
+ aTree.put("id", m_aWindow->GetLOKWindowId());
+ boost::property_tree::write_json(aStream, aTree);
+ const std::string message = aStream.str();
+ if (message != m_LastNotificationMessage)
+ {
+ m_LastNotificationMessage = message;
+ pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+ }
+ }
+ }
+ catch (boost::property_tree::json_parser::json_parser_error& rError)
+ {
+ SAL_WARN("vcl.jsdialog", rError.message());
}
}
+void JSDialogSender::notifyDialogState() { mpIdleNotify->Start(); }
+
JSInstanceBuilder::JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot,
const OUString& rUIFile)
: SalInstanceBuilder(dynamic_cast<SalInstanceWidget*>(pParent)
More information about the Libreoffice-commits
mailing list