summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-03-31 15:42:28 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-05-20 11:33:02 +0200
commit26a2c330c5a170d947fd3e33b07d396874a28925 (patch)
tree2f35723ec6a4e41be3fe57d9210b9f9e8710f066 /vcl
parent5749905df4e8421202878824d13862c6e9e07cf9 (diff)
jsdialog: use Idle timer to send updates
Change-Id: Ib4f18bab1279c622b576dca53169b40c4a2526bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94482 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx43
1 files changed, 32 insertions, 11 deletions
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)