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).
This commit is contained in:
Alexander Preisinger 2013-08-19 14:07:17 +02:00
parent c5e66dde33
commit 7cec294d08
2 changed files with 15 additions and 9 deletions

View File

@ -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)

View File

@ -58,7 +58,8 @@ struct vo_wayland_state {
int display_fd;
uint32_t formats;
struct wl_shm *shm;
uint32_t shm_formats;
} display;
struct {
@ -85,7 +86,6 @@ struct vo_wayland_state {
} window;
struct {
struct wl_shm *shm;
struct wl_cursor *default_cursor;
struct wl_cursor_theme *theme;
struct wl_surface *surface;