aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
Diffstat (limited to 'pugl')
-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;
}