| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | //#ifdef don't do this, this file is supposed to be included |
| 8 | //#define multiple times |
| 9 | |
| 10 | #include <QtGlobal> |
| 11 | |
| 12 | /* Usage: |
| 13 | |
| 14 | If you get compile errors caused by X11 includes (the line |
| 15 | where first error appears contains word like None, Unsorted, |
| 16 | Below, etc.), put #include <fixx11h.h> in the .cpp file |
| 17 | (not .h file!) between the place where X11 headers are |
| 18 | included and the place where the file with compile |
| 19 | error is included (or the place where the compile error |
| 20 | in the .cpp file occurs). |
| 21 | |
| 22 | This file remaps X11 #defines to const variables or |
| 23 | inline functions. The side effect may be that these |
| 24 | symbols may now refer to different variables |
| 25 | (e.g. if X11 #defined NoButton, after this file |
| 26 | is included NoButton would no longer be X11's |
| 27 | NoButton, but Qt::NoButton instead). At this time, |
| 28 | there's no conflict known that could cause problems. |
| 29 | |
| 30 | The original X11 symbols are still accessible |
| 31 | (e.g. for None) as X::None, XNone, and also still |
| 32 | None, unless name lookup finds different None |
| 33 | first (in the current class, etc.) |
| 34 | |
| 35 | Use 'Unsorted', 'Bool' and 'index' as templates. |
| 36 | |
| 37 | */ |
| 38 | |
| 39 | namespace X |
| 40 | { |
| 41 | // template ---> |
| 42 | // Affects: Should be without side effects. |
| 43 | #ifdef Unsorted |
| 44 | #ifndef FIXX11H_Unsorted |
| 45 | #define FIXX11H_Unsorted |
| 46 | const int XUnsorted = Unsorted; |
| 47 | #undef Unsorted |
| 48 | const int Unsorted = XUnsorted; |
| 49 | #endif |
| 50 | #undef Unsorted |
| 51 | #endif |
| 52 | // template <--- |
| 53 | |
| 54 | // Affects: Should be without side effects. |
| 55 | #ifdef None |
| 56 | #ifndef FIXX11H_None |
| 57 | #define FIXX11H_None |
| 58 | const XID XNone = None; |
| 59 | #undef None |
| 60 | const XID None = XNone; |
| 61 | #endif |
| 62 | #undef None |
| 63 | #endif |
| 64 | |
| 65 | // template ---> |
| 66 | // Affects: Should be without side effects. |
| 67 | #ifdef Bool |
| 68 | #ifndef FIXX11H_Bool |
| 69 | #define FIXX11H_Bool |
| 70 | #ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */ |
| 71 | #undef Bool |
| 72 | #else |
| 73 | typedef Bool XBool; |
| 74 | #undef Bool |
| 75 | typedef XBool Bool; |
| 76 | #endif |
| 77 | #endif |
| 78 | #undef Bool |
| 79 | #define _XTYPEDEF_BOOL |
| 80 | #endif |
| 81 | // template <--- |
| 82 | |
| 83 | // Affects: Should be without side effects. |
| 84 | #ifdef KeyPress |
| 85 | #ifndef FIXX11H_KeyPress |
| 86 | #define FIXX11H_KeyPress |
| 87 | const int XKeyPress = KeyPress; |
| 88 | #undef KeyPress |
| 89 | const int KeyPress = XKeyPress; |
| 90 | #endif |
| 91 | #undef KeyPress |
| 92 | #endif |
| 93 | |
| 94 | // Affects: Should be without side effects. |
| 95 | #ifdef KeyRelease |
| 96 | #ifndef FIXX11H_KeyRelease |
| 97 | #define FIXX11H_KeyRelease |
| 98 | const int XKeyRelease = KeyRelease; |
| 99 | #undef KeyRelease |
| 100 | const int KeyRelease = XKeyRelease; |
| 101 | #endif |
| 102 | #undef KeyRelease |
| 103 | #endif |
| 104 | |
| 105 | // Affects: Should be without side effects. |
| 106 | #ifdef Above |
| 107 | #ifndef FIXX11H_Above |
| 108 | #define FIXX11H_Above |
| 109 | const int XAbove = Above; |
| 110 | #undef Above |
| 111 | const int Above = XAbove; |
| 112 | #endif |
| 113 | #undef Above |
| 114 | #endif |
| 115 | |
| 116 | // Affects: Should be without side effects. |
| 117 | #ifdef Below |
| 118 | #ifndef FIXX11H_Below |
| 119 | #define FIXX11H_Below |
| 120 | const int XBelow = Below; |
| 121 | #undef Below |
| 122 | const int Below = XBelow; |
| 123 | #endif |
| 124 | #undef Below |
| 125 | #endif |
| 126 | |
| 127 | // Affects: Should be without side effects. |
| 128 | #ifdef FocusIn |
| 129 | #ifndef FIXX11H_FocusIn |
| 130 | #define FIXX11H_FocusIn |
| 131 | const int XFocusIn = FocusIn; |
| 132 | #undef FocusIn |
| 133 | const int FocusIn = XFocusIn; |
| 134 | #endif |
| 135 | #undef FocusIn |
| 136 | #endif |
| 137 | |
| 138 | // Affects: Should be without side effects. |
| 139 | #ifdef FocusOut |
| 140 | #ifndef FIXX11H_FocusOut |
| 141 | #define FIXX11H_FocusOut |
| 142 | const int XFocusOut = FocusOut; |
| 143 | #undef FocusOut |
| 144 | const int FocusOut = XFocusOut; |
| 145 | #endif |
| 146 | #undef FocusOut |
| 147 | #endif |
| 148 | |
| 149 | // Affects: Should be without side effects. |
| 150 | #ifdef Always |
| 151 | #ifndef FIXX11H_Always |
| 152 | #define FIXX11H_Always |
| 153 | const int XAlways = Always; |
| 154 | #undef Always |
| 155 | const int Always = XAlways; |
| 156 | #endif |
| 157 | #undef Always |
| 158 | #endif |
| 159 | |
| 160 | // Affects: Should be without side effects. |
| 161 | #ifdef Expose |
| 162 | #ifndef FIXX11H_Expose |
| 163 | #define FIXX11H_Expose |
| 164 | const int XExpose = Expose; |
| 165 | #undef Expose |
| 166 | const int Expose = XExpose; |
| 167 | #endif |
| 168 | #undef Expose |
| 169 | #endif |
| 170 | |
| 171 | // Affects: Should be without side effects. |
| 172 | #ifdef Success |
| 173 | #ifndef FIXX11H_Success |
| 174 | #define FIXX11H_Success |
| 175 | const int XSuccess = Success; |
| 176 | #undef Success |
| 177 | const int Success = XSuccess; |
| 178 | #endif |
| 179 | #undef Success |
| 180 | #endif |
| 181 | |
| 182 | // Affects: Should be without side effects. |
| 183 | #ifdef GrayScale |
| 184 | #ifndef FIXX11H_GrayScale |
| 185 | #define FIXX11H_GrayScale |
| 186 | const int XGrayScale = GrayScale; |
| 187 | #undef GrayScale |
| 188 | const int GrayScale = XGrayScale; |
| 189 | #endif |
| 190 | #undef GrayScale |
| 191 | #endif |
| 192 | |
| 193 | // Affects: Should be without side effects. |
| 194 | #ifdef Status |
| 195 | #ifndef FIXX11H_Status |
| 196 | #define FIXX11H_Status |
| 197 | typedef Status XStatus; |
| 198 | #undef Status |
| 199 | typedef XStatus Status; |
| 200 | #endif |
| 201 | #undef Status |
| 202 | #endif |
| 203 | |
| 204 | // template ---> |
| 205 | // Affects: Should be without side effects. |
| 206 | #ifdef CursorShape |
| 207 | #ifndef FIXX11H_CursorShape |
| 208 | #define FIXX11H_CursorShape |
| 209 | const int XCursorShape = CursorShape; |
| 210 | #undef CursorShape |
| 211 | const int CursorShape = XCursorShape; |
| 212 | #endif |
| 213 | #undef CursorShape |
| 214 | #endif |
| 215 | // template <--- |
| 216 | |
| 217 | // template ---> |
| 218 | // Affects: Should be without side effects. |
| 219 | #ifdef FontChange |
| 220 | #ifndef FIXX11H_FontChange |
| 221 | #define FIXX11H_FontChange |
| 222 | const int XFontChange = FontChange; |
| 223 | #undef FontChange |
| 224 | const int FontChange = XFontChange; |
| 225 | #endif |
| 226 | #undef FontChange |
| 227 | #endif |
| 228 | // template <--- |
| 229 | |
| 230 | // Affects: Should be without side effects. |
| 231 | #ifdef NormalState |
| 232 | #ifndef FIXX11H_NormalState |
| 233 | #define FIXX11H_NormalState |
| 234 | const int XNormalState = NormalState; |
| 235 | #undef NormalState |
| 236 | const int NormalState = XNormalState; |
| 237 | #endif |
| 238 | #undef NormalState |
| 239 | #endif |
| 240 | |
| 241 | // template ---> |
| 242 | // Affects: Should be without side effects. |
| 243 | #ifdef index |
| 244 | #ifndef FIXX11H_index |
| 245 | #define FIXX11H_index |
| 246 | inline const char *Xindex(const char *s, int c) |
| 247 | { |
| 248 | return index(s, c); |
| 249 | } |
| 250 | #undef index |
| 251 | inline const char *index(const char *s, int c) |
| 252 | { |
| 253 | return Xindex(s, c); |
| 254 | } |
| 255 | #endif |
| 256 | #undef index |
| 257 | #endif |
| 258 | // template <--- |
| 259 | |
| 260 | #ifdef rindex |
| 261 | // Affects: Should be without side effects. |
| 262 | #ifndef FIXX11H_rindex |
| 263 | #define FIXX11H_rindex |
| 264 | inline const char *Xrindex(const char *s, int c) |
| 265 | { |
| 266 | return rindex(s, c); |
| 267 | } |
| 268 | #undef rindex |
| 269 | inline const char *rindex(const char *s, int c) |
| 270 | { |
| 271 | return Xrindex(s, c); |
| 272 | } |
| 273 | #endif |
| 274 | #undef rindex |
| 275 | #endif |
| 276 | } |
| 277 | |
| 278 | using namespace X; |
| 279 | |