[Spice-devel] [PATCH v2 spice-gtk 2/2] Gstreamer: fix window resize when using GstVideoOverlay
Snir Sheriber
ssheribe at redhat.com
Sun Dec 16 15:18:54 UTC 2018
With previous patch changes it's now possible to call GstVideoOverlay
interface functions in response to matching gtk events. This patch fixes
the window resize and possibly other rendering issues.
Signed-off-by: Snir Sheriber <ssheribe at redhat.com>
---
src/spice-widget.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/spice-widget.c b/src/spice-widget.c
index ae83420..f923103 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -120,6 +120,10 @@ static void size_allocate(GtkWidget *widget, GtkAllocation *conf, gpointer data)
static gboolean draw_event(GtkWidget *widget, cairo_t *cr, gpointer data);
static void update_size_request(SpiceDisplay *display);
static GdkDevice *spice_gdk_window_get_pointing_device(GdkWindow *window);
+#ifdef HAVE_GSTVIDEO
+static void gst_size_allocate(GtkWidget *widget, GdkRectangle *a, gpointer data);
+static gboolean gst_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data);
+#endif
/* ---------------------------------------------------------------- */
@@ -649,8 +653,14 @@ static void spice_display_init(SpiceDisplay *display)
NULL);
gtk_stack_add_named(d->stack, area, "gl-area");
#endif
+#ifdef HAVE_GSTVIDEO
area = gtk_drawing_area_new();
gtk_stack_add_named(d->stack, area, "gst-area");
+ g_object_connect(area,
+ "signal::draw", gst_draw_event, display,
+ "signal::size-allocate", gst_size_allocate, display,
+ NULL);
+#endif
gtk_widget_show_all(widget);
@@ -2588,8 +2598,37 @@ static void gst_sync_bus_call(GstBus *bus, GstMessage *msg, gpointer data)
}
#endif
+#ifdef HAVE_GSTVIDEO
+static gboolean gst_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
{
-#ifdef GDK_WINDOWING_X11
+ SpiceDisplay *display = SPICE_DISPLAY(data);
+ SpiceDisplayPrivate *d = display->priv;
+ GstElement *overlay_element = g_weak_ref_get(&d->overlay_element_weak_ref);
+
+ if (overlay_element) {
+ gst_video_overlay_expose(GST_VIDEO_OVERLAY(overlay_element));
+ gst_object_unref(overlay_element);
+ update_mouse_pointer(display);
+ return true;
+ }
+ return false;
+}
+
+void gst_size_allocate(GtkWidget *widget, GdkRectangle *a, gpointer data)
+{
+ SpiceDisplay *display = SPICE_DISPLAY(data);
+ SpiceDisplayPrivate *d = display->priv;
+ GstElement *overlay_element = g_weak_ref_get(&d->overlay_element_weak_ref);
+
+ if (overlay_element) {
+ gint scale = gtk_widget_get_scale_factor(widget);
+
+ gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(overlay_element), a->x * scale, a->y * scale, a->width * scale, a->height * scale);
+ gst_object_unref(overlay_element);
+ }
+}
+#endif
+
/* This callback should pass to the widget a pointer of the pipeline
* so that we can set pipeline and overlay related calls from here.
*/
--
2.19.1
More information about the Spice-devel
mailing list