consolidate NSGLView
authorRobin Gareus <robin@gareus.org>
Tue, 21 Mar 2017 14:45:21 +0000 (15:45 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 21 Mar 2017 14:53:29 +0000 (15:53 +0100)
libs/canvas/canvas.cc
libs/gtkmm2ext/cairo_widget.cc
libs/gtkmm2ext/nsglview.mm

index 1995608a9fcd346f6f7d8a5031cf8306d84b0def..eb40f785dd0361a035948ea7d98272da6c34145e 100644 (file)
@@ -409,9 +409,7 @@ GtkCanvas::use_nsglview ()
        assert (!_nsglview);
        assert (!is_realized());
 #ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h
-# ifndef __ppc__ // would need to flip RGBA <> RGBA
        _nsglview = Gtkmm2ext::nsglview_create (this);
-# endif
 #endif
 }
 
index d06f07ced29c45c67a9a36936e030bc2ea1b760f..4cf3fc3ae667e925f4f128f68fa6ed2d2b4da101 100644 (file)
@@ -85,10 +85,8 @@ CairoWidget::use_nsglview ()
        assert (!_canvas_widget);
        assert (!is_realized());
 #ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h
-# ifndef __ppc__ // would need to flip RGBA <> RGBA
        _nsglview = Gtkmm2ext::nsglview_create (this);
 #endif
-#endif
 }
 
 int
index 6c84eef494fc2c0c1fce4d561f1aaa014d7c745e..9115fc72875a1535753f4a8db27f14350df4ffb7 100644 (file)
 
 */
 
-/* the API is currently only used on intel mac
- * for big-endian  RGBA <> RGBA byte order of the texture
- * will have to be swapped.
- *
- * Also it does not currently compile as-is:
- *
- *   warning: Mac OS X version 10.5 or later is needed for use of property
- *   error: synthesized property 'tag' must either be named the same as a compatible ivar or must explicitly name an ivar
- *
- * the wscipt would have to relax MAC_OS_X_VERSION_MIN_REQUIRED=1040
- * (ardour's PPC build-stack is 10.5)
- */
-#ifndef __ppc__
-
 /* include order matter due to apple defines */
 #include <gtkmm/window.h>
 
 #include <OpenGL/gl.h>
 #import  <Cocoa/Cocoa.h>
 
+/* the gtk-quartz library which ardour links against
+ * is patched to pass events directly through to
+ * NSView child-views (AU Plugin GUIs).
+ *
+ * In this particular case however we do want the
+ * events to reach the GTK widget instead of the
+ * NSView subview.
+ *
+ * If a NSVIew tag equals to the given magic-number,
+ * Gdk events propagate.
+ */
 #ifndef ARDOUR_CANVAS_NSVIEW_TAG
-#define ARDOUR_CANVAS_NSVIEW_TAG 0xa2d0c2c4
+#define ARDOUR_CANVAS_NSVIEW_TAG 0x0
 #endif
 
 __attribute__ ((visibility ("hidden")))
@@ -58,6 +55,7 @@ __attribute__ ((visibility ("hidden")))
        int _height;
        Cairo::RefPtr<Cairo::ImageSurface> surf;
        Gtkmm2ext::CairoCanvas *cairo_canvas;
+       NSInteger _tag;
 }
 
 @property (readwrite) NSInteger tag;
@@ -74,7 +72,7 @@ __attribute__ ((visibility ("hidden")))
 
 @implementation ArdourCanvasOpenGLView
 
-@synthesize tag = tag;
+@synthesize tag = _tag;
 
 - (id) initWithFrame:(NSRect)frame
 {
@@ -260,6 +258,7 @@ __attribute__ ((visibility ("hidden")))
        glFlush();
        glSwapAPPLE();
        [NSOpenGLContext clearCurrentContext];
+       [super setNeedsDisplay:NO];
 }
 @end
 
@@ -267,6 +266,13 @@ __attribute__ ((visibility ("hidden")))
 void*
 Gtkmm2ext::nsglview_create (Gtkmm2ext::CairoCanvas* canvas)
 {
+/* the API is currently only used on intel mac
+ * for big-endian  RGBA <> RGBA byte order of the texture
+ * will have to be swapped.
+ */
+#ifdef __ppc__
+       return 0;
+#endif
        ArdourCanvasOpenGLView* gl_view = [ArdourCanvasOpenGLView new];
        if (!gl_view) {
                return 0;
@@ -308,5 +314,3 @@ Gtkmm2ext::nsglview_set_visible (void* glv, bool vis)
                [gl_view setHidden:YES];
        }
 }
-
-#endif