Commit d3908b631c531aa3721d91297badad1c85e3c4f1

Ran Benita 2012-03-24T12:33:28

Define our own None atom value Since we define our own xkb_atom_t type, it makes sense not to use the X11/X.h None value. This way we can also remove a lot of X11 includes. Signed-off-by: Ran Benita <ran234@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
diff --git a/src/atom.c b/src/atom.c
index 40c2153..f39ba45 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -88,7 +88,7 @@ typedef struct _Node {
 
 #define BAD_RESOURCE 0xe0000000
 
-static xkb_atom_t lastAtom = None;
+static xkb_atom_t lastAtom = XKB_ATOM_NONE;
 static NodePtr atomRoot = NULL;
 static unsigned long tableLength;
 static NodePtr *nodeTable = NULL;
@@ -98,7 +98,7 @@ XkbcAtomText(xkb_atom_t atom)
 {
     NodePtr node;
 
-    if ((atom == None) || (atom > lastAtom))
+    if ((atom == XKB_ATOM_NONE) || (atom > lastAtom))
         return NULL;
     if (!(node = nodeTable[atom]))
         return NULL;
@@ -123,7 +123,7 @@ xkb_intern_atom(const char *string)
     int makeit = True;
 
     if (!string)
-	return None;
+	return XKB_ATOM_NONE;
 
     len = strlen(string);
     np = &atomRoot;
@@ -181,7 +181,7 @@ xkb_intern_atom(const char *string)
                 return BAD_RESOURCE;
             }
             tableLength = newLength;
-	    table[None] = NULL;
+	    table[XKB_ATOM_NONE] = NULL;
 
             nodeTable = table;
         }
@@ -195,7 +195,7 @@ xkb_intern_atom(const char *string)
         return nd->a;
     }
     else
-        return None;
+        return XKB_ATOM_NONE;
 }
 
 static void
@@ -218,5 +218,5 @@ XkbcFreeAllAtoms(void)
     atomRoot = NULL;
     free(nodeTable);
     nodeTable = NULL;
-    lastAtom = None;
+    lastAtom = XKB_ATOM_NONE;
 }
diff --git a/src/map.c b/src/map.c
index 34df22b..e51a67a 100644
--- a/src/map.c
+++ b/src/map.c
@@ -57,7 +57,6 @@
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 #include "xkballoc.h"
-#include <X11/X.h>
 
 /**
  * Returns the total number of modifiers active in the keymap.
diff --git a/src/maprules.c b/src/maprules.c
index ecac8ae..1537ab8 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -40,11 +40,6 @@
 #define XOS_USE_NO_LOCKING
 #include <X11/Xos_r.h>
 
-#include <X11/Xproto.h>
-#include <X11/X.h>
-#include <X11/Xos.h>
-#include <X11/Xfuncs.h>
-
 #ifdef DEBUG
 #define PR_DEBUG(s)		fprintf(stderr,s)
 #define PR_DEBUG1(s,a)		fprintf(stderr,s,a)
diff --git a/src/misc.c b/src/misc.c
index 03ffeb7..37e6375 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -60,25 +60,25 @@ static struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
       1,        /* num_levels */
       0,        /* map_count */
       NULL, NULL,
-      None, NULL
+      NULL, NULL
     },
     { { ShiftMask, ShiftMask, 0 },
       2,        /* num_levels */
       mapSize(map2Level),   /* map_count */
       map2Level, NULL,
-      None,      NULL
+      NULL,      NULL
     },
     { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
       2,        /* num_levels */
       mapSize(mapAlpha),    /* map_count */
       mapAlpha, preAlpha,
-      None,     NULL
+      NULL,     NULL
     },
     { { ShiftMask, ShiftMask, NL_VMOD_MASK },
       2,        /* num_levels */
       mapSize(mapKeypad),   /* map_count */
       mapKeypad, NULL,
-      None,      NULL
+      NULL,      NULL
     }
 };
 
diff --git a/src/xkballoc.h b/src/xkballoc.h
index 2839eda..2e0a23e 100644
--- a/src/xkballoc.h
+++ b/src/xkballoc.h
@@ -27,8 +27,8 @@ authorization from the authors.
 #ifndef _XKBALLOC_H_
 #define _XKBALLOC_H_
 
-#include <X11/X.h>
 #include <X11/Xdefs.h>
+#include <X11/X.h>
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index d0e2f0f..eca1d6d 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -24,6 +24,8 @@
 
  ********************************************************/
 
