waylandsink: cleanup GstWlWindow a bit after the overlaying semantics change
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Mon, 26 May 2014 09:54:10 +0000 (12:54 +0300)
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Tue, 17 Jun 2014 11:51:27 +0000 (13:51 +0200)
* own_surface is not needed anymore
* gst_wl_window_from_surface is not used externally anymore
* many initializations to 0 are not needed (GObject does them)

ext/wayland/wlwindow.c
ext/wayland/wlwindow.h

index c3e513a..6d45885 100644 (file)
@@ -74,33 +74,54 @@ gst_wl_window_finalize (GObject * gobject)
 {
   GstWlWindow *self = GST_WL_WINDOW (gobject);
 
-  wl_viewport_destroy (self->viewport);
-
   if (self->shell_surface) {
     wl_shell_surface_destroy (self->shell_surface);
   }
 
-  if (self->own_surface) {
-    wl_surface_destroy (self->surface);
-  }
-
   if (self->subsurface) {
     wl_subsurface_destroy (self->subsurface);
   }
 
+  wl_viewport_destroy (self->viewport);
+  wl_surface_destroy (self->surface);
+
   g_clear_object (&self->display);
 
   G_OBJECT_CLASS (gst_wl_window_parent_class)->finalize (gobject);
 }
 
+static GstWlWindow *
+gst_wl_window_new_internal (GstWlDisplay * display, struct wl_surface *surface)
+{
+  GstWlWindow *window;
+  struct wl_region *region;
+
+  g_return_val_if_fail (surface != NULL, NULL);
+
+  window = g_object_new (GST_TYPE_WL_WINDOW, NULL);
+  window->display = g_object_ref (display);
+  window->surface = surface;
+
+  /* make sure the surface runs on our local queue */
+  wl_proxy_set_queue ((struct wl_proxy *) surface, display->queue);
+
+  window->viewport = wl_scaler_get_viewport (display->scaler, window->surface);
+
+  /* do not accept input */
+  region = wl_compositor_create_region (display->compositor);
+  wl_surface_set_input_region (surface, region);
+  wl_region_destroy (region);
+
+  return window;
+}
+
 GstWlWindow *
 gst_wl_window_new_toplevel (GstWlDisplay * display, gint width, gint height)
 {
   GstWlWindow *window;
 
-  window = gst_wl_window_new_from_surface (display,
+  window = gst_wl_window_new_internal (display,
       wl_compositor_create_surface (display->compositor));
-  window->own_surface = TRUE;
 
   gst_wl_window_set_size (window, 0, 0, width, height);
 
@@ -127,9 +148,8 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
 {
   GstWlWindow *window;
 
-  window = gst_wl_window_new_from_surface (display,
+  window = gst_wl_window_new_internal (display,
       wl_compositor_create_surface (display->compositor));
-  window->own_surface = TRUE;
 
   window->subsurface = wl_subcompositor_get_subsurface (display->subcompositor,
       window->surface, parent);
@@ -138,38 +158,6 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
   return window;
 }
 
-GstWlWindow *
-gst_wl_window_new_from_surface (GstWlDisplay * display,
-    struct wl_surface * surface)
-{
-  GstWlWindow *window;
-  struct wl_region *region;
-
-  g_return_val_if_fail (surface != NULL, NULL);
-
-  window = g_object_new (GST_TYPE_WL_WINDOW, NULL);
-  window->display = g_object_ref (display);
-  window->x = 0;
-  window->y = 0;
-  window->width = 0;
-  window->height = 0;
-
-  window->surface = surface;
-  window->own_surface = FALSE;
-
-  /* make sure the surface runs on our local queue */
-  wl_proxy_set_queue ((struct wl_proxy *) surface, display->queue);
-
-  window->viewport = wl_scaler_get_viewport (display->scaler, window->surface);
-
-  /* do not accept input */
-  region = wl_compositor_create_region (display->compositor);
-  wl_surface_set_input_region (surface, region);
-  wl_region_destroy (region);
-
-  return window;
-}
-
 GstWlDisplay *
 gst_wl_window_get_display (GstWlWindow * window)
 {
index ca30fda..51e3d79 100644 (file)
@@ -45,7 +45,6 @@ struct _GstWlWindow
   struct wl_viewport *viewport;
   struct wl_shell_surface *shell_surface;
   gint x, y, width, height;
-  gboolean own_surface;
 };
 
 struct _GstWlWindowClass
@@ -59,8 +58,6 @@ GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display,
         gint width, gint height);
 GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display,
         struct wl_surface * parent);
-GstWlWindow *gst_wl_window_new_from_surface (GstWlDisplay * display,
-        struct wl_surface * surface);
 
 GstWlDisplay *gst_wl_window_get_display (GstWlWindow * window);
 struct wl_surface *gst_wl_window_get_wl_surface (GstWlWindow * window);