aboutsummaryrefslogtreecommitdiff
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-05-16 01:08:00 +0000
committerDavid Robillard <d@drobilla.net>2014-05-16 01:08:00 +0000
commitc6454d69b012d1023f375686cba29d6344ccc1d5 (patch)
treed8f36833bd32ada612538e637d28e867c523f4b7 /pugl
parent85ee7c8408240526ed8b7c9877c7fe15536aa7f2 (diff)
downloadcanvas_display.lv2-c6454d69b012d1023f375686cba29d6344ccc1d5.tar.xz
Fix compilation and event handling (except keys) on OSX.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/pugl_osx.m66
1 files changed, 42 insertions, 24 deletions
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index e50e518..346d833 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -60,7 +60,7 @@
- (void)setPuglview:(PuglView*)view
{
puglview = view;
- [self setContentSize:NSMakeSize(view->width, view->height) ];
+ [self setContentSize:NSMakeSize(view->width, view->height)];
}
- (BOOL)windowShouldClose:(id)sender
@@ -70,6 +70,16 @@
return YES;
}
+- (BOOL) canBecomeKeyWindow
+{
+ return YES;
+}
+
+- (BOOL) canBecomeMainWindow
+{
+ return YES;
+}
+
@end
static void
@@ -178,6 +188,11 @@ puglDisplay(PuglView* view)
glSwapAPPLE();
}
+- (BOOL) acceptsFirstResponder
+{
+ return YES;
+}
+
static unsigned
getModifiers(PuglView* view, NSEvent* ev)
{
@@ -333,30 +348,24 @@ getModifiers(PuglView* view, NSEvent* ev)
@end
struct PuglInternalsImpl {
+ NSApplication* app;
PuglOpenGLView* glview;
id window;
};
-PuglView*
-puglCreate(PuglNativeWindow parent,
- const char* title,
- int width,
- int height,
- bool resizable,
- bool visible)
-{
- PuglView* view = (PuglView*)calloc(1, sizeof(PuglView));
- PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals));
- if (!view || !impl) {
- return NULL;
- }
+PuglInternals*
+puglInitInternals()
+{
+ return (PuglInternals*)calloc(1, sizeof(PuglInternals));
+}
- view->impl = impl;
- view->width = width;
- view->height = height;
+int
+puglCreateWindow(PuglView* view, const char* title)
+{
+ PuglInternals* impl = view->impl;
[NSAutoreleasePool new];
- [NSApplication sharedApplication];
+ impl->app = [NSApplication sharedApplication];
NSString* titleString = [[NSString alloc]
initWithBytes:title
@@ -373,16 +382,23 @@ puglCreate(PuglNativeWindow parent,
impl->glview->puglview = view;
[window setContentView:impl->glview];
- [NSApp activateIgnoringOtherApps:YES];
+ [impl->app activateIgnoringOtherApps:YES];
[window makeFirstResponder:impl->glview];
-
[window makeKeyAndOrderFront:window];
- if (!visible) {
- [window setIsVisible:NO];
- }
+ return 0;
+}
- return view;
+void
+puglShowWindow(PuglView* view)
+{
+ [view->impl->window setIsVisible:YES];
+}
+
+void
+puglHideWindow(PuglView* view)
+{
+ [view->impl->window setIsVisible:NO];
}
void
@@ -399,6 +415,8 @@ puglDestroy(PuglView* view)
PuglStatus
puglProcessEvents(PuglView* view)
{
+ NSEvent* ev = [view->impl->window nextEventMatchingMask: NSAnyEventMask];
+ [view->impl->app sendEvent: ev];
[view->impl->glview setNeedsDisplay: YES];
return PUGL_SUCCESS;