File indexing completed on 2024-05-12 05:46:54

0001 /****************************************************************************
0002 
0003  Copyright (C) 2003 Lubos Lunak        <l.lunak@kde.org>
0004 
0005 Permission is hereby granted, free of charge, to any person obtaining a
0006 copy of this software and associated documentation files (the "Software"),
0007 to deal in the Software without restriction, including without limitation
0008 the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009 and/or sell copies of the Software, and to permit persons to whom the
0010 Software is furnished to do so, subject to the following conditions:
0011 
0012 The above copyright notice and this permission notice shall be included in
0013 all copies or substantial portions of the Software.
0014 
0015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0020 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0021 DEALINGS IN THE SOFTWARE.
0022 
0023 ****************************************************************************/
0024 
0025 //#ifdef    don't do this, this file is supposed to be included
0026 //#define   multiple times
0027 
0028 #include <QtGlobal>
0029 
0030 /* Usage:
0031 
0032  If you get compile errors caused by X11 includes (the line
0033  where first error appears contains word like None, Unsorted,
0034  Below, etc.), put #include <fixx11h.h> in the .cpp file
0035  (not .h file!) between the place where X11 headers are
0036  included and the place where the file with compile
0037  error is included (or the place where the compile error
0038  in the .cpp file occurs).
0039 
0040  This file remaps X11 #defines to const variables or
0041  inline functions. The side effect may be that these
0042  symbols may now refer to different variables
0043  (e.g. if X11 #defined NoButton, after this file
0044  is included NoButton would no longer be X11's
0045  NoButton, but Qt::NoButton instead). At this time,
0046  there's no conflict known that could cause problems.
0047 
0048  The original X11 symbols are still accessible
0049  (e.g. for None) as X::None, XNone, and also still
0050  None, unless name lookup finds different None
0051  first (in the current class, etc.)
0052 
0053  Use 'Unsorted', 'Bool' and 'index' as templates.
0054 
0055 */
0056 
0057 namespace X
0058 {
0059 
0060 // template --->
0061 // Affects: Should be without side effects.
0062 #ifdef Unsorted
0063 #ifndef FIXX11H_Unsorted
0064 #define FIXX11H_Unsorted
0065 const int XUnsorted = Unsorted;
0066 #undef Unsorted
0067 const int Unsorted = XUnsorted;
0068 #endif
0069 #undef Unsorted
0070 #endif
0071 // template <---
0072 
0073 // Affects: Should be without side effects.
0074 #ifdef None
0075 #ifndef FIXX11H_None
0076 #define FIXX11H_None
0077 const XID XNone = None;
0078 #undef None
0079 const XID None = XNone;
0080 #endif
0081 #undef None
0082 #endif
0083 
0084 // template --->
0085 // Affects: Should be without side effects.
0086 #ifdef Bool
0087 #ifndef FIXX11H_Bool
0088 #define FIXX11H_Bool
0089 #ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */
0090 #undef Bool
0091 #else
0092 typedef Bool XBool;
0093 #undef Bool
0094 typedef XBool Bool;
0095 #endif
0096 #endif
0097 #undef Bool
0098 #define _XTYPEDEF_BOOL
0099 #endif
0100 // template <---
0101 
0102 // Affects: Should be without side effects.
0103 #ifdef KeyPress
0104 #ifndef FIXX11H_KeyPress
0105 #define FIXX11H_KeyPress
0106 const int XKeyPress = KeyPress;
0107 #undef KeyPress
0108 const int KeyPress = XKeyPress;
0109 #endif
0110 #undef KeyPress
0111 #endif
0112 
0113 // Affects: Should be without side effects.
0114 #ifdef KeyRelease
0115 #ifndef FIXX11H_KeyRelease
0116 #define FIXX11H_KeyRelease
0117 const int XKeyRelease = KeyRelease;
0118 #undef KeyRelease
0119 const int KeyRelease = XKeyRelease;
0120 #endif
0121 #undef KeyRelease
0122 #endif
0123 
0124 // Affects: Should be without side effects.
0125 #ifdef Above
0126 #ifndef FIXX11H_Above
0127 #define FIXX11H_Above
0128 const int XAbove = Above;
0129 #undef Above
0130 const int Above = XAbove;
0131 #endif
0132 #undef Above
0133 #endif
0134 
0135 // Affects: Should be without side effects.
0136 #ifdef Below
0137 #ifndef FIXX11H_Below
0138 #define FIXX11H_Below
0139 const int XBelow = Below;
0140 #undef Below
0141 const int Below = XBelow;
0142 #endif
0143 #undef Below
0144 #endif
0145 
0146 // Affects: Should be without side effects.
0147 #ifdef FocusIn
0148 #ifndef FIXX11H_FocusIn
0149 #define FIXX11H_FocusIn
0150 const int XFocusIn = FocusIn;
0151 #undef FocusIn
0152 const int FocusIn = XFocusIn;
0153 #endif
0154 #undef FocusIn
0155 #endif
0156 
0157 // Affects: Should be without side effects.
0158 #ifdef FocusOut
0159 #ifndef FIXX11H_FocusOut
0160 #define FIXX11H_FocusOut
0161 const int XFocusOut = FocusOut;
0162 #undef FocusOut
0163 const int FocusOut = XFocusOut;
0164 #endif
0165 #undef FocusOut
0166 #endif
0167 
0168 // Affects: Should be without side effects.
0169 #ifdef Always
0170 #ifndef FIXX11H_Always
0171 #define FIXX11H_Always
0172 const int XAlways = Always;
0173 #undef Always
0174 const int Always = XAlways;
0175 #endif
0176 #undef Always
0177 #endif
0178 
0179 // Affects: Should be without side effects.
0180 #ifdef Expose
0181 #ifndef FIXX11H_Expose
0182 #define FIXX11H_Expose
0183 const int XExpose = Expose;
0184 #undef Expose
0185 const int Expose = XExpose;
0186 #endif
0187 #undef Expose
0188 #endif
0189 
0190 // Affects: Should be without side effects.
0191 #ifdef Success
0192 #ifndef FIXX11H_Success
0193 #define FIXX11H_Success
0194 const int XSuccess = Success;
0195 #undef Success
0196 const int Success = XSuccess;
0197 #endif
0198 #undef Success
0199 #endif
0200 
0201 // Affects: Should be without side effects.
0202 #ifdef GrayScale
0203 #ifndef FIXX11H_GrayScale
0204 #define FIXX11H_GrayScale
0205 const int XGrayScale = GrayScale;
0206 #undef GrayScale
0207 const int GrayScale = XGrayScale;
0208 #endif
0209 #undef GrayScale
0210 #endif
0211 
0212 // Affects: Should be without side effects.
0213 #ifdef Status
0214 #ifndef FIXX11H_Status
0215 #define FIXX11H_Status
0216 typedef Status XStatus;
0217 #undef Status
0218 typedef XStatus Status;
0219 #endif
0220 #undef Status
0221 #endif
0222 
0223 // template --->
0224 // Affects: Should be without side effects.
0225 #ifdef CursorShape
0226 #ifndef FIXX11H_CursorShape
0227 #define FIXX11H_CursorShape
0228 const int XCursorShape = CursorShape;
0229 #undef CursorShape
0230 const int CursorShape = XCursorShape;
0231 #endif
0232 #undef CursorShape
0233 #endif
0234 // template <---
0235 
0236 // template --->
0237 // Affects: Should be without side effects.
0238 #ifdef FontChange
0239 #ifndef FIXX11H_FontChange
0240 #define FIXX11H_FontChange
0241 const int XFontChange = FontChange;
0242 #undef FontChange
0243 const int FontChange = XFontChange;
0244 #endif
0245 #undef FontChange
0246 #endif
0247 // template <---
0248 
0249 // Affects: Should be without side effects.
0250 #ifdef NormalState
0251 #ifndef FIXX11H_NormalState
0252 #define FIXX11H_NormalState
0253 const int XNormalState = NormalState;
0254 #undef NormalState
0255 const int NormalState = XNormalState;
0256 #endif
0257 #undef NormalState
0258 #endif
0259 
0260 // template --->
0261 // Affects: Should be without side effects.
0262 #ifdef index
0263 #ifndef FIXX11H_index
0264 #define FIXX11H_index
0265 inline
0266 const char *Xindex(const char *s, int c)
0267 {
0268     return index(s, c);
0269 }
0270 #undef index
0271 inline
0272 const char *index(const char *s, int c)
0273 {
0274     return Xindex(s, c);
0275 }
0276 #endif
0277 #undef index
0278 #endif
0279 // template <---
0280 
0281 #ifdef rindex
0282 // Affects: Should be without side effects.
0283 #ifndef FIXX11H_rindex
0284 #define FIXX11H_rindex
0285 inline
0286 const char *Xrindex(const char *s, int c)
0287 {
0288     return rindex(s, c);
0289 }
0290 #undef rindex
0291 inline
0292 const char *rindex(const char *s, int c)
0293 {
0294     return Xrindex(s, c);
0295 }
0296 #endif
0297 #undef rindex
0298 #endif
0299 }
0300 
0301 using namespace X;