diff options
author | David Robillard <d@drobilla.net> | 2019-09-07 14:16:19 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-07 14:40:39 +0200 |
commit | dc9f1d852d3fba8ddcf7bb535810ad384900fe06 (patch) | |
tree | b3ea2e2b5be850fa3b42c476ae03f04d960b0433 /pugl/detail/x11.c | |
parent | 7162fa4f5656ad7dfe2d6fea02f9f33c5aa1b1cf (diff) | |
download | pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.gz pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.tar.bz2 pugl-dc9f1d852d3fba8ddcf7bb535810ad384900fe06.zip |
Clean up error handling
Diffstat (limited to 'pugl/detail/x11.c')
-rw-r--r-- | pugl/detail/x11.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index adf8c9d..429d89f 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -127,7 +127,8 @@ puglPollEvents(PuglWorld* world, const double timeout) ret = select(nfds, &fds, NULL, NULL, &tv); } - return ret < 0 ? PUGL_ERR_UNKNOWN : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS; + return ret < 0 ? PUGL_UNKNOWN_ERROR + : ret == 0 ? PUGL_FAILURE : PUGL_SUCCESS; } static PuglView* @@ -185,10 +186,13 @@ puglCreateWindow(PuglView* view, const char* title) impl->screen = DefaultScreen(display); if (!view->backend || !view->backend->configure) { - return 1; - } else if (view->backend->configure(view) || !impl->vi) { + return PUGL_BAD_BACKEND; + } + + PuglStatus st = view->backend->configure(view); + if (st || !impl->vi) { view->backend->destroy(view); - return 2; + return st ? st : PUGL_BACKEND_FAILED; } Window xParent = view->parent ? (Window)view->parent @@ -207,8 +211,8 @@ puglCreateWindow(PuglView* view, const char* title) 0, impl->vi->depth, InputOutput, impl->vi->visual, CWColormap | CWEventMask, &attr); - if (view->backend->create(view)) { - return 3; + if ((st = view->backend->create(view))) { + return st; } XSizeHints sizeHints = getSizeHints(view); @@ -239,7 +243,7 @@ puglCreateWindow(PuglView* view, const char* title) fprintf(stderr, "warning: XCreateIC failed\n"); } - return 0; + return PUGL_SUCCESS; } PuglStatus @@ -793,7 +797,7 @@ puglSetFrame(PuglView* view, const PuglRect frame) XMoveResizeWindow(view->world->impl->display, view->impl->win, (int)frame.x, (int)frame.y, (int)frame.width, (int)frame.height)) { - return PUGL_ERR_UNKNOWN; + return PUGL_UNKNOWN_ERROR; } return PUGL_SUCCESS; |