1 From b8bbab864a1367ac47bcc0998b4c07d20020965a Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Thu, 5 Oct 2023 18:23:52 +0300
4 Subject: [PATCH] ext/wayland: Add title/appid support
6 Upstream-Status: Pending
9 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
11 ext/wayland/gstwaylandsink.c | 41 +++++++++++++++++++++++++++++-
12 ext/wayland/gstwaylandsink.h | 2 ++
13 gst-libs/gst/wayland/gstwlwindow.c | 12 ++++++++-
14 gst-libs/gst/wayland/gstwlwindow.h | 3 ++-
15 4 files changed, 55 insertions(+), 3 deletions(-)
17 diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c
18 index 2f116bf..69f4a00 100644
19 --- a/ext/wayland/gstwaylandsink.c
20 +++ b/ext/wayland/gstwaylandsink.c
21 @@ -61,6 +61,8 @@ enum
30 @@ -177,6 +179,16 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass)
31 GST_TYPE_VIDEO_ORIENTATION_METHOD, GST_VIDEO_ORIENTATION_IDENTITY,
32 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
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));
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));
45 * waylandsink:render-rectangle:
47 @@ -266,6 +278,16 @@ gst_wayland_sink_get_property (GObject * object,
48 g_value_set_enum (value, self->current_rotate_method);
49 GST_OBJECT_UNLOCK (self);
52 + GST_OBJECT_LOCK (self);
53 + g_value_set_string (value, self->app_id);
54 + GST_OBJECT_UNLOCK (self);
57 + GST_OBJECT_LOCK (self);
58 + g_value_set_string (value, self->title);
59 + GST_OBJECT_UNLOCK (self);
62 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
64 @@ -289,6 +311,16 @@ gst_wayland_sink_set_property (GObject * object,
65 gst_wayland_sink_set_fullscreen (self, g_value_get_boolean (value));
66 GST_OBJECT_UNLOCK (self);
69 + GST_OBJECT_LOCK (self);
70 + self->app_id = g_value_dup_string (value);
71 + GST_OBJECT_UNLOCK (self);
74 + GST_OBJECT_LOCK (self);
75 + self->title = g_value_dup_string (value);
76 + GST_OBJECT_UNLOCK (self);
78 case PROP_ROTATE_METHOD:
79 gst_wayland_sink_set_rotate_method (self, g_value_get_enum (value),
81 @@ -310,12 +342,18 @@ gst_wayland_sink_finalize (GObject * object)
82 gst_buffer_unref (self->last_buffer);
84 g_object_unref (self->display);
86 + g_object_unref (self->title);
88 + g_object_unref (self->app_id);
90 g_object_unref (self->window);
92 gst_object_unref (self->pool);
94 g_free (self->display_name);
95 + g_free (self->title);
96 + g_free (self->app_id);
98 g_mutex_clear (&self->display_lock);
99 g_mutex_clear (&self->render_lock);
100 @@ -761,7 +799,8 @@ gst_wayland_sink_show_frame (GstVideoSink * vsink, GstBuffer * buffer)
102 /* if we were not provided a window, create one ourselves */
103 self->window = gst_wl_window_new_toplevel (self->display,
104 - &self->video_info, self->fullscreen, &self->render_lock);
105 + &self->video_info, self->fullscreen, &self->app_id, &self->title,
106 + &self->render_lock);
107 g_signal_connect_object (self->window, "closed",
108 G_CALLBACK (on_window_closed), self, 0);
109 gst_wl_window_set_rotate_method (self->window,
110 diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h
111 index 3243d8c..6aee19d 100644
112 --- a/ext/wayland/gstwaylandsink.h
113 +++ b/ext/wayland/gstwaylandsink.h
114 @@ -58,6 +58,8 @@ struct _GstWaylandSink
121 gboolean redraw_pending;
123 diff --git a/gst-libs/gst/wayland/gstwlwindow.c b/gst-libs/gst/wayland/gstwlwindow.c
124 index 6004993..de0a81e 100644
125 --- a/gst-libs/gst/wayland/gstwlwindow.c
126 +++ b/gst-libs/gst/wayland/gstwlwindow.c
127 @@ -270,7 +270,7 @@ gst_wl_window_ensure_fullscreen (GstWlWindow * self, gboolean fullscreen)
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)
135 GstWlWindowPrivate *priv;
136 @@ -307,6 +307,16 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
138 gst_wl_window_ensure_fullscreen (self, fullscreen);
141 + xdg_toplevel_set_app_id (priv->xdg_toplevel, app_id);
143 + xdg_toplevel_set_app_id (priv->xdg_toplevel, "ext.wayland.waylandsink");
145 + xdg_toplevel_set_title (priv->xdg_toplevel, title);
147 + xdg_toplevel_set_title (priv->xdg_toplevel, "ext.wayland.waylandsink");
150 /* Finally, commit the xdg_surface state as toplevel */
151 priv->configured = FALSE;
152 wl_surface_commit (priv->area_surface);
153 diff --git a/gst-libs/gst/wayland/gstwlwindow.h b/gst-libs/gst/wayland/gstwlwindow.h
154 index 06c4001..e102052 100644
155 --- a/gst-libs/gst/wayland/gstwlwindow.h
156 +++ b/gst-libs/gst/wayland/gstwlwindow.h
157 @@ -39,7 +39,8 @@ void gst_wl_window_ensure_fullscreen (GstWlWindow * self,
160 GstWlWindow *gst_wl_window_new_toplevel (GstWlDisplay * display,
161 - const GstVideoInfo * info, gboolean fullscreen, GMutex * render_lock);
162 + const GstVideoInfo * info, gboolean fullscreen, gchar * app_id,
163 + gchar *title, GMutex * render_lock);
166 GstWlWindow *gst_wl_window_new_in_surface (GstWlDisplay * display,