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
7 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
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(-)
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
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));
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));
44 gst_type_mark_as_plugin_api (GST_TYPE_WAYLAND_VIDEO, 0);
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);
52 + GST_OBJECT_LOCK (sink);
53 + g_value_set_string (value, sink->app_id);
54 + GST_OBJECT_UNLOCK (sink);
57 + GST_OBJECT_LOCK (sink);
58 + g_value_set_string (value, sink->title);
59 + GST_OBJECT_UNLOCK (sink);
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);
69 + GST_OBJECT_LOCK (sink);
70 + sink->app_id = g_value_dup_string (value);
71 + GST_OBJECT_UNLOCK (sink);
74 + GST_OBJECT_LOCK (sink);
75 + sink->title = g_value_dup_string (value);
76 + GST_OBJECT_UNLOCK (sink);
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);
84 g_object_unref (sink->display);
86 + g_object_unref (sink->title);
88 + g_object_unref (sink->app_id);
90 g_object_unref (sink->window);
92 gst_object_unref (sink->pool);
94 g_free (sink->display_name);
95 + g_free (sink->title);
96 + g_free (sink->app_id);
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)
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);
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
121 gboolean redraw_pending;
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)
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)
136 @@ -287,6 +287,14 @@ gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
138 /* Finally, commit the xdg_surface state as toplevel */
139 window->configured = FALSE;
141 + xdg_toplevel_set_app_id (window->xdg_toplevel, app_id);
143 + xdg_toplevel_set_app_id (window->xdg_toplevel, "ext.wayland.waylandsink");
145 + xdg_toplevel_set_title (window->xdg_toplevel, title);
147 + xdg_toplevel_set_title (window->xdg_toplevel, "ext.wayland.waylandsink");
148 wl_surface_commit (window->area_surface);
149 wl_display_flush (display->display);
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);