Support Wayland in wxGTK wxMediaCtrl
For GTK, the current implementation assumes X11 is the only window option. Introduce runtime checks to manage Wayland too. Signed-off-by: Pierluigi Passaro <pierluigi.p@variscite.com> Closes https://github.com/wxWidgets/wxWidgets/pull/2257
This commit is contained in:
committed by
Vadim Zeitlin
parent
c82e13068a
commit
b824ed8fe6
54
include/wx/gtk/private/mediactrl.h
Normal file
54
include/wx/gtk/private/mediactrl.h
Normal file
@@ -0,0 +1,54 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gtk/private/mediactrl.h
|
||||
// Purpose: Wrap runtime checks to manage GTK windows with Wayland and X11
|
||||
// Author: Pierluigi Passaro
|
||||
// Created: 2021-03-18
|
||||
// Copyright: (c) 2021 Pierluigi Passaro <pierluigi.p@variscite.com>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GTK_PRIVATE_MEDIACTRL_H_
|
||||
#define _WX_GTK_PRIVATE_MEDIACTRL_H_
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include <gdk/gdkwayland.h>
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// "wxGtkGetIdFromWidget" from widget
|
||||
//
|
||||
// Get the windows_id performing run-time checks If the window wasn't realized
|
||||
// when Load was called, this is the callback for when it is - the purpose of
|
||||
// which is to tell GStreamer to play the video in our control
|
||||
//-----------------------------------------------------------------------------
|
||||
extern "C" {
|
||||
inline gpointer wxGtkGetIdFromWidget(GtkWidget* widget)
|
||||
{
|
||||
gdk_flush();
|
||||
|
||||
GdkWindow* window = gtk_widget_get_window(widget);
|
||||
wxASSERT(window);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#ifdef __WXGTK3__
|
||||
if ( GDK_IS_X11_WINDOW(window) )
|
||||
#endif
|
||||
{
|
||||
return (gpointer)GDK_WINDOW_XID(window);
|
||||
}
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
if ( GDK_IS_WAYLAND_WINDOW(window) )
|
||||
{
|
||||
return (gpointer)gdk_wayland_window_get_wl_surface(window);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (gpointer)NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _WX_GTK_PRIVATE_MEDIACTRL_H_
|
@@ -35,7 +35,13 @@
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include "wx/gtk/private/wrapgtk.h"
|
||||
#include <gdk/gdkx.h>
|
||||
#include "wx/gtk/private/mediactrl.h"
|
||||
#endif
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
typedef guintptr window_id_type;
|
||||
#else
|
||||
typedef gulong window_id_type;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -301,19 +307,12 @@ extern "C" {
|
||||
static gint gtk_window_realize_callback(GtkWidget* widget,
|
||||
wxGStreamerMediaBackend* be)
|
||||
{
|
||||
gdk_flush();
|
||||
|
||||
GdkWindow* window = gtk_widget_get_window(widget);
|
||||
wxASSERT(window);
|
||||
window_id_type window_id = (window_id_type)wxGtkGetIdFromWidget(widget);
|
||||
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
gst_video_overlay_set_window_handle(be->m_xoverlay,
|
||||
GDK_WINDOW_XID(window)
|
||||
);
|
||||
gst_video_overlay_set_window_handle(be->m_xoverlay, window_id);
|
||||
#else
|
||||
gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay),
|
||||
GDK_WINDOW_XID(window)
|
||||
);
|
||||
gst_x_overlay_set_xwindow_id( GST_X_OVERLAY(be->m_xoverlay), window_id);
|
||||
#endif
|
||||
GtkWidget* w = be->GetControl()->m_wxwindow;
|
||||
#ifdef __WXGTK3__
|
||||
@@ -663,6 +662,7 @@ void wxGStreamerMediaBackend::SetupXOverlay()
|
||||
wxASSERT( wxIsMainThread() );
|
||||
|
||||
// Use the xoverlay extension to tell gstreamer to play in our window
|
||||
window_id_type window_id;
|
||||
#ifdef __WXGTK__
|
||||
if (!gtk_widget_get_realized(m_ctrl->m_wxwindow))
|
||||
{
|
||||
@@ -674,22 +674,17 @@ void wxGStreamerMediaBackend::SetupXOverlay()
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_flush();
|
||||
window_id = (window_id_type)wxGtkGetIdFromWidget(m_ctrl->m_wxwindow);
|
||||
#else
|
||||
window_id = ctrl->GetHandle();
|
||||
#endif
|
||||
|
||||
GdkWindow* window = gtk_widget_get_window(m_ctrl->m_wxwindow);
|
||||
wxASSERT(window);
|
||||
#endif
|
||||
#if GST_CHECK_VERSION(1,0,0)
|
||||
gst_video_overlay_set_window_handle(m_xoverlay,
|
||||
gst_video_overlay_set_window_handle(m_xoverlay, window_id);
|
||||
#else
|
||||
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_xoverlay),
|
||||
gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_xoverlay), window_id);
|
||||
#endif
|
||||
#ifdef __WXGTK__
|
||||
GDK_WINDOW_XID(window)
|
||||
#else
|
||||
ctrl->GetHandle()
|
||||
#endif
|
||||
);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
GtkWidget* w = m_ctrl->m_wxwindow;
|
||||
#ifdef __WXGTK3__
|
||||
|
@@ -27,7 +27,7 @@
|
||||
|
||||
#ifdef __WXGTK__
|
||||
#include "wx/gtk/private/wrapgtk.h"
|
||||
#include <gdk/gdkx.h>
|
||||
#include "wx/gtk/private/mediactrl.h"
|
||||
#endif
|
||||
|
||||
wxGCC_WARNING_SUPPRESS(cast-qual)
|
||||
@@ -175,13 +175,8 @@ expose_event_callback(GtkWidget* widget, GdkEventExpose* event, wxGStreamerMedia
|
||||
extern "C" {
|
||||
static void realize_callback(GtkWidget* widget, wxGStreamerMediaBackend* be)
|
||||
{
|
||||
gdk_flush();
|
||||
|
||||
GdkWindow* window = gtk_widget_get_window(widget);
|
||||
wxASSERT(window);
|
||||
|
||||
gst_player_video_overlay_video_renderer_set_window_handle(GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(be->m_video_renderer),
|
||||
(gpointer) GDK_WINDOW_XID(window)
|
||||
wxGtkGetIdFromWidget(widget)
|
||||
);
|
||||
GtkWidget* w = be->GetControl()->m_wxwindow;
|
||||
#ifdef __WXGTK3__
|
||||
@@ -326,9 +321,7 @@ bool wxGStreamerMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkWindow* window = gtk_widget_get_window(m_ctrl->m_wxwindow);
|
||||
wxASSERT(window);
|
||||
window_handle = (gpointer) GDK_WINDOW_XID(window);
|
||||
window_handle = wxGtkGetIdFromWidget(m_ctrl->m_wxwindow);
|
||||
|
||||
GtkWidget* w = m_ctrl->m_wxwindow;
|
||||
#ifdef __WXGTK3__
|
||||
|
Reference in New Issue
Block a user