aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-10-27 18:30:14 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-10-27 18:30:14 +0200
commit6697cbbf5eba0116b3012ab5318153c96007b376 (patch)
tree36522a3bc1a406f1b82f3d1ed584e8539c3f4a31
parentb0a89a03a800bb023fa115d7129272e880984dc6 (diff)
parent5afaf317c6380c4d950473408a94116a46f333cf (diff)
downloadcanvas.lv2-6697cbbf5eba0116b3012ab5318153c96007b376.zip
canvas.lv2-6697cbbf5eba0116b3012ab5318153c96007b376.tar.gz
canvas.lv2-6697cbbf5eba0116b3012ab5318153c96007b376.tar.bz2
canvas.lv2-6697cbbf5eba0116b3012ab5318153c96007b376.tar.xz
Merge commit '5afaf317c6380c4d950473408a94116a46f333cf'
-rw-r--r--pugl/pugl/pugl_osx.m49
-rw-r--r--pugl/pugl_test.c1
2 files changed, 30 insertions, 20 deletions
diff --git a/pugl/pugl/pugl_osx.m b/pugl/pugl/pugl_osx.m
index f495811..e8ecc98 100644
--- a/pugl/pugl/pugl_osx.m
+++ b/pugl/pugl/pugl_osx.m
@@ -109,14 +109,6 @@ struct PuglInternalsImpl {
@end
-static void
-puglDisplay(PuglView* view)
-{
- if (view->displayFunc) {
- view->displayFunc(view);
- }
-}
-
@interface PuglOpenGLView : NSOpenGLView
{
@public
@@ -211,7 +203,18 @@ puglDisplay(PuglView* view)
- (void) drawRect:(NSRect)rect
{
- puglDisplay(puglview);
+ const PuglEventExpose ev = {
+ PUGL_EXPOSE,
+ puglview,
+ 0,
+ rect.origin.x,
+ rect.origin.y,
+ rect.size.width,
+ rect.size.height,
+ 0
+ };
+
+ puglDispatchEvent(puglview, (const PuglEvent*)&ev);
#ifdef PUGL_HAVE_CAIRO
if (puglview->ctx_type & PUGL_CAIRO) {
@@ -219,8 +222,6 @@ puglDisplay(PuglView* view)
&puglview->impl->cairo_gl, puglview->width, puglview->height);
}
#endif
-
- [[self openGLContext] flushBuffer];
}
- (BOOL) acceptsFirstResponder
@@ -233,8 +234,6 @@ getModifiers(PuglView* view, NSEvent* ev)
{
const unsigned modifierFlags = [ev modifierFlags];
- view->event_timestamp_ms = fmod([ev timestamp] * 1000.0, UINT32_MAX);
-
unsigned mods = 0;
mods |= (modifierFlags & NSShiftKeyMask) ? PUGL_MOD_SHIFT : 0;
mods |= (modifierFlags & NSControlKeyMask) ? PUGL_MOD_CTRL : 0;
@@ -434,7 +433,8 @@ getModifiers(PuglView* view, NSEvent* ev)
- (void) flagsChanged:(NSEvent*)event
{
- if (puglview->specialFunc) {
+ // TODO: Is this a sensible way to handle special keys?
+ /*
const unsigned mods = getModifiers(puglview, event);
if ((mods & PUGL_MOD_SHIFT) != (puglview->mods & PUGL_MOD_SHIFT)) {
puglview->specialFunc(puglview, mods & PUGL_MOD_SHIFT, PUGL_KEY_SHIFT);
@@ -447,6 +447,7 @@ getModifiers(PuglView* view, NSEvent* ev)
}
puglview->mods = mods;
}
+ */
}
@end
@@ -585,13 +586,21 @@ puglWaitForEvent(PuglView* view)
PuglStatus
puglProcessEvents(PuglView* view)
{
- if (!view->impl->nextEvent) {
- view->impl->nextEvent = [view->impl->window
- nextEventMatchingMask: NSAnyEventMask];
- }
+ while (true) {
+ // Get the next event, or use the cached one from puglWaitForEvent
+ if (!view->impl->nextEvent) {
+ view->impl->nextEvent = [view->impl->window
+ nextEventMatchingMask: NSAnyEventMask];
+ }
+
+ if (!view->impl->nextEvent) {
+ break; // No events to process, done
+ }
- [view->impl->app sendEvent: view->impl->nextEvent];
- view->impl->nextEvent = NULL;
+ // Dispatch event
+ [view->impl->app sendEvent: view->impl->nextEvent];
+ view->impl->nextEvent = NULL;
+ }
return PUGL_SUCCESS;
}
diff --git a/pugl/pugl_test.c b/pugl/pugl_test.c
index 4a3d066..367e7a4 100644
--- a/pugl/pugl_test.c
+++ b/pugl/pugl_test.c
@@ -182,6 +182,7 @@ onEvent(PuglView* view, const PuglEvent* event)
(event->type == PUGL_BUTTON_PRESS) ? "down" : "up",
event->button.x,
event->button.y);
+ printModifiers(view, event->scroll.state);
break;
case PUGL_SCROLL:
fprintf(stderr, "Scroll %f %f %f %f ",