From 729974492d1580ea6c4988cd2f36d5e517daacca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 8 Jul 2019 16:12:02 +0200 Subject: [PATCH] main: verify compositor has WL_SHM_FORMAT_ARGB8888 --- main.c | 9 ++++++++- terminal.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 5ce9c623..247d153d 100644 --- a/main.c +++ b/main.c @@ -38,6 +38,9 @@ static const struct rgb default_background = {0.067, 0.067, 0.067}; static void shm_format(void *data, struct wl_shm *wl_shm, uint32_t format) { + struct terminal *term = data; + if (format == WL_SHM_FORMAT_ARGB8888) + term->wl.have_argb8888 = true; } static const struct wl_shm_listener shm_listener = { @@ -107,7 +110,7 @@ handle_global(void *data, struct wl_registry *registry, else if (strcmp(interface, wl_shm_interface.name) == 0) { term->wl.shm = wl_registry_bind( term->wl.registry, name, &wl_shm_interface, 1); - wl_shm_add_listener(term->wl.shm, &shm_listener, NULL); + wl_shm_add_listener(term->wl.shm, &shm_listener, term); wl_display_roundtrip(term->wl.display); } @@ -378,6 +381,10 @@ main(int argc, char *const *argv) LOG_ERR("no XDG shell interface"); goto out; } + if (!term.wl.have_argb8888) { + LOG_ERR("compositor does not support ARGB surfaces"); + goto out; + } /* Cursor */ term.wl.pointer.surface = wl_compositor_create_surface(term.wl.compositor); diff --git a/terminal.h b/terminal.h index d897b10a..0ffcf01c 100644 --- a/terminal.h +++ b/terminal.h @@ -34,6 +34,7 @@ struct wayland { struct xdg_wm_base *shell; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; + bool have_argb8888; }; struct rgb { double r, g, b; } __attribute__((packed));