neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

commit ff31e9dedc1a3d7cff57113e3f576518b18e3463
parent b075784a5319bbc081ac649d0ad11fd0a912d883
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 15 Jan 2014 04:37:42 -0800

wayland: Keep track of event queue and destroy when context is destroyed

Diffstat:
Mwayland-drm.c | 10++++++----
Mwayland-private.h | 8+++++++-
Mwayland-shm.c | 9+++++----
Mwayland.c | 2--
4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/wayland-drm.c b/wayland-drm.c @@ -39,7 +39,7 @@ struct drm_context { - struct wld_context base; + struct wayland_context base; struct wld_context * driver_context; struct wl_drm * wl; struct wl_registry * registry; @@ -89,7 +89,8 @@ struct wld_context * wld_wayland_drm_create_context(struct wl_display * display, if (!(context = malloc(sizeof *context))) goto error0; - context_initialize(&context->base, &context_impl); + context_initialize(&context->base.base, &context_impl); + context->base.queue = queue; context->wl = NULL; context->fd = -1; context->capabilities = 0; @@ -142,7 +143,7 @@ struct wld_context * wld_wayland_drm_create_context(struct wl_display * display, goto error4; } - return &context->base; + return &context->base.base; error4: close(context->fd); @@ -197,7 +198,7 @@ struct wld_buffer * context_create_buffer(struct wld_context * base, union wld_object object; struct wl_buffer * wl; - if (!wld_wayland_drm_has_format(&context->base, format)) + if (!wld_wayland_drm_has_format(base, format)) goto error0; buffer = wld_create_buffer(context->driver_context, width, height, format); @@ -248,6 +249,7 @@ void context_destroy(struct wld_context * base) wl_drm_destroy(context->wl); wl_registry_destroy(context->registry); wl_array_release(&context->formats); + wl_event_queue_destroy(context->base.queue); free(context); } diff --git a/wayland-private.h b/wayland-private.h @@ -24,7 +24,7 @@ #ifndef WLD_WAYLAND_PRIVATE_H #define WLD_WAYLAND_PRIVATE_H -#include <stdint.h> +#include "wld.h" struct wl_display; struct wl_event_queue; @@ -36,6 +36,12 @@ struct wld_wayland_interface struct wl_event_queue * queue); }; +struct wayland_context +{ + struct wld_context base; + struct wl_event_queue * queue; +}; + #if WITH_WAYLAND_DRM extern const struct wld_wayland_interface wayland_drm_interface; #endif diff --git a/wayland-shm.c b/wayland-shm.c @@ -38,8 +38,7 @@ struct shm_context { - struct wld_context base; - + struct wayland_context base; struct wl_registry * registry; struct wl_shm * wl; struct wl_array formats; @@ -91,7 +90,8 @@ struct wld_context * wld_wayland_shm_create_context if (!(context = malloc(sizeof *context))) goto error0; - context_initialize(&context->base, &context_impl); + context_initialize(&context->base.base, &context_impl); + context->base.queue = queue; context->wl = NULL; wl_array_init(&context->formats); @@ -118,7 +118,7 @@ struct wld_context * wld_wayland_shm_create_context /* Wait for SHM formats. */ wayland_roundtrip(display, queue); - return &context->base; + return &context->base.base; error2: wl_registry_destroy(context->registry); @@ -231,6 +231,7 @@ void context_destroy(struct wld_context * base) wl_shm_destroy(context->wl); wl_registry_destroy(context->registry); wl_array_release(&context->formats); + wl_event_queue_destroy(context->base.queue); free(context); } diff --git a/wayland.c b/wayland.c @@ -95,8 +95,6 @@ struct wld_context * wld_wayland_create_context } } - wl_event_queue_destroy(queue); - if (!context) { DEBUG("Could not initialize any of the specified interfaces\n");