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 | |
parent | jsdialog: use the "WindowShow" event (diff) | |
download | core-496083206f73b6479f54d91712b47aac92cacb47.tar.gz core-496083206f73b6479f54d91712b47aac92cacb47.zip |
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>
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 4 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 45 |
2 files changed, 49 insertions, 0 deletions
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 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) |