File: type.c

package info (click to toggle)
elk 3.99.6-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 5,292 kB
  • ctags: 3,323
  • sloc: ansic: 22,255; sh: 8,333; lisp: 6,208; makefile: 1,143; awk: 154; cpp: 92
file content (832 lines) | stat: -rw-r--r-- 30,487 bytes parent folder | download | duplicates (2)
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
/* type.c
 *
 * $Id: type.c 158 2003-09-15 12:53:36Z sam $
 *
 * Copyright 1990, 1991, 1992, 1993, 1994, 1995, Oliver Laumann, Berlin
 * Copyright 2002, 2003 Sam Hocevar <sam@zoy.org>, Paris
 *
 * This software was derived from Elk 1.2, which was Copyright 1987, 1988,
 * 1989, Nixdorf Computer AG and TELES GmbH, Berlin (Elk 1.2 has been written
 * by Oliver Laumann for TELES Telematic Services, Berlin, in a joint project
 * between TELES and Nixdorf Microprocessor Engineering, Berlin).
 *
 * Oliver Laumann, TELES GmbH, Nixdorf Computer AG and Sam Hocevar, as co-
 * owners or individual owners of copyright in this software, grant to any
 * person or company a worldwide, royalty free, license to
 *
 *    i) copy this software,
 *   ii) prepare derivative works based on this software,
 *  iii) distribute copies of this software or derivative works,
 *   iv) perform this software, or
 *    v) display this software,
 *
 * provided that this notice is not removed and that neither Oliver Laumann
 * nor Teles nor Nixdorf are deemed to have made any representations as to
 * the suitability of this software for any purpose nor are held responsible
 * for any defects of this software.
 *
 * THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
 */

#include "xlib.h"

static Object Set_Attr_Slots;
static Object Conf_Slots;
static Object GC_Slots;
static Object Geometry_Slots;
static Object Win_Attr_Slots;
static Object Font_Info_Slots;
static Object Char_Info_Slots;
static Object Wm_Hints_Slots;
static Object Size_Hints_Slots;

static Object Sym_Parent_Relative, Sym_Copy_From_Parent;

XSetWindowAttributes SWA;
RECORD Set_Attr_Rec[] = {
    { (char *)&SWA.background_pixmap,     "background-pixmap",     T_BACKGROUND,
        0,                  CWBackPixmap },
    { (char *)&SWA.background_pixel,      "background-pixel",      T_PIXEL,
        0,                  CWBackPixel },
    { (char *)&SWA.border_pixmap,         "border-pixmap",         T_BORDER,
        0,                  CWBorderPixmap },
    { (char *)&SWA.border_pixel,          "border-pixel",          T_PIXEL,
        0,                  CWBorderPixel },
    { (char *)&SWA.bit_gravity,           "bit-gravity",           T_SYM,
        Bit_Grav_Syms,      CWBitGravity },
    { (char *)&SWA.win_gravity,           "gravity",               T_SYM,
        Grav_Syms,          CWWinGravity },
    { (char *)&SWA.backing_store,         "backing-store",         T_SYM,
        Backing_Store_Syms, CWBackingStore },
    { (char *)&SWA.backing_planes,        "backing-planes",        T_PIXEL,
        0,                  CWBackingPlanes },
    { (char *)&SWA.backing_pixel,         "backing-pixel",         T_PIXEL,
        0,                  CWBackingPixel },
    { (char *)&SWA.save_under,            "save-under",            T_BOOL,
        0,                  CWSaveUnder },
    { (char *)&SWA.event_mask,            "event-mask",            T_MASK,
        Event_Syms,         CWEventMask },
    { (char *)&SWA.do_not_propagate_mask, "do-not-propagate-mask", T_MASK,
        Event_Syms,         CWDontPropagate },
    { (char *)&SWA.override_redirect,     "override-redirect",     T_BOOL,
        0,                  CWOverrideRedirect },
    { (char *)&SWA.colormap,              "colormap",              T_COLORMAP,
        0,                  CWColormap },
    { (char *)&SWA.cursor,                "cursor",                T_CURSOR,
        0,                  CWCursor },
    { 0, 0, T_NONE, 0, 0 }
};
int Set_Attr_Size = sizeof Set_Attr_Rec / sizeof (RECORD);

