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 #include <unistd.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <fcntl.h>
31 #include <dlfcn.h>
32
33 #include "osl/file.h"
34 #include "osl/process.h"
35 #include "osl/security.h"
36
37 #include "vcl/svapp.hxx"
38
39 #include "unx/salunx.h"
40 #include <X11/Xatom.h>
41 #ifdef USE_CDE
42 #include "unx/cdeint.hxx"
43 #endif
44 #include "unx/dtint.hxx"
45 #include "unx/saldisp.hxx"
46 #include "unx/saldata.hxx"
47 #include "unx/wmadaptor.hxx"
48
49 #include "dtsetenum.hxx"
50
51 #include <set>
52 #include <stdio.h>
53
54 // NETBSD has no RTLD_GLOBAL
55 #ifndef RTLD_GLOBAL
56 #define DLOPEN_MODE (RTLD_LAZY)
57 #else
58 #define DLOPEN_MODE (RTLD_GLOBAL | RTLD_LAZY)
59 #endif
60
61
62 using namespace rtl;
63 using namespace vcl_sal;
64
65 String DtIntegrator::aHomeDir;
66
DtIntegrator()67 DtIntegrator::DtIntegrator() :
68 meType( DtGeneric ),
69 mnSystemLookCommandProcess( -1 )
70 {
71 mpSalDisplay = GetX11SalData()->GetDisplay();
72 mpDisplay = mpSalDisplay->GetDisplay();
73 OUString aDir;
74 oslSecurity aCur = osl_getCurrentSecurity();
75 if( aCur )
76 {
77 osl_getHomeDir( aCur, &aDir.pData );
78 osl_freeSecurityHandle( aCur );
79 OUString aSysDir;
80 osl_getSystemPathFromFileURL( aDir.pData, &aSysDir.pData );
81 aHomeDir = aSysDir;
82 }
83 }
84
~DtIntegrator()85 DtIntegrator::~DtIntegrator()
86 {
87 }
88
CreateDtIntegrator()89 DtIntegrator* DtIntegrator::CreateDtIntegrator()
90 {
91 /*
92 * #i22061# override desktop detection
93 * if environment variable OOO_FORCE_DESKTOP is set
94 * to one of "cde" "kde" "gnome" then autodetection
95 * is overridden.
96 */
97 static const char* pOverride = getenv( "OOO_FORCE_DESKTOP" );
98 if( pOverride && *pOverride )
99 {
100 OString aOver( pOverride );
101
102 #if USE_CDE
103 if( aOver.equalsIgnoreAsciiCase( "cde" ) )
104 return new CDEIntegrator();
105 #endif
106 if( aOver.equalsIgnoreAsciiCase( "none" ) )
107 return new DtIntegrator();
108 }
109
110 #ifdef USE_CDE
111 void* pLibrary = NULL;
112
113 // check dt type
114 // CDE
115 SalDisplay* pSalDisplay = GetX11SalData()->GetDisplay();
116 Display* pDisplay = pSalDisplay->GetDisplay();
117 Atom nDtAtom = XInternAtom( pDisplay, "_DT_WM_READY", True );
118 if( nDtAtom && ( pLibrary = dlopen( "/usr/dt/lib/libDtSvc.so", DLOPEN_MODE ) ) )
119 {
120 dlclose( pLibrary );
121 return new CDEIntegrator();
122 }
123 #endif
124
125 // default: generic implementation
126 return new DtIntegrator();
127 }
128
GetSystemLook(AllSettings & rSettings)129 void DtIntegrator::GetSystemLook( AllSettings& rSettings )
130 {
131 // #i48001# set a default blink rate
132 StyleSettings aStyleSettings = rSettings.GetStyleSettings();
133 aStyleSettings.SetCursorBlinkTime( 500 );
134 rSettings.SetStyleSettings( aStyleSettings );
135 }
136