summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2018-04-10 18:12:03 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-06-01 10:06:23 +0200
commit6f4b116ef51102d59ff11a2109b2188ec9c71abb (patch)
tree03ce8a5c1bcfabaee3b68e853d1fec876ea4c1ec /vcl
parent3a0b3d3fa7ed8984908c4b6c54ae135cc0683051 (diff)
Move create_SalInstance to KDE5SalInstance class
with this, we get the same display as Qt5 + cairo rendering Change-Id: I30206d0431e16aed90f6a995fa6a475e2f418708
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vclplug_kde5.mk1
-rw-r--r--vcl/inc/qt5/Qt5Data.hxx3
-rw-r--r--vcl/inc/vclpluginapi.h6
-rw-r--r--vcl/unx/kde5/KDE5SalInstance.cxx85
-rw-r--r--vcl/unx/kde5/main.cxx88
5 files changed, 92 insertions, 91 deletions
diff --git a/vcl/Library_vclplug_kde5.mk b/vcl/Library_vclplug_kde5.mk
index 9480fca4ce44..086cae5332f2 100644
--- a/vcl/Library_vclplug_kde5.mk
+++ b/vcl/Library_vclplug_kde5.mk
@@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_kde5,\
vcl/unx/kde5/KDE5SalInstance \
vcl/unx/kde5/KDE5XLib \
vcl/unx/kde5/VCLKDE5Application \
- vcl/unx/kde5/main \
))
ifeq ($(OS),LINUX)
diff --git a/vcl/inc/qt5/Qt5Data.hxx b/vcl/inc/qt5/Qt5Data.hxx
index f8cf4fb05e6a..631e66f31f3a 100644
--- a/vcl/inc/qt5/Qt5Data.hxx
+++ b/vcl/inc/qt5/Qt5Data.hxx
@@ -24,10 +24,11 @@
#include <o3tl/enumarray.hxx>
#include <vcl/ptrstyle.hxx>
#include <memory>
+#include <vclpluginapi.h>
class QCursor;
-class Qt5Data : public GenericUnixSalData
+class VCLPLUG_QT5_PUBLIC Qt5Data : public GenericUnixSalData
{
o3tl::enumarray<PointerStyle, std::unique_ptr<QCursor>> m_aCursors;
diff --git a/vcl/inc/vclpluginapi.h b/vcl/inc/vclpluginapi.h
index aaf9f7cc4577..e8677d239937 100644
--- a/vcl/inc/vclpluginapi.h
+++ b/vcl/inc/vclpluginapi.h
@@ -41,6 +41,12 @@
#define VCLPLUG_KDE4_PUBLIC SAL_DLLPUBLIC_IMPORT
#endif
+#if defined VCLPLUG_KDE5_IMPLEMENTATION
+#define VCLPLUG_KDE5_PUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define VCLPLUG_KDE5_PUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
#if defined VCLPLUG_QT5_IMPLEMENTATION
#define VCLPLUG_QT5_PUBLIC SAL_DLLPUBLIC_EXPORT
#else
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index 31c55e3436bd..b5ce3f812c72 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -20,11 +20,13 @@
//#include "KDE4FilePicker.hxx"
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QThread>
-#include <QtGui/QClipboard>
#include <QtWidgets/QApplication>
+#include <QtGui/QClipboard>
#include <QtWidgets/QFrame>
#include <QtX11Extras/QX11Info>
+#include <osl/process.h>
+#include <qt5/Qt5Data.hxx>
#include "KDE5SalInstance.hxx"
#include "KDE5SalFrame.hxx"
@@ -67,4 +69,85 @@ bool KDE5SalInstance::IsMainThread() const
return qApp->thread() == QThread::currentThread();
}
+extern "C" {
+VCLPLUG_KDE5_PUBLIC SalInstance* create_SalInstance()
+{
+ OString aVersion(qVersion());
+ SAL_INFO("vcl.qt5", "qt version string is " << aVersion);
+
+ QApplication* pQApplication;
+ char** pFakeArgvFreeable = nullptr;
+
+ int nFakeArgc = 2;
+ const sal_uInt32 nParams = osl_getCommandArgCount();
+ OString aDisplay;
+ OUString aParam, aBin;
+
+ for (sal_uInt32 nIdx = 0; nIdx < nParams; ++nIdx)
+ {
+ osl_getCommandArg(nIdx, &aParam.pData);
+ if (aParam != "-display")
+ continue;
+ if (!pFakeArgvFreeable)
+ {
+ pFakeArgvFreeable = new char*[nFakeArgc + 2];
+ pFakeArgvFreeable[nFakeArgc++] = strdup("-display");
+ }
+ else
+ free(pFakeArgvFreeable[nFakeArgc]);
+
+ ++nIdx;
+ osl_getCommandArg(nIdx, &aParam.pData);
+ aDisplay = OUStringToOString(aParam, osl_getThreadTextEncoding());
+ pFakeArgvFreeable[nFakeArgc] = strdup(aDisplay.getStr());
+ }
+ if (!pFakeArgvFreeable)
+ pFakeArgvFreeable = new char*[nFakeArgc];
+ else
+ nFakeArgc++;
+
+ osl_getExecutableFile(&aParam.pData);
+ osl_getSystemPathFromFileURL(aParam.pData, &aBin.pData);
+ OString aExec = OUStringToOString(aBin, osl_getThreadTextEncoding());
+ pFakeArgvFreeable[0] = strdup(aExec.getStr());
+ pFakeArgvFreeable[1] = strdup("--nocrashhandler");
+
+ char** pFakeArgv = new char*[nFakeArgc];
+ for (int i = 0; i < nFakeArgc; i++)
+ pFakeArgv[i] = pFakeArgvFreeable[i];
+
+ char* session_manager = nullptr;
+ if (getenv("SESSION_MANAGER") != nullptr)
+ {
+ session_manager = strdup(getenv("SESSION_MANAGER"));
+ unsetenv("SESSION_MANAGER");
+ }
+
+ int* pFakeArgc = new int;
+ *pFakeArgc = nFakeArgc;
+ pQApplication = new QApplication(*pFakeArgc, pFakeArgv);
+
+ if (session_manager != nullptr)
+ {
+ // coverity[tainted_string] - trusted source for setenv
+ setenv("SESSION_MANAGER", session_manager, 1);
+ free(session_manager);
+ }
+
+ QApplication::setQuitOnLastWindowClosed(false);
+
+ KDE5SalInstance* pInstance = new KDE5SalInstance(new SalYieldMutex());
+
+ // initialize SalData
+ new Qt5Data(pInstance);
+
+ pInstance->m_pQApplication.reset(pQApplication);
+ pInstance->m_pFakeArgvFreeable.reset(pFakeArgvFreeable);
+ pInstance->m_pFakeArgv.reset(pFakeArgv);
+ pInstance->m_pFakeArgc.reset(pFakeArgc);
+
+ return pInstance;
+}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/main.cxx b/vcl/unx/kde5/main.cxx
deleted file mode 100644
index ad9b8234eb1d..000000000000
--- a/vcl/unx/kde5/main.cxx
+++ /dev/null
@@ -1,88 +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/.
- *
- * 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 <QtWidgets/QApplication>
-
-#include "KDE5Data.hxx"
-#include "KDE5SalInstance.hxx"
-
-#include <vclpluginapi.h>
-
-#include <rtl/string.hxx>
-
-/// entry point for the KDE4 VCL plugin
-extern "C" {
- VCLPLUG_KDE4_PUBLIC SalInstance* create_SalInstance()
- {
- /* #i92121# workaround deadlocks in the X11 implementation
- */
- static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
- /* #i90094#
- from now on we know that an X connection will be
- established, so protect X against itself
- */
- if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
- {
-#if QT_VERSION >= 0x040800
- // let Qt call XInitThreads(), so that also Qt knows it's been used
- // (otherwise QPixmap may warn about threads not being initialized)
- QApplication::setAttribute( Qt::AA_X11InitThreads );
-#else
- XInitThreads();
- // just in case somebody builds with old version and then upgrades Qt,
- // otherwise this is a no-op
- QApplication::setAttribute( static_cast< Qt::ApplicationAttribute >( 10 ));
-#endif
- }
-
-#if QT_VERSION < 0x050000
- // Qt 4.x support needs >= 4.1.0
- OString aVersion( qVersion() );
- SAL_INFO( "vcl.kde5", "qt version string is " << aVersion );
-
- sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0;
- nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
- if( nIndex > 0 )
- nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
- if( nMajor != 4 || nMinor < 1 )
- {
-#if OSL_DEBUG_LEVEL > 1
- sal_Int32 nMicro = 0;
- if( nIndex > 0 )
- nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
- SAL_INFO( "vcl.kde5", "unsuitable qt version " << nMajor << "." << nMinor << "." << nMicro );
-#endif
- return nullptr;
- }
-#endif
-
- KDE5SalInstance* pInstance = new KDE5SalInstance( new SalYieldMutex() );
- SAL_INFO( "vcl.kde5", "created KDE5SalInstance " << &pInstance );
-
- // initialize SalData
- KDE5Data *salData = new KDE5Data( pInstance );
- salData->Init();
- salData->initNWF();
- pInstance->SetLib(salData->GetLib());
-
- return pInstance;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */