From a9341bd5f03dad86161786c1f764471b23273601 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 30 Apr 2013 13:50:15 -0400 Subject: [PATCH] improve relationship between ArdourDialog and Splash on OS X, where window restacking doesn't really work the way we need it to. more complex than anticipated because it seems that destroying a Gtk::Dialog does not emit its hide() or unmap() or unmap_event() signals --- gtk2_ardour/ardour_dialog.cc | 16 +++++++++++++--- gtk2_ardour/ardour_dialog.h | 1 + gtk2_ardour/ardour_ui.cc | 6 ++++-- gtk2_ardour/splash.cc | 24 +++++++++++++++++++++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/gtk2_ardour/ardour_dialog.cc b/gtk2_ardour/ardour_dialog.cc index c0e1708781..6775a70953 100644 --- a/gtk2_ardour/ardour_dialog.cc +++ b/gtk2_ardour/ardour_dialog.cc @@ -34,12 +34,14 @@ sigc::signal ArdourDialog::CloseAllDialogs; ArdourDialog::ArdourDialog (string title, bool modal, bool use_seperator) : Dialog (title, modal, use_seperator) + , _splash_pushed (false) { init (); } ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool use_seperator) : Dialog (title, parent, modal, use_seperator) + , _splash_pushed (false) { init (); set_position (Gtk::WIN_POS_CENTER_ON_PARENT); @@ -47,6 +49,13 @@ ArdourDialog::ArdourDialog (Gtk::Window& parent, string title, bool modal, bool ArdourDialog::~ArdourDialog () { + if (_splash_pushed) { + Splash* spl = Splash::instance(); + + if (spl) { + spl->pop_front(); + } + } } bool @@ -73,15 +82,16 @@ ArdourDialog::on_unmap () void ArdourDialog::on_show () { + Dialog::on_show (); + // never allow the splash screen to obscure any dialog Splash* spl = Splash::instance(); - if (spl) { + if (spl && spl->is_visible()) { spl->pop_back_for (*this); + _splash_pushed = true; } - - Dialog::on_show (); } void diff --git a/gtk2_ardour/ardour_dialog.h b/gtk2_ardour/ardour_dialog.h index 4f53662c23..1008f63000 100644 --- a/gtk2_ardour/ardour_dialog.h +++ b/gtk2_ardour/ardour_dialog.h @@ -46,6 +46,7 @@ class ArdourDialog : public Gtk::Dialog, public ARDOUR::SessionHandlePtr static void close_all_dialogs () { CloseAllDialogs(); } private: + bool _splash_pushed; void init (); static sigc::signal CloseAllDialogs; diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index eebd35aefb..7e972b8032 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3771,12 +3771,14 @@ audio may be played at the wrong sample rate.\n"), desired, PROGRAM_NAME, actual image->show(); hbox->show(); - switch (dialog.run ()) { + switch (dialog.run()) { case RESPONSE_ACCEPT: return 0; default: - return 1; + break; } + + return 1; } diff --git a/gtk2_ardour/splash.cc b/gtk2_ardour/splash.cc index 0922ec75ba..99adff68e9 100644 --- a/gtk2_ardour/splash.cc +++ b/gtk2_ardour/splash.cc @@ -25,6 +25,10 @@ #include "ardour/ardour.h" #include "ardour/filesystem_paths.h" +#ifdef check +#undef check +#endif + #include "gui_thread.h" #include "splash.h" @@ -96,15 +100,33 @@ Splash::~Splash () void Splash::pop_back_for (Gtk::Window& win) { +#ifdef __APPLE__ + /* April 2013: window layering on OS X is a bit different to X Window. at present, + the "restack()" functionality in GDK will only operate on windows in the same + "level" (e.g. two normal top level windows, or two utility windows) and will not + work across them. The splashscreen is on its own "StatusWindowLevel" so restacking + is not going to work. + + So for OS X, we just hide ourselves. + */ + hide(); +#else set_keep_above (false); get_window()->restack (win.get_window(), false); - win.signal_hide().connect (sigc::mem_fun (*this, &Splash::pop_front)); +#endif } void Splash::pop_front () { + +#ifdef __APPLE__ + if (get_window()) { + show (); + } +#else set_keep_above (true); +#endif } void