commit ff31e9d
Michael Forney
·
2014-01-15 12:37:42 +0000 UTC
parent b075784
wayland: Keep track of event queue and destroy when context is destroyed
4 files changed,
+18,
-11
+6,
-4
1@@ -39,7 +39,7 @@
2
3 struct drm_context
4 {
5- struct wld_context base;
6+ struct wayland_context base;
7 struct wld_context * driver_context;
8 struct wl_drm * wl;
9 struct wl_registry * registry;
10@@ -89,7 +89,8 @@ struct wld_context * wld_wayland_drm_create_context(struct wl_display * display,
11 if (!(context = malloc(sizeof *context)))
12 goto error0;
13
14- context_initialize(&context->base, &context_impl);
15+ context_initialize(&context->base.base, &context_impl);
16+ context->base.queue = queue;
17 context->wl = NULL;
18 context->fd = -1;
19 context->capabilities = 0;
20@@ -142,7 +143,7 @@ struct wld_context * wld_wayland_drm_create_context(struct wl_display * display,
21 goto error4;
22 }
23
24- return &context->base;
25+ return &context->base.base;
26
27 error4:
28 close(context->fd);
29@@ -197,7 +198,7 @@ struct wld_buffer * context_create_buffer(struct wld_context * base,
30 union wld_object object;
31 struct wl_buffer * wl;
32
33- if (!wld_wayland_drm_has_format(&context->base, format))
34+ if (!wld_wayland_drm_has_format(base, format))
35 goto error0;
36
37 buffer = wld_create_buffer(context->driver_context, width, height, format);
38@@ -248,6 +249,7 @@ void context_destroy(struct wld_context * base)
39 wl_drm_destroy(context->wl);
40 wl_registry_destroy(context->registry);
41 wl_array_release(&context->formats);
42+ wl_event_queue_destroy(context->base.queue);
43 free(context);
44 }
45
+7,
-1
1@@ -24,7 +24,7 @@
2 #ifndef WLD_WAYLAND_PRIVATE_H
3 #define WLD_WAYLAND_PRIVATE_H
4
5-#include <stdint.h>
6+#include "wld.h"
7
8 struct wl_display;
9 struct wl_event_queue;
10@@ -36,6 +36,12 @@ struct wld_wayland_interface
11 struct wl_event_queue * queue);
12 };
13
14+struct wayland_context
15+{
16+ struct wld_context base;
17+ struct wl_event_queue * queue;
18+};
19+
20 #if WITH_WAYLAND_DRM
21 extern const struct wld_wayland_interface wayland_drm_interface;
22 #endif
+5,
-4
1@@ -38,8 +38,7 @@
2
3 struct shm_context
4 {
5- struct wld_context base;
6-
7+ struct wayland_context base;
8 struct wl_registry * registry;
9 struct wl_shm * wl;
10 struct wl_array formats;
11@@ -91,7 +90,8 @@ struct wld_context * wld_wayland_shm_create_context
12 if (!(context = malloc(sizeof *context)))
13 goto error0;
14
15- context_initialize(&context->base, &context_impl);
16+ context_initialize(&context->base.base, &context_impl);
17+ context->base.queue = queue;
18 context->wl = NULL;
19 wl_array_init(&context->formats);
20
21@@ -118,7 +118,7 @@ struct wld_context * wld_wayland_shm_create_context
22 /* Wait for SHM formats. */
23 wayland_roundtrip(display, queue);
24
25- return &context->base;
26+ return &context->base.base;
27
28 error2:
29 wl_registry_destroy(context->registry);
30@@ -231,6 +231,7 @@ void context_destroy(struct wld_context * base)
31 wl_shm_destroy(context->wl);
32 wl_registry_destroy(context->registry);
33 wl_array_release(&context->formats);
34+ wl_event_queue_destroy(context->base.queue);
35 free(context);
36 }
37
+0,
-2
1@@ -95,8 +95,6 @@ struct wld_context * wld_wayland_create_context
2 }
3 }
4
5- wl_event_queue_destroy(queue);
6-
7 if (!context)
8 {
9 DEBUG("Could not initialize any of the specified interfaces\n");