Fix crash when X11 is not available for VST UIs
[ardour.git] / gtk2_ardour / port_matrix_grid.cc
index a4ca3df1b810d021123df3b98f5ef3e5619d39fc..861794cc24173eb3430e8af23ca64349fcc143a1 100644 (file)
@@ -1,26 +1,26 @@
 /*
-    Copyright (C) 2002-2009 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2009-2013 Paul Davis <paul@linuxaudiosystems.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <iostream>
-#include <cairo/cairo.h>
+#include <cairo.h>
 #include "ardour/bundle.h"
-#include "ardour/types.h"
 #include "port_matrix_grid.h"
 #include "port_matrix.h"
 #include "port_matrix_body.h"
@@ -138,7 +138,7 @@ PortMatrixGrid::render (cairo_t* cr)
                cairo_line_to (cr, _width, y);
                cairo_stroke (cr);
        }
-       
+
        /* ASSOCIATION INDICATORS and NON-CONNECTABLE INDICATORS */
 
        /* we draw a grey square in a matrix box if the two ports that intersect at that box
@@ -231,7 +231,7 @@ PortMatrixGrid::render (cairo_t* cr)
                                                */
                                                draw_non_connectable_indicator (cr, x, y);
                                        }
-                                       
+
                                        x += grid_spacing();
                                }
 
@@ -312,12 +312,12 @@ PortMatrixGrid::position_to_node (double x, double y) const
 }
 
 void
-PortMatrixGrid::button_press (double x, double y, int b, uint32_t t, guint)
+PortMatrixGrid::button_press (double x, double y, GdkEventButton* ev)
 {
        ARDOUR::BundleChannel const px = position_to_channel (x, y, _matrix->visible_columns());
        ARDOUR::BundleChannel const py = position_to_channel (y, x, _matrix->visible_rows());
 
-       if (b == 1) {
+       if (ev->button == 1) {
 
                _dragging = true;
                _drag_valid = (px.bundle && py.bundle);
@@ -326,9 +326,9 @@ PortMatrixGrid::button_press (double x, double y, int b, uint32_t t, guint)
                _drag_start_x = x / grid_spacing ();
                _drag_start_y = y / grid_spacing ();
 
-       } else if (b == 3) {
+       } else if (ev->button == 3) {
 
-               _matrix->popup_menu (px, py, t);
+               _matrix->popup_menu (px, py, ev->time);
 
        }
 }
@@ -366,9 +366,9 @@ PortMatrixGrid::set_association (PortMatrixNode node, bool s)
 }
 
 void
-PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint s)
+PortMatrixGrid::button_release (double x, double y, GdkEventButton* ev)
 {
-       if (b == 1) {
+       if (ev->button == 1) {
 
                if (x != -1) {
 
@@ -387,7 +387,7 @@ PortMatrixGrid::button_release (double x, double y, int b, uint32_t /*t*/, guint
 
                        } else {
 
-                               if (Keyboard::modifier_state_equals (s, Keyboard::PrimaryModifier)) {
+                               if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
                                        /* associate/disassociate things diagonally down and right until we run out */
                                        PortMatrixNode::State s = (PortMatrixNode::State) 0;
                                        while (1) {