From e0535b44d4dceb3554dd67ff0402730d263e2e04 Mon Sep 17 00:00:00 2001 From: Matteo Valdina Date: Mon, 9 Jul 2018 20:20:59 -0500 Subject: [PATCH] waylandsink: relaxed wl_shell check and added zwp_fullscreen_shell. Relaxed the wl_shell interface constrains, so application that pass via GstContext the wl_surface can use waylandsink in a compositor without wl_surface and zwp_fullscreen_shell. Added support for zwp_fullscreen_shell. https://bugzilla.gnome.org/show_bug.cgi?id=796772 --- ext/wayland/Makefile.am | 7 +++++-- ext/wayland/meson.build | 4 +++- ext/wayland/wldisplay.c | 16 +++++++++++++++- ext/wayland/wldisplay.h | 2 ++ ext/wayland/wlwindow.c | 29 +++++++++++++++++++---------- 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/ext/wayland/Makefile.am b/ext/wayland/Makefile.am index 387f84f..a7fcc32 100644 --- a/ext/wayland/Makefile.am +++ b/ext/wayland/Makefile.am @@ -4,7 +4,9 @@ BUILT_SOURCES = \ viewporter-protocol.c \ viewporter-client-protocol.h \ linux-dmabuf-unstable-v1-protocol.c \ - linux-dmabuf-unstable-v1-client-protocol.h + linux-dmabuf-unstable-v1-client-protocol.h \ + fullscreen-shell-unstable-v1-protocol.c \ + fullscreen-shell-unstable-v1-client-protocol.h libgstwaylandsink_la_SOURCES = \ gstwaylandsink.c \ @@ -17,7 +19,8 @@ libgstwaylandsink_la_SOURCES = \ nodist_libgstwaylandsink_la_SOURCES = \ viewporter-protocol.c \ - linux-dmabuf-unstable-v1-protocol.c + linux-dmabuf-unstable-v1-protocol.c \ + fullscreen-shell-unstable-v1-protocol.c libgstwaylandsink_la_CFLAGS = \ $(GST_PLUGINS_BAD_CFLAGS) \ diff --git a/ext/wayland/meson.build b/ext/wayland/meson.build index e4bb754..3246cae 100644 --- a/ext/wayland/meson.build +++ b/ext/wayland/meson.build @@ -14,7 +14,9 @@ if use_wayland protocol_defs = [ ['/stable/viewporter/viewporter.xml', 'viewporter-protocol.c', 'viewporter-client-protocol.h'], ['/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml', - 'linux-dmabuf-unstable-v1-protocol.c', 'linux-dmabuf-unstable-v1-client-protocol.h'] + 'linux-dmabuf-unstable-v1-protocol.c', 'linux-dmabuf-unstable-v1-client-protocol.h'], + ['/unstable/fullscreen-shell/fullscreen-shell-unstable-v1.xml', + 'fullscreen-shell-unstable-v1-protocol.c', 'fullscreen-shell-unstable-v1-client-protocol.h'] ] protocols_files = [] diff --git a/ext/wayland/wldisplay.c b/ext/wayland/wldisplay.c index 39782bc..90a57fb 100644 --- a/ext/wayland/wldisplay.c +++ b/ext/wayland/wldisplay.c @@ -90,6 +90,9 @@ gst_wl_display_finalize (GObject * gobject) if (self->shell) wl_shell_destroy (self->shell); + if (self->fullscreen_shell) + zwp_fullscreen_shell_v1_release (self->fullscreen_shell); + if (self->compositor) wl_compositor_destroy (self->compositor); @@ -225,6 +228,9 @@ registry_handle_global (void *data, struct wl_registry *registry, wl_registry_bind (registry, id, &wl_subcompositor_interface, 1); } else if (g_strcmp0 (interface, "wl_shell") == 0) { self->shell = wl_registry_bind (registry, id, &wl_shell_interface, 1); + } else if (g_strcmp0 (interface, "zwp_fullscreen_shell_v1") == 0) { + self->fullscreen_shell = wl_registry_bind (registry, id, + &zwp_fullscreen_shell_v1_interface, 1); } else if (g_strcmp0 (interface, "wl_shm") == 0) { self->shm = wl_registry_bind (registry, id, &wl_shm_interface, 1); wl_shm_add_listener (self->shm, &shm_listener, self); @@ -336,7 +342,6 @@ gst_wl_display_new_existing (struct wl_display * display, VERIFY_INTERFACE_EXISTS (compositor, "wl_compositor"); VERIFY_INTERFACE_EXISTS (subcompositor, "wl_subcompositor"); - VERIFY_INTERFACE_EXISTS (shell, "wl_shell"); VERIFY_INTERFACE_EXISTS (shm, "wl_shm"); #undef VERIFY_INTERFACE_EXISTS @@ -353,6 +358,15 @@ gst_wl_display_new_existing (struct wl_display * display, g_warning ("Could not bind to zwp_linux_dmabuf_v1"); } + if (!self->shell && !self->fullscreen_shell) { + /* If wl_surface and wl_display are passed via GstContext + * wl_shell, zwp_fullscreen_shell are not used. + * In this case is correct to continue. + */ + g_warning ("Could not bind to wl_shell or zwp_fullscreen_shell, video " + "display may not work properly."); + } + self->thread = g_thread_try_new ("GstWlDisplay", gst_wl_display_thread_run, self, &err); if (err) { diff --git a/ext/wayland/wldisplay.h b/ext/wayland/wldisplay.h index 7c89212..5bab5ed 100644 --- a/ext/wayland/wldisplay.h +++ b/ext/wayland/wldisplay.h @@ -26,6 +26,7 @@ #include #include "viewporter-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" +#include "fullscreen-shell-unstable-v1-client-protocol.h" G_BEGIN_DECLS @@ -52,6 +53,7 @@ struct _GstWlDisplay struct wl_compositor *compositor; struct wl_subcompositor *subcompositor; struct wl_shell *shell; + struct zwp_fullscreen_shell_v1 *fullscreen_shell; struct wl_shm *shm; struct wp_viewporter *viewporter; struct zwp_linux_dmabuf_v1 *dmabuf; diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c index 9ef8c32..0c2e929 100644 --- a/ext/wayland/wlwindow.c +++ b/ext/wayland/wlwindow.c @@ -172,17 +172,26 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info, window = gst_wl_window_new_internal (display, render_lock); - /* go toplevel */ - window->shell_surface = wl_shell_get_shell_surface (display->shell, - window->area_surface); - - if (window->shell_surface) { - wl_shell_surface_add_listener (window->shell_surface, - &shell_surface_listener, window); - gst_wl_window_ensure_fullscreen (window, fullscreen); - } else { - GST_ERROR ("Unable to get wl_shell_surface"); + if (display->shell) { + /* go toplevel */ + window->shell_surface = wl_shell_get_shell_surface (display->shell, + window->area_surface); + if (window->shell_surface) { + wl_shell_surface_add_listener (window->shell_surface, + &shell_surface_listener, window); + gst_wl_window_ensure_fullscreen (window, fullscreen); + } else { + GST_ERROR ("Unable to get wl_shell_surface"); + g_object_unref (window); + return NULL; + } + } else if (display->fullscreen_shell) { + zwp_fullscreen_shell_v1_present_surface (display->fullscreen_shell, + window->area_surface, ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM, + NULL); + } else { + GST_ERROR ("Unable to use wl_shell or zwp_fullscreen_shell."); g_object_unref (window); return NULL; } -- 2.7.4