diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc index d1efb4d7de..6556238240 100644 --- a/gtk2_ardour/ardour_ui_dialogs.cc +++ b/gtk2_ardour/ardour_ui_dialogs.cc @@ -393,19 +393,61 @@ ARDOUR_UI::toggle_mixer_window () void ARDOUR_UI::toggle_meterbridge () { - Glib::RefPtr act = ActionManager::get_action (X_("Common"), X_("toggle-meterbridge")); - if (!act) { + if (!editor || !meterbridge) { + /* can this really happen? + * keyboard shortcut during session close, maybe? + */ +#ifndef NDEBUG + /* one way to find out: */ + printf("ARDOUR_UI::toggle_meterbridge: Editor: %p MB: %p\n", editor, meterbridge); + PBD::stacktrace (std::cerr, 20); + assert (0); +#endif return; } - Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act); + bool show = false; + bool obscuring = false; - if (tact->get_active()) { + if (meterbridge->not_visible ()) { + show = true; + } + else if (editor->get_screen() == meterbridge->get_screen()) { + gint ex, ey, ew, eh; + gint mx, my, mw, mh; + + editor->get_position (ex, ey); + editor->get_size (ew, eh); + meterbridge->get_position (mx, my); + meterbridge->get_size (mw, mh); + + GdkRectangle e; + GdkRectangle m; + GdkRectangle r; + + e.x = ex; + e.y = ey; + e.width = ew; + e.height = eh; + + m.x = mx; + m.y = my; + m.width = mw; + m.height = mh; + + if (gdk_rectangle_intersect (&e, &m, &r)) { + obscuring = true; + } + } + + if (obscuring && editor->property_has_toplevel_focus()) { + show = true; + } + + if (show) { meterbridge->show_window (); meterbridge->present (); - if (editor) { - meterbridge->set_transient_for (*editor); - } + meterbridge->raise (); } else { meterbridge->hide_window (NULL); } diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 3f0bb44336..2b427bf04f 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -203,7 +203,7 @@ if (Profile->get_mixbus()) ActionManager::register_toggle_action (common_actions, X_("toggle-mixer"), S_("Window|Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_window)); ActionManager::register_action (common_actions, X_("toggle-editor-mixer"), _("Toggle Editor+Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_editor_mixer)); - ActionManager::register_toggle_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge)); + ActionManager::register_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge)); ActionManager::register_action (common_actions, X_("reattach-all-tearoffs"), _("Reattach All Tearoffs"), sigc::mem_fun (*this, &ARDOUR_UI::reattach_all_tearoffs)); diff --git a/gtk2_ardour/ardour_ui_mixer.cc b/gtk2_ardour/ardour_ui_mixer.cc index a2669f968d..009442f769 100644 --- a/gtk2_ardour/ardour_ui_mixer.cc +++ b/gtk2_ardour/ardour_ui_mixer.cc @@ -65,7 +65,6 @@ ARDOUR_UI::create_meterbridge () } meterbridge->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), false)); - meterbridge->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("/Common/toggle-meterbridge"))); return 0; } diff --git a/gtk2_ardour/meterbridge.cc b/gtk2_ardour/meterbridge.cc index e325ff814b..aaf1842c79 100644 --- a/gtk2_ardour/meterbridge.cc +++ b/gtk2_ardour/meterbridge.cc @@ -439,7 +439,6 @@ Meterbridge::set_session (Session* s) if (_visible) { show_window(); present (); - ActionManager::check_toggleaction ("/Common/toggle-meterbridge"); } start_updating (); }