From a048b76368e78082dfbdd324d59572235c2c4ea1 Mon Sep 17 00:00:00 2001 From: gambas Date: Mon, 23 Oct 2017 23:10:49 +0200 Subject: [PATCH] Define the parent window of a modal dialog the same way in all GUI components. [GB.QT4] * BUG: Define the parent window of a modal dialog the same way in all GUI components. [GB.QT5] * BUG: Define the parent window of a modal dialog the same way in all GUI components. [GB.GTK] * BUG: Define the parent window of a modal dialog the same way in all GUI components. [GB.GTK3] * BUG: Define the parent window of a modal dialog the same way in all GUI components. --- gb.gtk/src/gmainwindow.cpp | 13 +++++++++++-- gb.qt4/src/CWindow.cpp | 11 ++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gb.gtk/src/gmainwindow.cpp b/gb.gtk/src/gmainwindow.cpp index a9779683f..04c1aee18 100644 --- a/gb.gtk/src/gmainwindow.cpp +++ b/gb.gtk/src/gmainwindow.cpp @@ -787,6 +787,7 @@ bool gMainWindow::isModal() const void gMainWindow::showModal() { gMainWindow *save; + gMainWindow *parent; if (!isTopLevel()) return; if (isModal()) return; @@ -798,8 +799,16 @@ void gMainWindow::showModal() //show(); gtk_grab_add(border); - if (_active) - gtk_window_set_transient_for(GTK_WINDOW(border), GTK_WINDOW(_active->topLevel()->border)); + parent = _current; + if (!parent) + { + parent = gApplication::mainWindow(); + if (!parent) + parent = _active; + } + + if (parent) + gtk_window_set_transient_for(GTK_WINDOW(border), GTK_WINDOW(parent->topLevel()->border)); save = _current; _current = this; diff --git a/gb.qt4/src/CWindow.cpp b/gb.qt4/src/CWindow.cpp index 6713739aa..255246fdc 100644 --- a/gb.qt4/src/CWindow.cpp +++ b/gb.qt4/src/CWindow.cpp @@ -1672,9 +1672,10 @@ void MyMainWindow::activateLater() void MyMainWindow::present(QWidget *parent) { - //CWIDGET *_object = CWidget::get(this); - //CWIDGET *_parent = parent ? CWidget::get(parent) : 0; - //qDebug("present: %p %s: parent = %p %s", THIS, _object->name, _parent, _parent ? _parent->name : ""); + /*CWIDGET *_object = CWidget::get(this); + CWIDGET *_parent = parent ? CWidget::get(parent) : 0; + + qDebug("present: %p %s: parent = %p %s", THIS, _object->name, _parent, _parent ? _parent->name : "");*/ if (parent) _screen = QApplication::desktop()->screenNumber(parent); @@ -1837,7 +1838,11 @@ void MyMainWindow::showModal(void) parent = CWINDOW_Current; if (!parent) + { parent = CWINDOW_Main; + if (!parent) + parent = CWINDOW_Active; + } present(parent ? CWidget::getTopLevel((CWIDGET *)parent)->widget.widget : 0); setEventLoop();