meta-fy handling of button2, to deal with apple's messed up design decisions; on...
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 3 Nov 2008 17:05:17 +0000 (17:05 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 3 Nov 2008 17:05:17 +0000 (17:05 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4087 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/crossfade_edit.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/gain_meter.cc
gtk2_ardour/keyboard.cc
gtk2_ardour/keyboard.h
gtk2_ardour/redirect_box.cc
gtk2_ardour/route_ui.cc

index 2c0085c7963f1d74a0a6a15d072714d2c5787ecd..c5d7b72db4261d5ed55acd1f18ec2d05ba5466eb 100644 (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;
index a3585d2872ece1e8fe030c2da7b143c85882ae85..7b526c86e629ed761e937e5113e3ca3f5a620157 100644 (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;
index 1d05d438762a1fde3d6cb879053b129b6770663c..3e60b3912852c53ddee1725deec7c7aee30257ee 100644 (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))) {
 
index e5fb8d8b1014fa1202852202f1bc06da3d7f5d42..4b0a810429ce1e4dc98db303ab6a77dff38c012c 100644 (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)
 {
index 2b6d7c456427c708974a1d884b814c83416564f0..e8ded792b9f0de89e494cc592a450ce531613a86 100644 (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;
index 6748034cfaa4f0bbd3db1d608bc137f43c0a492e..155fa4e1e6a8d532892b76f21e3400ac1a3b0b81 100644 (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 */
 
index a46a61314c7f6dfc9e507026dde02b6ffd93e595..de6b6cfad9b8b90b7f24d90e46c3b94b278d0e50 100644 (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;