xref: /trunk/main/vcl/inc/unx/saldata.hxx (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 #ifndef _SV_SALDATA_HXX
29 #define _SV_SALDATA_HXX
30 
31 // -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
32 #include <signal.h>
33 #include <unx/salstd.hxx>
34 #include <salframe.hxx>
35 #include <unx/salinst.h>
36 #include <saldatabasic.hxx>
37 #ifndef _OSL_MODULE_H
38 #include <osl/module.h>
39 #endif
40 #include <vclpluginapi.h>
41 
42 // -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
43 class SalXLib;
44 class SalDisplay;
45 class SalPrinter;
46 
47 // -=-= typedefs -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
48 
49 DECLARE_LIST( SalDisplays, SalDisplay* )
50 
51 #if defined SCO || defined LINUX || defined NETBSD || defined AIX || defined HPUX || defined FREEBSD
52 #include <pthread.h>
53 #else
54 typedef	unsigned int pthread_t;
55 #endif
56 
57 // -=-= SalData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
58 class VCLPLUG_GEN_PUBLIC X11SalData : public SalData
59 {
60 protected:
61 			sal_Bool				bNoExceptions_;
62             SalXLib			   *pXLib_;
63             SalDisplay		   *m_pSalDisplay;
64             pthread_t			hMainThread_;
65             rtl::OUString       maLocalHostName;
66             rtl::OUString       maUnicodeAccumulator;
67 
68 public:
69     X11SalData();
70     virtual ~X11SalData();
71 
72     virtual void			Init();
73     virtual void			initNWF();
74     virtual void			deInitNWF();
75 
76 	inline	void			XError( Display     *pDisplay, XErrorEvent *pEvent ) const;
77 
78     SalDisplay*				GetDisplay() const
79     { return m_pSalDisplay; }
80     void					SetSalDisplay( SalDisplay* pDisplay )
81     { m_pSalDisplay = pDisplay; }
82 
83     void					DeleteDisplay(); // for shutdown
84 
85 	inline	SalXLib*		GetLib() const { return pXLib_; }
86 	inline	pthread_t		GetMainThread() const { return hMainThread_; }
87 
88     void					StartTimer( sal_uLong nMS );
89 	inline	void			StopTimer();
90     void					Timeout() const;
91 
92     const rtl::OUString&    GetLocalHostName() const
93     { return maLocalHostName; }
94     rtl::OUString&          GetUnicodeAccumulator() { return maUnicodeAccumulator; }
95 
96     static int XErrorHdl( Display*, XErrorEvent* );
97     static int XIOErrorHdl( Display* );
98 
99     // set helper functions to set class and res name in W_CLASS hint
100     static const char* getFrameResName();
101     static const char* getFrameClassName();
102     static rtl::OString getFrameResName( SalExtStyle nStyle );
103 
104 };
105 
106 inline X11SalData* GetX11SalData()
107 { return (X11SalData*)ImplGetSVData()->mpSalData; }
108 
109 
110 #ifdef _SV_SALDISP_HXX
111 inline void X11SalData::XError( Display *pDisplay,	XErrorEvent *pEvent ) const
112 { pXLib_->XError( pDisplay, pEvent ); }
113 #endif
114 
115 class YieldMutexReleaser
116 {
117 	sal_uLong				m_nYieldCount;
118 public:
119 	inline YieldMutexReleaser();
120 	inline ~YieldMutexReleaser();
121 };
122 
123 inline YieldMutexReleaser::YieldMutexReleaser()
124 {
125 	m_nYieldCount = GetSalData()->m_pInstance->ReleaseYieldMutex();
126 }
127 
128 inline YieldMutexReleaser::~YieldMutexReleaser()
129 {
130     GetSalData()->m_pInstance->AcquireYieldMutex( m_nYieldCount );
131 }
132 
133 #endif // _SV_SALDATA_HXX
134 
135