XWindowChanges WC;
RECORD Conf_Rec[] = {
    { (char *)&WC.x,            "x",            T_INT,     0, CWX },
    { (char *)&WC.y,            "y",            T_INT,     0, CWY },
    { (char *)&WC.width,        "width",        T_INT,     0, CWWidth },
    { (char *)&WC.height,       "height",       T_INT,     0, CWHeight },
    { (char *)&WC.border_width, "border-width", T_INT,     0, CWBorderWidth },
    { (char *)&WC.sibling,      "sibling",      T_WINDOW,  0, CWSibling },
    { (char *)&WC.stack_mode,   "stack-mode",   T_SYM,     Stack_Mode_Syms,
        CWStackMode },
    { 0, 0, T_NONE, 0, 0 }
};
int Conf_Size = sizeof Conf_Rec / sizeof (RECORD);

XGCValues GCV;
RECORD GC_Rec[] = {
    { (char *)&GCV.function,           "function",       T_SYM,
        Func_Syms,        GCFunction },
    { (char *)&GCV.plane_mask,         "plane-mask",     T_PIXEL,
        0,                GCPlaneMask },
    { (char *)&GCV.foreground,         "foreground",     T_PIXEL,
        0,                GCForeground },
    { (char *)&GCV.background,         "background",     T_PIXEL,
        0,                GCBackground },
    { (char *)&GCV.line_width,         "line-width",     T_INT,
        0,                GCLineWidth },
    { (char *)&GCV.line_style,         "line-style",     T_SYM,
        Line_Style_Syms,  GCLineStyle },
    { (char *)&GCV.cap_style,          "cap-style",      T_SYM,
        Cap_Style_Syms,   GCCapStyle },
    { (char *)&GCV.join_style,         "join-style",     T_SYM,
        Join_Style_Syms,  GCJoinStyle },
    { (char *)&GCV.fill_style,         "fill-style",     T_SYM,
        Fill_Style_Syms,  GCFillStyle },
    { (char *)&GCV.fill_rule,          "fill-rule",      T_SYM,
        Fill_Rule_Syms,   GCFillRule },
    { (char *)&GCV.arc_mode,           "arc-mode",       T_SYM,
        Arc_Mode_Syms,    GCArcMode },
    { (char *)&GCV.tile,               "tile",           T_PIXMAP,
        0,                GCTile },
    { (char *)&GCV.stipple,            "stipple",        T_PIXMAP,
        0,                GCStipple },
    { (char *)&GCV.ts_x_origin,        "ts-x",           T_INT,
        0,                GCTileStipXOrigin },
    { (char *)&GCV.ts_y_origin,        "ts-y",           T_INT,
        0,                GCTileStipYOrigin },
    { (char *)&GCV.font,               "font",           T_FONT,
        0,                GCFont },
    { (char *)&GCV.subwindow_mode,     "subwindow-mode", T_SYM,
        Subwin_Mode_Syms, GCSubwindowMode },
    { (char *)&GCV.graphics_exposures, "exposures",      T_BOOL,
        0,                GCGraphicsExposures },
    { (char *)&GCV.clip_x_origin,      "clip-x",         T_INT,
        0,                GCClipXOrigin },
    { (char *)&GCV.clip_y_origin,      "clip-y",         T_INT,
        0,                GCClipYOrigin },
    { (char *)&GCV.clip_mask,          "clip-mask",      T_PIXMAP,
        0,                GCClipMask },
    { (char *)&GCV.dash_offset,        "dash-offset",    T_INT,
        0,                GCDashOffset },
    { (char *)&GCV.dashes,             "dashes",         T_CHAR,
        0,                GCDashList },
    {0, 0, T_NONE, 0, 0 }
};
int GC_Size = sizeof GC_Rec / sizeof (RECORD);

GEOMETRY GEO;
RECORD Geometry_Rec[] = {
    { (char *)&GEO.root,              "root",         T_WINDOW, 0, 0 },
    { (char *)&GEO.x,                 "x",            T_INT,    0, 0 },
    { (char *)&GEO.y,                 "y",            T_INT,    0, 0 },
    { (char *)&GEO.width,             "width",        T_INT,    0, 0 },
    { (char *)&GEO.height,            "height",       T_INT,    0, 0 },
    { (char *)&GEO.border_width,      "border-width", T_INT,    0, 0 },
    { (char *)&GEO.depth,             "depth",        T_INT,    0, 0 },
    {0, 0, T_NONE, 0, 0 }
};
int Geometry_Size = sizeof Geometry_Rec / sizeof (RECORD);

