aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pugl/pugl_internal.h27
1 files changed, 16 insertions, 11 deletions
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index aeb580d..44fe103 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -219,19 +219,24 @@ puglDecodeUTF8(const uint8_t* buf)
static void
puglDispatchEvent(PuglView* view, const PuglEvent* event)
{
- if (event->type == PUGL_NOTHING) {
- return;
- } else if (event->type == PUGL_EXPOSE && event->expose.count > 0) {
- return;
- } else if (view->eventFunc) {
- const bool is_draw = (event->type == PUGL_CONFIGURE ||
- event->type == PUGL_EXPOSE);
- if (is_draw) {
+ switch (event->type) {
+ case PUGL_NOTHING:
+ break;
+ case PUGL_CONFIGURE:
+ view->width = event->configure.width;
+ view->height = event->configure.height;
+ puglEnterContext(view);
+ view->eventFunc(view, event);
+ puglLeaveContext(view, false);
+ break;
+ case PUGL_EXPOSE:
+ if (event->expose.count == 0) {
puglEnterContext(view);
+ view->eventFunc(view, event);
+ puglLeaveContext(view, true);
}
+ break;
+ default:
view->eventFunc(view, event);
- if (is_draw) {
- puglLeaveContext(view, event->type == PUGL_EXPOSE);
- }
}
}