aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-16 16:13:50 +0100
committerDavid Robillard <d@drobilla.net>2020-03-16 16:13:50 +0100
commit67b7970697011bbd26fbf4175eb2e5ebd1b00939 (patch)
tree4c76fdb48e2280b3caa81b3647b3ea22989b7e12 /pugl
parentab7df6c8f3dfd820331ef96c217c0fc477972835 (diff)
downloadpugl-67b7970697011bbd26fbf4175eb2e5ebd1b00939.tar.gz
pugl-67b7970697011bbd26fbf4175eb2e5ebd1b00939.tar.bz2
pugl-67b7970697011bbd26fbf4175eb2e5ebd1b00939.zip
Factor out dispatching configure events in the drawing context
The updates here need to happen whenever a configure is dispatched, even outside puglDispatchEvent(). This removes the last remaining direct calls to the event callback so the common implementation can always do the right thing.
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;