xref: /aoo41x/main/vcl/inc/unx/saldata.hxx (revision 161f4cd1)
1*161f4cd1SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*161f4cd1SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*161f4cd1SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*161f4cd1SAndrew Rist  * distributed with this work for additional information
6*161f4cd1SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*161f4cd1SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*161f4cd1SAndrew Rist  * "License"); you may not use this file except in compliance
9*161f4cd1SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*161f4cd1SAndrew Rist  *
11*161f4cd1SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*161f4cd1SAndrew Rist  *
13*161f4cd1SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*161f4cd1SAndrew Rist  * software distributed under the License is distributed on an
15*161f4cd1SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*161f4cd1SAndrew Rist  * KIND, either express or implied.  See the License for the
17*161f4cd1SAndrew Rist  * specific language governing permissions and limitations
18*161f4cd1SAndrew Rist  * under the License.
19*161f4cd1SAndrew Rist  *
20*161f4cd1SAndrew Rist  *************************************************************/
21*161f4cd1SAndrew Rist 
22*161f4cd1SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_SALDATA_HXX
25cdf0e10cSrcweir #define _SV_SALDATA_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
28cdf0e10cSrcweir #include <signal.h>
29cdf0e10cSrcweir #include <unx/salstd.hxx>
30cdf0e10cSrcweir #include <salframe.hxx>
31cdf0e10cSrcweir #include <unx/salinst.h>
32cdf0e10cSrcweir #include <saldatabasic.hxx>
33cdf0e10cSrcweir #ifndef _OSL_MODULE_H
34cdf0e10cSrcweir #include <osl/module.h>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <vclpluginapi.h>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
39cdf0e10cSrcweir class SalXLib;
40cdf0e10cSrcweir class SalDisplay;
41cdf0e10cSrcweir class SalPrinter;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -=-= typedefs -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
44cdf0e10cSrcweir 
45cdf0e10cSrcweir DECLARE_LIST( SalDisplays, SalDisplay* )
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #if defined SCO || defined LINUX || defined NETBSD || defined AIX || defined HPUX || defined FREEBSD
48cdf0e10cSrcweir #include <pthread.h>
49cdf0e10cSrcweir #else
50cdf0e10cSrcweir typedef	unsigned int pthread_t;
51cdf0e10cSrcweir #endif
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
54cdf0e10cSrcweir class VCLPLUG_GEN_PUBLIC X11SalData : public SalData
55cdf0e10cSrcweir {
56cdf0e10cSrcweir protected:
57cdf0e10cSrcweir 			sal_Bool				bNoExceptions_;
58cdf0e10cSrcweir             SalXLib			   *pXLib_;
59cdf0e10cSrcweir             SalDisplay		   *m_pSalDisplay;
60cdf0e10cSrcweir             pthread_t			hMainThread_;
61cdf0e10cSrcweir             rtl::OUString       maLocalHostName;
62cdf0e10cSrcweir             rtl::OUString       maUnicodeAccumulator;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir public:
65cdf0e10cSrcweir     X11SalData();
66cdf0e10cSrcweir     virtual ~X11SalData();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     virtual void			Init();
69cdf0e10cSrcweir     virtual void			initNWF();
70cdf0e10cSrcweir     virtual void			deInitNWF();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	inline	void			XError( Display     *pDisplay, XErrorEvent *pEvent ) const;
73cdf0e10cSrcweir 
GetDisplay() const74cdf0e10cSrcweir     SalDisplay*				GetDisplay() const
75cdf0e10cSrcweir     { return m_pSalDisplay; }
SetSalDisplay(SalDisplay * pDisplay)76cdf0e10cSrcweir     void					SetSalDisplay( SalDisplay* pDisplay )
77cdf0e10cSrcweir     { m_pSalDisplay = pDisplay; }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     void					DeleteDisplay(); // for shutdown
80cdf0e10cSrcweir 
GetLib() const81cdf0e10cSrcweir 	inline	SalXLib*		GetLib() const { return pXLib_; }
GetMainThread() const82cdf0e10cSrcweir 	inline	pthread_t		GetMainThread() const { return hMainThread_; }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     void					StartTimer( sal_uLong nMS );
85cdf0e10cSrcweir 	inline	void			StopTimer();
86cdf0e10cSrcweir     void					Timeout() const;
87cdf0e10cSrcweir 
GetLocalHostName() const88cdf0e10cSrcweir     const rtl::OUString&    GetLocalHostName() const
89cdf0e10cSrcweir     { return maLocalHostName; }
GetUnicodeAccumulator()90cdf0e10cSrcweir     rtl::OUString&          GetUnicodeAccumulator() { return maUnicodeAccumulator; }
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     static int XErrorHdl( Display*, XErrorEvent* );
93cdf0e10cSrcweir     static int XIOErrorHdl( Display* );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // set helper functions to set class and res name in W_CLASS hint
96cdf0e10cSrcweir     static const char* getFrameResName();
97cdf0e10cSrcweir     static const char* getFrameClassName();
98cdf0e10cSrcweir     static rtl::OString getFrameResName( SalExtStyle nStyle );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir };
101cdf0e10cSrcweir 
GetX11SalData()102cdf0e10cSrcweir inline X11SalData* GetX11SalData()
103cdf0e10cSrcweir { return (X11SalData*)ImplGetSVData()->mpSalData; }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 
106cdf0e10cSrcweir #ifdef _SV_SALDISP_HXX
XError(Display * pDisplay,XErrorEvent * pEvent) const107cdf0e10cSrcweir inline void X11SalData::XError( Display *pDisplay,	XErrorEvent *pEvent ) const
108cdf0e10cSrcweir { pXLib_->XError( pDisplay, pEvent ); }
109cdf0e10cSrcweir #endif
110cdf0e10cSrcweir 
111cdf0e10cSrcweir class YieldMutexReleaser
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	sal_uLong				m_nYieldCount;
114cdf0e10cSrcweir public:
115cdf0e10cSrcweir 	inline YieldMutexReleaser();
116cdf0e10cSrcweir 	inline ~YieldMutexReleaser();
117cdf0e10cSrcweir };
118cdf0e10cSrcweir 
YieldMutexReleaser()119cdf0e10cSrcweir inline YieldMutexReleaser::YieldMutexReleaser()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	m_nYieldCount = GetSalData()->m_pInstance->ReleaseYieldMutex();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
~YieldMutexReleaser()124cdf0e10cSrcweir inline YieldMutexReleaser::~YieldMutexReleaser()
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     GetSalData()->m_pInstance->AcquireYieldMutex( m_nYieldCount );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir #endif // _SV_SALDATA_HXX
130cdf0e10cSrcweir 
131