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