13
0

Use NSGLView with patched gdk

Special case Ardour's Canvas NSView to forward gdk-events
which are otherwise special-cased to read AU-views..
This commit is contained in:
Robin Gareus 2017-03-20 02:15:15 +01:00
parent c371fc5115
commit 5fe355af92
2 changed files with 14 additions and 5 deletions

View 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

View File

@ -31,6 +31,10 @@
#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;
}