diff options
author | David Robillard <d@drobilla.net> | 2023-01-07 19:27:00 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-01-07 19:27:00 -0500 |
commit | 28631e2b202e661084039464f45228b9ce323a8f (patch) | |
tree | 6b8d7f586052093e3d47e33d6db04f71406c1bdb /src/internal.c | |
parent | b6ecd23cfb3c82c2c3f05795ebd9c65314e6367c (diff) | |
download | pugl-28631e2b202e661084039464f45228b9ce323a8f.tar.gz pugl-28631e2b202e661084039464f45228b9ce323a8f.tar.bz2 pugl-28631e2b202e661084039464f45228b9ce323a8f.zip |
Replace visible flag with a more descriptive view "stage"
Diffstat (limited to 'src/internal.c')
-rw-r--r-- | src/internal.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/internal.c b/src/internal.c index 2f277bb..ef1bcef 100644 --- a/src/internal.c +++ b/src/internal.c @@ -182,39 +182,60 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) switch (event->type) { case PUGL_NOTHING: break; + case PUGL_CREATE: + assert(view->stage == PUGL_VIEW_STAGE_ALLOCATED); + if (!(st0 = view->backend->enter(view, NULL))) { + st0 = view->eventFunc(view, event); + st1 = view->backend->leave(view, NULL); + } + view->stage = PUGL_VIEW_STAGE_CREATED; + break; + case PUGL_DESTROY: + assert(view->stage >= PUGL_VIEW_STAGE_CREATED); if (!(st0 = view->backend->enter(view, NULL))) { st0 = view->eventFunc(view, event); st1 = view->backend->leave(view, NULL); } + view->stage = PUGL_VIEW_STAGE_ALLOCATED; break; + case PUGL_CONFIGURE: + assert(view->stage >= PUGL_VIEW_STAGE_CREATED); if (puglMustConfigure(view, &event->configure)) { if (!(st0 = view->backend->enter(view, NULL))) { st0 = puglConfigure(view, event); st1 = view->backend->leave(view, NULL); } } + if (view->stage == PUGL_VIEW_STAGE_CREATED) { + view->stage = PUGL_VIEW_STAGE_CONFIGURED; + } break; + case PUGL_MAP: - if (!view->visible) { - view->visible = true; - st0 = view->eventFunc(view, event); + assert(view->stage >= PUGL_VIEW_STAGE_CONFIGURED); + if (view->stage != PUGL_VIEW_STAGE_MAPPED) { + st0 = view->eventFunc(view, event); + view->stage = PUGL_VIEW_STAGE_MAPPED; } break; + case PUGL_UNMAP: - if (view->visible) { - view->visible = false; - st0 = view->eventFunc(view, event); - } + assert(view->stage == PUGL_VIEW_STAGE_MAPPED); + st0 = view->eventFunc(view, event); + view->stage = PUGL_VIEW_STAGE_CONFIGURED; break; + case PUGL_EXPOSE: + assert(view->stage == PUGL_VIEW_STAGE_MAPPED); if (!(st0 = view->backend->enter(view, &event->expose))) { st0 = puglExpose(view, event); st1 = view->backend->leave(view, &event->expose); } break; + default: st0 = view->eventFunc(view, event); } |