diff options
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index cb816b751cd9..0f09eb6e0877 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2666,11 +2666,13 @@ struct DialogRunner gint m_nResponseId; GMainLoop *m_pLoop; VclPtr<vcl::Window> m_xFrameWindow; + int m_nModalDepth; DialogRunner(GtkDialog* pDialog) : m_pDialog(pDialog) , m_nResponseId(GTK_RESPONSE_NONE) , m_pLoop(nullptr) + , m_nModalDepth(0) { GtkWindow* pParent = gtk_window_get_transient_for(GTK_WINDOW(m_pDialog)); GtkSalFrame* pFrame = pParent ? GtkSalFrame::getFromWindow(pParent) : nullptr; @@ -2711,13 +2713,19 @@ struct DialogRunner void inc_modal_count() { if (m_xFrameWindow) + { m_xFrameWindow->IncModalCount(); + ++m_nModalDepth; + } } void dec_modal_count() { if (m_xFrameWindow) + { m_xFrameWindow->DecModalCount(); + --m_nModalDepth; + } } // same as gtk_dialog_run except that unmap doesn't auto-respond @@ -2764,6 +2772,18 @@ struct DialogRunner return m_nResponseId; } + + ~DialogRunner() + { + if (m_xFrameWindow) + { + // if, like the calc validation dialog does, the modality was + // toggled off during execution ensure that on cleanup the parent + // is left in the state it was found + while (m_nModalDepth++ < 0) + m_xFrameWindow->IncModalCount(); + } + } }; typedef std::set<GtkWidget*> winset; @@ -2954,6 +2974,22 @@ public: m_aDialogRun.inc_modal_count(); } + virtual void set_modal(bool bModal) override + { + if (get_modal() == bModal) + return; + GtkInstanceWindow::set_modal(bModal); + // see hide comment, but the modality-change example + // is the validity dialog in calc + if (m_aDialogRun.loop_is_running()) + { + if (bModal) + m_aDialogRun.inc_modal_count(); + else + m_aDialogRun.dec_modal_count(); + } + } + static int VclToGtk(int nResponse) { if (nResponse == RET_OK) |