Patch from colinf to fix problems with toggle mixer on top (#2477).
authorCarl Hetherington <carl@carlh.net>
Wed, 13 Jun 2012 21:18:00 +0000 (21:18 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 13 Jun 2012 21:18:00 +0000 (21:18 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12714 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_dependents.cc
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/ardour_ui_mixer.cc
gtk2_ardour/mixer_ui.cc

index c5d9dc10031c95f64f6d9e3741a67bdd8e52958c..7b4ffb9f0e52a12bd9c0deb9efea0026c1b54547 100644 (file)
@@ -256,6 +256,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        void get_process_buffers ();
        void drop_process_buffers ();
 
+       void goto_editor_window ();
+       
   protected:
        friend class PublicEditor;
 
@@ -281,7 +283,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        ARDOUR::AudioEngine *engine;
        Gtk::Tooltips        _tooltips;
 
-       void                goto_editor_window ();
        void                goto_mixer_window ();
        void                toggle_mixer_window ();
        void                toggle_mixer_on_top ();
index c55942b4bda74ec78c39f4dfaca75425f6948b45..2b0e0df215eb32b8baf48b7c028b4842eeaa7c5f 100644 (file)
@@ -133,29 +133,25 @@ ARDOUR_UI::toggle_mixer_window ()
 void
 ARDOUR_UI::toggle_mixer_on_top ()
 {
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("toggle-mixer-on-top"));
-       if (!act) {
-               return;
-       }
-
-       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-
-       if (tact->get_active()) {
-
-               /* Toggle the mixer to `visible' if required */
-               act = ActionManager::get_action (X_("Common"), X_("toggle-mixer"));
-               if (act) {
-                       tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
+       /* Only called if the editor window received the shortcut key or if selected
+          from the editor window menu, so the mixer is definitely not on top, and
+          we can unconditionally make it so here.
+          
+          XXX this might not work so well where there is a global menu bar, e.g.
+          on OS X.
+       */
+
+       /* Toggle the mixer to `visible' if required */
+       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("toggle-mixer"));
+       if (act) {
+               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
 
-                       if (!tact->get_active()) {
-                               tact->set_active ();
-                       }
+               if (!tact->get_active()) {
+                       tact->set_active (true);
                }
-
-               goto_mixer_window ();
-       } else {
-               goto_editor_window ();
        }
+       
+       goto_mixer_window ();
 }
 
 /** The main editor window has been closed */
index 9a2a7b204395c65f1374c23718ec0badf20e75de..9519143af2cb8d9baebff2bb3cf77044b6555e49 100644 (file)
@@ -229,7 +229,7 @@ ARDOUR_UI::install_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
 
        ActionManager::register_toggle_action (common_actions, X_("toggle-mixer"), S_("Window|Mixer"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_window));
-       ActionManager::register_toggle_action (common_actions, X_("toggle-mixer-on-top"), _("Mixer on Top"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_on_top));
+       ActionManager::register_action (common_actions, X_("toggle-mixer-on-top"), _("Mixer on Top"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_on_top));
        ActionManager::register_toggle_action (common_actions, X_("ToggleRCOptionsEditor"), _("Preferences"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_rc_options_window));
        ActionManager::register_toggle_action (common_actions, X_("ToggleSessionOptionsEditor"), _("Properties"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_options_window));
        act = ActionManager::register_toggle_action (common_actions, X_("ToggleInspector"), _("Tracks and Busses"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_route_params_window));
index e3250d2a1f552d642463a0f416a4a2cf4944b1fb..aacffa9d203fc7dc6356fe74a3aa63f5fb400ed9 100644 (file)
@@ -44,7 +44,6 @@ ARDOUR_UI::create_mixer ()
 
        mixer->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), false));
        mixer->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/toggle-mixer")));
-       mixer->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/toggle-mixer-on-top")));
 
        return 0;
 }
index 60b3f7b0d87d0ccd450c9e99c61300f4d6a5e276..8dd83ad771dccd7ebb582c0e22c44c6bd45dc702 100644 (file)
@@ -1550,6 +1550,18 @@ Mixer_UI::on_key_press_event (GdkEventKey* ev)
        }
        
        KeyboardKey k (ev->state, ev->keyval);
+
+       GtkAccelKey key;
+       
+       /* Handle toggle-mixer-on-top here, so it can do a different thing if the
+          mixer is already on top and received this key press.
+       */
+       if (gtk_accel_map_lookup_entry("<Actions>/Common/toggle-mixer-on-top", &key)) {
+               if (int (k.state()) == key.accel_mods && k.key() == key.accel_key) {
+                       ARDOUR_UI::instance()->goto_editor_window();
+                       return true;
+               }
+       } 
        
        if (bindings.activate (k, Bindings::Press)) {
                return true;