diff --git a/include/SubWindow.h b/include/SubWindow.h index 303d06eba71..8fd6f7c5ed8 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -77,6 +77,7 @@ public slots: virtual void paintEvent( QPaintEvent * pe ); virtual void changeEvent( QEvent * event ); virtual void showEvent( QShowEvent* event ); + virtual bool eventFilter( QObject * obj, QEvent * event ) override; bool isDetached() const; diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index b8204f40496..b0eb4f1e14d 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -94,8 +94,15 @@ class vstSubWin : public QMdiSubWindow { // ignore close-events - for some reason otherwise the VST GUI // remains hidden when re-opening - hide(); - e->ignore(); + if (windowFlags().testFlag(Qt::Window)) + { + e->accept(); + } + else + { + hide(); + e->ignore(); + } } }; diff --git a/src/gui/ControllerDialog.cpp b/src/gui/ControllerDialog.cpp index f854ab1b94e..63dcb662529 100644 --- a/src/gui/ControllerDialog.cpp +++ b/src/gui/ControllerDialog.cpp @@ -27,6 +27,8 @@ #include "ControllerDialog.h" #include "Controller.h" +#include "GuiApplication.h" +#include "MainWindow.h" ControllerDialog::ControllerDialog( Controller * _controller, @@ -46,7 +48,20 @@ ControllerDialog::~ControllerDialog() void ControllerDialog::closeEvent( QCloseEvent * _ce ) { - _ce->ignore(); + if (windowFlags().testFlag(Qt::Window)) + { + _ce->accept(); + } + else if (gui->mainWindow()->workspace()) + { + parentWidget()->hide(); + _ce->ignore(); + } + else + { + hide(); + _ce->ignore(); + } emit closed(); } diff --git a/src/gui/EffectControlDialog.cpp b/src/gui/EffectControlDialog.cpp index c43f451aa7a..5132b3c9218 100644 --- a/src/gui/EffectControlDialog.cpp +++ b/src/gui/EffectControlDialog.cpp @@ -28,6 +28,8 @@ #include "EffectControlDialog.h" #include "EffectControls.h" +#include "GuiApplication.h" +#include "MainWindow.h" EffectControlDialog::EffectControlDialog( EffectControls * _controls ) : @@ -50,7 +52,20 @@ EffectControlDialog::~EffectControlDialog() void EffectControlDialog::closeEvent( QCloseEvent * _ce ) { - _ce->ignore(); + if (windowFlags().testFlag(Qt::Window)) + { + _ce->accept(); + } + else if (gui->mainWindow()->workspace()) + { + parentWidget()->hide(); + _ce->ignore(); + } + else + { + hide(); + _ce->ignore(); + } emit closed(); } diff --git a/src/gui/FxMixerView.cpp b/src/gui/FxMixerView.cpp index cbcfd0a47eb..2912c3398fe 100644 --- a/src/gui/FxMixerView.cpp +++ b/src/gui/FxMixerView.cpp @@ -544,16 +544,21 @@ void FxMixerView::keyPressEvent(QKeyEvent * e) void FxMixerView::closeEvent( QCloseEvent * _ce ) - { - if( parentWidget() ) +{ + if (windowFlags().testFlag(Qt::Window)) + { + _ce->accept(); + } + else if (gui->mainWindow()->workspace()) { parentWidget()->hide(); + _ce->ignore(); } else { hide(); + _ce->ignore(); } - _ce->ignore(); } diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 8e615ea14a3..80fed530f94 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -285,6 +285,7 @@ void SubWindow::detach() if (isDetached()) { return; } + auto pos = mapToGlobal(widget()->pos()); widget()->setWindowFlags(Qt::Window); widget()->show(); @@ -455,3 +456,17 @@ void SubWindow::resizeEvent( QResizeEvent * event ) m_trackedNormalGeom.setSize( event->size() ); } } + +bool SubWindow::eventFilter(QObject * obj, QEvent * event) +{ + if (obj != static_cast(widget())) { + return QMdiSubWindow::eventFilter(obj, event); + } + switch (event->type()) { + case QEvent::WindowStateChange: + event->accept(); + return true; + default: + return QMdiSubWindow::eventFilter(obj, event); + } +} diff --git a/src/gui/widgets/ControllerRackView.cpp b/src/gui/widgets/ControllerRackView.cpp index a6090418265..2e19b21094e 100644 --- a/src/gui/widgets/ControllerRackView.cpp +++ b/src/gui/widgets/ControllerRackView.cpp @@ -203,14 +203,19 @@ void ControllerRackView::addController() void ControllerRackView::closeEvent( QCloseEvent * _ce ) { - if( parentWidget() ) + if (windowFlags().testFlag(Qt::Window)) + { + _ce->accept(); + } + else if (gui->mainWindow()->workspace()) { parentWidget()->hide(); + _ce->ignore(); } else { hide(); + _ce->ignore(); } - _ce->ignore(); } diff --git a/src/gui/widgets/ProjectNotes.cpp b/src/gui/widgets/ProjectNotes.cpp index 7fc35b446a6..de1320d8ce1 100644 --- a/src/gui/widgets/ProjectNotes.cpp +++ b/src/gui/widgets/ProjectNotes.cpp @@ -398,13 +398,18 @@ void ProjectNotes::loadSettings( const QDomElement & _this ) void ProjectNotes::closeEvent( QCloseEvent * _ce ) { - if( parentWidget() ) + if (windowFlags().testFlag(Qt::Window)) + { + _ce->accept(); + } + else if (gui->mainWindow()->workspace()) { parentWidget()->hide(); + _ce->ignore(); } else { hide(); + _ce->ignore(); } - _ce->ignore(); } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 5b4a255d128..935fba5cd8d 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -1686,15 +1686,19 @@ void InstrumentTrackWindow::toggleVisibility( bool on ) void InstrumentTrackWindow::closeEvent( QCloseEvent* event ) { - event->ignore(); - - if( gui->mainWindow()->workspace() ) + if (windowFlags().testFlag(Qt::Window)) + { + event->accept(); + } + else if (gui->mainWindow()->workspace()) { parentWidget()->hide(); + event->ignore(); } else { hide(); + event->ignore(); } m_itv->m_tlb->setFocus();