+#include <X11/X.h>
+
 #include "xkbcomp.h"
 #include "xkbmisc.h"
 #include "expr.h"
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index cd35494..75c59ad 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -30,6 +30,7 @@
 #include "vmod.h"
 
 #include <ctype.h>
+#include <X11/X.h>
 
 /***====================================================================***/
 
@@ -169,7 +170,7 @@ SimpleLookup(const void * priv, xkb_atom_t field, unsigned type,
     const LookupEntry *entry;
     const char *str;
 
-    if ((priv == NULL) || (field == None) || (type != TypeInt))
+    if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt))
     {
         return False;
     }
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index f03d7dd..bfe7d13 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -141,7 +141,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
     ii->defs.fileID = info->fileID;
     ii->defs.next = NULL;
     ii->ndx = 0;
-    ii->name = None;
+    ii->name = XKB_ATOM_NONE;
     ii->virtual = False;
 }
 
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 00dc139..0a03afc 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -121,7 +121,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
     info->dflt.defs.fileID = 0;
     info->dflt.defs.merge = MergeOverride;
     info->dflt.defs.next = NULL;
-    info->dflt.name = None;
+    info->dflt.name = XKB_ATOM_NONE;
     info->dflt.mask = 0;
     info->dflt.vmask = 0;
     info->dflt.groupInfo = False;
@@ -758,7 +758,7 @@ AddLevelName(KeyTypeInfo * type,
         }
         return True;
     }
-    else if (type->lvlNames[level] != None)
+    else if (type->lvlNames[level] != XKB_ATOM_NONE)
     {
         if (warningLevel > 0)
         {
@@ -984,7 +984,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
     }
     for (i = 0; i < info->dflt.szNames; i++)
     {
-        if ((i < type.numLevels) && (info->dflt.lvlNames[i] != None))
+        if ((i < type.numLevels) && (info->dflt.lvlNames[i] != XKB_ATOM_NONE))
         {
             AddLevelName(&type, i, info->dflt.lvlNames[i], False, False);
         }
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 35210e8..ddb7afb 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -93,11 +93,11 @@ InitKeyInfo(KeyInfo * info)
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
         info->numLevels[i] = 0;
-        info->types[i] = None;
+        info->types[i] = XKB_ATOM_NONE;
         info->syms[i] = NULL;
         info->acts[i] = NULL;
     }
-    info->dfltType = None;
+    info->dfltType = XKB_ATOM_NONE;
     info->behavior.type = XkbKB_Default;
     info->behavior.data = 0;
     info->vmodmap = 0;
@@ -122,13 +122,13 @@ FreeKeyInfo(KeyInfo * info)
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
         info->numLevels[i] = 0;
-        info->types[i] = None;
+        info->types[i] = XKB_ATOM_NONE;
         free(info->syms[i]);
         info->syms[i] = NULL;
         free(info->acts[i]);
         info->acts[i] = NULL;
     }
-    info->dfltType = None;
+    info->dfltType = XKB_ATOM_NONE;
     info->behavior.type = XkbKB_Default;
     info->behavior.data = 0;
     info->vmodmap = 0;
@@ -242,7 +242,7 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
     info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo);
     info->modMap = NULL;
     for (i = 0; i < XkbNumKbdGroups; i++)
-        info->groupNames[i] = None;
+        info->groupNames[i] = XKB_ATOM_NONE;
     InitKeyInfo(&info->dflt);
     InitVModInfo(&info->vmods, xkb);
     info->action = NULL;
@@ -507,9 +507,9 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
                 MergeKeyGroups(info, into, from, (unsigned) i);
             }
         }
-        if (from->types[i] != None)
+        if (from->types[i] != XKB_ATOM_NONE)
         {
-            if ((into->types[i] != None) && (report) &&
+            if ((into->types[i] != XKB_ATOM_NONE) && report &&
                 (into->types[i] != from->types[i]))
             {
                 xkb_atom_t use, ignore;
@@ -532,7 +532,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
                         XkbcAtomText(ignore));
             }
             if ((from->defs.merge != MergeAugment)
-                || (into->types[i] == None))
+                || (into->types[i] == XKB_ATOM_NONE))
             {
                 into->types[i] = from->types[i];
             }
@@ -703,9 +703,10 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
     }
     for (i = 0; i < XkbNumKbdGroups; i++)
     {
-        if (from->groupNames[i] != None)
+        if (from->groupNames[i] != XKB_ATOM_NONE)
         {
-            if ((merge != MergeAugment) || (into->groupNames[i] == None))
+            if ((merge != MergeAugment) ||
+                (into->groupNames[i] == XKB_ATOM_NONE))
                 into->groupNames[i] = from->groupNames[i];
         }
     }
