From 8237add6d2cdf95d79e8549edd48bf2b79207f83 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Jun 2021 12:52:16 +0200 Subject: [PATCH] Keep track of splash visibility behind dialogs This fixes various issues, esp on macOS and Windows where the window is only hidden, not re-stacked: * plugin scan dialog hides the splash, but the plugin-manager emits BootMessage (this worked mostly because gtk event loop didn't have time to catch up) * More than one dialog can pop back/front the splash, e.g. scripted session-setup or error messages when loading recent sessions. --- gtk2_ardour/ardour_dialog.cc | 2 +- gtk2_ardour/ardour_message.cc | 2 +- gtk2_ardour/ardour_ui_startup.cc | 4 ++-- gtk2_ardour/luadialog.cc | 2 +- gtk2_ardour/splash.cc | 15 +++++++++++++++ gtk2_ardour/splash.h | 7 ++++++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/ardour_dialog.cc b/gtk2_ardour/ardour_dialog.cc index 96de0f57f0..8c177b5e7c 100644 --- a/gtk2_ardour/ardour_dialog.cc +++ b/gtk2_ardour/ardour_dialog.cc @@ -92,7 +92,7 @@ ArdourDialog::pop_splash () Splash* spl = Splash::exists () ? Splash::instance() : NULL; if (spl) { - spl->pop_front(); + spl->pop_front_for (*this); } _splash_pushed = false; } diff --git a/gtk2_ardour/ardour_message.cc b/gtk2_ardour/ardour_message.cc index 14039d7fe6..230307ec7c 100644 --- a/gtk2_ardour/ardour_message.cc +++ b/gtk2_ardour/ardour_message.cc @@ -79,7 +79,7 @@ ArdourMessageDialog::pop_splash () if (_splash_pushed) { Splash* spl = Splash::exists () ? Splash::instance() : NULL; if (spl) { - spl->pop_front(); + spl->pop_front_for (*this); } _splash_pushed = false; } diff --git a/gtk2_ardour/ardour_ui_startup.cc b/gtk2_ardour/ardour_ui_startup.cc index 41c55df619..661b845c3c 100644 --- a/gtk2_ardour/ardour_ui_startup.cc +++ b/gtk2_ardour/ardour_ui_startup.cc @@ -536,7 +536,7 @@ ARDOUR_UI::starting () /* allow signals to be handled, ShouldLoad() from flush-pending */ - Splash::instance()->pop_front(); + Splash::instance()->exists(); // create splash flush_pending (); if (!startup_fsm) { @@ -811,7 +811,7 @@ ARDOUR_UI::load_from_application_api (const std::string& path) * 3) no audio/MIDI setup required */ - Splash::instance()->pop_front(); + Splash::instance()->exists(); // create splash startup_fsm->start (); } } diff --git a/gtk2_ardour/luadialog.cc b/gtk2_ardour/luadialog.cc index 2f701575a1..dc5a07b9af 100644 --- a/gtk2_ardour/luadialog.cc +++ b/gtk2_ardour/luadialog.cc @@ -63,7 +63,7 @@ Message::run () if (splash_pushed) { spl = Splash::instance(); if (spl) { - spl->pop_front(); + spl->pop_front_for (_message_dialog); } } diff --git a/gtk2_ardour/splash.cc b/gtk2_ardour/splash.cc index 8e3c6de65a..824fb43242 100644 --- a/gtk2_ardour/splash.cc +++ b/gtk2_ardour/splash.cc @@ -153,12 +153,27 @@ Splash::pop_back_for (Gtk::Window& win) if (is_mapped()) { get_window()->restack (win.get_window(), false); } +#endif + _window_stack.insert (&win); +} + +void +Splash::pop_front_for (Gtk::Window& win) +{ +#ifndef NDEBUG + assert (1 == _window_stack.erase (&win)); +#else + _window_stack.erase (&win); #endif } void Splash::pop_front () { + if (!_window_stack.empty ()) { + return; + } + if (get_window()) { #if defined __APPLE__ || defined PLATFORM_WINDOWS show (); diff --git a/gtk2_ardour/splash.h b/gtk2_ardour/splash.h index 342673cd76..44b44bb923 100644 --- a/gtk2_ardour/splash.h +++ b/gtk2_ardour/splash.h @@ -21,6 +21,8 @@ #ifndef __ardour_gtk_splash_h__ #define __ardour_gtk_splash_h__ +#include + #include #include #include @@ -42,7 +44,7 @@ public: void display (); void pop_back_for (Gtk::Window&); - void pop_front (); + void pop_front_for (Gtk::Window&); bool expose (GdkEventExpose*); bool on_button_release_event (GdkEventButton*); @@ -59,6 +61,9 @@ private: Gtk::DrawingArea darea; Glib::RefPtr layout; + void pop_front (); + std::set _window_stack; + void boot_message (std::string); PBD::ScopedConnection msg_connection;