aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-09-14 15:59:26 -0400
committerDavid Robillard <d@drobilla.net>2015-09-14 15:59:26 -0400
commit845061e593cc8d62fd2ca2295e5b013687a1ec2d (patch)
treeec49ed2a16a65c60a23b35d045fb70377638ca34
parent117556327a6e87843ae3c187ecc5d37bec0b3477 (diff)
downloadpugl-845061e593cc8d62fd2ca2295e5b013687a1ec2d.tar.gz
pugl-845061e593cc8d62fd2ca2295e5b013687a1ec2d.tar.bz2
pugl-845061e593cc8d62fd2ca2295e5b013687a1ec2d.zip
Fix events on OSX.
-rw-r--r--pugl/pugl_osx.m23
1 files changed, 15 insertions, 8 deletions
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index f41c863..1f31bdf 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -418,6 +418,7 @@ struct PuglInternalsImpl {
NSApplication* app;
PuglOpenGLView* glview;
id window;
+ NSEvent* nextEvent;
};
PuglInternals*
@@ -527,9 +528,14 @@ puglGrabFocus(PuglView* view)
PuglStatus
puglWaitForEvent(PuglView* view)
{
- [view->impl->window nextEventMatchingMask: NSAnyEventMask
- untilDate: [NSDate distantFuture]
- dequeue: NO];
+ /* OSX supposedly has queue: and untilDate: selectors that can be used for
+ a blocking non-queueing event check, but if used here cause an
+ unsupported selector error at runtime. I have no idea why, so just get
+ the event and keep it around until the call to puglProcessEvents. */
+ if (!view->impl->nextEvent) {
+ view->impl->nextEvent = [view->impl->window
+ nextEventMatchingMask: NSAnyEventMask];
+ }
return PUGL_SUCCESS;
}
@@ -537,13 +543,14 @@ puglWaitForEvent(PuglView* view)
PuglStatus
puglProcessEvents(PuglView* view)
{
- NSEvent* ev = [view->impl->window nextEventMatchingMask: NSAnyEventMask
- untilDate: [NSDate distantPast]];
-
- if (ev) {
- [view->impl->app sendEvent: ev];
+ if (!view->impl->nextEvent) {
+ view->impl->nextEvent = [view->impl->window
+ nextEventMatchingMask: NSAnyEventMask];
}
+ [view->impl->app sendEvent: view->impl->nextEvent];
+ view->impl->nextEvent = NULL;
+
return PUGL_SUCCESS;
}