gstreamer1.0-plugins-bad_%.bbappend: Added a title/appid
[AGL/meta-agl.git] / meta-agl-core / recipes-multimedia / gstreamer1.0-plugins-bad / files / 0001-Added-appid-and-title-support.patch
1 From 2de455486403a710cb6896b0052b4cd7e46d83a2 Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Thu, 10 Aug 2023 14:20:48 +0300
4 Subject: [PATCH] ext/wayland: Add title/appid support
5
6 Bug-AGL: SPEC-4870
7 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
8 ---
9  ext/wayland/gstwaylandsink.c | 43 ++++++++++++++++++++++++++++++++++--
10  ext/wayland/gstwaylandsink.h |  2 ++
11  ext/wayland/wlwindow.c       | 10 ++++++++-
12  ext/wayland/wlwindow.h       |  2 +-
13  4 files changed, 53 insertions(+), 4 deletions(-)
14
15 diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
16 index 0761304..8913ee2 100644
17 --- a/ext/wayland/gstwaylandsink.c
18 +++ b/ext/wayland/gstwaylandsink.c
19 @@ -63,7 +63,9 @@ enum
20  {
21    PROP_0,
22    PROP_DISPLAY,
23 -  PROP_FULLSCREEN
24 +  PROP_FULLSCREEN,
25 +  PROP_APP_ID,
26 +  PROP_TITLE
27  };
28  
29  GST_DEBUG_CATEGORY (gstwayland_debug);
30 @@ -212,6 +214,16 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
31            "Whether the surface should be made fullscreen ", FALSE,
32            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
33  
34 +  g_object_class_install_property (gobject_class, PROP_APP_ID,
35 +      g_param_spec_string ("appid", "Top-level application id", "Wayland "
36 +          "appid, as xdg_shell::set_app_id",
37 +          NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
38 +
39 +  g_object_class_install_property (gobject_class, PROP_TITLE,
40 +      g_param_spec_string ("title", "Top-level title", "Wayland "
41 +          "title, xdg_shell::set_title",
42 +          NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
43 +
44    gst_type_mark_as_plugin_api (GST_TYPE_WAYLAND_VIDEO, 0);
45  }
46  
47 @@ -246,6 +258,16 @@ gst_wayland_sink_get_property (GObject * object,
48        g_value_set_string (value, sink->display_name);
49        GST_OBJECT_UNLOCK (sink);
50        break;
51 +    case PROP_APP_ID:
52 +      GST_OBJECT_LOCK (sink);
53 +      g_value_set_string (value, sink->app_id);
54 +      GST_OBJECT_UNLOCK (sink);
55 +      break;
56 +    case PROP_TITLE:
57 +      GST_OBJECT_LOCK (sink);
58 +      g_value_set_string (value, sink->title);
59 +      GST_OBJECT_UNLOCK (sink);
60 +      break;
61      case PROP_FULLSCREEN:
62        GST_OBJECT_LOCK (sink);
63        g_value_set_boolean (value, sink->fullscreen);
64 @@ -269,6 +291,16 @@ gst_wayland_sink_set_property (GObject * object,
65        sink->display_name = g_value_dup_string (value);
66        GST_OBJECT_UNLOCK (sink);
67        break;
68 +    case PROP_APP_ID:
69 +      GST_OBJECT_LOCK (sink);
70 +      sink->app_id = g_value_dup_string (value);
71 +      GST_OBJECT_UNLOCK (sink);
72 +      break;
73 +    case PROP_TITLE:
74 +      GST_OBJECT_LOCK (sink);
75 +      sink->title = g_value_dup_string (value);
76 +      GST_OBJECT_UNLOCK (sink);
77 +      break;
78      case PROP_FULLSCREEN:
79        GST_OBJECT_LOCK (sink);
80        gst_wayland_sink_set_fullscreen (sink, g_value_get_boolean (value));
81 @@ -291,12 +323,18 @@ gst_wayland_sink_finalize (GObject * object)
82      gst_buffer_unref (sink->last_buffer);
83    if (sink->display)
84      g_object_unref (sink->display);
85 +  if (sink->title)
86 +    g_object_unref (sink->title);
87 +  if (sink->app_id)
88 +    g_object_unref (sink->app_id);
89    if (sink->window)
90      g_object_unref (sink->window);
91    if (sink->pool)
92      gst_object_unref (sink->pool);
93  
94    g_free (sink->display_name);
95 +  g_free (sink->title);
96 +  g_free (sink->app_id);
97  
98    g_mutex_clear (&sink->display_lock);
99    g_mutex_clear (&sink->render_lock);
100 @@ -718,7 +756,8 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
101      if (!sink->window) {
102        /* if we were not provided a window, create one ourselves */
103        sink->window = gst_wl_window_new_toplevel (sink->display,
104 -          &sink->video_info, sink->fullscreen, &sink->render_lock);
105 +          &sink->video_info, sink->fullscreen, sink->app_id, sink->title,
106 +         &sink->render_lock);
107        g_signal_connect_object (sink->window, "closed",
108            G_CALLBACK (on_window_closed), sink, 0);
109      }
110 diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
111 index 7aabb6f..4db00e5 100644
112 --- a/ext/wayland/gstwaylandsink.h
113 +++ b/ext/wayland/gstwaylandsink.h
114 @@ -63,6 +63,8 @@ struct _GstWaylandSink
115    gboolean fullscreen;
116  
117    gchar *display_name;
118 +  gchar *app_id;
119 +  gchar *title;
120  
121    gboolean redraw_pending;
122    GMutex render_lock;
123 diff --git a/ext/wayland/wlwindow.c b/ext/wayland/wlwindow.c
124 index 66df0fc..ad2d3f3 100644
125 --- a/ext/wayland/wlwindow.c
126 +++ b/ext/wayland/wlwindow.c
127 @@ -254,7 +254,7 @@ gst_wl_window_ensure_fullscreen (GstWlWindow * window, gboolean fullscreen)
128  
129  GstWlWindow *
130  gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
131 -    gboolean fullscreen, GMutex * render_lock)
132 +    gboolean fullscreen, gchar *app_id, gchar *title, GMutex * render_lock)
133  {
134    GstWlWindow *window;
135  
136 @@ -287,6 +287,14 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
137  
138      /* Finally, commit the xdg_surface state as toplevel */
139      window->configured = FALSE;
140 +    if (app_id)
141 +           xdg_toplevel_set_app_id (window->xdg_toplevel, app_id);
142 +    else
143 +           xdg_toplevel_set_app_id (window->xdg_toplevel, "ext.wayland.waylandsink");
144 +    if (title)
145 +           xdg_toplevel_set_title (window->xdg_toplevel, title);
146 +    else
147 +           xdg_toplevel_set_title (window->xdg_toplevel, "ext.wayland.waylandsink");
148      wl_surface_commit (window->area_surface);
149      wl_display_flush (display->display);
150  
151 diff --git a/ext/wayland/wlwindow.h b/ext/wayland/wlwindow.h
152 index 303c336..64399b3 100644
153 --- a/ext/wayland/wlwindow.h
154 +++ b/ext/wayland/wlwindow.h
155 @@ -83,7 +83,7 @@ GType gst_wl_window_get_type (void);
156  void gst_wl_window_ensure_fullscreen (GstWlWindow * window,
157          gboolean fullscreen);
158  GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display,
159 -        const GstVideoInfo * info, gboolean fullscreen, GMutex * render_lock);
160 +        const GstVideoInfo * info, gboolean fullscreen, gchar * app_id, gchar *title, GMutex * render_lock);
161  GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display,
162          struct wl_surface * parent, GMutex * render_lock);
163  
164 -- 
165 2.35.1
166