waylandsink: relaxed wl_shell check and added zwp_fullscreen_shell.
authorMatteo Valdina <matteo.valdina@gmail.com>
Tue, 10 Jul 2018 01:20:59 +0000 (20:20 -0500)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 25 Jul 2018 11:53:09 +0000 (07:53 -0400)
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
ext/wayland/meson.build
ext/wayland/wldisplay.c
ext/wayland/wldisplay.h
ext/wayland/wlwindow.c

index 387f84fc718f54a84ec1fb02cb2de1b5425ea1db..a7fcc32786ea3b8608c83f4d86b790e3c4ae48b9 100644 (file)
@@ -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) \
index e4bb754c415f1dbc4691d14424d2bf2eacd341e5..3246cae9b0f367886fefb7441cd2131cfcb5a498 100644 (file)
@@ -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 = []
 
index 39782bca5c3641f13c475d470aa49c17b664c30c..90a57fbf80fa3cfd24a0ef9f87c3e444eee7e941 100644 (file)
@@ -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) {
index 7c892123fdba32692301bf71358f64a1c0563a83..5bab5edcd385c3a7c051a4aaa44d1ffa5be80990 100644 (file)
@@ -26,6 +26,7 @@
 #include <wayland-client.h>
 #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;
index 9ef8c322973bfddbd5bc5e81bd492d0d1b60ac61..0c2e92937943dbc97fce8a3ab68029048bd5d46a 100644 (file)
@@ -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;
   }