waylandsink: properly implement full screen wayland shell window

This makes the sink properly fullscreen by default (configurable
via the 'fullscreen' property). No other screen elements such as
weston panel are visible, which makes composition faster (and is
a much saner definition of fullscreen).

BUG: 142883165
Change-Id: Icd384e817ecea890716b3b1e55983acdc3719b87
diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
index 265c466..3160b54 100644
--- a/ext/wayland/gstwaylandsink.c
+++ b/ext/wayland/gstwaylandsink.c
@@ -77,7 +77,8 @@
   PROP_WINDOW_HEIGHT,
   PROP_DISPLAY,
   PROP_ALPHA,
-  PROP_ENABLE_TILE
+  PROP_ENABLE_TILE,
+  PROP_FULLSCREEN
 };
 
 GST_DEBUG_CATEGORY (gstwayland_debug);
@@ -229,7 +230,7 @@
       g_param_spec_string ("display", "Wayland Display name", "Wayland "
           "display name to connect to, if not supplied via the GstContext",
           NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-  
+
   g_object_class_install_property (gobject_class, PROP_ALPHA,
       g_param_spec_float ("alpha", "Wayland surface alpha", "Wayland "
           "surface alpha value, apply custom alpha value to wayland surface",
@@ -239,6 +240,12 @@
       g_param_spec_boolean ("enable-tile", "enable hantro tile",
       "When enabled, the sink propose VSI tile modifier to VPU", FALSE,
       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (gobject_class, PROP_FULLSCREEN,
+      g_param_spec_boolean ("fullscreen", "Fullscreen",
+      "Configure internally created windows as fullscreen"
+      " (does not affect external windows)", TRUE,
+      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
 }
 
 static void
@@ -253,6 +260,7 @@
   sink->frame_showed = 0;
   sink->run_time = 0;
   sink->enable_tile = FALSE;
+  sink->fullscreen = TRUE;
 }
 
 static void
@@ -279,6 +287,9 @@
     case PROP_ENABLE_TILE:
       g_value_set_boolean (value, sink->enable_tile);
       break;
+    case PROP_FULLSCREEN:
+      g_value_set_boolean (value, sink->fullscreen);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -309,6 +320,9 @@
     case PROP_ENABLE_TILE:
       sink->enable_tile = g_value_get_boolean (value);
       break;
+    case PROP_FULLSCREEN:
+      sink->fullscreen = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -873,7 +887,7 @@
     if (!sink->window) {
       /* if we were not provided a window, create one ourselves */
       sink->window = gst_wl_window_new_toplevel (sink->display,
-          &sink->video_info, &sink->render_lock);
+          &sink->video_info, &sink->render_lock, sink->fullscreen);
     }
     gst_wl_window_set_alpha (sink->window, sink->alpha);
   }
diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
index 2288319..257fec7 100644
--- a/ext/wayland/gstwaylandsink.h
+++ b/ext/wayland/gstwaylandsink.h
@@ -80,6 +80,7 @@
   GstClockTime run_time;
 
   gboolean enable_tile;
+  gboolean fullscreen;
 };
 
 struct _GstWaylandSinkClass
diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c
index e4d0a6d..3cc6db1 100644
--- a/ext/wayland/wlwindow.c
+++ b/ext/wayland/wlwindow.c
@@ -171,7 +171,7 @@
 
 GstWlWindow *
 gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
-    GMutex * render_lock)
+    GMutex * render_lock, gboolean fullscreen)
 {
   GstWlWindow *window;
   gint width;
@@ -198,6 +198,13 @@
       gst_util_uint64_scale_int_round (info->width, info->par_n, info->par_d);
   gst_wl_window_set_render_rectangle (window, 0, 0, width / window->scale, info->height / window->scale);
 
+  if (fullscreen) {
+    /* this triggers handle_configure with the fullscreen dimensions */
+    wl_shell_surface_set_fullscreen (window->shell_surface,
+        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
+        0, NULL);
+  }
+
   return window;
 }
 
diff --git a/ext/wayland/wlwindow.h b/ext/wayland/wlwindow.h
index f9c9e0d..057ff3fd 100644
--- a/ext/wayland/wlwindow.h
+++ b/ext/wayland/wlwindow.h
@@ -82,7 +82,7 @@
 GType gst_wl_window_get_type (void);
 
 GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display,
-        const GstVideoInfo * info, GMutex * render_lock);
+        const GstVideoInfo * info, GMutex * render_lock, gboolean fullscreen);
 GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display,
         struct wl_surface * parent, GMutex * render_lock);