summaryrefslogtreecommitdiff
path: root/clients/simple-shm.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-11-17 10:27:17 -0500
committerKristian Høgsberg <krh@bitplanet.net>2011-11-17 10:27:17 -0500
commita3cdf59cee41af3d555efab577061804ad28ac9d (patch)
tree5dfe1105f40c19894de261c6434ae58857d3124b /clients/simple-shm.c
parent2ca8630aab29b1c4c61cd6a6e5c295ef8f2f7138 (diff)
downloadweston-a3cdf59cee41af3d555efab577061804ad28ac9d.tar.gz
simple-shm: Add a wl_shm listener
This way we properly check that WL_SHM_FORMAT_XRGB32 is available.
Diffstat (limited to 'clients/simple-shm.c')
-rw-r--r--clients/simple-shm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/clients/simple-shm.c b/clients/simple-shm.c
index a93c2033..c112303f 100644
--- a/clients/simple-shm.c
+++ b/clients/simple-shm.c
@@ -37,6 +37,7 @@ struct display {
struct wl_compositor *compositor;
struct wl_shell *shell;
struct wl_shm *shm;
+ uint32_t formats;
uint32_t mask;
};
@@ -141,6 +142,18 @@ static const struct wl_callback_listener frame_listener = {
};
static void
+shm_format(void *data, struct wl_shm *wl_shm, uint32_t format)
+{
+ struct display *d = data;
+
+ d->formats |= (1 << format);
+}
+
+struct wl_shm_listener shm_listenter = {
+ shm_format
+};
+
+static void
display_handle_global(struct wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data)
{
@@ -153,6 +166,7 @@ display_handle_global(struct wl_display *display, uint32_t id,
d->shell = wl_display_bind(display, id, &wl_shell_interface);
} else if (strcmp(interface, "wl_shm") == 0) {
d->shm = wl_display_bind(display, id, &wl_shm_interface);
+ wl_shm_add_listener(d->shm, &shm_listenter, d);
}
}
@@ -175,9 +189,16 @@ create_display(void)
display->display = wl_display_connect(NULL);
assert(display->display);
+ display->formats = 0;
wl_display_add_global_listener(display->display,
display_handle_global, display);
wl_display_iterate(display->display, WL_DISPLAY_READABLE);
+ wl_display_roundtrip(display->display);
+
+ if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB32))) {
+ fprintf(stderr, "WL_SHM_FORMAT_XRGB32 not available\n");
+ exit(1);
+ }
wl_display_get_fd(display->display, event_mask_update, display);