summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorAlexander Preisinger <alexander.preisinger@gmail.com>2013-08-19 14:07:17 +0200
committerAlexander Preisinger <alexander.preisinger@gmail.com>2013-08-19 14:12:39 +0200
commit7cec294d088d80f293e44218c748cf61db4f0879 (patch)
tree687b525276c9cf832c4867606cd2b4ec34a9e172 /video
parentc5e66dde334c6ec5ea08418e58e0a35d0e58dd1f (diff)
downloadmpv-7cec294d088d80f293e44218c748cf61db4f0879.tar.bz2
mpv-7cec294d088d80f293e44218c748cf61db4f0879.tar.xz
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).
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c20
-rw-r--r--video/out/wayland_common.h4
2 files changed, 15 insertions, 9 deletions
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)
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index 27dc057043..bb26f756a2 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -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;