From 89e48e00724b130f14719f737389bd7db28b349f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 15 Feb 2016 15:55:40 +0000 Subject: [PATCH 4/5] implement wayland handle passing for gstreamer Change-Id: I3b0effe35ad7b37ff7ab3de2a3b78b6312779139 (cherry picked from commit c0d4f3ad3307c7a0d0fddd8c413ef0cc91d382ae) --- vcl/inc/unx/gtk/gtkframe.hxx | 1 + vcl/unx/gtk3/gtk3gtkframe.cxx | 34 +++++++++++++++++++++++++++++----- vcl/unx/gtk3/gtk3gtkobject.cxx | 4 +--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index f7edd73..20a1e84 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -519,6 +519,7 @@ public: static GtkSalFrame *getFromWindow( GtkWindow *pWindow ); + sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget); virtual sal_uIntPtr GetNativeWindowHandle() override; static void KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode, diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index a88c5d0..925b185 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -48,7 +48,12 @@ #include #include #include -#include +#if defined(GDK_WINDOWING_X11) +# include +#endif +#if defined(GDK_WINDOWING_WAYLAND) +# include +#endif #include #include @@ -1085,9 +1090,7 @@ void GtkSalFrame::InitCommon() //system data m_aSystemData.nSize = sizeof( SystemEnvData ); - static int nWindow = 0; - m_aSystemData.aWindow = nWindow; - ++nWindow; + m_aSystemData.aWindow = GetNativeWindowHandle(m_pWindow); m_aSystemData.aShellWindow = reinterpret_cast(this); m_aSystemData.pSalFrame = this; m_aSystemData.pWidget = m_pWindow; @@ -3926,9 +3929,30 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen ) return Size( aRect.GetWidth(), aRect.GetHeight() ); } +sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) +{ + (void) this; // Silence loplugin:staticmethods + GdkDisplay *pDisplay = getGdkDisplay(); + GdkWindow *pWindow = gtk_widget_get_window(pWidget); + +#if defined(GDK_WINDOWING_X11) + if (GDK_IS_X11_DISPLAY(pDisplay)) + { + return GDK_WINDOW_XID(pWindow); + } +#endif +#if defined(GDK_WINDOWING_WAYLAND) + if (GDK_IS_WAYLAND_DISPLAY(pDisplay)) + { + return reinterpret_cast(gdk_wayland_window_get_wl_surface(pWindow)); + } +#endif + return 0; +} + sal_uIntPtr GtkSalFrame::GetNativeWindowHandle() { - return widget_get_xid(m_pWindow); + return GetNativeWindowHandle(m_pWindow); } void GtkDragSource::startDrag(const datatransfer::dnd::DragGestureEvent& rEvent, diff --git a/vcl/unx/gtk3/gtk3gtkobject.cxx b/vcl/unx/gtk3/gtk3gtkobject.cxx index 8c06b4e..1154033 100644 --- a/vcl/unx/gtk3/gtk3gtkobject.cxx +++ b/vcl/unx/gtk3/gtk3gtkobject.cxx @@ -51,9 +51,7 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow ) // system data m_aSystemData.nSize = sizeof( SystemEnvData ); - static int nWindow = 0; - m_aSystemData.aWindow = nWindow; - ++nWindow; + m_aSystemData.aWindow = pParent->GetNativeWindowHandle(m_pSocket); m_aSystemData.aShellWindow = reinterpret_cast(this); m_aSystemData.pSalFrame = nullptr; m_aSystemData.pWidget = m_pSocket; -- 2.7.1