vcl/Library_vcl.mk | 2 vcl/inc/unx/gtk/gtkframe.hxx | 7 +- vcl/inc/unx/nativewindowhandleprovider.hxx | 25 +++++++ vcl/inc/unx/salframe.h | 6 - vcl/inc/unx/x11/x11display.hxx | 25 ------- vcl/inc/unx/x11windowprovider.hxx | 28 -------- vcl/opengl/x11/gdiimpl.cxx | 4 - vcl/unx/generic/app/saldata.cxx | 56 ++++++++++++++++ vcl/unx/generic/gdi/nativewindowhandleprovider.cxx | 17 ++++ vcl/unx/generic/gdi/salgdi.cxx | 2 vcl/unx/generic/gdi/x11windowprovider.cxx | 72 --------------------- vcl/unx/generic/window/salframe.cxx | 2 vcl/unx/gtk/gtksalframe.cxx | 2 vcl/unx/gtk3/gtk3gtkframe.cxx | 36 ++++++++-- vcl/unx/gtk3/gtk3gtkobject.cxx | 4 - 15 files changed, 141 insertions(+), 147 deletions(-)
New commits: commit c0d4f3ad3307c7a0d0fddd8c413ef0cc91d382ae Author: Caolán McNamara <[email protected]> Date: Mon Feb 15 15:55:40 2016 +0000 implement wayland handle passing for gstreamer Change-Id: I3b0effe35ad7b37ff7ab3de2a3b78b6312779139 diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index ccef8c5..d3ec70f 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -521,6 +521,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 e92eb13..ddfde5a 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> @@ -1084,9 +1089,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<long>(this); m_aSystemData.pSalFrame = this; m_aSystemData.pWidget = m_pWindow; @@ -3904,9 +3907,30 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen ) return Size( aRect.GetWidth(), aRect.GetHeight() ); } +sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) +{ + 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); + } + else +#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 d213e1c..062b07f 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<long>(this); m_aSystemData.pSalFrame = nullptr; m_aSystemData.pWidget = m_pSocket; commit e35e762d564da18b0b508112f3e4d78fd26ba99c Author: Caolán McNamara <[email protected]> Date: Mon Feb 15 15:37:37 2016 +0000 rename X11WindowProvider to a NativeWindowHandle provider sort of thing and genericize it Change-Id: I27e1e47f2b371e5269db079cfc1262d056105f80 diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 22e026e..3270175 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -580,7 +580,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/unx/generic/plugadapt/salplug \ vcl/unx/generic/printer/jobdata \ vcl/unx/generic/printer/ppdparser \ - vcl/unx/generic/gdi/x11windowprovider \ + vcl/unx/generic/gdi/nativewindowhandleprovider \ vcl/unx/generic/window/screensaverinhibitor \ $(if $(filter TRUE,$(ENABLE_CUPS)),\ vcl/unx/generic/printer/cupsmgr \ diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 6c7058a..ccef8c5 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -33,7 +33,7 @@ #include <salframe.hxx> #include <vcl/sysdata.hxx> -#include <unx/x11windowprovider.hxx> +#include <unx/nativewindowhandleprovider.hxx> #include <unx/saltype.h> #include <unx/screensaverinhibitor.hxx> @@ -67,7 +67,7 @@ class GtkDnDTransferable; #endif class GtkSalFrame : public SalFrame - , public X11WindowProvider + , public NativeWindowHandleProvider { struct IMHandler { @@ -521,7 +521,7 @@ public: static GtkSalFrame *getFromWindow( GtkWindow *pWindow ); - virtual Window GetX11Window() override; + virtual sal_uIntPtr GetNativeWindowHandle() override; static void KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode, guint* pGdkKeyCode, GdkModifierType *pGdkModifiers); diff --git a/vcl/inc/unx/x11windowprovider.hxx b/vcl/inc/unx/nativewindowhandleprovider.hxx similarity index 63% rename from vcl/inc/unx/x11windowprovider.hxx rename to vcl/inc/unx/nativewindowhandleprovider.hxx index 776c8e4..1d85cb4 100644 --- a/vcl/inc/unx/x11windowprovider.hxx +++ b/vcl/inc/unx/nativewindowhandleprovider.hxx @@ -7,20 +7,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef INCLUDED_VCL_UNX_X11WINDOWPROVIDER -#define INCLUDED_VCL_UNX_X11WINDOWPROVIDER - -#include <prex.h> -#include <postx.h> +#ifndef INCLUDED_VCL_UNX_NATIVEWINDOWHANDLEPROVIDER +#define INCLUDED_VCL_UNX_NATIVEWINDOWHANDLEPROVIDER #include <vcl/dllapi.h> -class VCL_PLUGIN_PUBLIC X11WindowProvider +class VCL_PLUGIN_PUBLIC NativeWindowHandleProvider { public: - virtual ~X11WindowProvider(); + virtual ~NativeWindowHandleProvider(); - virtual Window GetX11Window() = 0; + virtual sal_uIntPtr GetNativeWindowHandle() = 0; }; #endif diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index 87d38a3..e3c1e58 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -27,7 +27,7 @@ #include <unx/saltype.h> #include <unx/saldisp.hxx> #include <unx/screensaverinhibitor.hxx> -#include <unx/x11windowprovider.hxx> +#include <unx/nativewindowhandleprovider.hxx> #include <salframe.hxx> #include <salwtype.hxx> #include <salinst.hxx> @@ -50,7 +50,7 @@ namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; } #define SHOWSTATE_NORMAL 1 #define SHOWSTATE_HIDDEN 2 -class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame, public X11WindowProvider +class VCLPLUG_GEN_PUBLIC X11SalFrame : public SalFrame, public NativeWindowHandleProvider { friend class vcl_sal::WMAdaptor; friend class vcl_sal::NetWMAdaptor; @@ -261,7 +261,7 @@ public: // done setting up the clipregion virtual void EndSetClipRegion() override; - virtual Window GetX11Window() override; + virtual sal_uIntPtr GetNativeWindowHandle() override; /// @internal void setPendingSizeEvent(); diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index b1bc724..fc49e25 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -47,12 +47,12 @@ void X11OpenGLSalGraphicsImpl::Init() rtl::Reference<OpenGLContext> X11OpenGLSalGraphicsImpl::CreateWinContext() { - X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame); + NativeWindowHandleProvider *pProvider = dynamic_cast<NativeWindowHandleProvider*>(mrParent.m_pFrame); if( !pProvider ) return nullptr; - Window aWin = pProvider->GetX11Window(); + sal_uIntPtr aWin = pProvider->GetNativeWindowHandle(); rtl::Reference<OpenGLContext> pContext = OpenGLContext::Create(); pContext->setVCLOnly(); pContext->init( mrParent.GetXDisplay(), aWin, diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 3f9d184..92f4679 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/inc/unx/x11/x11display.hxx b/vcl/unx/generic/gdi/nativewindowhandleprovider.cxx similarity index 55% rename from vcl/inc/unx/x11/x11display.hxx rename to vcl/unx/generic/gdi/nativewindowhandleprovider.cxx index 9cb2ea5..3afd26e 100644 --- a/vcl/inc/unx/x11/x11display.hxx +++ b/vcl/unx/generic/gdi/nativewindowhandleprovider.cxx @@ -7,19 +7,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef INCLUDED_VCL_INC_UNX_X11_X11DISPLAY_HXX -#define INCLUDED_VCL_INC_UNX_X11_X11DISPLAY_HXX +#include "unx/nativewindowhandleprovider.hxx" -#include <prex.h> -#include <X11/Xproto.h> -#include <postx.h> +NativeWindowHandleProvider::~NativeWindowHandleProvider() +{ +} -#include <rtl/string.hxx> - -#include <vcl/dllapi.h> - -VCL_DLLPUBLIC Display* OpenX11Display(OString& rDisplay); - -#endif // INCLUDED_VCL_INC_UNX_X11_X11DISPLAY_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx index 7bc1719..1a0e34e 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 e8604ad..0000000 --- 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 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; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index aeeae87..abecfd3 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -4134,7 +4134,7 @@ void X11SalFrame::EndSetClipRegion() } -Window X11SalFrame::GetX11Window() +sal_uIntPtr X11SalFrame::GetNativeWindowHandle() { return mhWindow; } diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx index 4576f36..c164bcd 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -3936,7 +3936,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 c7d2a40..e92eb13 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -3904,7 +3904,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); }
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
