vcl/inc/jsdialog/jsdialogbuilder.hxx | 4 +++ vcl/jsdialog/jsdialogbuilder.cxx | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+)
New commits: commit 32bfa0e1c7e859aedc3988d5bfdf86f5d7bab98a Author: Henry Castro <hcas...@collabora.com> AuthorDate: Thu Dec 17 11:34:46 2020 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Mon Dec 28 13:21:02 2020 +0100 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 <hcas...@collabora.com> diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index 1f5ad5563f9d..cf7b17dca2d1 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -50,6 +50,7 @@ public: void ForceUpdate(); void sendClose(); VclPtr<vcl::Window> getNotifierWindow() { return m_aNotifierWindow; } + void updateStatus(VclPtr<vcl::Window> pWindow); private: void send(tools::JsonWriter& aJsonWriter); @@ -71,6 +72,7 @@ public: void notifyDialogState(bool bForce = false); void sendClose(); void dumpStatus(); + void sendUpdate(VclPtr<vcl::Window> pWindow); }; class JSDropTarget final @@ -363,6 +365,8 @@ public: class JSTreeView : public JSWidget<SalInstanceTreeView, ::SvTabListBox> { + DECL_LINK(on_window_event, VclWindowEvent&, void); + public: JSTreeView(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow, ::SvTabListBox* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership, diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 1b7d8428c880..160ef1b512bc 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits