diff options
author | Henry Castro <hcastro@collabora.com> | 2020-12-17 11:34:46 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-04-09 11:56:10 +0200 |
commit | 496083206f73b6479f54d91712b47aac92cacb47 (patch) | |
tree | df96064292df8a7c686a3927d8e5bd00ab782618 /vcl/jsdialog | |
parent | f3fbffd75d909a7c69e24107c5cf77adf5c2ba73 (diff) |
jsdialog: use "WindowPaint" event to update
If the idle notifier is disabled instead it uses
the "WindowPaint" when the model has changed to
notify update status to client side.
Anyway the "WindowPaint" is supposed to be
asynchronous.
Change-Id: I0bb99526c72510a97e3906340c1e9269478da8cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107916
Tested-by: Jenkins
Reviewed-by: Henry Castro <hcastro@collabora.com>
Diffstat (limited to 'vcl/jsdialog')
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 7604d06b4c39..aa1febfe5d2a 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -97,6 +97,35 @@ std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::dumpStatus() const return aJsonWriter; } +void JSDialogNotifyIdle::updateStatus(VclPtr<vcl::Window> pWindow) +{ + if (!m_aNotifierWindow) + return; + + if (m_aNotifierWindow->IsReallyVisible()) + { + if (const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier()) + { + tools::JsonWriter aJsonWriter; + + aJsonWriter.put("commandName", ".uno:jsdialog"); + aJsonWriter.put("success", "true"); + { + auto aResult = aJsonWriter.startNode("result"); + aJsonWriter.put("dialog_id", m_aNotifierWindow->GetLOKWindowId()); + aJsonWriter.put("control_id", pWindow->get_id()); + { + auto aEntries = aJsonWriter.startNode("control"); + pWindow->DumpAsPropertyTree(aJsonWriter); + } + } + + pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_UNO_COMMAND_RESULT, + aJsonWriter.extractData()); + } + } +} + std::unique_ptr<tools::JsonWriter> JSDialogNotifyIdle::generateCloseMessage() const { std::unique_ptr<tools::JsonWriter> aJsonWriter(new tools::JsonWriter()); @@ -127,6 +156,11 @@ void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); } void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); } +void JSDialogSender::sendUpdate(VclPtr<vcl::Window> pWindow) +{ + mpIdleNotify->updateStatus(pWindow); +} + namespace { vcl::Window* extract_sal_widget(weld::Widget* pParent) @@ -920,6 +954,8 @@ JSTreeView::JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> : JSWidget<SalInstanceTreeView, ::SvTabListBox>(aNotifierWindow, aContentWindow, pTreeView, pBuilder, bTakeOwnership, sTypeOfJSON) { + if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify()) + pTreeView->AddEventListener(LINK(this, JSTreeView, on_window_event)); } void JSTreeView::set_toggle(int pos, TriState eState, int col) @@ -986,6 +1022,15 @@ void JSTreeView::drag_end() g_DragSource = nullptr; } +IMPL_LINK(JSTreeView, on_window_event, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowPaint && get_visible() && m_xTreeView->IsDirtyModel()) + { + sendUpdate(m_xTreeView); + m_xTreeView->SetDirtyModel(false); + } +} + JSExpander::JSExpander(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::VclExpander* pExpander, SalInstanceBuilder* pBuilder, bool bTakeOwnership, std::string sTypeOfJSON) |