summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-02-12 16:55:12 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-19 14:54:59 +0000
commit05eccaef907c9fca4f874b8ffa608d4815fbeebd (patch)
tree940b846007d1f5d1e683d9e9cc6c9e23939dd7b7 /vcl/unx
parent4b0390a9cb45f56a7c6d04eff795de8b63b13b2e (diff)
gtk3+wayland: implement video playback under gtk3 + wayland
split the gtk2 and gtk3 gtkobjects (cherry picked from commit 31fa4545985acc1594107e087cedc2d99b3d0f0b) Change-Id: I32084232c44a12e9641010b51e75710abc827695 rename X11WindowProvider to a NativeWindowHandle provider sort of thing and genericize it (cherry picked from commit e35e762d564da18b0b508112f3e4d78fd26ba99c) Change-Id: I27e1e47f2b371e5269db079cfc1262d056105f80 implement wayland handle passing for gstreamer Change-Id: I3b0effe35ad7b37ff7ab3de2a3b78b6312779139 (cherry picked from commit c0d4f3ad3307c7a0d0fddd8c413ef0cc91d382ae) gtk3+wayland: play video via gtksink gstreamer element (cherry picked from commit 8543fbc72fafc0d71a8760752ca2ef5b7119cb5c) Change-Id: Ib371fa06eda73962cbe94739e69a68b46c26e4bf Reviewed-on: https://gerrit.libreoffice.org/22462 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/app/saldata.cxx56
-rw-r--r--vcl/unx/generic/gdi/nativewindowhandleprovider.cxx17
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx2
-rw-r--r--vcl/unx/generic/gdi/x11windowprovider.cxx72
-rw-r--r--vcl/unx/generic/window/salframe.cxx2
-rw-r--r--vcl/unx/gtk/gtkobject.cxx22
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx3
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx37
-rw-r--r--vcl/unx/gtk3/gtk3gtkobject.cxx180
9 files changed, 287 insertions, 104 deletions
diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx
index 3f9d184a5566..92f4679ae793 100644
--- a/vcl/unx/generic/app/saldata.cxx
+++ b/vcl/unx/generic/app/saldata.cxx
@@ -48,7 +48,9 @@
#include "unx/sm.hxx"
#include "unx/i18n_im.hxx"
#include "unx/i18n_xkb.hxx"
-#include "unx/x11/x11display.hxx"
+#include <prex.h>
+#include <X11/Xproto.h>
+#include <postx.h>
#include "salinst.hxx"
#include <osl/signal.h>
@@ -374,6 +376,58 @@ SalXLib::~SalXLib()
close (m_pTimeoutFDS[1]);
}
+static Display *OpenX11Display(OString& rDisplay)
+{
+ /*
+ * open connection to X11 Display
+ * try in this order:
+ * o -display command line parameter,
+ * o $DISPLAY environment variable
+ * o default display
+ */
+
+ Display *pDisp = nullptr;
+
+ // is there a -display command line parameter?
+
+ sal_uInt32 nParams = osl_getCommandArgCount();
+ OUString aParam;
+ for (sal_uInt32 i=0; i<nParams; i++)
+ {
+ osl_getCommandArg(i, &aParam.pData);
+ if ( aParam == "-display" )
+ {
+ osl_getCommandArg(i+1, &aParam.pData);
+ rDisplay = OUStringToOString(
+ aParam, osl_getThreadTextEncoding());
+
+ if ((pDisp = XOpenDisplay(rDisplay.getStr()))!=nullptr)
+ {
+ /*
+ * if a -display switch was used, we need
+ * to set the environment accordingly since
+ * the clipboard build another connection
+ * to the xserver using $DISPLAY
+ */
+ OUString envVar("DISPLAY");
+ osl_setEnvironment(envVar.pData, aParam.pData);
+ }
+ break;
+ }
+ }
+
+ if (!pDisp && rDisplay.isEmpty())
+ {
+ // Open $DISPLAY or default...
+ char *pDisplay = getenv("DISPLAY");
+ if (pDisplay != nullptr)
+ rDisplay = OString(pDisplay);
+ pDisp = XOpenDisplay(pDisplay);
+ }
+
+ return pDisp;
+}
+
void SalXLib::Init()
{
SalI18N_InputMethod* pInputMethod = new SalI18N_InputMethod;
diff --git a/vcl/unx/generic/gdi/nativewindowhandleprovider.cxx b/vcl/unx/generic/gdi/nativewindowhandleprovider.cxx
new file mode 100644
index 000000000000..3afd26e31498
--- /dev/null
+++ b/vcl/unx/generic/gdi/nativewindowhandleprovider.cxx
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "unx/nativewindowhandleprovider.hxx"
+
+NativeWindowHandleProvider::~NativeWindowHandleProvider()
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 738d59bf769c..f5ffead4beeb 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -53,7 +53,7 @@
#include <unx/x11/xlimits.hxx>
#include "salgdiimpl.hxx"
-#include "unx/x11windowprovider.hxx"
+#include "unx/nativewindowhandleprovider.hxx"
#include "textrender.hxx"
#include "gdiimpl.hxx"
#include "opengl/x11/gdiimpl.hxx"
diff --git a/vcl/unx/generic/gdi/x11windowprovider.cxx b/vcl/unx/generic/gdi/x11windowprovider.cxx
deleted file mode 100644
index 5f7d289196ec..000000000000
--- a/vcl/unx/generic/gdi/x11windowprovider.cxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <vcl/svapp.hxx>
-
-#include "unx/x11windowprovider.hxx"
-#include "unx/x11/x11display.hxx"
-
-X11WindowProvider::~X11WindowProvider()
-{
-}
-
-Display *OpenX11Display(OString& rDisplay)
-{
- /*
- * open connection to X11 Display
- * try in this order:
- * o -display command line parameter,
- * o $DISPLAY environment variable
- * o default display
- */
-
- Display *pDisp = nullptr;
-
- // is there a -display command line parameter?
-
- sal_uInt32 nParams = osl_getCommandArgCount();
- OUString aParam;
- for (sal_uInt32 i=0; i<nParams; i++)
- {
- osl_getCommandArg(i, &aParam.pData);
- if ( aParam == "-display" )
- {
- osl_getCommandArg(i+1, &aParam.pData);
- rDisplay = OUStringToOString(
- aParam, osl_getThreadTextEncoding());
-
- if ((pDisp = XOpenDisplay(rDisplay.getStr()))!=nullptr)
- {
- /*
- * if a -display switch was used, we need
- * to set the environment accoringly since
- * the clipboard build another connection
- * to the xserver using $DISPLAY
- */
- OUString envVar("DISPLAY");
- osl_setEnvironment(envVar.pData, aParam.pData);
- }
- break;
- }
- }
-
- if (!pDisp && rDisplay.isEmpty())
- {
- // Open $DISPLAY or default...
- char *pDisplay = getenv("DISPLAY");
- if (pDisplay != nullptr)
- rDisplay = OString(pDisplay);
- pDisp = XOpenDisplay(pDisplay);
- }
-
- return pDisp;
-}
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index c0e3e75e36ec..63f7c9d68cd2 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -4133,7 +4133,7 @@ void X11SalFrame::EndSetClipRegion()
}
-Window X11SalFrame::GetX11Window()
+sal_uIntPtr X11SalFrame::GetNativeWindowHandle()
{
return mhWindow;
}
diff --git a/vcl/unx/gtk/gtkobject.cxx b/vcl/unx/gtk/gtkobject.cxx
index 35084aa4ef4e..18aa63a115c6 100644
--- a/vcl/unx/gtk/gtkobject.cxx
+++ b/vcl/unx/gtk/gtkobject.cxx
@@ -51,7 +51,6 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
// system data
m_aSystemData.nSize = sizeof( SystemEnvData );
-#if !GTK_CHECK_VERSION(3,0,0)
SalDisplay* pDisp = vcl_sal::getSalDisplay(GetGenericData());
m_aSystemData.pDisplay = pDisp->GetDisplay();
m_aSystemData.pVisual = pDisp->GetVisual(pParent->getXScreenNumber()).GetVisual();
@@ -59,17 +58,12 @@ GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
m_aSystemData.aColormap = pDisp->GetColormap(pParent->getXScreenNumber()).GetXColormap();
m_aSystemData.aWindow = GDK_WINDOW_XWINDOW(widget_get_window(m_pSocket));
m_aSystemData.aShellWindow = GDK_WINDOW_XWINDOW(widget_get_window(GTK_WIDGET(pParent->getWindow())));
-#else
- static int nWindow = 0;
- m_aSystemData.aWindow = nWindow;
- ++nWindow;
- m_aSystemData.aShellWindow = reinterpret_cast<long>(this);
-#endif
m_aSystemData.pSalFrame = nullptr;
m_aSystemData.pWidget = m_pSocket;
m_aSystemData.nScreen = pParent->getXScreenNumber().getXScreen();
m_aSystemData.pAppContext = nullptr;
m_aSystemData.pShellWidget = GTK_WIDGET(pParent->getWindow());
+ m_aSystemData.pToolkit = "gtk2";
g_signal_connect( G_OBJECT(m_pSocket), "button-press-event", G_CALLBACK(signalButton), this );
g_signal_connect( G_OBJECT(m_pSocket), "button-release-event", G_CALLBACK(signalButton), this );
@@ -86,11 +80,7 @@ GtkSalObject::~GtkSalObject()
{
if( m_pRegion )
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_region_destroy( m_pRegion );
-#else
gdk_region_destroy( m_pRegion );
-#endif
}
if( m_pSocket )
{
@@ -119,15 +109,9 @@ sal_uInt16 GtkSalObject::GetClipRegionType()
void GtkSalObject::BeginSetClipRegion( sal_uLong )
{
-#if GTK_CHECK_VERSION(3,0,0)
- if( m_pRegion )
- cairo_region_destroy( m_pRegion );
- m_pRegion = cairo_region_create();
-#else
if( m_pRegion )
gdk_region_destroy( m_pRegion );
m_pRegion = gdk_region_new();
-#endif
}
void GtkSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
@@ -138,11 +122,7 @@ void GtkSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight
aRect.width = nWidth;
aRect.height = nHeight;
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_region_union_rectangle( m_pRegion, &aRect );
-#else
gdk_region_union_with_rect( m_pRegion, &aRect );
-#endif
}
void GtkSalObject::EndSetClipRegion()
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 3b6caa6b3fd6..7a7c293273fb 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -1022,6 +1022,7 @@ void GtkSalFrame::InitCommon()
m_aSystemData.nScreen = m_nXScreen.getXScreen();
m_aSystemData.pAppContext = nullptr;
m_aSystemData.pShellWidget = m_aSystemData.pWidget;
+ m_aSystemData.pToolkit = "gtk2";
m_bGraphics = false;
m_pGraphics = NULL;
@@ -3929,7 +3930,7 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
return Size( aRect.GetWidth(), aRect.GetHeight() );
}
-Window GtkSalFrame::GetX11Window()
+sal_uIntPtr GtkSalFrame::GetNativeWindowHandle()
{
return widget_get_xid(m_pWindow);
}
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 70e0c9b536ef..f3bdfb251b4c 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -48,7 +48,12 @@
#include <gtk/gtk.h>
#include <prex.h>
#include <X11/Xatom.h>
-#include <gdk/gdkx.h>
+#if defined(GDK_WINDOWING_X11)
+# include <gdk/gdkx.h>
+#endif
+#if defined(GDK_WINDOWING_WAYLAND)
+# include <gdk/gdkwayland.h>
+#endif
#include <postx.h>
#include <dlfcn.h>
@@ -1085,15 +1090,14 @@ 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<long>(this);
m_aSystemData.pSalFrame = this;
m_aSystemData.pWidget = m_pWindow;
m_aSystemData.nScreen = m_nXScreen.getXScreen();
m_aSystemData.pAppContext = nullptr;
m_aSystemData.pShellWidget = m_aSystemData.pWidget;
+ m_aSystemData.pToolkit = "gtk3";
m_bGraphics = false;
m_pGraphics = nullptr;
@@ -3926,9 +3930,30 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
return Size( aRect.GetWidth(), aRect.GetHeight() );
}
-Window GtkSalFrame::GetX11Window()
+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<sal_uIntPtr>(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 96c152726c58..8f1c032190db 100644
--- a/vcl/unx/gtk3/gtk3gtkobject.cxx
+++ b/vcl/unx/gtk3/gtk3gtkobject.cxx
@@ -5,8 +5,186 @@
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include "../gtk/gtkobject.cxx"
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#include <unx/gtk/gtkobject.hxx>
+#include <unx/gtk/gtkframe.hxx>
+#include <unx/gtk/gtkdata.hxx>
+#include <unx/gtk/gtkinst.hxx>
+#include <unx/gtk/gtkgdi.hxx>
+
+GtkSalObject::GtkSalObject( GtkSalFrame* pParent, bool bShow )
+ : m_pSocket( nullptr ),
+ m_pRegion( nullptr )
+{
+ if( pParent )
+ {
+ // our plug window
+ m_pSocket = gtk_grid_new();
+ Show( bShow );
+ // insert into container
+ gtk_fixed_put( pParent->getFixedContainer(),
+ m_pSocket,
+ 0, 0 );
+ // realize so we can get a window id
+ gtk_widget_realize( m_pSocket );
+
+ // system data
+ m_aSystemData.nSize = sizeof( SystemEnvData );
+ m_aSystemData.aWindow = pParent->GetNativeWindowHandle(m_pSocket);
+ m_aSystemData.aShellWindow = reinterpret_cast<long>(this);
+ m_aSystemData.pSalFrame = nullptr;
+ m_aSystemData.pWidget = m_pSocket;
+ m_aSystemData.nScreen = pParent->getXScreenNumber().getXScreen();
+ m_aSystemData.pAppContext = nullptr;
+ m_aSystemData.pShellWidget = GTK_WIDGET(pParent->getWindow());
+ m_aSystemData.pToolkit = "gtk3";
+
+ g_signal_connect( G_OBJECT(m_pSocket), "button-press-event", G_CALLBACK(signalButton), this );
+ g_signal_connect( G_OBJECT(m_pSocket), "button-release-event", G_CALLBACK(signalButton), this );
+ g_signal_connect( G_OBJECT(m_pSocket), "focus-in-event", G_CALLBACK(signalFocus), this );
+ g_signal_connect( G_OBJECT(m_pSocket), "focus-out-event", G_CALLBACK(signalFocus), this );
+ g_signal_connect( G_OBJECT(m_pSocket), "destroy", G_CALLBACK(signalDestroy), this );
+
+ // #i59255# necessary due to sync effects with java child windows
+ pParent->Flush();
+ }
+}
+
+GtkSalObject::~GtkSalObject()
+{
+ if( m_pRegion )
+ {
+ cairo_region_destroy( m_pRegion );
+ }
+ if( m_pSocket )
+ {
+ // remove socket from parent frame's fixed container
+ gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pSocket)),
+ m_pSocket );
+ // get rid of the socket
+ // actually the gtk_container_remove should let the ref count
+ // of the socket sink to 0 and destroy it (see signalDestroy)
+ // this is just a sanity check
+ if( m_pSocket )
+ gtk_widget_destroy( m_pSocket );
+ }
+}
+
+void GtkSalObject::ResetClipRegion()
+{
+ if( m_pSocket )
+ gdk_window_shape_combine_region( widget_get_window(m_pSocket), nullptr, 0, 0 );
+}
+
+sal_uInt16 GtkSalObject::GetClipRegionType()
+{
+ return SAL_OBJECT_CLIP_INCLUDERECTS;
+}
+
+void GtkSalObject::BeginSetClipRegion( sal_uLong )
+{
+ if( m_pRegion )
+ cairo_region_destroy( m_pRegion );
+ m_pRegion = cairo_region_create();
+}
+
+void GtkSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
+{
+ GdkRectangle aRect;
+ aRect.x = nX;
+ aRect.y = nY;
+ aRect.width = nWidth;
+ aRect.height = nHeight;
+
+ cairo_region_union_rectangle( m_pRegion, &aRect );
+}
+
+void GtkSalObject::EndSetClipRegion()
+{
+ if( m_pSocket )
+ gdk_window_shape_combine_region( widget_get_window(m_pSocket), m_pRegion, 0, 0 );
+}
+
+void GtkSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
+{
+ if( m_pSocket )
+ {
+ GtkFixed* pContainer = GTK_FIXED(gtk_widget_get_parent(m_pSocket));
+ gtk_fixed_move( pContainer, m_pSocket, nX, nY );
+ gtk_widget_set_size_request( m_pSocket, nWidth, nHeight );
+ gtk_container_resize_children( GTK_CONTAINER(pContainer) );
+ }
+}
+
+void GtkSalObject::Show( bool bVisible )
+{
+ if( m_pSocket )
+ {
+ if( bVisible )
+ gtk_widget_show( m_pSocket );
+ else
+ gtk_widget_hide( m_pSocket );
+ }
+}
+
+const SystemEnvData* GtkSalObject::GetSystemData() const
+{
+ return &m_aSystemData;
+}
+
+gboolean GtkSalObject::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer object )
+{
+ GtkSalObject* pThis = static_cast<GtkSalObject*>(object);
+
+ if( pEvent->type == GDK_BUTTON_PRESS )
+ {
+ pThis->CallCallback( SALOBJ_EVENT_TOTOP, nullptr );
+ }
+
+ return FALSE;
+}
+
+gboolean GtkSalObject::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer object )
+{
+ GtkSalObject* pThis = static_cast<GtkSalObject*>(object);
+
+ pThis->CallCallback( pEvent->in ? SALOBJ_EVENT_GETFOCUS : SALOBJ_EVENT_LOSEFOCUS, nullptr );
+
+ return FALSE;
+}
+
+void GtkSalObject::signalDestroy( GtkWidget* pObj, gpointer object )
+{
+ GtkSalObject* pThis = static_cast<GtkSalObject*>(object);
+ if( pObj == pThis->m_pSocket )
+ {
+ pThis->m_pSocket = nullptr;
+ }
+}
+
+void GtkSalObject::SetForwardKey( bool bEnable )
+{
+ if( bEnable )
+ gtk_widget_add_events( GTK_WIDGET( m_pSocket ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE );
+ else
+ gtk_widget_set_events( GTK_WIDGET( m_pSocket ), ~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE) & gtk_widget_get_events( GTK_WIDGET( m_pSocket ) ) );
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */