From 7cec294d088d80f293e44218c748cf61db4f0879 Mon Sep 17 00:00:00 2001 From: Alexander Preisinger Date: Mon, 19 Aug 2013 14:07:17 +0200 Subject: wayland: separate shm and cursor context The display, window, keyboard and cursor structures are now cleanly and logically separated. Also could prevent a future bug where no shm format is set when the cursor image is loaded (Never happened until now). --- video/out/wayland_common.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'video/out/wayland_common.c') diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 535c662730..9e58a3617e 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -433,7 +433,7 @@ static void shm_handle_format(void *data, uint32_t format) { struct vo_wayland_state *wl = data; - wl->display.formats |= (1 << format); + wl->display.shm_formats |= (1 << format); } const struct wl_shm_listener shm_listener = { @@ -462,11 +462,8 @@ static void registry_handle_global (void *data, else if (strcmp(interface, "wl_shm") == 0) { - wl->cursor.shm = wl_registry_bind(reg, id, &wl_shm_interface, 1); - wl->cursor.theme = wl_cursor_theme_load(NULL, 32, wl->cursor.shm); - wl->cursor.default_cursor = wl_cursor_theme_get_cursor(wl->cursor.theme, - "left_ptr"); - wl_shm_add_listener(wl->cursor.shm, &shm_listener, wl); + wl->display.shm = wl_registry_bind(reg, id, &wl_shm_interface, 1); + wl_shm_add_listener(wl->display.shm, &shm_listener, wl); } else if (strcmp(interface, "wl_output") == 0) { @@ -624,10 +621,19 @@ static void destroy_window (struct vo_wayland_state *wl) static bool create_cursor (struct vo_wayland_state *wl) { + if (!wl->display.shm) + return false; + wl->cursor.surface = wl_compositor_create_surface(wl->display.compositor); - return wl->cursor.surface != NULL; + if (!wl->cursor.surface) + return false; + + wl->cursor.theme = wl_cursor_theme_load(NULL, 32, wl->display.shm); + wl->cursor.default_cursor = wl_cursor_theme_get_cursor(wl->cursor.theme, + "left_ptr"); + return true; } static void destroy_cursor (struct vo_wayland_state *wl) -- cgit v1.2.3