From e3db863a0e767f248a13f3d8f14e185bee3b82d8 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Wed, 9 Jun 2021 15:38:24 +0900 Subject: [PATCH] wxMediaCtrl wayland support: resize video in expose_event_callback the Move handler apparently misses some resize events, so move the gst_player_video_overlay_video_renderer_set_render_rectangle call to expose_event_callback. This is kept as a separate commit because it would be more efficient to keep it in Move once we can catch that initial size change, so this commit can get reverted then. --- src/unix/mediactrl_gstplayer.cpp | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/unix/mediactrl_gstplayer.cpp b/src/unix/mediactrl_gstplayer.cpp index 606ac7271f..f8f84374e7 100644 --- a/src/unix/mediactrl_gstplayer.cpp +++ b/src/unix/mediactrl_gstplayer.cpp @@ -142,7 +142,24 @@ expose_event_callback(GtkWidget* widget, GdkEventExpose* event, wxGStreamerMedia // GST Doesn't redraw automatically while paused // Plus, the video sometimes doesn't redraw when it looses focus // or is painted over so we just tell it to redraw... - gst_player_video_overlay_video_renderer_expose(GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(be->m_video_renderer)); + gst_player_video_overlay_video_renderer_expose( + GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(be->m_video_renderer) + ); +#ifdef __WXGTK3__ + GdkWindow* window = gtk_widget_get_window(widget); + if (strcmp("GdkWaylandWindow", g_type_name(G_TYPE_FROM_INSTANCE(window))) == 0) + { + // on wayland we need to place the video + int x, y; + GtkAllocation allocation; + gdk_window_get_origin(window, &x, &y); + gtk_widget_get_allocation(widget, &allocation); + gst_player_video_overlay_video_renderer_set_render_rectangle( + GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(be->m_video_renderer), + x, y, allocation.width, allocation.height + ); + } +#endif } else { @@ -524,22 +541,10 @@ wxLongLong wxGStreamerMediaBackend::GetDuration() void wxGStreamerMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(w), int WXUNUSED(h)) { - /* GTK+ on X11 does not require explicitely setting the video size. - * Other toolkits might need to do something similar to GTK wayland too. + /* Nothing to be done here, at least for GTK+. For other toolkits we might + * have to call + * gst_player_video_overlay_video_renderer_set_render_rectangle() here */ -#ifdef __WXGTK3__ - GdkWindow* window = gtk_widget_get_window(m_ctrl->m_wxwindow); - if (window && strcmp("GdkWaylandWindow", g_type_name(G_TYPE_FROM_INSTANCE(window))) == 0) { - int x, y; - GtkAllocation allocation; - gdk_window_get_origin(window, &x, &y); - gtk_widget_get_allocation(m_ctrl->m_wxwindow, &allocation); - gst_player_video_overlay_video_renderer_set_render_rectangle( - GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(m_video_renderer), - x, y, allocation.width, allocation.height - ); - } -#endif } wxSize wxGStreamerMediaBackend::GetVideoSize() const