diff options
Diffstat (limited to 'pugl/detail')
-rw-r--r-- | pugl/detail/implementation.c | 24 | ||||
-rw-r--r-- | pugl/detail/mac_cairo.m | 8 | ||||
-rw-r--r-- | pugl/detail/mac_gl.m | 6 | ||||
-rw-r--r-- | pugl/detail/types.h | 8 | ||||
-rw-r--r-- | pugl/detail/win.c | 8 | ||||
-rw-r--r-- | pugl/detail/win_cairo.c | 36 | ||||
-rw-r--r-- | pugl/detail/win_gl.c | 8 | ||||
-rw-r--r-- | pugl/detail/x11.c | 11 | ||||
-rw-r--r-- | pugl/detail/x11_cairo.c | 8 | ||||
-rw-r--r-- | pugl/detail/x11_gl.c | 6 |
10 files changed, 61 insertions, 62 deletions
diff --git a/pugl/detail/implementation.c b/pugl/detail/implementation.c index df87276..917efa6 100644 --- a/pugl/detail/implementation.c +++ b/pugl/detail/implementation.c @@ -228,14 +228,22 @@ puglGetContext(PuglView* view) PuglStatus puglEnterContext(PuglView* view, bool drawing) { - view->backend->enter(view, drawing); + const PuglEventExpose expose = { + PUGL_EXPOSE, 0, 0, 0, view->frame.width, view->frame.height, 0}; + + view->backend->enter(view, drawing ? &expose : NULL); + return PUGL_SUCCESS; } PuglStatus puglLeaveContext(PuglView* view, bool drawing) { - view->backend->leave(view, drawing); + const PuglEventExpose expose = { + PUGL_EXPOSE, 0, 0, 0, view->frame.width, view->frame.height, 0}; + + view->backend->leave(view, drawing ? &expose : NULL); + return PUGL_SUCCESS; } @@ -287,16 +295,14 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) case PUGL_NOTHING: break; case PUGL_CONFIGURE: - puglEnterContext(view, false); + view->backend->enter(view, NULL); view->eventFunc(view, event); - puglLeaveContext(view, false); + view->backend->leave(view, NULL); break; case PUGL_EXPOSE: - if (event->expose.count == 0) { - puglEnterContext(view, true); - view->eventFunc(view, event); - puglLeaveContext(view, true); - } + view->backend->enter(view, &event->expose); + view->eventFunc(view, event); + view->backend->leave(view, &event->expose); break; default: view->eventFunc(view, event); diff --git a/pugl/detail/mac_cairo.m b/pugl/detail/mac_cairo.m index 6b9f36c..40f5026 100644 --- a/pugl/detail/mac_cairo.m +++ b/pugl/detail/mac_cairo.m @@ -93,10 +93,10 @@ puglMacCairoDestroy(PuglView* view) } static PuglStatus -puglMacCairoEnter(PuglView* view, bool drawing) +puglMacCairoEnter(PuglView* view, const PuglEventExpose* expose) { PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView; - if (!drawing) { + if (!expose) { return PUGL_SUCCESS; } @@ -114,10 +114,10 @@ puglMacCairoEnter(PuglView* view, bool drawing) } static PuglStatus -puglMacCairoLeave(PuglView* view, bool drawing) +puglMacCairoLeave(PuglView* view, const PuglEventExpose* expose) { PuglCairoView* const drawView = (PuglCairoView*)view->impl->drawView; - if (!drawing) { + if (!expose) { return PUGL_SUCCESS; } diff --git a/pugl/detail/mac_gl.m b/pugl/detail/mac_gl.m index 145b614..07df642 100644 --- a/pugl/detail/mac_gl.m +++ b/pugl/detail/mac_gl.m @@ -125,7 +125,7 @@ puglMacGlDestroy(PuglView* view) } static PuglStatus -puglMacGlEnter(PuglView* view, bool PUGL_UNUSED(drawing)) +puglMacGlEnter(PuglView* view, const PuglEventExpose* PUGL_UNUSED(expose)) { PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView; @@ -134,11 +134,11 @@ puglMacGlEnter(PuglView* view, bool PUGL_UNUSED(drawing)) } static PuglStatus -puglMacGlLeave(PuglView* view, bool drawing) +puglMacGlLeave(PuglView* view, const PuglEventExpose* expose) { PuglOpenGLView* const drawView = (PuglOpenGLView*)view->impl->drawView; - if (drawing) { + if (expose) { [[drawView openGLContext] flushBuffer]; } diff --git a/pugl/detail/types.h b/pugl/detail/types.h index 7b2934f..656c34d 100644 --- a/pugl/detail/types.h +++ b/pugl/detail/types.h @@ -96,11 +96,11 @@ struct PuglBackendImpl { /** Destroy surface and drawing context. */ PuglStatus (*destroy)(PuglView*); - /** Enter drawing context, for drawing if parameter is true. */ - PuglStatus (*enter)(PuglView*, bool); + /** Enter drawing context, for drawing if expose is non-null. */ + PuglStatus (*enter)(PuglView*, const PuglEventExpose*); - /** Leave drawing context, after drawing if parameter is true. */ - PuglStatus (*leave)(PuglView*, bool); + /** Leave drawing context, after drawing if expose is non-null. */ + PuglStatus (*leave)(PuglView*, const PuglEventExpose*); /** Resize drawing context to the given width and height. */ PuglStatus (*resize)(PuglView*, int, int); diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 6ef9255..1b86d3c 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -947,9 +947,9 @@ puglSetClipboard(PuglView* const view, } static PuglStatus -puglWinStubEnter(PuglView* view, bool drawing) +puglWinStubEnter(PuglView* view, const PuglEventExpose* expose) { - if (drawing) { + if (expose) { PAINTSTRUCT ps; BeginPaint(view->impl->hwnd, &ps); } @@ -958,9 +958,9 @@ puglWinStubEnter(PuglView* view, bool drawing) } static PuglStatus -puglWinStubLeave(PuglView* view, bool drawing) +puglWinStubLeave(PuglView* view, const PuglEventExpose* expose) { - if (drawing) { + if (expose) { PAINTSTRUCT ps; EndPaint(view->impl->hwnd, &ps); SwapBuffers(view->impl->hdc); diff --git a/pugl/detail/win_cairo.c b/pugl/detail/win_cairo.c index 7966b07..84761a3 100644 --- a/pugl/detail/win_cairo.c +++ b/pugl/detail/win_cairo.c @@ -110,39 +110,37 @@ puglWinCairoDestroy(PuglView* view) } static PuglStatus -puglWinCairoEnter(PuglView* view, bool drawing) +puglWinCairoEnter(PuglView* view, const PuglEventExpose* expose) { PuglInternals* const impl = view->impl; PuglWinCairoSurface* const surface = (PuglWinCairoSurface*)impl->surface; - if (!drawing) { - return PUGL_SUCCESS; - } - PAINTSTRUCT ps; - BeginPaint(view->impl->hwnd, &ps); - cairo_save(surface->cr); + if (expose) { + PAINTSTRUCT ps; + BeginPaint(view->impl->hwnd, &ps); + cairo_save(surface->cr); + } return PUGL_SUCCESS; } static PuglStatus -puglWinCairoLeave(PuglView* view, bool drawing) +puglWinCairoLeave(PuglView* view, const PuglEventExpose* expose) { PuglInternals* const impl = view->impl; PuglWinCairoSurface* const surface = (PuglWinCairoSurface*)impl->surface; - if (!drawing) { - return PUGL_SUCCESS; - } - cairo_restore(surface->cr); - cairo_surface_flush(surface->surface); - BitBlt(impl->hdc, - 0, 0, (int)view->frame.width, (int)view->frame.height, - surface->drawDc, 0, 0, SRCCOPY); + if (expose) { + cairo_restore(surface->cr); + cairo_surface_flush(surface->surface); + BitBlt(impl->hdc, + 0, 0, (int)view->frame.width, (int)view->frame.height, + surface->drawDc, 0, 0, SRCCOPY); - PAINTSTRUCT ps; - EndPaint(view->impl->hwnd, &ps); - SwapBuffers(view->impl->hdc); + PAINTSTRUCT ps; + EndPaint(view->impl->hwnd, &ps); + SwapBuffers(view->impl->hdc); + } return PUGL_SUCCESS; } diff --git a/pugl/detail/win_gl.c b/pugl/detail/win_gl.c index ee3b032..c09e23a 100644 --- a/pugl/detail/win_gl.c +++ b/pugl/detail/win_gl.c @@ -246,13 +246,13 @@ puglWinGlDestroy(PuglView* view) } static PuglStatus -puglWinGlEnter(PuglView* view, bool drawing) +puglWinGlEnter(PuglView* view, const PuglEventExpose* expose) { PuglWinGlSurface* surface = (PuglWinGlSurface*)view->impl->surface; wglMakeCurrent(view->impl->hdc, surface->hglrc); - if (drawing) { + if (expose) { PAINTSTRUCT ps; BeginPaint(view->impl->hwnd, &ps); } @@ -261,9 +261,9 @@ puglWinGlEnter(PuglView* view, bool drawing) } static PuglStatus -puglWinGlLeave(PuglView* view, bool drawing) +puglWinGlLeave(PuglView* view, const PuglEventExpose* expose) { - if (drawing) { + if (expose) { PAINTSTRUCT ps; EndPaint(view->impl->hwnd, &ps); SwapBuffers(view->impl->hdc); diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index b62e62d..38f10d0 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -744,16 +744,11 @@ puglDispatchEvents(PuglWorld* world) PuglEvent* const expose = &view->impl->pendingExpose; if (configure->type || expose->type) { - const bool mustExpose = expose->type && expose->expose.count == 0; - puglEnterContext(view, mustExpose); - + view->backend->enter(view, &expose->expose); flushPendingConfigure(view); + view->eventFunc(view, expose); + view->backend->leave(view, &expose->expose); - if (mustExpose) { - view->eventFunc(view, &view->impl->pendingExpose); - } - - puglLeaveContext(view, mustExpose); configure->type = 0; expose->type = 0; } diff --git a/pugl/detail/x11_cairo.c b/pugl/detail/x11_cairo.c index 9d3ec16..7a02dcd 100644 --- a/pugl/detail/x11_cairo.c +++ b/pugl/detail/x11_cairo.c @@ -79,12 +79,12 @@ puglX11CairoDestroy(PuglView* view) } static PuglStatus -puglX11CairoEnter(PuglView* view, bool drawing) +puglX11CairoEnter(PuglView* view, const PuglEventExpose* expose) { PuglInternals* const impl = view->impl; PuglX11CairoSurface* const surface = (PuglX11CairoSurface*)impl->surface; - if (drawing) { + if (expose) { surface->cr = cairo_create(surface->front); if (!surface->cr || cairo_status(surface->cr)) { return PUGL_CREATE_CONTEXT_FAILED; @@ -95,12 +95,12 @@ puglX11CairoEnter(PuglView* view, bool drawing) } static PuglStatus -puglX11CairoLeave(PuglView* view, bool drawing) +puglX11CairoLeave(PuglView* view, const PuglEventExpose* expose) { PuglInternals* const impl = view->impl; PuglX11CairoSurface* const surface = (PuglX11CairoSurface*)impl->surface; - if (drawing) { + if (expose) { // Destroy front context that was used by the user for drawing cairo_destroy(surface->cr); diff --git a/pugl/detail/x11_gl.c b/pugl/detail/x11_gl.c index d325f9d..d3807f2 100644 --- a/pugl/detail/x11_gl.c +++ b/pugl/detail/x11_gl.c @@ -165,7 +165,7 @@ puglX11GlDestroy(PuglView* view) } static PuglStatus -puglX11GlEnter(PuglView* view, bool PUGL_UNUSED(drawing)) +puglX11GlEnter(PuglView* view, const PuglEventExpose* PUGL_UNUSED(expose)) { PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface; glXMakeCurrent(view->impl->display, view->impl->win, surface->ctx); @@ -173,11 +173,11 @@ puglX11GlEnter(PuglView* view, bool PUGL_UNUSED(drawing)) } static PuglStatus -puglX11GlLeave(PuglView* view, bool drawing) +puglX11GlLeave(PuglView* view, const PuglEventExpose* expose) { PuglX11GlSurface* surface = (PuglX11GlSurface*)view->impl->surface; - if (drawing && surface->double_buffered) { + if (expose && surface->double_buffered) { glXSwapBuffers(view->impl->display, view->impl->win); } |