XWindowAttributes WA;
RECORD Win_Attr_Rec[] = {
    { (char *)&WA.x,                    "x",                      T_INT,
        0,                  0 },
    { (char *)&WA.y,                    "y",                      T_INT,
        0,                  0 },
    { (char *)&WA.width,                "width",                  T_INT,
        0,                  0 },
    { (char *)&WA.height,               "height",                 T_INT,
        0,                  0 },
    { (char *)&WA.border_width,         "border-width",           T_INT,
        0,                  0 },
    { (char *)&WA.depth,                "depth",                  T_INT,
        0,                  0 },
    { (char *)&WA.visual,               "visual",                 T_NONE,
        0,                  0 },
    { (char *)&WA.root,                 "root",                   T_WINDOW,
        0,                  0 },
#if defined(__cplusplus) || defined(c_plusplus)
    { (char *)&WA.c_class,              "class",                  T_SYM,
#else
    { (char *)&WA.class,                "class",                  T_SYM,
#endif
        Class_Syms,         0 },
    { (char *)&WA.bit_gravity,          "bit-gravity",            T_SYM,
        Bit_Grav_Syms,      0 },
    { (char *)&WA.win_gravity,          "gravity",                T_SYM,
        Grav_Syms,          0 },
    { (char *)&WA.backing_store,        "backing-store",          T_SYM,
        Backing_Store_Syms, 0 },
    { (char *)&WA.backing_planes,       "backing-planes",         T_PIXEL,
        0,                  0 },
    { (char *)&WA.backing_pixel,        "backing-pixel",          T_PIXEL,
        0,                  0 },
    { (char *)&WA.save_under,           "save-under",             T_BOOL,
        0,                  0 },
    { (char *)&WA.colormap ,            "colormap",               T_COLORMAP,
        0,                  0 },
    { (char *)&WA.map_installed,        "map-installed",          T_BOOL,
        0,                  0 },
    { (char *)&WA.map_state,            "map-state",              T_SYM,
        Map_State_Syms,     0 },
    { (char *)&WA.all_event_masks,      "all-event-masks",        T_MASK,
        Event_Syms,         0 },
    { (char *)&WA.your_event_mask,      "your-event-mask",        T_MASK,
        Event_Syms,         0 },
    { (char *)&WA.do_not_propagate_mask, "do-not-propagate-mask", T_MASK,
        Event_Syms,         0 },
    { (char *)&WA.override_redirect,    "override-redirect",      T_BOOL,
        0,                  0 },
    { (char *)&WA.screen,               "screen",                 T_NONE,
        0,                  0 },
    {0, 0, T_NONE, 0, 0 }
};
int Win_Attr_Size = sizeof Win_Attr_Rec / sizeof (RECORD);

XFontStruct FI;
RECORD Font_Info_Rec[] = {
    { (char *)&FI.direction,            "direction",             T_SYM,
        Direction_Syms,     0 },
    { (char *)&FI.min_char_or_byte2,    "min-byte2",             T_INT,
        0,                  0 },
    { (char *)&FI.max_char_or_byte2,    "max-byte2",             T_INT,
        0,                  0 },
    { (char *)&FI.min_byte1,            "min-byte1",             T_INT,
        0,                  0 },
    { (char *)&FI.max_byte1,            "max-byte1",             T_INT,
        0,                  0 },
    { (char *)&FI.all_chars_exist,      "all-chars-exist?",      T_BOOL,
        0,                  0 },
    { (char *)&FI.default_char,         "default-char",          T_INT,
        0,                  0 },
    { (char *)&FI.ascent,               "ascent",                T_INT,
        0,                  0 },
    { (char *)&FI.descent,              "descent",               T_INT,
        0,                  0 },
    {0, 0, T_NONE, 0, 0 }
};
int Font_Info_Size = sizeof Font_Info_Rec / sizeof (RECORD);

XCharStruct CI;
RECORD Char_Info_Rec[] = {
    { (char *)&CI.lbearing,      "lbearing",       T_SHORT, 0, 0 },
    { (char *)&CI.rbearing,      "rbearing",       T_SHORT, 0, 0 },
    { (char *)&CI.width,         "width",          T_SHORT, 0, 0 },
    { (char *)&CI.ascent,        "ascent",         T_SHORT, 0, 0 },
    { (char *)&CI.descent,       "descent",        T_SHORT, 0, 0 },
    { (char *)&CI.attributes,    "attributes",     T_SHORT, 0, 0 },
    {0, 0, T_NONE, 0, 0 }
};
int Char_Info_Size = sizeof Char_Info_Rec / sizeof (RECORD);

XWMHints WMH;
RECORD Wm_Hints_Rec[] = {
    { (char *)&WMH.input,         "input?",        T_BOOL,
        0,                  InputHint },
    { (char *)&WMH.initial_state, "initial-state", T_SYM,
        Initial_State_Syms, StateHint },
    { (char *)&WMH.icon_pixmap,   "icon-pixmap",   T_PIXMAP,
        0,                  IconPixmapHint },
    { (char *)&WMH.icon_window,   "icon-window",   T_WINDOW,
        0,                  IconWindowHint },
    { (char *)&WMH.icon_x,        "icon-x",        T_INT,
        0,                  IconPositionHint },
    { (char *)&WMH.icon_y,        "icon-y",        T_INT,
        0,                  IconPositionHint },
    { (char *)&WMH.icon_mask,     "icon-mask",     T_PIXMAP,
        0,                  IconMaskHint },
    { (char *)&WMH.window_group,  "window-group",  T_WINDOW,
        0,                  WindowGroupHint },
    {0, 0, T_NONE, 0, 0 }
};
int Wm_Hints_Size = sizeof Wm_Hints_Rec / sizeof (RECORD);

XSizeHints SZH;
RECORD Size_Hints_Rec[] = {
    { (char *)&SZH.x,              "x",               T_INT,  0, PPosition },
    { (char *)&SZH.y,              "y",               T_INT,  0, PPosition },
    { (char *)&SZH.width,          "width",           T_INT,  0, PSize },
    { (char *)&SZH.height,         "height",          T_INT,  0, PSize },
    { (char *)&SZH.x,              "x",               T_INT,  0, USPosition },
    { (char *)&SZH.y,              "y",               T_INT,  0, USPosition },
    { (char *)&SZH.width,          "width",           T_INT,  0, USSize },
    { (char *)&SZH.height,         "height",          T_INT,  0, USSize },
    { (char *)&SZH.min_width,      "min-width",       T_INT,  0, PMinSize },
    { (char *)&SZH.min_height,     "min-height",      T_INT,  0, PMinSize },
    { (char *)&SZH.max_width,      "max-width",       T_INT,  0, PMaxSize },
    { (char *)&SZH.max_height,     "max-height",      T_INT,  0, PMaxSize },
    { (char *)&SZH.width_inc,      "width-inc",       T_INT,  0, PResizeInc },
    { (char *)&SZH.height_inc,     "height-inc",      T_INT,  0, PResizeInc },
    { (char *)&SZH.min_aspect.x,   "min-aspect-x",    T_INT,  0, PAspect },
    { (char *)&SZH.min_aspect.y,   "min-aspect-y",    T_INT,  0, PAspect },
    { (char *)&SZH.max_aspect.x,   "max-aspect-x",    T_INT,  0, PAspect },
    { (char *)&SZH.max_aspect.y,   "max-aspect-y",    T_INT,  0, PAspect },
    { (char *)&SZH.base_width,     "base-width",      T_INT,  0, PBaseSize },
    { (char *)&SZH.base_height,    "base-height",     T_INT,  0, PBaseSize },
    { (char *)&SZH.win_gravity,    "gravity",         T_SYM,  Grav_Syms,
                                                                 PWinGravity },
    {0, 0, T_NONE, 0, 0 }
};
int Size_Hints_Size = sizeof Size_Hints_Rec / sizeof (RECORD);

unsigned long Vector_To_Record (Object v, unsigned int len, Object sym,
                                register RECORD *rp) {
    register Object *p;
    unsigned long mask = 0;

    Check_Type (v, T_Vector);
    p = VECTOR(v)->data;
    if (VECTOR(v)->size != len && !EQ(p[0], sym))
        Primitive_Error ("invalid argument");
    for ( ; rp->slot; rp++) {
        ++p;
        if (rp->type == T_NONE || Nullp (*p))
            continue;
        switch (rp->type) {
        case T_INT:
            *(int *)rp->slot = Get_Integer (*p); break;
        case T_SHORT:
            *(short *)rp->slot = Get_Integer (*p); break;
        case T_CHAR:
            *(char *)rp->slot = Get_Integer (*p); break;
        case T_PIXEL:
            *(unsigned long *)rp->slot = Get_Pixel (*p); break;
        case T_BACKGROUND:
            if (EQ(*p, Sym_None))
                *(Pixmap *)rp->slot = None;
            else if (EQ(*p, Sym_Parent_Relative))
                *(Pixmap *)rp->slot = ParentRelative;
            else
                *(Pixmap *)rp->slot = Get_Pixmap (*p);
            break;
        case T_BORDER:
            if (EQ(*p, Sym_Copy_From_Parent)) {
                *(Pixmap *)rp->slot = CopyFromParent;
                break;
            }
            /* fall through */
        case T_PIXMAP:
            *(Pixmap *)rp->slot = Get_Pixmap (*p); break;
        case T_BOOL:
            Check_Type (*p, T_Boolean);
            *(Bool *)rp->slot = (Bool)(FIXNUM(*p));
            break;
        case T_FONT:
            *(Font *)rp->slot = Get_Font (*p);
            break;
        case T_COLORMAP:
            *(Colormap *)rp->slot = Get_Colormap (*p); break;
        case T_CURSOR:
            *(Cursor *)rp->slot = Get_Cursor (*p);
            break;
        case T_WINDOW:
            break;
        case T_MASK:
            *(long *)rp->slot = Symbols_To_Bits (*p, 1, rp->syms);
            break;
        case T_SYM:
            *(int *)rp->slot = (int)Symbols_To_Bits (*p, 0, rp->syms);
            break;
        default:
            Panic ("vector->record");
        }
        mask |= rp->mask;
    }
    return mask;
}

Object Record_To_Vector (register RECORD *rp, int len, Object sym,
                         Display *dpy, unsigned long flags) {
    register int i;
    Object v, x;
    GC_Node2;

    v = Null;
    GC_Link2 (sym, v);
    v = Make_Vector (len, Null);
    VECTOR(v)->data[0] = sym;
    for (i = 1; rp->slot; i++, rp++) {
        if (rp->type == T_NONE)
            continue;
        if (rp->mask && !(flags & rp->mask))
            continue;
        x = Null;
        switch (rp->type) {
        case T_INT:
            x = Make_Integer (*(int *)rp->slot); break;
        case T_SHORT:
            x = Make_Integer (*(short *)rp->slot); break;
        case T_CHAR:
            x = Make_Integer (*(char *)rp->slot); break;
        case T_PIXEL:
            x = Make_Pixel (*(unsigned long *)rp->slot); break;
        case T_PIXMAP:
            if (*(unsigned long *)rp->slot == ~0UL)
                x = Sym_None;
            else
                x = Make_Pixmap_Foreign (dpy, *(Pixmap *)rp->slot);
            break;
        case T_FONT:
            if (*(unsigned long *)rp->slot == ~0UL)
                x = Sym_None;
            else {
                register XFontStruct *info;
                Disable_Interrupts;
                info = XQueryFont (dpy, *(Font *)rp->slot);
                Enable_Interrupts;
                x = Make_Font_Foreign (dpy, False, *(Font *)rp->slot, info);
            }
            break;
        case T_BOOL:
            x = *(Bool *)rp->slot ? True : False; break;
        case T_COLORMAP:
            x = Make_Colormap (0, dpy, *(Colormap *)rp->slot); break;
        case T_WINDOW:
            x = Make_Window (0, dpy, *(Window *)rp->slot); break;
        case T_MASK:
            x = Bits_To_Symbols (*(long *)rp->slot, 1, rp->syms);
            break;
        case T_SYM:
            x = Bits_To_Symbols ((unsigned long)*(int *)rp->slot, 0, rp->syms);
            break;
        default:
            Panic ("record->vector");
        }
        VECTOR(v)->data[i] = x;
    }
    GC_Unlink;
    return v;
}

SYMDESCR Func_Syms[] = {
    { "clear",         GXclear },
    { "and",           GXand },
    { "and-reverse",   GXandReverse },
    { "copy",          GXcopy },
    { "and-inverted",  GXandInverted },
    { "no-op",         GXnoop },
    { "xor",           GXxor },
    { "or",            GXor },
    { "nor",           GXnor },
    { "equiv",         GXequiv },
    { "invert",        GXinvert },
    { "or-reverse",    GXorReverse },
    { "copy-inverted", GXcopyInverted },
    { "or-inverted",   GXorInverted },
    { "nand",          GXnand },
    { "set",           GXset },
    { 0, 0 }
};

SYMDESCR Bit_Grav_Syms[] = {
    { "forget",        ForgetGravity },
    { "north-west",    NorthWestGravity },
    { "north",         NorthGravity },
    { "north-east",    NorthEastGravity },
    { "west",          WestGravity },
    { "center",        CenterGravity },
    { "east",          EastGravity },
    { "south-west",    SouthWestGravity },
    { "south",         SouthGravity },
    { "south-east",    SouthEastGravity },
    { "static",        StaticGravity },
    { 0, 0 }
};

SYMDESCR Grav_Syms[] = {
    { "unmap",         UnmapGravity },
    { "north-west",    NorthWestGravity },
    { "north",         NorthGravity },
    { "north-east",    NorthEastGravity },
    { "west",          WestGravity },
    { "center",        CenterGravity },
    { "east",          EastGravity },
    { "south-west",    SouthWestGravity },
    { "south",         SouthGravity },
    { "south-east",    SouthEastGravity },
    { "static",        StaticGravity },
    { 0, 0 }
};

SYMDESCR Backing_Store_Syms[] = {
    { "not-useful",    NotUseful },
    { "when-mapped",   WhenMapped },
    { "always",        Always },
    { 0, 0 }
};

SYMDESCR Stack_Mode_Syms[] = {
    { "above",        Above },
    { "below",        Below },
    { "top-if",       TopIf },
    { "bottom-if",    BottomIf },
    { "opposite",     Opposite },
    { 0, 0 }
};

SYMDESCR Line_Style_Syms[] = {
    { "solid",        LineSolid },
    { "dash",         LineOnOffDash },
    { "double-dash",  LineDoubleDash },
    { 0, 0 }
};

SYMDESCR Cap_Style_Syms[] = {
    { "not-last",     CapNotLast },
    { "butt",         CapButt },
    { "round",        CapRound },
    { "projecting",   CapProjecting },
    { 0, 0 }
};

SYMDESCR Join_Style_Syms[] = {
    { "miter",        JoinMiter },
    { "round",        JoinRound },
    { "bevel",        JoinBevel },
    { 0, 0 }
};

SYMDESCR Fill_Style_Syms[] = {
    { "solid",        FillSolid },
    { "tiled",        FillTiled },
    { "stippled",     FillStippled },
    { "opaque-stippled", FillOpaqueStippled },
    { 0, 0 }
};

SYMDESCR Fill_Rule_Syms[] = {
    { "even-odd",     EvenOddRule },
    { "winding",      WindingRule },
    { 0, 0 }
};

SYMDESCR Arc_Mode_Syms[] = {
    { "chord",        ArcChord },
    { "pie-slice",    ArcPieSlice },
    { 0, 0 }
};

SYMDESCR Subwin_Mode_Syms[] = {
    { "clip-by-children",    ClipByChildren },
    { "include-inferiors",   IncludeInferiors },
    { 0, 0 }
};

SYMDESCR Class_Syms[] = {
    { "input-output",    InputOutput },
    { "input-only",      InputOnly },
    { 0, 0 }
};

SYMDESCR Map_State_Syms[] = {
    { "unmapped",      IsUnmapped },
    { "unviewable",    IsUnviewable },
    { "viewable",      IsViewable },
    { 0, 0 }
};

SYMDESCR State_Syms[] = {
    { "shift",        ShiftMask },
    { "lock",         LockMask },
    { "control",      ControlMask },
    { "mod1",         Mod1Mask },
    { "mod2",         Mod2Mask },
    { "mod3",         Mod3Mask },
    { "mod4",         Mod4Mask },
    { "mod5",         Mod5Mask },
    { "button1",      Button1Mask },
    { "button2",      Button2Mask },
    { "button3",      Button3Mask },
    { "button4",      Button4Mask },
    { "button5",      Button5Mask },
    { "any-modifier", AnyModifier },
    { 0, 0 }
};

SYMDESCR Button_Syms[] = {
    { "any-button",   AnyButton },
    { "button1",      Button1 },
    { "button2",      Button2 },
    { "button3",      Button3 },
    { "button4",      Button4 },
    { "button5",      Button5 },
    { 0, 0 }
};

SYMDESCR Cross_Mode_Syms[] = {
    { "normal",       NotifyNormal },
    { "grab",         NotifyGrab },
    { "ungrab",       NotifyUngrab },
    { 0, 0 }
};

SYMDESCR Cross_Detail_Syms[] = {
    { "ancestor",          NotifyAncestor },
    { "virtual",           NotifyVirtual },
    { "inferior",          NotifyInferior },
    { "nonlinear",         NotifyNonlinear },
    { "nonlinear-virtual", NotifyNonlinearVirtual },
    { 0, 0 }
};

SYMDESCR Focus_Detail_Syms[] = {
    { "ancestor",          NotifyAncestor },
    { "virtual",           NotifyVirtual },
    { "inferior",          NotifyInferior },
    { "nonlinear",         NotifyNonlinear },
    { "nonlinear-virtual", NotifyNonlinearVirtual },
    { "pointer",           NotifyPointer },
    { "pointer-root",      NotifyPointerRoot },
    { "none",              NotifyDetailNone },
    { 0, 0 }
};

SYMDESCR Visibility_Syms[] = {
    { "unobscured",         VisibilityUnobscured },
    { "partially-obscured", VisibilityPartiallyObscured },
    { "fully-obscured",     VisibilityFullyObscured },
    { 0, 0 }
};

SYMDESCR Place_Syms[] = {
    { "top",      PlaceOnTop },
    { "bottom",   PlaceOnBottom },
    { 0, 0 }
};

SYMDESCR Prop_Syms[] = {
    { "new-value", PropertyNewValue },
    { "deleted",   PropertyDelete },
    { 0, 0 }
};

SYMDESCR Mapping_Syms[] = {
    { "modifier", MappingModifier },
    { "keyboard", MappingKeyboard },
    { "pointer",  MappingPointer },
    { 0, 0 }
};

SYMDESCR Direction_Syms[] = {
    { "left-to-right", FontLeftToRight },
    { "right-to-left", FontRightToLeft },
    { 0, 0 }
};

SYMDESCR Polyshape_Syms[] = {
    { "complex",       Complex },
    { "non-convex",    Nonconvex },
    { "convex",        Convex },
    { 0, 0 }
};

SYMDESCR Propmode_Syms[] = {
    { "replace",    PropModeReplace },
    { "prepend",    PropModePrepend },
    { "append",     PropModeAppend },
    { 0, 0 }
};

SYMDESCR Grabstatus_Syms[] = {
    { "success",         Success },
    { "not-viewable",    GrabNotViewable },
    { "already-grabbed", AlreadyGrabbed },
    { "frozen",          GrabFrozen },
    { "invalid-time",    GrabInvalidTime },
    { 0, 0 }
};

SYMDESCR Bitmapstatus_Syms[] = {
    { "success",         BitmapSuccess },
    { "open-failed",     BitmapOpenFailed },
    { "file-invalid",    BitmapFileInvalid },
    { "no-memory",       BitmapNoMemory },
    { 0, 0 }
};

SYMDESCR Circulate_Syms[] = {
    { "raise-lowest",      RaiseLowest },
    { "lower-highest",     LowerHighest },
    { 0, 0 }
};

SYMDESCR Allow_Events_Syms[] = {
    { "async-pointer",    AsyncPointer },
    { "sync-pointer",     SyncPointer },
    { "replay-pointer",   ReplayPointer },
    { "async-keyboard",   AsyncKeyboard },
    { "sync-keyboard",    SyncKeyboard },
    { "replay-keyboard",  ReplayKeyboard },
    { "async-both",       AsyncBoth },
    { "sync-both",        SyncBoth },
    { 0, 0 }
};

SYMDESCR Revert_Syms[] = {
    { "none",         RevertToNone },
    { "pointer-root", RevertToPointerRoot },
    { "parent",       RevertToParent },
    { 0, 0 }
};

SYMDESCR Shape_Syms[] = {
    { "cursor",  CursorShape },
    { "tile",    TileShape },
    { "stipple", StippleShape },
    { 0, 0 }
};

SYMDESCR Initial_State_Syms[] = {
    { "dont-care", DontCareState },
    { "normal",    NormalState },
    { "zoom",      ZoomState },
    { "iconic",    IconicState },
    { "inactive",  InactiveState },
    { 0, 0 }
};

SYMDESCR Ordering_Syms[] = {
    { "unsorted",  Unsorted },
    { "y-sorted",  YSorted },
    { "yx-sorted", YXSorted },
    { "yx-banded", YXBanded },
    { 0, 0 }
};

SYMDESCR Byte_Order_Syms[] = {
    { "lsb-first", LSBFirst },
    { "msb-first", MSBFirst },
    { 0, 0 }
};

SYMDESCR Saveset_Syms[] = {
    { "insert",    SetModeInsert },
    { "delete",    SetModeDelete },
    { 0, 0 }
};

SYMDESCR Closemode_Syms[] = {
    { "destroy-all",         DestroyAll },
    { "retain-permanent",    RetainPermanent },
    { "retain-temporary",    RetainTemporary },
    { 0, 0 }
};

SYMDESCR Event_Syms[] = {
    { "key-press",               KeyPressMask },
    { "key-release",             KeyReleaseMask },
    { "button-press",            ButtonPressMask },
    { "button-release",          ButtonReleaseMask },
    { "enter-window",            EnterWindowMask },
    { "leave-window",            LeaveWindowMask },
    { "pointer-motion",          PointerMotionMask },
    { "pointer-motion-hint",     PointerMotionHintMask },
    { "button-1-motion",         Button1MotionMask },
    { "button-2-motion",         Button2MotionMask },
    { "button-3-motion",         Button3MotionMask },
    { "button-4-motion",         Button4MotionMask },
    { "button-5-motion",         Button5MotionMask },
    { "button-motion",           ButtonMotionMask },
    { "keymap-state",            KeymapStateMask },
    { "exposure",                ExposureMask },
    { "visibility-change",       VisibilityChangeMask },
    { "structure-notify",        StructureNotifyMask },
    { "resize-redirect",         ResizeRedirectMask },
    { "substructure-notify",     SubstructureNotifyMask },
    { "substructure-redirect",   SubstructureRedirectMask },
    { "focus-change",            FocusChangeMask },
    { "property-change",         PropertyChangeMask },
    { "colormap-change",         ColormapChangeMask },
    { "owner-grab-button",       OwnerGrabButtonMask },
    { "all-events",              ~(unsigned long)0 },
    { 0, 0 }
};

SYMDESCR Error_Syms[] = {
    { "bad-request",        BadRequest },
    { "bad-value",          BadValue },
    { "bad-window",         BadWindow },
    { "bad-pixmap",         BadPixmap },
    { "bad-atom",           BadAtom },
    { "bad-cursor",         BadCursor },
    { "bad-font",           BadFont },
    { "bad-match",          BadMatch },
    { "bad-drawable",       BadDrawable },
    { "bad-access",         BadAccess },
    { "bad-alloc",          BadAlloc },
    { "bad-color",          BadColor },
    { "bad-gcontext",       BadGC },
    { "bad-id-choice",      BadIDChoice },
    { "bad-name",           BadName },
    { "bad-length",         BadLength },
    { "bad-implementation", BadImplementation },
    { 0, 0 }
};

static void Init_Record (RECORD *rec, int size, char *name, Object *var) {
    Object list, tail, cell;
    register int i;
    char buf[128];
    GC_Node2;

    GC_Link2 (list, tail);
    for (list = tail = Null, i = 1; i < size; tail = cell, i++, rec++) {
        cell = Intern (rec->name);
        cell = Cons (cell, Make_Integer (i));
        cell = Cons (cell, Null);
        if (Nullp (list))
            list = cell;
        else
            P_Set_Cdr (tail, cell);
    }
    sprintf (buf, "%s-slots", name);
    Define_Variable (var, buf, list);
    GC_Unlink;
}

void elk_init_xlib_type () {
    Init_Record (Set_Attr_Rec, Set_Attr_Size, "set-window-attributes",
        &Set_Attr_Slots);
    Init_Record (Conf_Rec, Conf_Size, "window-configuration", &Conf_Slots);
    Init_Record (GC_Rec, GC_Size, "gcontext", &GC_Slots);
    Init_Record (Geometry_Rec, Geometry_Size, "geometry", &Geometry_Slots);
    Init_Record (Win_Attr_Rec, Win_Attr_Size, "get-window-attributes",
        &Win_Attr_Slots);
    Init_Record (Font_Info_Rec, Font_Info_Size, "font-info", &Font_Info_Slots);
    Init_Record (Char_Info_Rec, Char_Info_Size, "char-info", &Char_Info_Slots);
    Init_Record (Wm_Hints_Rec, Wm_Hints_Size, "wm-hints", &Wm_Hints_Slots);
    Init_Record (Size_Hints_Rec, Size_Hints_Size, "size-hints",
        &Size_Hints_Slots);
    Define_Symbol (&Sym_Parent_Relative, "parent-relative");
    Define_Symbol (&Sym_Copy_From_Parent, "copy-from-parent");
}