vcl/inc/jsdialog/jsdialogbuilder.hxx |    6 ++++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 95f3f93d07f9a7459c610b8989d44f11a21dab0a
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Thu Dec 17 11:15:25 2020 -0400
Commit:     Henry Castro <hcas...@collabora.com>
CommitDate: Tue Jan 19 01:44:09 2021 +0100

    jsdialog: use the "WindowShow" event
    
    If the idle notifier is disabled use the
    "WindowShow" event to notify the dialog status.
    
    This ensures the dialog is initialized with all
    children and its properties.
    
    There is a bug with the "WindowShow" event, it
    looks like it receive 2 times.
    
    Change-Id: I81947de8498aee99c3ea4ad504611c7afa62d7c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107915
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109142
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx 
b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 1cf706f415ec..297b150e2f13 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -72,6 +72,7 @@ public:
 
     void notifyDialogState(bool bForce = false);
     void sendClose();
+    void dumpStatus();
 };
 
 class JSDropTarget final
@@ -234,6 +235,11 @@ public:
 
 class VCL_DLLPUBLIC JSDialog : public JSWidget<SalInstanceDialog, ::Dialog>
 {
+    DECL_LINK(on_dump_status, void*, void);
+    DECL_LINK(on_window_event, VclWindowEvent&, void);
+
+    bool m_bNotifyCreated;
+
 public:
     JSDialog(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
              ::Dialog* pDialog, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 141bd9badf6c..0d5f2c8f77ce 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -118,6 +118,8 @@ void JSDialogSender::notifyDialogState(bool bForce)
 
 void JSDialogSender::sendClose() { mpIdleNotify->sendClose(); }
 
+void JSDialogSender::dumpStatus() { mpIdleNotify->Invoke(); }
+
 // Drag and drop
 
 class JSDropTargetDropContext
@@ -654,6 +656,11 @@ JSDialog::JSDialog(VclPtr<vcl::Window> aNotifierWindow, 
VclPtr<vcl::Window> aCon
     : JSWidget<SalInstanceDialog, ::Dialog>(aNotifierWindow, aContentWindow, 
pDialog, pBuilder,
                                             bTakeOwnership, sTypeOfJSON)
 {
+    if (aNotifierWindow && aNotifierWindow->IsDisableIdleNotify())
+    {
+        pDialog->AddEventListener(LINK(this, JSDialog, on_window_event));
+        m_bNotifyCreated = false;
+    }
 }
 
 void JSDialog::collapse(weld::Widget* pEdit, weld::Widget* pButton)
@@ -674,6 +681,17 @@ void JSDialog::response(int response)
     SalInstanceDialog::response(response);
 }
 
+IMPL_LINK_NOARG(JSDialog, on_dump_status, void*, void) { 
JSDialogSender::dumpStatus(); }
+
+IMPL_LINK(JSDialog, on_window_event, VclWindowEvent&, rEvent, void)
+{
+    if (rEvent.GetId() == VclEventId::WindowShow && !m_bNotifyCreated)
+    {
+        Application::PostUserEvent(LINK(this, JSDialog, on_dump_status));
+        m_bNotifyCreated = true;
+    }
+}
+
 JSLabel::JSLabel(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> 
aContentWindow,
                  FixedText* pLabel, SalInstanceBuilder* pBuilder, bool 
bTakeOwnership,
                  std::string sTypeOfJSON)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to