aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
Diffstat (limited to 'pugl')
-rw-r--r--pugl/detail/implementation.c25
-rw-r--r--pugl/detail/implementation.h3
-rw-r--r--pugl/detail/mac.m2
-rw-r--r--pugl/detail/x11.c4
4 files changed, 25 insertions, 9 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c
index d7e7058..4e1b3de 100644
--- a/pugl/detail/implementation.c
+++ b/pugl/detail/implementation.c
@@ -388,6 +388,24 @@ puglDispatchSimpleEvent(PuglView* view, const PuglEventType type)
}
void
+puglDispatchEventInContext(PuglView* view, const PuglEvent* event)
+{
+ if (event->type == PUGL_CONFIGURE) {
+ view->frame.x = event->configure.x;
+ view->frame.y = event->configure.y;
+ view->frame.width = event->configure.width;
+ view->frame.height = event->configure.height;
+
+ if (puglMustConfigure(view, &event->configure)) {
+ view->eventFunc(view, event);
+ view->configured = true;
+ }
+ } else {
+ view->eventFunc(view, event);
+ }
+}
+
+void
puglDispatchEvent(PuglView* view, const PuglEvent* event)
{
switch (event->type) {
@@ -401,13 +419,8 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event)
break;
case PUGL_CONFIGURE:
if (puglMustConfigure(view, &event->configure)) {
- view->frame.x = event->configure.x;
- view->frame.y = event->configure.y;
- view->frame.width = event->configure.width;
- view->frame.height = event->configure.height;
-
view->backend->enter(view, NULL);
- view->eventFunc(view, event);
+ puglDispatchEventInContext(view, event);
view->backend->leave(view, NULL);
}
break;
diff --git a/pugl/detail/implementation.h b/pugl/detail/implementation.h
index 2ad3f65..bcecd85 100644
--- a/pugl/detail/implementation.h
+++ b/pugl/detail/implementation.h
@@ -54,6 +54,9 @@ uint32_t puglDecodeUTF8(const uint8_t* buf);
/** Dispatch an event with a simple `type` to `view`. */
void puglDispatchSimpleEvent(PuglView* view, PuglEventType type);
+/** Dispatch `event` to `view` while already in the graphics context. */
+void puglDispatchEventInContext(PuglView* view, const PuglEvent* event);
+
/** Dispatch `event` to `view`, entering graphics context if necessary. */
void puglDispatchEvent(PuglView* view, const PuglEvent* event);
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m
index 2ec4345..6b02c75 100644
--- a/pugl/detail/mac.m
+++ b/pugl/detail/mac.m
@@ -969,7 +969,7 @@ dispatchClientEvent(PuglWorld* world, NSEvent* ev)
[ev data1],
[ev data2]};
- view->eventFunc(view, (const PuglEvent*)&event);
+ puglDispatchEvent(view, (const PuglEvent*)&event);
}
}
}
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c
index 5fc769d..72dcf59 100644
--- a/pugl/detail/x11.c
+++ b/pugl/detail/x11.c
@@ -755,8 +755,8 @@ flushExposures(PuglWorld* world)
if (configure->type || expose->type) {
view->backend->enter(view, expose->type ? &expose->expose : NULL);
- view->eventFunc(view, configure);
- view->eventFunc(view, expose);
+ puglDispatchEventInContext(view, configure);
+ puglDispatchEventInContext(view, expose);
view->backend->leave(view, expose->type ? &expose->expose : NULL);
configure->type = 0;