@@ -1773,9 +1774,9 @@ CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
             haveActions = True;
         autoType = False;
         /* Assign the type to the key, if it is missing. */
-        if (key->types[i] == None)
+        if (key->types[i] == XKB_ATOM_NONE)
         {
-            if (key->dfltType != None)
+            if (key->dfltType != XKB_ATOM_NONE)
                 key->types[i] = key->dfltType;
             else if (FindAutomaticType(key->numLevels[i], key->syms[i],
                                        &key->types[i], &autoType))
@@ -2016,7 +2017,7 @@ CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
             ApplyAliases(xkb, &info.aliases);
         for (i = 0; i < XkbNumKbdGroups; i++)
         {
-            if (info.groupNames[i] != None)
+            if (info.groupNames[i] != XKB_ATOM_NONE)
             {
                 free(UNCONSTIFY(xkb->names->groups[i]));
                 xkb->names->groups[i] = XkbcAtomGetString(info.groupNames[i]);
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index 3c98a4e..baab968 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -27,9 +27,6 @@
 #ifndef XKBCOMP_H
 #define	XKBCOMP_H 1
 
-#include <X11/X.h>
-#include <X11/Xdefs.h>
-
 #include "utils.h"
 
 #include "xkbcommon/xkbcommon.h"
diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y
index 13e5628..9db7ee5 100644
--- a/src/xkbcomp/xkbparse.y
+++ b/src/xkbcomp/xkbparse.y
@@ -569,11 +569,11 @@ Element		:	ACTION_TOK
 		|	SHAPE	
 			{ $$= xkb_intern_atom("shape"); }
 		|	ROW	
-			{ $$= None; }
+			{ $$= XKB_ATOM_NONE; }
 		|	SECTION	
-			{ $$= None; }
+			{ $$= XKB_ATOM_NONE; }
 		|	TEXT
-			{ $$= None; }
+			{ $$= XKB_ATOM_NONE; }
 		;
 
 OptMergeMode	:	MergeMode		{ $$= $1; }
@@ -658,7 +658,7 @@ Lhs		:	FieldSpec
 			{
 			    ExprDef *expr;
 			    expr= ExprCreate(ExprArrayRef,TypeUnknown);
-			    expr->value.array.element= None;
+			    expr->value.array.element= XKB_ATOM_NONE;
 			    expr->value.array.field= $1;
 			    expr->value.array.entry= $3;
 			    $$= expr;
diff --git a/src/xkbmisc.h b/src/xkbmisc.h
index 1d74ef5..7167aa0 100644
--- a/src/xkbmisc.h
+++ b/src/xkbmisc.h
@@ -27,13 +27,14 @@ authorization from the authors.
 #ifndef _XKBMISC_H_
 #define _XKBMISC_H_
 
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 
 typedef uint32_t xkb_atom_t;
 
+#define XKB_ATOM_NONE 0
+
 /***====================================================================***/
 
 extern Bool
diff --git a/src/xkbrules.h b/src/xkbrules.h
index a69e8b9..e57b056 100644
--- a/src/xkbrules.h
+++ b/src/xkbrules.h
@@ -27,12 +27,9 @@ authorization from the authors.
 #ifndef _XKBRULES_H_
 #define _XKBRULES_H_
 
-#include <stdio.h>
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 
-
 /* From filecommon */
 
 #define XkbXKMFile  0
diff --git a/test/filecomp.c b/test/filecomp.c
index e5538af..370c4b2 100644
--- a/test/filecomp.c
+++ b/test/filecomp.c
@@ -32,8 +32,6 @@ authorization from the authors.
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
 
diff --git a/test/namescomp.c b/test/namescomp.c
index 95dcecc..bd81447 100644
--- a/test/namescomp.c
+++ b/test/namescomp.c
@@ -26,8 +26,6 @@ authorization from the authors.
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
 
diff --git a/test/rulescomp.c b/test/rulescomp.c
index 0a84c94..c761a49 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -26,7 +26,6 @@ authorization from the authors.
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <X11/X.h>
 #include <X11/Xdefs.h>
 #include "xkbcommon/xkbcommon.h"
 #include "utils.h"
diff --git a/test/state.c b/test/state.c
index 476ee18..5c6d1f5 100644
--- a/test/state.c
+++ b/test/state.c
@@ -26,8 +26,6 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <X11/X.h>
-#include <X11/Xdefs.h>
 #include <X11/keysym.h>
 #include <linux/input.h>
 #include "xkbcommon/xkbcommon.h"