From 04de1501e65758a6290e66f9591d491bb20c4e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 15 Feb 2016 15:37:37 +0000 Subject: [PATCH 3/5] rename X11WindowProvider to a NativeWindowHandle provider sort of thing and genericize it (cherry picked from commit e35e762d564da18b0b508112f3e4d78fd26ba99c) Change-Id: I27e1e47f2b371e5269db079cfc1262d056105f80 --- 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 | 2 +- 14 files changed, 111 insertions(+), 139 deletions(-) create mode 100644 vcl/inc/unx/nativewindowhandleprovider.hxx delete mode 100644 vcl/inc/unx/x11/x11display.hxx delete mode 100644 vcl/inc/unx/x11windowprovider.hxx create mode 100644 vcl/unx/generic/gdi/nativewindowhandleprovider.cxx delete mode 100644 vcl/unx/generic/gdi/x11windowprovider.cxx diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a9fe72f..da80ab6 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -581,7 +581,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 da629b7..f7edd73 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include @@ -66,7 +66,8 @@ class GtkDnDTransferable; typedef void GDBusConnection; #endif -class GtkSalFrame : public SalFrame, public X11WindowProvider +class GtkSalFrame : public SalFrame + , public NativeWindowHandleProvider { struct IMHandler { @@ -518,7 +519,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/nativewindowhandleprovider.hxx b/vcl/inc/unx/nativewindowhandleprovider.hxx new file mode 100644 index 0000000..1d85cb4 --- /dev/null +++ b/vcl/inc/unx/nativewindowhandleprovider.hxx @@ -0,0 +1,25 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_VCL_UNX_NATIVEWINDOWHANDLEPROVIDER +#define INCLUDED_VCL_UNX_NATIVEWINDOWHANDLEPROVIDER + +#include + +class VCL_PLUGIN_PUBLIC NativeWindowHandleProvider +{ +public: + virtual ~NativeWindowHandleProvider(); + + virtual sal_uIntPtr GetNativeWindowHandle() = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index 9ba1957..9848e1e 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -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/inc/unx/x11/x11display.hxx b/vcl/inc/unx/x11/x11display.hxx deleted file mode 100644 index 9cb2ea5..0000000 --- a/vcl/inc/unx/x11/x11display.hxx +++ /dev/null @@ -1,25 +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/. - */ - -#ifndef INCLUDED_VCL_INC_UNX_X11_X11DISPLAY_HXX -#define INCLUDED_VCL_INC_UNX_X11_X11DISPLAY_HXX - -#include -#include -#include - -#include - -#include - -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/inc/unx/x11windowprovider.hxx b/vcl/inc/unx/x11windowprovider.hxx deleted file mode 100644 index 776c8e4..0000000 --- a/vcl/inc/unx/x11windowprovider.hxx +++ /dev/null @@ -1,28 +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/. - */ - -#ifndef INCLUDED_VCL_UNX_X11WINDOWPROVIDER -#define INCLUDED_VCL_UNX_X11WINDOWPROVIDER - -#include -#include - -#include - -class VCL_PLUGIN_PUBLIC X11WindowProvider -{ -public: - virtual ~X11WindowProvider(); - - virtual Window GetX11Window() = 0; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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 X11OpenGLSalGraphicsImpl::CreateWinContext() { - X11WindowProvider *pProvider = dynamic_cast(mrParent.m_pFrame); + NativeWindowHandleProvider *pProvider = dynamic_cast(mrParent.m_pFrame); if( !pProvider ) return nullptr; - Window aWin = pProvider->GetX11Window(); + sal_uIntPtr aWin = pProvider->GetNativeWindowHandle(); rtl::Reference 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 +#include +#include #include "salinst.hxx" #include @@ -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 #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 5f7d289..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 - -#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