Use NSGLView with patched gdk
authorRobin Gareus <robin@gareus.org>
Mon, 20 Mar 2017 01:15:15 +0000 (02:15 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 20 Mar 2017 01:15:15 +0000 (02:15 +0100)
Special case Ardour's Canvas NSView to forward gdk-events
which are otherwise special-cased to read AU-views..

libs/canvas/canvas.cc
libs/canvas/nsglview.mm

index 70fd36e8b541921c8e115f2cc8a23d5f43508b4d..52bff497af5339d30898b4e29d9cba165f9054ce 100644 (file)
@@ -45,6 +45,7 @@
 #include "canvas/utils.h"
 
 #ifdef __APPLE__
+#include <gdk/gdk.h>
 #include "canvas/nsglview.h"
 #endif
 
@@ -401,7 +402,7 @@ GtkCanvas::GtkCanvas ()
                    Gdk::SCROLL_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK |
                    Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
 
-#ifdef __APPLE__NotYetToDueGdkForeignViewMousePatch // XXX
+#ifdef ARDOUR_CANVAS_NSVIEW_TAG // patched gdkquartz.h
 # ifndef __ppc__ // would need to flip RGBA <> RGBA
        _nsglview = nsglview_create (this);
 # endif
index 09d0ae13424ce9e4a474b345a2d442784956c6d5..b4fea995a32f69410701c1d72d65872c2dde94f4 100644 (file)
 #include <OpenGL/gl.h>
 #import  <Cocoa/Cocoa.h>
 
+#ifndef ARDOUR_CANVAS_NSVIEW_TAG
+#define ARDOUR_CANVAS_NSVIEW_TAG 0xa2d0c2c4
+#endif
+
 __attribute__ ((visibility ("hidden")))
 @interface ArdourCanvasOpenGLView : NSOpenGLView
 {
@@ -42,9 +46,11 @@ __attribute__ ((visibility ("hidden")))
        ArdourCanvas::GtkCanvas *gtkcanvas;
 }
 
+@property (readwrite) NSInteger tag;
+
 - (id) initWithFrame:(NSRect)frame;
 - (void) dealloc;
-- (void) set_ardour_canvas:(ArdourCanvas::GtkCanvas*)c;
+- (void) setArdourCanvas:(ArdourCanvas::GtkCanvas*)c;
 - (void) reshape;
 - (void) drawRect:(NSRect)rect;
 - (BOOL) canBecomeKeyWindow:(id)sender;
@@ -54,6 +60,8 @@ __attribute__ ((visibility ("hidden")))
 
 @implementation ArdourCanvasOpenGLView
 
+@synthesize tag = _tag;
+
 - (id) initWithFrame:(NSRect)frame
 {
        NSOpenGLPixelFormatAttribute pixelAttribs[16] = {
@@ -82,7 +90,7 @@ __attribute__ ((visibility ("hidden")))
        _height = 0;
 
        if (self) {
-
+               self.tag = ARDOUR_CANVAS_NSVIEW_TAG;
                [[self openGLContext] makeCurrentContext];
                glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
                glDisable (GL_DEPTH_TEST);
@@ -105,7 +113,7 @@ __attribute__ ((visibility ("hidden")))
        [super dealloc];
 }
 
-- (void) set_ardour_canvas:(ArdourCanvas::GtkCanvas*)c
+- (void) setArdourCanvas:(ArdourCanvas::GtkCanvas*)c
 {
        gtkcanvas = c;
 }
@@ -242,7 +250,7 @@ ArdourCanvas::nsglview_create (GtkCanvas* canvas)
        if (!gl_view) {
                return 0;
        }
-       [gl_view set_ardour_canvas:canvas];
+       [gl_view setArdourCanvas:canvas];
        return gl_view;
 }