aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_redisplay.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-02 21:09:27 +0100
committerDavid Robillard <d@drobilla.net>2021-01-02 21:09:27 +0100
commit1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712 (patch)
tree4b77266a9ce3e2a11b59bbd2754869c6ee1d172b /test/test_redisplay.c
parenta92a194b4fc64e0cfa4a88a59e261f236414d61c (diff)
downloadpugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.gz
pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.bz2
pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.zip
Simplify clang-format configuration and format all code
Diffstat (limited to 'test/test_redisplay.c')
-rw-r--r--test/test_redisplay.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/test/test_redisplay.c b/test/test_redisplay.c
index 1d5b084..c5b9887 100644
--- a/test/test_redisplay.c
+++ b/test/test_redisplay.c
@@ -38,19 +38,18 @@ static const double timeout = -1.0;
#endif
typedef enum {
- START,
- EXPOSED,
- SHOULD_REDISPLAY,
- POSTED_REDISPLAY,
- REDISPLAYED,
+ START,
+ EXPOSED,
+ SHOULD_REDISPLAY,
+ POSTED_REDISPLAY,
+ REDISPLAYED,
} State;
-typedef struct
-{
- PuglWorld* world;
- PuglView* view;
- PuglTestOptions opts;
- State state;
+typedef struct {
+ PuglWorld* world;
+ PuglView* view;
+ PuglTestOptions opts;
+ State state;
} PuglTest;
static const PuglRect redisplayRect = {2, 4, 8, 16};
@@ -59,83 +58,84 @@ static const uintptr_t postRedisplayId = 42;
static PuglStatus
onEvent(PuglView* view, const PuglEvent* event)
{
- PuglTest* test = (PuglTest*)puglGetHandle(view);
-
- if (test->opts.verbose) {
- printEvent(event, "Event: ", true);
- }
-
- switch (event->type) {
- case PUGL_UPDATE:
- if (test->state == SHOULD_REDISPLAY) {
- puglPostRedisplayRect(view, redisplayRect);
- test->state = POSTED_REDISPLAY;
- }
- break;
-
- case PUGL_EXPOSE:
- if (test->state == START) {
- test->state = EXPOSED;
- } else if (test->state == POSTED_REDISPLAY &&
- event->expose.x == redisplayRect.x &&
- event->expose.y == redisplayRect.y &&
- event->expose.width == redisplayRect.width &&
- event->expose.height == redisplayRect.height) {
- test->state = REDISPLAYED;
- }
- break;
-
- case PUGL_CLIENT:
- if (event->client.data1 == postRedisplayId) {
- test->state = SHOULD_REDISPLAY;
- }
- break;
-
- default: break;
- }
-
- return PUGL_SUCCESS;
+ PuglTest* test = (PuglTest*)puglGetHandle(view);
+
+ if (test->opts.verbose) {
+ printEvent(event, "Event: ", true);
+ }
+
+ switch (event->type) {
+ case PUGL_UPDATE:
+ if (test->state == SHOULD_REDISPLAY) {
+ puglPostRedisplayRect(view, redisplayRect);
+ test->state = POSTED_REDISPLAY;
+ }
+ break;
+
+ case PUGL_EXPOSE:
+ if (test->state == START) {
+ test->state = EXPOSED;
+ } else if (test->state == POSTED_REDISPLAY &&
+ event->expose.x == redisplayRect.x &&
+ event->expose.y == redisplayRect.y &&
+ event->expose.width == redisplayRect.width &&
+ event->expose.height == redisplayRect.height) {
+ test->state = REDISPLAYED;
+ }
+ break;
+
+ case PUGL_CLIENT:
+ if (event->client.data1 == postRedisplayId) {
+ test->state = SHOULD_REDISPLAY;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return PUGL_SUCCESS;
}
int
main(int argc, char** argv)
{
- PuglTest app = {puglNewWorld(PUGL_PROGRAM, 0),
- NULL,
- puglParseTestOptions(&argc, &argv),
- START};
-
- // Set up view
- app.view = puglNewView(app.world);
- puglSetClassName(app.world, "Pugl Test");
- puglSetBackend(app.view, puglStubBackend());
- puglSetHandle(app.view, &app);
- puglSetEventFunc(app.view, onEvent);
- puglSetDefaultSize(app.view, 512, 512);
-
- // Create and show window
- assert(!puglRealize(app.view));
- assert(!puglShow(app.view));
- while (app.state != EXPOSED) {
- assert(!puglUpdate(app.world, timeout));
- }
-
- // Send a custom event to trigger a redisplay in the event loop
- PuglEvent client_event = {{PUGL_CLIENT, 0}};
- client_event.client.data1 = postRedisplayId;
- client_event.client.data2 = 0;
- assert(!puglSendEvent(app.view, &client_event));
-
- // Loop until an expose happens in the same iteration as the redisplay
- app.state = SHOULD_REDISPLAY;
- while (app.state != REDISPLAYED) {
- assert(!puglUpdate(app.world, timeout));
- assert(app.state != POSTED_REDISPLAY);
- }
-
- // Tear down
- puglFreeView(app.view);
- puglFreeWorld(app.world);
-
- return 0;
+ PuglTest app = {puglNewWorld(PUGL_PROGRAM, 0),
+ NULL,
+ puglParseTestOptions(&argc, &argv),
+ START};
+
+ // Set up view
+ app.view = puglNewView(app.world);
+ puglSetClassName(app.world, "Pugl Test");
+ puglSetBackend(app.view, puglStubBackend());
+ puglSetHandle(app.view, &app);
+ puglSetEventFunc(app.view, onEvent);
+ puglSetDefaultSize(app.view, 512, 512);
+
+ // Create and show window
+ assert(!puglRealize(app.view));
+ assert(!puglShow(app.view));
+ while (app.state != EXPOSED) {
+ assert(!puglUpdate(app.world, timeout));
+ }
+
+ // Send a custom event to trigger a redisplay in the event loop
+ PuglEvent client_event = {{PUGL_CLIENT, 0}};
+ client_event.client.data1 = postRedisplayId;
+ client_event.client.data2 = 0;
+ assert(!puglSendEvent(app.view, &client_event));
+
+ // Loop until an expose happens in the same iteration as the redisplay
+ app.state = SHOULD_REDISPLAY;
+ while (app.state != REDISPLAYED) {
+ assert(!puglUpdate(app.world, timeout));
+ assert(app.state != POSTED_REDISPLAY);
+ }
+
+ // Tear down
+ puglFreeView(app.view);
+ puglFreeWorld(app.world);
+
+ return 0;
}