xref: /aoo41x/main/vcl/unx/generic/gdi/dtint.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
30 
31 #include <unistd.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <fcntl.h>
35 #include <dlfcn.h>
36 
37 #include "osl/file.h"
38 #include "osl/process.h"
39 #include "osl/security.h"
40 
41 #include "vcl/svapp.hxx"
42 
43 #include "unx/salunx.h"
44 #include <X11/Xatom.h>
45 #ifdef USE_CDE
46 #include "unx/cdeint.hxx"
47 #endif
48 #include "unx/dtint.hxx"
49 #include "unx/saldisp.hxx"
50 #include "unx/saldata.hxx"
51 #include "unx/wmadaptor.hxx"
52 
53 #include "dtsetenum.hxx"
54 
55 #include <set>
56 #include <stdio.h>
57 
58 // NETBSD has no RTLD_GLOBAL
59 #ifndef RTLD_GLOBAL
60 #define DLOPEN_MODE (RTLD_LAZY)
61 #else
62 #define DLOPEN_MODE (RTLD_GLOBAL | RTLD_LAZY)
63 #endif
64 
65 
66 using namespace rtl;
67 using namespace vcl_sal;
68 
69 String DtIntegrator::aHomeDir;
70 
71 DtIntegrator::DtIntegrator() :
72 		meType( DtGeneric ),
73         mnSystemLookCommandProcess( -1 )
74 {
75     mpSalDisplay = GetX11SalData()->GetDisplay();
76 	mpDisplay = mpSalDisplay->GetDisplay();
77     OUString aDir;
78     oslSecurity aCur = osl_getCurrentSecurity();
79     if( aCur )
80     {
81         osl_getHomeDir( aCur, &aDir.pData );
82         osl_freeSecurityHandle( aCur );
83         OUString aSysDir;
84         osl_getSystemPathFromFileURL( aDir.pData, &aSysDir.pData );
85         aHomeDir = aSysDir;
86     }
87 }
88 
89 DtIntegrator::~DtIntegrator()
90 {
91 }
92 
93 DtIntegrator* DtIntegrator::CreateDtIntegrator()
94 {
95     /*
96      *  #i22061# override desktop detection
97      *  if environment variable OOO_FORCE_DESKTOP is set
98      *  to one of "cde" "kde" "gnome" then autodetection
99      *  is overridden.
100      */
101     static const char* pOverride = getenv( "OOO_FORCE_DESKTOP" );
102     if( pOverride && *pOverride )
103     {
104         OString aOver( pOverride );
105 
106 #if USE_CDE
107         if( aOver.equalsIgnoreAsciiCase( "cde" ) )
108             return new CDEIntegrator();
109 #endif
110         if( aOver.equalsIgnoreAsciiCase( "none" ) )
111             return new DtIntegrator();
112     }
113 
114 #ifdef USE_CDE
115 	void* pLibrary = NULL;
116 
117 	// check dt type
118 	// CDE
119     SalDisplay* pSalDisplay = GetX11SalData()->GetDisplay();
120     Display* pDisplay = pSalDisplay->GetDisplay();
121 	Atom nDtAtom = XInternAtom( pDisplay, "_DT_WM_READY", True );
122 	if( nDtAtom && ( pLibrary = dlopen( "/usr/dt/lib/libDtSvc.so", DLOPEN_MODE ) ) )
123 	{
124         dlclose( pLibrary );
125 		return new CDEIntegrator();
126 	}
127 #endif
128 
129 	// default: generic implementation
130 	return new DtIntegrator();
131 }
132 
133 void DtIntegrator::GetSystemLook( AllSettings& rSettings )
134 {
135     // #i48001# set a default blink rate
136     StyleSettings aStyleSettings = rSettings.GetStyleSettings();
137     aStyleSettings.SetCursorBlinkTime( 500 );
138     rSettings.SetStyleSettings( aStyleSettings );
139 }
140