meta-fy handling of button2, to deal with apple's messed up design decisions; on gtk/osx, button2 is (currently) Ctrl-Option-Button1

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4087 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-11-03 17:05:17 +00:00
parent 1ae268ad2a
commit bb520383a3
7 changed files with 27 additions and 10 deletions

View File

@ -403,7 +403,7 @@ CrossfadeEditor::point_event (GdkEvent* event, Point* point)
if (Keyboard::is_delete_event (&event->button)) {
fade[current].points.remove (point);
delete point;
}
}
redraw ();
break;

View File

@ -1850,7 +1850,7 @@ Editor::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
if (event->button.button == 2) {
if (Keyboard::is_button2_event (&event->button)) {
if (Keyboard::modifier_state_equals (event->button.state, Keyboard::SecondaryModifier)) {
drag_info.y_constrained = true;
drag_info.x_constrained = false;

View File

@ -453,7 +453,7 @@ GainMeterBase::meter_press(GdkEventButton* ev)
} else {
if (ev->button == 2) {
if (Keyboard::is_button2_event(ev)) {
// Primary-button2 click is the midi binding click
// button2-click is "momentary"
@ -464,7 +464,7 @@ GainMeterBase::meter_press(GdkEventButton* ev)
}
}
if (ev->button == 1 || ev->button == 2) {
if (ev->button == 1 || Keyboard::is_button2_event (ev)) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {

View File

@ -61,6 +61,7 @@ guint Keyboard::TertiaryModifier = GDK_SHIFT_MASK; // Shift
guint Keyboard::Level4Modifier = GDK_CONTROL_MASK; // Control
guint Keyboard::CopyModifier = GDK_MOD1_MASK; // Alt/Option
guint Keyboard::RangeSelectModifier = GDK_SHIFT_MASK;
guint Keyboard::button2_modifiers = Keyboard::SecondaryModifier|Keyboard::Level4Modifier;
#else
guint Keyboard::PrimaryModifier = GDK_CONTROL_MASK; // Control
guint Keyboard::SecondaryModifier = GDK_MOD1_MASK; // Alt/Option
@ -68,8 +69,10 @@ guint Keyboard::TertiaryModifier = GDK_SHIFT_MASK; // Shift
guint Keyboard::Level4Modifier = GDK_MOD4_MASK; // Mod4/Windows
guint Keyboard::CopyModifier = GDK_CONTROL_MASK;
guint Keyboard::RangeSelectModifier = GDK_SHIFT_MASK;
guint Keyboard::button2_modifiers = 0; /* not used */
#endif
Keyboard* Keyboard::_the_keyboard = 0;
Gtk::Window* Keyboard::current_window = 0;
bool Keyboard::_some_magic_widget_has_focus = false;
@ -375,6 +378,18 @@ Keyboard::is_edit_event (GdkEventButton *ev)
((ev->state & RelevantModifierKeyMask) == Keyboard::edit_modifier());
}
bool
Keyboard::is_button2_event (GdkEventButton* ev)
{
#ifdef GTKOSX
return (ev->button == 2) ||
((ev->button == 1) &&
((ev->state & Keyboard::button2_modifiers) == Keyboard::button2_modifiers));
#else
return ev->button == 2;
#endif
}
bool
Keyboard::is_delete_event (GdkEventButton *ev)
{

View File

@ -108,6 +108,7 @@ class Keyboard : public sigc::trackable, Stateful
static bool is_edit_event (GdkEventButton*);
static bool is_delete_event (GdkEventButton*);
static bool is_context_menu_event (GdkEventButton*);
static bool is_button2_event (GdkEventButton*);
static Keyboard& the_keyboard() { return *_the_keyboard; }
@ -144,6 +145,7 @@ class Keyboard : public sigc::trackable, Stateful
static guint delete_but;
static guint delete_mod;
static guint snap_mod;
static guint button2_modifiers;
static Gtk::Window* current_window;
static std::string user_keybindings_path;
static bool can_save_keybindings;

View File

@ -349,7 +349,7 @@ RedirectBox::redirect_button_release_event (GdkEventButton *ev)
show_redirect_menu(ev->time);
ret = true;
} else if (redirect && (ev->button == 2) && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))) {
} else if (redirect && Keyboard::is_button2_event (ev) && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))) {
/* button2-click with no modifiers */

View File

@ -218,7 +218,7 @@ RouteUI::mute_press(GdkEventButton* ev)
} else {
if (ev->button == 2) {
if (Keyboard::is_button2_event (ev)) {
// Primary-button2 click is the midi binding click
// button2-click is "momentary"
@ -229,7 +229,7 @@ RouteUI::mute_press(GdkEventButton* ev)
}
}
if (ev->button == 1 || ev->button == 2) {
if (ev->button == 1 || Keyboard::is_button2_event (ev)) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
@ -301,7 +301,7 @@ RouteUI::solo_press(GdkEventButton* ev)
} else {
if (ev->button == 2) {
if (Keyboard::is_button2_event (ev)) {
// Primary-button2 click is the midi binding click
// button2-click is "momentary"
@ -313,7 +313,7 @@ RouteUI::solo_press(GdkEventButton* ev)
}
}
if (ev->button == 1 || ev->button == 2) {
if (ev->button == 1 || Keyboard::is_button2_event (ev)) {
if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
@ -398,7 +398,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev)
if (!ignore_toggle && is_track() && rec_enable_button) {
if (ev->button == 2 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
// do nothing on midi bind event
return false;