xref: /aoo42x/main/vcl/unx/kde4/main.cxx (revision 9f62ea84)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #define Region QtXRegion
28 #include <QApplication>
29 #undef Region
30 
31 #include "KDEData.hxx"
32 #include "KDESalInstance.hxx"
33 
34 #include "vclpluginapi.h"
35 
36 #if OSL_DEBUG_LEVEL > 1
37 #include <stdio.h>
38 #endif
39 
40 #include <rtl/string.hxx>
41 
42 /// entry point for the KDE4 VCL plugin
43 extern "C" {
create_SalInstance(oslModule)44 	VCLPLUG_KDE4_PUBLIC SalInstance* create_SalInstance( oslModule )
45 	{
46         /* #i92121# workaround deadlocks in the X11 implementation
47         */
48         static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
49         /* #i90094#
50            from now on we know that an X connection will be
51            established, so protect X against itself
52         */
53         if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
54             XInitThreads();
55 
56 #if QT_VERSION < 0x050000
57 		// Qt 4.x support needs >= 4.1.0
58 		rtl::OString aVersion( qVersion() );
59 #if OSL_DEBUG_LEVEL > 1
60 		fprintf( stderr, "qt version string is \"%s\"\n", aVersion.getStr() );
61 #endif
62 		sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0, nMicro = 0;
63 		nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
64 		if( nIndex > 0 )
65 			nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
66 		if( nIndex > 0 )
67 			nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
68 		if( nMajor != 4 || nMinor < 1 )
69 		{
70 #if OSL_DEBUG_LEVEL > 1
71 			fprintf( stderr, "unsuitable qt version %d.%d.%d\n", nMajor, nMinor, nMicro );
72 #endif
73 			return NULL;
74 		}
75 #endif
76 
77 		KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
78 #if OSL_DEBUG_LEVEL > 1
79 		fprintf( stderr, "created KDESalInstance 0x%p\n", pInstance );
80 #endif
81 
82 		// initialize SalData
83 		KDEData *salData = new KDEData();
84 		SetSalData(salData);
85 		salData->m_pInstance = pInstance;
86 		salData->Init();
87 		salData->initNWF();
88 
89 		return pInstance;
90 	}
91 }
92