From c162aa7acae230cdda52f1c0fd7a3b076eedfcdb Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 31 Oct 2023 20:10:49 +0100 Subject: [PATCH] Consistently use context-menu button action This fixes an issue where brining up a menu can directly activate an action in the menu. Notably on macOS. Nathan reports that this may also address #9515 Note: mac touchpads are not affected since right-click there is effectively a "press and hold". --- gtk2_ardour/ardour_ui_ed.cc | 2 +- gtk2_ardour/audio_clock.cc | 2 +- gtk2_ardour/automation_controller.cc | 4 ++-- gtk2_ardour/control_slave_ui.cc | 2 +- gtk2_ardour/cuebox_ui.cc | 2 +- gtk2_ardour/editor_markers.cc | 14 +++++++------- gtk2_ardour/editor_sources.cc | 2 +- gtk2_ardour/gain_meter.cc | 2 +- gtk2_ardour/mixer_strip.cc | 4 ++-- gtk2_ardour/mixer_ui.cc | 4 ++-- gtk2_ardour/panner_ui.cc | 4 ++-- gtk2_ardour/port_matrix.cc | 2 +- gtk2_ardour/processor_box.cc | 2 +- gtk2_ardour/route_params_ui.cc | 2 +- gtk2_ardour/route_ui.cc | 10 +++++----- gtk2_ardour/trigger_master.cc | 2 +- gtk2_ardour/trigger_strip.cc | 2 +- gtk2_ardour/trigger_ui.cc | 6 +++--- gtk2_ardour/trigger_ui.h | 2 +- gtk2_ardour/triggerbox_ui.cc | 2 +- gtk2_ardour/vca_master_strip.cc | 4 ++-- gtk2_ardour/visibility_group.cc | 2 +- 22 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index e1a7a286c1..2bb2637d15 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -1109,7 +1109,7 @@ ARDOUR_UI::tabbable_visibility_button_press (GdkEventButton* ev, string const& t string menu_name = string ("/ui/") + tabbable_name + X_("TabbableButtonMenu"); Gtk::Menu* menu = dynamic_cast (ActionManager::get_widget (menu_name.c_str())); if (menu) { - menu->popup (3, ev->time); + menu->popup (ev->button, ev->time); } return true; } diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index f060c861e6..02b3651126 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -1745,7 +1745,7 @@ AudioClock::on_button_release_event (GdkEventButton *ev) if (ops_menu == 0) { build_ops_menu (); } - ops_menu->popup (1, ev->time); + ops_menu->popup (ev->button, ev->time); return true; } diff --git a/gtk2_ardour/automation_controller.cc b/gtk2_ardour/automation_controller.cc index a62fee2672..fdaf7e4abd 100644 --- a/gtk2_ardour/automation_controller.cc +++ b/gtk2_ardour/automation_controller.cc @@ -314,7 +314,7 @@ AutomationController::on_button_release(GdkEventButton* ev) MenuList& items = menu->items(); items.push_back(MenuElem(_("Select Note..."), sigc::mem_fun(*this, &AutomationController::run_note_select_dialog))); - menu->popup(1, ev->time); + menu->popup(ev->button, ev->time); return true; } else if (desc.unit == ARDOUR::ParameterDescriptor::HZ) { Gtk::Menu* menu = ARDOUR_UI_UTILS::shared_popup_menu (); @@ -338,7 +338,7 @@ AutomationController::on_button_release(GdkEventButton* ev) (double)beats))); } } - menu->popup(1, ev->time); + menu->popup(ev->button, ev->time); return true; } diff --git a/gtk2_ardour/control_slave_ui.cc b/gtk2_ardour/control_slave_ui.cc index 38c680e8e1..8e1276ab43 100644 --- a/gtk2_ardour/control_slave_ui.cc +++ b/gtk2_ardour/control_slave_ui.cc @@ -213,7 +213,7 @@ ControlSlaveUI::vca_button_release (GdkEventButton* ev, uint32_t n) } if (!items.empty()) { - context_menu->popup (1, ev->time); + context_menu->popup (ev->button, ev->time); return true; } diff --git a/gtk2_ardour/cuebox_ui.cc b/gtk2_ardour/cuebox_ui.cc index a71d6c3eda..fd9114bdde 100644 --- a/gtk2_ardour/cuebox_ui.cc +++ b/gtk2_ardour/cuebox_ui.cc @@ -298,7 +298,7 @@ CueBoxUI::context_menu (uint64_t idx) items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Clear All..."), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::clear_all_triggers), idx))); - _context_menu->popup (1, gtk_get_current_event_time ()); + _context_menu->popup (3, gtk_get_current_event_time ()); } void diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index e320997b04..6a74eef452 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -1026,14 +1026,14 @@ Editor::tempo_map_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* i if (mm) { can_remove = !mm->meter().map().is_initial (mm->meter()); build_meter_marker_menu (mm, can_remove); - meter_marker_menu->popup (1, ev->time); + meter_marker_menu->popup (ev->button, ev->time); } else if (tm) { can_remove = !tm->tempo().map().is_initial(tm->tempo()) && !tm->tempo().locked_to_meter(); build_tempo_marker_menu (tm, can_remove); - tempo_marker_menu->popup (1, ev->time); + tempo_marker_menu->popup (ev->button, ev->time); } else if (bm) { build_bbt_marker_menu (bm); - bbt_marker_menu->popup (1, ev->time); + bbt_marker_menu->popup (ev->button, ev->time); } else { return; } @@ -1062,7 +1062,7 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) build_range_marker_menu (loc, loc == transport_loop_location() || loc == transport_punch_location(), loc->is_session_range()); marker_menu_item = item; - range_marker_menu->popup (1, ev->time); + range_marker_menu->popup (ev->button, ev->time); } else if (loc->is_mark()) { @@ -1083,12 +1083,12 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) } #endif marker_menu_item = item; - marker_menu->popup (1, ev->time); + marker_menu->popup (ev->button, ev->time); } else if (loc->is_range_marker()) { build_range_marker_menu (loc, false, false); marker_menu_item = item; - range_marker_menu->popup (1, ev->time); + range_marker_menu->popup (ev->button, ev->time); } } @@ -1099,7 +1099,7 @@ Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Ite build_new_transport_marker_menu (); } - new_transport_marker_menu->popup (1, ev->time); + new_transport_marker_menu->popup (ev->button, ev->time); } diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index 47fd6ec2ae..6ddb7351d4 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -148,7 +148,7 @@ EditorSources::show_context_menu (int button, int time) #endif items.push_back (MenuElem (_("Remove the selected Sources"), sigc::mem_fun (*this, &EditorSources::remove_selected_sources))); - menu->popup (1, time); + menu->popup (button, time); } void diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index b0771a9d01..e554609e67 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -497,7 +497,7 @@ GainMeterBase::popup_meter_menu (GdkEventButton *ev) items.push_back (MenuElem ("-4 .. -2dBFS")); } - meter_menu->popup (1, ev->time); + meter_menu->popup (ev->button, ev->time); } bool diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index d6f4004d3c..2f8bc7a493 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1210,7 +1210,7 @@ MixerStrip::name_button_button_press (GdkEventButton* ev) Gtkmm2ext::anchored_menu_popup(route_ops_menu, &name_button, "", 1, ev->time); } else { - route_ops_menu->popup (3, ev->time); + route_ops_menu->popup (ev->button, ev->time); } return true; @@ -1230,7 +1230,7 @@ MixerStrip::number_button_button_press (GdkEventButton* ev) if (ev->button == 3) { list_route_operations (); - route_ops_menu->popup (1, ev->time); + route_ops_menu->popup (ev->button, ev->time); return true; } diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 576faa56b7..c5300afbbf 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -2079,7 +2079,7 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev) RouteGroup* group = (*iter)[group_columns.group]; if (Keyboard::is_context_menu_event (ev)) { - _group_tabs->get_menu(group)->popup (1, ev->time); + _group_tabs->get_menu(group)->popup (ev->button, ev->time); return true; } @@ -4107,7 +4107,7 @@ Mixer_UI::popup_scene_menu (GdkEventButton* ev, int scn_idx) items.back().set_sensitive (!PublicEditor::instance().get_selection().tracks.routelist ().empty ()); } - menu->popup(1, ev->time); + menu->popup(ev->button, ev->time); } bool diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index aa33a231f1..5f8a5f8ff2 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -385,7 +385,7 @@ PannerUI::pan_button_event (GdkEventButton* ev) pan_menu->set_name ("ArdourContextMenu"); } build_pan_menu (); - pan_menu->popup (1, ev->time); + pan_menu->popup (ev->button, ev->time); return true; break; default: @@ -528,7 +528,7 @@ PannerUI::pan_automation_state_button_event (GdkEventButton *ev) if (pan_astate_menu == 0) { build_astate_menu (); } - pan_astate_menu->popup (1, ev->time); + pan_astate_menu->popup (ev->button, ev->time); break; default: break; diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 6532a7da79..020b2a3278 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -559,7 +559,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t) items.push_back (MenuElem (_("Flip"), sigc::mem_fun (*this, &PortMatrix::flip))); items.back().set_sensitive (can_flip ()); - _menu->popup (1, t); + _menu->popup (3, t); } void diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index d5eb8d2864..defe87e79a 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -2527,7 +2527,7 @@ ProcessorBox::show_processor_menu (int arg) && !std::dynamic_pointer_cast (single_selection->processor ()) && !std::dynamic_pointer_cast (single_selection->processor ())); - processor_menu->popup (1, arg); + processor_menu->popup (3, arg); /* Add a placeholder gap to the processor list to indicate where a processor would be inserted were one chosen from the menu. diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc index e9f69c6eec..fae1833af7 100644 --- a/gtk2_ardour/route_params_ui.cc +++ b/gtk2_ardour/route_params_ui.cc @@ -456,7 +456,7 @@ RouteParams_UI::show_track_menu() track_menu->set_name ("ArdourContextMenu"); track_menu->items().push_back (MenuElem (_("Add Track or Bus"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route))); } - track_menu->popup (1, gtk_get_current_event_time()); + track_menu->popup (1, gtk_get_current_event_time()); // show by "clicked" signal, btn1 } void diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 88f81bb1f3..11bdeb9b32 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -487,7 +487,7 @@ RouteUI::mute_press (GdkEventButton* ev) build_mute_menu(); } - mute_menu->popup(0,ev->time); + mute_menu->popup (ev->button, ev->time); return true; @@ -653,7 +653,7 @@ RouteUI::solo_press(GdkEventButton* ev) build_solo_menu (); } - solo_menu->popup (1, ev->time); + solo_menu->popup (ev->button, ev->time); } else { @@ -1027,7 +1027,7 @@ RouteUI::rec_enable_release (GdkEventButton* ev) if (Keyboard::is_context_menu_event (ev)) { build_record_menu (); if (_record_menu) { - _record_menu->popup (1, ev->time); + _record_menu->popup (ev->button, ev->time); } return false; } @@ -1154,7 +1154,7 @@ RouteUI::show_sends_press(GdkEventButton* ev) build_sends_menu (); } - sends_menu->popup (0, ev->time); + sends_menu->popup (ev->button, ev->time); } else if (ev->button == 1) { @@ -2233,7 +2233,7 @@ RouteUI::invert_press (GdkEventButton* ev) --_i_am_the_modifier; } - _invert_menu->popup (0, ev->time); + _invert_menu->popup (ev->button, ev->time); return true; } diff --git a/gtk2_ardour/trigger_master.cc b/gtk2_ardour/trigger_master.cc index f41c6aea88..b9907bb419 100644 --- a/gtk2_ardour/trigger_master.cc +++ b/gtk2_ardour/trigger_master.cc @@ -721,7 +721,7 @@ CueMaster::context_menu () items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Clear All..."), sigc::mem_fun (*this, &CueMaster::clear_all_triggers))); - _context_menu->popup (1, gtk_get_current_event_time ()); + _context_menu->popup (3, gtk_get_current_event_time ()); } void diff --git a/gtk2_ardour/trigger_strip.cc b/gtk2_ardour/trigger_strip.cc index 5bc71db878..5d828fa742 100644 --- a/gtk2_ardour/trigger_strip.cc +++ b/gtk2_ardour/trigger_strip.cc @@ -574,7 +574,7 @@ TriggerStrip::name_button_press (GdkEventButton* ev) if (ev->button == 1) { Gtkmm2ext::anchored_menu_popup (_route_ops_menu, &_name_button, "", 1, ev->time); } else { - _route_ops_menu->popup (3, ev->time); + _route_ops_menu->popup (ev->button, ev->time); } return true; diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 6972517e81..413b625e02 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -546,11 +546,11 @@ TriggerUI::launch_context_menu () dynamic_cast (&items.back ())->set_active (true); } - _launch_context_menu->popup (1, gtk_get_current_event_time ()); + _launch_context_menu->popup (3, gtk_get_current_event_time ()); } void -TriggerUI::follow_context_menu () +TriggerUI::follow_context_menu (GdkEventButton* ev) { using namespace Gtk; using namespace Gtk::Menu_Helpers; @@ -583,7 +583,7 @@ TriggerUI::follow_context_menu () _ignore_menu_action = false; - _follow_context_menu->popup (1, gtk_get_current_event_time ()); + _follow_context_menu->popup (ev->button, ev->time); } void diff --git a/gtk2_ardour/trigger_ui.h b/gtk2_ardour/trigger_ui.h index dd5d46613d..0c7d906b3c 100644 --- a/gtk2_ardour/trigger_ui.h +++ b/gtk2_ardour/trigger_ui.h @@ -73,7 +73,7 @@ public: void sample_chosen (int r); void launch_context_menu (); - void follow_context_menu (); + void follow_context_menu (GdkEventButton*); void context_menu (); void edit_jump_done (int r, TriggerJumpDialog* d); diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index 216a0ab291..89b4de83a1 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -664,7 +664,7 @@ TriggerEntry::follow_button_event (GdkEvent* ev) switch (ev->button.button) { case 1: case 3: - follow_context_menu (); + follow_context_menu (ev->button); default: break; } diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 2c9cce0317..80772a54e5 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -401,7 +401,7 @@ VCAMasterStrip::vertical_button_release (GdkEventButton* ev) if (!context_menu) { build_context_menu (); } - context_menu->popup (1, ev->time); + context_menu->popup (ev->time, ev->time); return true; } @@ -419,7 +419,7 @@ VCAMasterStrip::number_button_press (GdkEventButton* ev) if (!context_menu) { build_context_menu (); } - context_menu->popup (1, ev->time); + context_menu->popup (ev->time, ev->time); return true; } return false; diff --git a/gtk2_ardour/visibility_group.cc b/gtk2_ardour/visibility_group.cc index bd4f2cda8b..a71f6734ec 100644 --- a/gtk2_ardour/visibility_group.cc +++ b/gtk2_ardour/visibility_group.cc @@ -82,7 +82,7 @@ VisibilityGroup::button_press_event (GdkEventButton* ev) j->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &VisibilityGroup::toggle), i)); } - m->popup (1, ev->time); + m->popup (ev->button, ev->time); return true; }