xref: /aoo42x/main/vcl/inc/unx/saldata.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _SV_SALDATA_HXX
29*cdf0e10cSrcweir #define _SV_SALDATA_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
32*cdf0e10cSrcweir #include <signal.h>
33*cdf0e10cSrcweir #include <unx/salstd.hxx>
34*cdf0e10cSrcweir #include <salframe.hxx>
35*cdf0e10cSrcweir #include <unx/salinst.h>
36*cdf0e10cSrcweir #include <saldatabasic.hxx>
37*cdf0e10cSrcweir #ifndef _OSL_MODULE_H
38*cdf0e10cSrcweir #include <osl/module.h>
39*cdf0e10cSrcweir #endif
40*cdf0e10cSrcweir #include <vclpluginapi.h>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
43*cdf0e10cSrcweir class SalXLib;
44*cdf0e10cSrcweir class SalDisplay;
45*cdf0e10cSrcweir class SalPrinter;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // -=-= typedefs -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir DECLARE_LIST( SalDisplays, SalDisplay* )
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #if defined SCO || defined LINUX || defined NETBSD || defined AIX || defined HPUX || defined FREEBSD
52*cdf0e10cSrcweir #include <pthread.h>
53*cdf0e10cSrcweir #else
54*cdf0e10cSrcweir typedef	unsigned int pthread_t;
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir // -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
58*cdf0e10cSrcweir class VCLPLUG_GEN_PUBLIC X11SalData : public SalData
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir protected:
61*cdf0e10cSrcweir 			sal_Bool				bNoExceptions_;
62*cdf0e10cSrcweir             SalXLib			   *pXLib_;
63*cdf0e10cSrcweir             SalDisplay		   *m_pSalDisplay;
64*cdf0e10cSrcweir             pthread_t			hMainThread_;
65*cdf0e10cSrcweir             rtl::OUString       maLocalHostName;
66*cdf0e10cSrcweir             rtl::OUString       maUnicodeAccumulator;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir public:
69*cdf0e10cSrcweir     X11SalData();
70*cdf0e10cSrcweir     virtual ~X11SalData();
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir     virtual void			Init();
73*cdf0e10cSrcweir     virtual void			initNWF();
74*cdf0e10cSrcweir     virtual void			deInitNWF();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	inline	void			XError( Display     *pDisplay, XErrorEvent *pEvent ) const;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     SalDisplay*				GetDisplay() const
79*cdf0e10cSrcweir     { return m_pSalDisplay; }
80*cdf0e10cSrcweir     void					SetSalDisplay( SalDisplay* pDisplay )
81*cdf0e10cSrcweir     { m_pSalDisplay = pDisplay; }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir     void					DeleteDisplay(); // for shutdown
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	inline	SalXLib*		GetLib() const { return pXLib_; }
86*cdf0e10cSrcweir 	inline	pthread_t		GetMainThread() const { return hMainThread_; }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     void					StartTimer( sal_uLong nMS );
89*cdf0e10cSrcweir 	inline	void			StopTimer();
90*cdf0e10cSrcweir     void					Timeout() const;
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     const rtl::OUString&    GetLocalHostName() const
93*cdf0e10cSrcweir     { return maLocalHostName; }
94*cdf0e10cSrcweir     rtl::OUString&          GetUnicodeAccumulator() { return maUnicodeAccumulator; }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     static int XErrorHdl( Display*, XErrorEvent* );
97*cdf0e10cSrcweir     static int XIOErrorHdl( Display* );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     // set helper functions to set class and res name in W_CLASS hint
100*cdf0e10cSrcweir     static const char* getFrameResName();
101*cdf0e10cSrcweir     static const char* getFrameClassName();
102*cdf0e10cSrcweir     static rtl::OString getFrameResName( SalExtStyle nStyle );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir };
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir inline X11SalData* GetX11SalData()
107*cdf0e10cSrcweir { return (X11SalData*)ImplGetSVData()->mpSalData; }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir #ifdef _SV_SALDISP_HXX
111*cdf0e10cSrcweir inline void X11SalData::XError( Display *pDisplay,	XErrorEvent *pEvent ) const
112*cdf0e10cSrcweir { pXLib_->XError( pDisplay, pEvent ); }
113*cdf0e10cSrcweir #endif
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir class YieldMutexReleaser
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir 	sal_uLong				m_nYieldCount;
118*cdf0e10cSrcweir public:
119*cdf0e10cSrcweir 	inline YieldMutexReleaser();
120*cdf0e10cSrcweir 	inline ~YieldMutexReleaser();
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir inline YieldMutexReleaser::YieldMutexReleaser()
124*cdf0e10cSrcweir {
125*cdf0e10cSrcweir 	m_nYieldCount = GetSalData()->m_pInstance->ReleaseYieldMutex();
126*cdf0e10cSrcweir }
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir inline YieldMutexReleaser::~YieldMutexReleaser()
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     GetSalData()->m_pInstance->AcquireYieldMutex( m_nYieldCount );
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir #endif // _SV_SALDATA_HXX
134*cdf0e10cSrcweir 
135