~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to xkb/xkbInit.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: xkbInit.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */
 
2
/* $XdotOrg: xserver/xorg/xkb/xkbInit.c,v 1.10 2005/12/26 04:23:58 daniels Exp $ */
 
3
/************************************************************
 
4
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
 
5
 
 
6
Permission to use, copy, modify, and distribute this
 
7
software and its documentation for any purpose and without
 
8
fee is hereby granted, provided that the above copyright
 
9
notice appear in all copies and that both that copyright
 
10
notice and this permission notice appear in supporting
 
11
documentation, and that the name of Silicon Graphics not be 
 
12
used in advertising or publicity pertaining to distribution 
 
13
of the software without specific prior written permission.
 
14
Silicon Graphics makes no representation about the suitability 
 
15
of this software for any purpose. It is provided "as is"
 
16
without any express or implied warranty.
 
17
 
 
18
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
 
19
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
 
20
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
 
21
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
 
22
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 
 
23
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
 
24
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 
25
THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
26
 
 
27
********************************************************/
 
28
/* $XFree86: xc/programs/Xserver/xkb/xkbInit.c,v 3.32tsi Exp $ */
 
29
 
 
30
#ifdef HAVE_DIX_CONFIG_H
 
31
#include <dix-config.h>
 
32
#endif
 
33
 
 
34
#ifdef HAVE_XKB_CONFIG_H
 
35
#include <xkb-config.h>
 
36
#endif
 
37
 
 
38
#include <stdio.h>
 
39
#include <stdlib.h>
 
40
#include <ctype.h>
 
41
#include <unistd.h>
 
42
#include <math.h>
 
43
#define NEED_EVENTS 1
 
44
#include <X11/X.h>
 
45
#include <X11/Xproto.h>
 
46
#include <X11/keysym.h>
 
47
#include <X11/Xatom.h>
 
48
#include "misc.h"
 
49
#include "inputstr.h"
 
50
#include "opaque.h"
 
51
#include "property.h"
 
52
#define XKBSRV_NEED_FILE_FUNCS
 
53
#include <X11/extensions/XKBsrv.h>
 
54
#include <X11/extensions/XKBgeom.h>
 
55
#include <X11/extensions/XKMformat.h>
 
56
#include <X11/extensions/XKBfile.h>
 
57
#include "xkb.h"
 
58
 
 
59
#define CREATE_ATOM(s)  MakeAtom(s,sizeof(s)-1,1)
 
60
 
 
61
#ifdef sgi
 
62
#define LED_CAPS        5
 
63
#define LED_NUM         6
 
64
#define LED_SCROLL      7
 
65
#define PHYS_LEDS       0x7f
 
66
#define LED_COMPOSE     8
 
67
#else
 
68
#if defined(ultrix) || defined(__osf__) || defined(__alpha) || defined(__alpha__)
 
69
#define LED_COMPOSE     2
 
70
#define LED_CAPS        3
 
71
#define LED_SCROLL      4
 
72
#define LED_NUM         5
 
73
#define PHYS_LEDS       0x1f
 
74
#else
 
75
#ifdef sun
 
76
#define LED_NUM         1
 
77
#define LED_SCROLL      2
 
78
#define LED_COMPOSE     3
 
79
#define LED_CAPS        4
 
80
#define PHYS_LEDS       0x0f
 
81
#else
 
82
#define LED_CAPS        1
 
83
#define LED_NUM         2
 
84
#define LED_SCROLL      3
 
85
#define PHYS_LEDS       0x07
 
86
#endif
 
87
#endif
 
88
#endif
 
89
 
 
90
#define MAX_TOC 16
 
91
typedef struct  _SrvXkmInfo {
 
92
        DeviceIntPtr    dev;
 
93
        FILE *          file;
 
94
        XkbFileInfo     xkbinfo;
 
95
} SrvXkmInfo;
 
96
 
 
97
 
 
98
/***====================================================================***/
 
99
 
 
100
#ifndef XKB_BASE_DIRECTORY
 
101
#define XKB_BASE_DIRECTORY      "/usr/lib/X11/xkb"
 
102
#endif
 
103
#ifndef XKB_BIN_DIRECTORY
 
104
#define XKB_BIN_DIRECTORY       XKB_BASE_DIRECTORY
 
105
#endif
 
106
#ifndef XKB_DFLT_RULES_FILE
 
107
#define XKB_DFLT_RULES_FILE     "rules"
 
108
#endif
 
109
#ifndef XKB_DFLT_KB_LAYOUT
 
110
#define XKB_DFLT_KB_LAYOUT      "us"
 
111
#endif
 
112
#ifndef XKB_DFLT_KB_MODEL
 
113
#define XKB_DFLT_KB_MODEL       "dflt"
 
114
#endif
 
115
#ifndef XKB_DFLT_KB_VARIANT
 
116
#define XKB_DFLT_KB_VARIANT     NULL
 
117
#endif
 
118
#ifndef XKB_DFLT_KB_OPTIONS
 
119
#define XKB_DFLT_KB_OPTIONS     NULL
 
120
#endif
 
121
#ifndef XKB_DFLT_DISABLED
 
122
#define XKB_DFLT_DISABLED       True
 
123
#endif
 
124
#ifndef XKB_DFLT_RULES_PROP
 
125
#define XKB_DFLT_RULES_PROP     True
 
126
#endif
 
127
 
 
128
char    *               XkbBaseDirectory=       XKB_BASE_DIRECTORY;
 
129
char    *               XkbBinDirectory=        XKB_BIN_DIRECTORY;
 
130
char    *               XkbInitialMap=          NULL;
 
131
int                     XkbWantAccessX=         0;      
 
132
static XkbFileInfo *    _XkbInitFileInfo=       NULL;
 
133
 
 
134
static Bool             rulesDefined=           False;
 
135
static char *           XkbRulesFile=           NULL;
 
136
static char *           XkbModelDflt=           NULL;
 
137
static char *           XkbLayoutDflt=          NULL;
 
138
static char *           XkbVariantDflt=         NULL;
 
139
static char *           XkbOptionsDflt=         NULL;
 
140
 
 
141
char *                  XkbModelUsed=   NULL;
 
142
char *                  XkbLayoutUsed=  NULL;
 
143
char *                  XkbVariantUsed= NULL;
 
144
char *                  XkbOptionsUsed= NULL;
 
145
 
 
146
int                     _XkbClientMajor=        XkbMajorVersion;
 
147
int                     _XkbClientMinor=        XkbMinorVersion;
 
148
 
 
149
Bool                    noXkbExtension=         XKB_DFLT_DISABLED;
 
150
Bool                    XkbWantRulesProp=       XKB_DFLT_RULES_PROP;
 
151
 
 
152
/***====================================================================***/
 
153
 
 
154
char *
 
155
XkbGetRulesDflts(XkbRF_VarDefsPtr defs)
 
156
{
 
157
    if (XkbModelDflt)   defs->model= XkbModelDflt;
 
158
    else                defs->model= XKB_DFLT_KB_MODEL;
 
159
    if (XkbLayoutDflt)  defs->layout= XkbLayoutDflt;
 
160
    else                defs->layout= XKB_DFLT_KB_LAYOUT;
 
161
    if (XkbVariantDflt) defs->variant= XkbVariantDflt;
 
162
    else                defs->variant= XKB_DFLT_KB_VARIANT;
 
163
    if (XkbOptionsDflt) defs->options= XkbOptionsDflt;
 
164
    else                defs->options= XKB_DFLT_KB_OPTIONS;
 
165
    return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE);
 
166
}
 
167
 
 
168
Bool
 
169
XkbWriteRulesProp(ClientPtr client, pointer closure)
 
170
{
 
171
int                     len,out;
 
172
Atom                    name;
 
173
char *                  pval;
 
174
 
 
175
    if (rulesDefined && (!XkbRulesFile))
 
176
        return False;
 
177
    len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE));
 
178
    len+= (XkbModelUsed?strlen(XkbModelUsed):0);
 
179
    len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0);
 
180
    len+= (XkbVariantUsed?strlen(XkbVariantUsed):0);
 
181
    len+= (XkbOptionsUsed?strlen(XkbOptionsUsed):0);
 
182
    if (len<1)
 
183
        return True;
 
184
 
 
185
    len+= 5; /* trailing NULs */
 
186
 
 
187
    name= MakeAtom(_XKB_RF_NAMES_PROP_ATOM,strlen(_XKB_RF_NAMES_PROP_ATOM),1);
 
188
    if (name==None) {
 
189
        ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
 
190
        return True;
 
191
    }
 
192
    pval= (char*) ALLOCATE_LOCAL(len);
 
193
    if (!pval) {
 
194
        ErrorF("Allocation error: %s proprerty not created\n",
 
195
                                                _XKB_RF_NAMES_PROP_ATOM);
 
196
        return True;
 
197
    }
 
198
    out= 0;
 
199
    if (XkbRulesFile) {
 
200
        strcpy(&pval[out],XkbRulesFile);
 
201
        out+= strlen(XkbRulesFile);
 
202
    } else {
 
203
        strcpy(&pval[out],XKB_DFLT_RULES_FILE);
 
204
        out+= strlen(XKB_DFLT_RULES_FILE);
 
205
    }
 
206
    pval[out++]= '\0';
 
207
    if (XkbModelUsed) {
 
208
        strcpy(&pval[out],XkbModelUsed);
 
209
        out+= strlen(XkbModelUsed);
 
210
    } 
 
211
    pval[out++]= '\0';
 
212
    if (XkbLayoutUsed) {
 
213
        strcpy(&pval[out],XkbLayoutUsed);
 
214
        out+= strlen(XkbLayoutUsed);
 
215
    }
 
216
    pval[out++]= '\0';
 
217
    if (XkbVariantUsed) {
 
218
        strcpy(&pval[out],XkbVariantUsed);
 
219
        out+= strlen(XkbVariantUsed);
 
220
    }
 
221
    pval[out++]= '\0';
 
222
    if (XkbOptionsUsed) {
 
223
        strcpy(&pval[out],XkbOptionsUsed);
 
224
        out+= strlen(XkbOptionsUsed);
 
225
    }
 
226
    pval[out++]= '\0';
 
227
    if (out!=len) {
 
228
        ErrorF("Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
 
229
                                                                out,len);
 
230
    }
 
231
    ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
 
232
                                                        len,pval,True);
 
233
    DEALLOCATE_LOCAL(pval);
 
234
    return True;
 
235
}
 
236
 
 
237
void
 
238
XkbSetRulesUsed(XkbRF_VarDefsPtr defs)
 
239
{
 
240
    if (XkbModelUsed)
 
241
        _XkbFree(XkbModelUsed);
 
242
    XkbModelUsed= (defs->model?_XkbDupString(defs->model):NULL);
 
243
    if (XkbLayoutUsed)
 
244
        _XkbFree(XkbLayoutUsed);
 
245
    XkbLayoutUsed= (defs->layout?_XkbDupString(defs->layout):NULL);
 
246
    if (XkbVariantUsed)
 
247
        _XkbFree(XkbVariantUsed);
 
248
    XkbVariantUsed= (defs->variant?_XkbDupString(defs->variant):NULL);
 
249
    if (XkbOptionsUsed)
 
250
        _XkbFree(XkbOptionsUsed);
 
251
    XkbOptionsUsed= (defs->options?_XkbDupString(defs->options):NULL);
 
252
    if (XkbWantRulesProp)
 
253
        QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
 
254
    return;
 
255
}
 
256
 
 
257
void
 
258
XkbSetRulesDflts(char *rulesFile,char *model,char *layout,
 
259
                                        char *variant,char *options)
 
260
{
 
261
    if (XkbRulesFile)
 
262
        _XkbFree(XkbRulesFile);
 
263
    XkbRulesFile= _XkbDupString(rulesFile);
 
264
    rulesDefined= True;
 
265
    if (model) {
 
266
        if (XkbModelDflt)
 
267
            _XkbFree(XkbModelDflt);
 
268
        XkbModelDflt= _XkbDupString(model);
 
269
    }
 
270
    if (layout) {
 
271
        if (XkbLayoutDflt)
 
272
            _XkbFree(XkbLayoutDflt);
 
273
        XkbLayoutDflt= _XkbDupString(layout);
 
274
    }
 
275
    if (variant) {
 
276
        if (XkbVariantDflt)
 
277
            _XkbFree(XkbVariantDflt);
 
278
        XkbVariantDflt= _XkbDupString(variant);
 
279
    }
 
280
    if (options) {
 
281
        if (XkbOptionsDflt)
 
282
            _XkbFree(XkbOptionsDflt);
 
283
        XkbOptionsDflt= _XkbDupString(options);
 
284
    }
 
285
    return;
 
286
}
 
287
 
 
288
/***====================================================================***/
 
289
 
 
290
#if defined(luna)
 
291
#define XKB_DDX_PERMANENT_LOCK  1
 
292
#endif
 
293
 
 
294
#include "xkbDflts.h"
 
295
 
 
296
/* A dummy to keep the compiler quiet */
 
297
pointer xkbBogus = &indicators;
 
298
 
 
299
static Bool
 
300
XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file)
 
301
{
 
302
    if (file->xkbinfo.defined&XkmTypesMask)
 
303
        return True;
 
304
    initTypeNames(NULL);
 
305
    if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_dflt_types)!=Success)
 
306
        return False;
 
307
    if (XkbCopyKeyTypes(dflt_types,xkb->map->types,num_dflt_types)!=
 
308
                                                                 Success) {
 
309
        return False;
 
310
    }
 
311
    xkb->map->size_types= xkb->map->num_types= num_dflt_types;
 
312
    return True;
 
313
}
 
314
 
 
315
static void
 
316
XkbInitRadioGroups(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
 
317
{
 
318
    xkbi->nRadioGroups = 0;
 
319
    xkbi->radioGroups = NULL;
 
320
    return;
 
321
}
 
322
 
 
323
 
 
324
static Status
 
325
XkbInitCompatStructs(XkbDescPtr xkb,SrvXkmInfo *file)
 
326
{
 
327
register int    i;
 
328
XkbCompatMapPtr compat;
 
329
 
 
330
    if (file->xkbinfo.defined&XkmCompatMapMask)
 
331
        return Success;
 
332
    if (XkbAllocCompatMap(xkb,XkbAllCompatMask,num_dfltSI)!=Success)
 
333
        return BadAlloc;
 
334
    compat = xkb->compat;
 
335
    if (compat->sym_interpret) {
 
336
        compat->num_si = num_dfltSI;
 
337
        memcpy((char *)compat->sym_interpret,(char *)dfltSI,sizeof(dfltSI));
 
338
    }
 
339
    for (i=0;i<XkbNumKbdGroups;i++) {
 
340
        compat->groups[i]= compatMap.groups[i];
 
341
        if (compat->groups[i].vmods!=0) {
 
342
            unsigned mask;
 
343
            mask= XkbMaskForVMask(xkb,compat->groups[i].vmods);
 
344
            compat->groups[i].mask= compat->groups[i].real_mods|mask;
 
345
        }
 
346
        else compat->groups[i].mask= compat->groups[i].real_mods;
 
347
    }
 
348
    return Success;
 
349
}
 
350
 
 
351
static void
 
352
XkbInitSemantics(XkbDescPtr xkb,SrvXkmInfo *file)
 
353
{
 
354
    XkbInitKeyTypes(xkb,file);
 
355
    XkbInitCompatStructs(xkb,file);
 
356
    return;
 
357
}
 
358
 
 
359
/***====================================================================***/
 
360
 
 
361
static Status
 
362
XkbInitNames(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
 
363
{
 
364
XkbDescPtr      xkb;
 
365
XkbNamesPtr     names;
 
366
Status          rtrn;
 
367
Atom            unknown;
 
368
 
 
369
    xkb= xkbi->desc;
 
370
    if ((rtrn=XkbAllocNames(xkb,XkbAllNamesMask,0,0))!=Success)
 
371
        return rtrn;
 
372
    unknown= CREATE_ATOM("unknown");
 
373
    names = xkb->names;
 
374
    if (names->keycodes==None)          names->keycodes= unknown;
 
375
    if (names->geometry==None)          names->geometry= unknown;
 
376
    if (names->phys_symbols==None)      names->phys_symbols= unknown;
 
377
    if (names->symbols==None)           names->symbols= unknown;
 
378
    if (names->types==None)             names->types= unknown;
 
379
    if (names->compat==None)            names->compat= unknown;
 
380
    if ((file->xkbinfo.defined&XkmVirtualModsMask)==0) {
 
381
        if (names->vmods[vmod_NumLock]==None)
 
382
            names->vmods[vmod_NumLock]= CREATE_ATOM("NumLock");
 
383
        if (names->vmods[vmod_Alt]==None)
 
384
            names->vmods[vmod_Alt]= CREATE_ATOM("Alt");
 
385
        if (names->vmods[vmod_AltGr]==None)
 
386
            names->vmods[vmod_AltGr]= CREATE_ATOM("ModeSwitch");
 
387
    }
 
388
 
 
389
    if (((file->xkbinfo.defined&XkmIndicatorsMask)==0)||
 
390
        ((file->xkbinfo.defined&XkmGeometryMask)==0)) {
 
391
        initIndicatorNames(NULL,xkb);
 
392
        if (names->indicators[LED_CAPS-1]==None)
 
393
            names->indicators[LED_CAPS-1] = CREATE_ATOM("Caps Lock");
 
394
        if (names->indicators[LED_NUM-1]==None)
 
395
            names->indicators[LED_NUM-1] = CREATE_ATOM("Num Lock");
 
396
        if (names->indicators[LED_SCROLL-1]==None)
 
397
            names->indicators[LED_SCROLL-1] = CREATE_ATOM("Scroll Lock");
 
398
#ifdef LED_COMPOSE
 
399
        if (names->indicators[LED_COMPOSE-1]==None)
 
400
            names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose");
 
401
#endif
 
402
    }
 
403
#ifdef DEBUG_RADIO_GROUPS
 
404
    if (names->num_rg<1) {
 
405
        names->radio_groups= (Atom *)_XkbCalloc(RG_COUNT, sizeof(Atom));
 
406
        if (names->radio_groups) {
 
407
            names->num_rg = RG_COUNT;
 
408
            names->radio_groups[RG_BOGUS_FUNCTION_GROUP]= CREATE_ATOM("BOGUS");
 
409
        }
 
410
    }
 
411
#endif
 
412
    if (xkb->geom!=NULL)
 
413
         names->geometry= xkb->geom->name;
 
414
    else names->geometry= unknown;
 
415
    return Success;
 
416
}
 
417
 
 
418
static Status
 
419
XkbInitIndicatorMap(XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
 
420
{
 
421
XkbDescPtr              xkb;
 
422
XkbIndicatorPtr         map;
 
423
XkbSrvLedInfoPtr        sli;
 
424
 
 
425
    xkb= xkbi->desc;
 
426
    if (XkbAllocIndicatorMaps(xkb)!=Success)
 
427
        return BadAlloc;
 
428
    if ((file->xkbinfo.defined&XkmIndicatorsMask)==0) {
 
429
        map= xkb->indicators;
 
430
        map->phys_indicators = PHYS_LEDS;
 
431
        map->maps[LED_CAPS-1].flags= XkbIM_NoExplicit;
 
432
        map->maps[LED_CAPS-1].which_mods= XkbIM_UseLocked;
 
433
        map->maps[LED_CAPS-1].mods.mask= LockMask;
 
434
        map->maps[LED_CAPS-1].mods.real_mods= LockMask;
 
435
 
 
436
        map->maps[LED_NUM-1].flags= XkbIM_NoExplicit;
 
437
        map->maps[LED_NUM-1].which_mods= XkbIM_UseLocked;
 
438
        map->maps[LED_NUM-1].mods.mask= 0;
 
439
        map->maps[LED_NUM-1].mods.real_mods= 0;
 
440
        map->maps[LED_NUM-1].mods.vmods= vmod_NumLockMask;
 
441
 
 
442
/* Metro Link */
 
443
        map->maps[LED_SCROLL-1].flags= XkbIM_NoExplicit;
 
444
        map->maps[LED_SCROLL-1].which_mods= XkbIM_UseLocked;
 
445
        map->maps[LED_SCROLL-1].mods.mask= Mod3Mask;
 
446
        map->maps[LED_SCROLL-1].mods.real_mods= Mod3Mask;
 
447
/* Metro Link */
 
448
    }
 
449
    sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0);
 
450
    if (sli)
 
451
        XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
 
452
    return Success;
 
453
}
 
454
 
 
455
static Status
 
456
XkbInitControls(DeviceIntPtr pXDev,XkbSrvInfoPtr xkbi,SrvXkmInfo *file)
 
457
{
 
458
XkbDescPtr      xkb;
 
459
XkbControlsPtr  ctrls;
 
460
 
 
461
    xkb= xkbi->desc;
 
462
    /* 12/31/94 (ef) -- XXX! Should check if controls loaded from file */
 
463
    if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success)
 
464
        FatalError("Couldn't allocate keyboard controls\n");
 
465
    ctrls= xkb->ctrls;
 
466
    if ((file->xkbinfo.defined&XkmSymbolsMask)==0)
 
467
        ctrls->num_groups = 1;
 
468
    ctrls->groups_wrap = XkbSetGroupInfo(1,XkbWrapIntoRange,0);
 
469
    ctrls->internal.mask = 0;
 
470
    ctrls->internal.real_mods = 0;
 
471
    ctrls->internal.vmods = 0;
 
472
    ctrls->ignore_lock.mask = 0;
 
473
    ctrls->ignore_lock.real_mods = 0;
 
474
    ctrls->ignore_lock.vmods = 0;
 
475
    ctrls->enabled_ctrls = XkbAccessXTimeoutMask|XkbRepeatKeysMask|
 
476
                                XkbMouseKeysAccelMask|XkbAudibleBellMask|
 
477
                                XkbIgnoreGroupLockMask;
 
478
    if (XkbWantAccessX)
 
479
        ctrls->enabled_ctrls|= XkbAccessXKeysMask;
 
480
    AccessXInit(pXDev);
 
481
    return Success;
 
482
}
 
483
 
 
484
void
 
485
XkbInitDevice(DeviceIntPtr pXDev)
 
486
{
 
487
int                     i;
 
488
XkbSrvInfoPtr           xkbi;
 
489
XkbChangesRec           changes;
 
490
SrvXkmInfo              file;
 
491
unsigned                check;
 
492
XkbEventCauseRec        cause;
 
493
 
 
494
    file.dev= pXDev;
 
495
    file.file=NULL;
 
496
    bzero(&file.xkbinfo,sizeof(XkbFileInfo));
 
497
    bzero(&changes,sizeof(XkbChangesRec));
 
498
    if (XkbInitialMap!=NULL) {
 
499
        if ((file.file=XkbDDXOpenConfigFile(XkbInitialMap,NULL,0))!=NULL) {
 
500
            XkmReadFile(file.file,0,XkmKeymapLegal,&file.xkbinfo);
 
501
            if (file.xkbinfo.xkb==NULL) {
 
502
                LogMessage(X_ERROR,
 
503
                                "Error loading keymap file %s (%s in %s)\n"
 
504
                                "\treverting to defaults\n",
 
505
                                XkbInitialMap, _XkbErrMessages[_XkbErrCode],
 
506
                                (_XkbErrLocation?_XkbErrLocation:"unknown"));
 
507
                fclose(file.file);
 
508
                file.file= NULL;
 
509
                bzero(&file.xkbinfo,sizeof(XkbFileInfo));
 
510
            }
 
511
            else {
 
512
                if (_XkbInitFileInfo!=NULL) {
 
513
                    XkbDescPtr  tmp;
 
514
                    if ((tmp=_XkbInitFileInfo->xkb)!=NULL) {
 
515
                        XkbFreeKeyboard(tmp,XkbAllComponentsMask,True);
 
516
                        _XkbInitFileInfo->xkb= NULL;
 
517
                    }
 
518
                }
 
519
                _XkbInitFileInfo= &file.xkbinfo;
 
520
            }
 
521
        }
 
522
        else {
 
523
            LogMessage(X_ERROR, "Error opening keymap file %s, reverting to defaults\n",
 
524
                    XkbInitialMap);
 
525
        }
 
526
    }
 
527
    pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec);
 
528
    if ( xkbi ) {
 
529
        XkbDescPtr      xkb;
 
530
        if ((_XkbInitFileInfo!=NULL)&&(_XkbInitFileInfo->xkb!=NULL)) {
 
531
            file.xkbinfo= *_XkbInitFileInfo;
 
532
            xkbi->desc= _XkbInitFileInfo->xkb;
 
533
            _XkbInitFileInfo= NULL;
 
534
        }
 
535
        else {
 
536
            xkbi->desc= XkbAllocKeyboard();
 
537
            if (!xkbi->desc)
 
538
                FatalError("Couldn't allocate keyboard description\n");
 
539
            xkbi->desc->min_key_code = pXDev->key->curKeySyms.minKeyCode;
 
540
            xkbi->desc->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
 
541
        }
 
542
        xkb= xkbi->desc;
 
543
        if (xkb->min_key_code == 0)
 
544
            xkb->min_key_code = pXDev->key->curKeySyms.minKeyCode;
 
545
        if (xkb->max_key_code == 0)
 
546
            xkb->max_key_code = pXDev->key->curKeySyms.maxKeyCode;
 
547
        if ((pXDev->key->curKeySyms.minKeyCode!=xkbi->desc->min_key_code)||
 
548
            (pXDev->key->curKeySyms.maxKeyCode!=xkbi->desc->max_key_code)) {
 
549
            /* 12/9/95 (ef) -- XXX! Maybe we should try to fix up one or */
 
550
            /*                 the other here, but for now just complain */
 
551
            /*                 can't just update the core range without */
 
552
            /*                 reallocating the KeySymsRec (pain)       */
 
553
            ErrorF("Internal Error!! XKB and core keymap have different range\n");
 
554
        }
 
555
        if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success)
 
556
            FatalError("Couldn't allocate client map in XkbInitDevice\n");
 
557
        i= XkbNumKeys(xkb)/3+1;
 
558
        if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,i)!=Success)
 
559
            FatalError("Couldn't allocate server map in XkbInitDevice\n");
 
560
 
 
561
        xkbi->dfltPtrDelta=1;
 
562
        xkbi->device = pXDev;
 
563
 
 
564
        file.xkbinfo.xkb= xkb;
 
565
        XkbInitSemantics(xkb,&file);
 
566
        XkbInitNames(xkbi,&file);
 
567
        XkbInitRadioGroups(xkbi,&file);
 
568
 
 
569
        /* 12/31/94 (ef) -- XXX! Should check if state loaded from file */
 
570
        bzero(&xkbi->state,sizeof(XkbStateRec));
 
571
 
 
572
        XkbInitControls(pXDev,xkbi,&file);
 
573
 
 
574
        if (file.xkbinfo.defined&XkmSymbolsMask)
 
575
           memcpy(pXDev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
 
576
        else
 
577
           memcpy(xkb->map->modmap,pXDev->key->modifierMap,xkb->max_key_code+1);
 
578
 
 
579
        XkbInitIndicatorMap(xkbi,&file);
 
580
 
 
581
        XkbDDXInitDevice(pXDev);
 
582
 
 
583
        if (!(file.xkbinfo.defined&XkmSymbolsMask)) {
 
584
            XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb),
 
585
                                                                &changes);
 
586
        }
 
587
        else {
 
588
            XkbUpdateCoreDescription(pXDev,True);
 
589
        }
 
590
        XkbSetCauseUnknown(&cause);
 
591
        XkbUpdateActions(pXDev,xkb->min_key_code, XkbNumKeys(xkb),&changes,
 
592
                                                                &check,&cause);
 
593
        /* For sanity.  The first time the connection
 
594
         * is opened, the client side min and max are set
 
595
         * using QueryMinMaxKeyCodes() which grabs them 
 
596
         * from pXDev.
 
597
         */
 
598
        pXDev->key->curKeySyms.minKeyCode = xkb->min_key_code;
 
599
        pXDev->key->curKeySyms.maxKeyCode = xkb->max_key_code;
 
600
    }
 
601
    if (file.file!=NULL)
 
602
        fclose(file.file);
 
603
    return;
 
604
}
 
605
 
 
606
#if MAP_LENGTH > XkbMaxKeyCount
 
607
#undef  XkbMaxKeyCount
 
608
#define XkbMaxKeyCount MAP_LENGTH
 
609
#endif
 
610
 
 
611
Bool
 
612
XkbInitKeyboardDeviceStruct(
 
613
    DeviceIntPtr                dev,
 
614
    XkbComponentNamesPtr        names,
 
615
    KeySymsPtr                  pSymsIn,
 
616
    CARD8                       pModsIn[],
 
617
    void                        (*bellProc)(
 
618
        int /*percent*/,
 
619
        DeviceIntPtr /*device*/,
 
620
        pointer /*ctrl*/,
 
621
        int),
 
622
    void                        (*ctrlProc)(
 
623
        DeviceIntPtr /*device*/,
 
624
        KeybdCtrl * /*ctrl*/))
 
625
{
 
626
XkbFileInfo             finfo;
 
627
KeySymsRec              tmpSyms,*pSyms;
 
628
CARD8                   tmpMods[XkbMaxLegalKeyCode+1],*pMods;
 
629
char                    name[PATH_MAX],*rules;
 
630
Bool                    ok=False;
 
631
XPointer                config;
 
632
XkbComponentNamesRec    cfgNames;
 
633
XkbRF_VarDefsRec        defs;
 
634
 
 
635
    if ((dev->key!=NULL)||(dev->kbdfeed!=NULL))
 
636
        return False;
 
637
    pSyms= pSymsIn;
 
638
    pMods= pModsIn;
 
639
    bzero(&defs,sizeof(XkbRF_VarDefsRec));
 
640
    bzero(&cfgNames,sizeof(XkbComponentNamesRec));
 
641
    rules= XkbGetRulesDflts(&defs);
 
642
    config= XkbDDXPreloadConfig(&rules,&defs,&cfgNames,dev);
 
643
 
 
644
    /*
 
645
     * The strings are duplicated because it is not guaranteed that
 
646
     * they are allocated, or that they are allocated for every server
 
647
     * generation. Eventually they will be freed at the end of this
 
648
     * function.
 
649
     */
 
650
    if (names->keymap) names->keymap = _XkbDupString(names->keymap);
 
651
    if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes);
 
652
    if (names->types) names->types = _XkbDupString(names->types);
 
653
    if (names->compat) names->compat = _XkbDupString(names->compat);
 
654
    if (names->geometry) names->geometry = _XkbDupString(names->geometry);
 
655
    if (names->symbols) names->symbols = _XkbDupString(names->symbols);
 
656
 
 
657
    if (defs.model && defs.layout && rules) {
 
658
        XkbComponentNamesRec    rNames;
 
659
        bzero(&rNames,sizeof(XkbComponentNamesRec));
 
660
        if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) {
 
661
            if (rNames.keymap) {
 
662
                if (!names->keymap)
 
663
                    names->keymap = rNames.keymap;
 
664
                else _XkbFree(rNames.keymap);
 
665
            }
 
666
            if (rNames.keycodes) {
 
667
                if (!names->keycodes)
 
668
                    names->keycodes =  rNames.keycodes;
 
669
                else
 
670
                    _XkbFree(rNames.keycodes);
 
671
            }
 
672
            if (rNames.types) {
 
673
                if (!names->types)
 
674
                    names->types = rNames.types;
 
675
                else  _XkbFree(rNames.types);
 
676
            }
 
677
            if (rNames.compat) {
 
678
                if (!names->compat) 
 
679
                    names->compat =  rNames.compat;
 
680
                else  _XkbFree(rNames.compat);
 
681
            }
 
682
            if (rNames.symbols) {
 
683
                if (!names->symbols)
 
684
                    names->symbols =  rNames.symbols;
 
685
                else _XkbFree(rNames.symbols);
 
686
            }
 
687
            if (rNames.geometry) {
 
688
                if (!names->geometry)
 
689
                    names->geometry = rNames.geometry;
 
690
                else _XkbFree(rNames.geometry);
 
691
            }
 
692
            XkbSetRulesUsed(&defs);
 
693
        }
 
694
    }
 
695
    if (cfgNames.keymap){
 
696
        if (names->keymap) _XkbFree(names->keymap);
 
697
        names->keymap= cfgNames.keymap;
 
698
    }
 
699
    if (cfgNames.keycodes){
 
700
        if (names->keycodes) _XkbFree(names->keycodes); 
 
701
        names->keycodes= cfgNames.keycodes;
 
702
    }
 
703
    if (cfgNames.types) {
 
704
        if (names->types) _XkbFree(names->types);       
 
705
        names->types= cfgNames.types;
 
706
    }
 
707
    if (cfgNames.compat) {
 
708
        if (names->compat) _XkbFree(names->compat);     
 
709
        names->compat= cfgNames.compat;
 
710
    }
 
711
    if (cfgNames.symbols){
 
712
        if (names->symbols) _XkbFree(names->symbols);   
 
713
        names->symbols= cfgNames.symbols;
 
714
    }
 
715
    if (cfgNames.geometry) {
 
716
        if (names->geometry) _XkbFree(names->geometry);
 
717
        names->geometry= cfgNames.geometry;
 
718
    }
 
719
 
 
720
    if (names->keymap) {
 
721
        XkbComponentNamesRec    tmpNames;
 
722
        bzero(&tmpNames,sizeof(XkbComponentNamesRec));
 
723
        tmpNames.keymap = names->keymap;
 
724
        ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0,
 
725
                                            &finfo,name,PATH_MAX);
 
726
    }
 
727
    if (!(ok && (finfo.xkb!=NULL)))
 
728
        ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,
 
729
                                            &finfo,name,PATH_MAX);
 
730
 
 
731
    if (ok && (finfo.xkb!=NULL)) {
 
732
        XkbDescPtr      xkb;
 
733
        KeyCode         minKC,maxKC;
 
734
 
 
735
        xkb= finfo.xkb;
 
736
        minKC= xkb->min_key_code;
 
737
        maxKC= xkb->max_key_code;
 
738
        if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&&
 
739
            ((minKC!=pSyms->minKeyCode)||(maxKC!=pSyms->maxKeyCode))) {
 
740
            if (xkb->map!=NULL) {
 
741
                KeySym  *inSym,*outSym;
 
742
                int     width= pSymsIn->mapWidth;
 
743
 
 
744
                tmpSyms.minKeyCode= minKC;
 
745
                tmpSyms.maxKeyCode= maxKC;
 
746
 
 
747
                if (minKC<pSymsIn->minKeyCode)
 
748
                    minKC= pSymsIn->minKeyCode;
 
749
                if (maxKC>pSymsIn->maxKeyCode)
 
750
                    maxKC= pSymsIn->maxKeyCode;
 
751
 
 
752
                tmpSyms.mapWidth= width;
 
753
                tmpSyms.map= _XkbTypedCalloc(width*XkbNumKeys(xkb),KeySym);
 
754
                inSym= &pSymsIn->map[(minKC-pSymsIn->minKeyCode)*width];
 
755
                outSym= &tmpSyms.map[(minKC-tmpSyms.minKeyCode)*width];
 
756
                memcpy(outSym,inSym,((maxKC-minKC+1)*width)*sizeof(KeySym));
 
757
                pSyms= &tmpSyms;
 
758
            }
 
759
            if ((xkb->map!=NULL)&&(xkb->map->modmap!=NULL)) {
 
760
                bzero(tmpMods,XkbMaxKeyCount);
 
761
                memcpy(tmpMods,xkb->map->modmap,maxKC+1);
 
762
                pMods= tmpMods;
 
763
            }
 
764
        }
 
765
        _XkbInitFileInfo= &finfo;
 
766
    }
 
767
    else {
 
768
        LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n");
 
769
    }
 
770
    ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc);
 
771
    if ((config!=NULL)&&(dev && dev->key && dev->key->xkbInfo))
 
772
        XkbDDXApplyConfig(config,dev->key->xkbInfo);
 
773
    _XkbInitFileInfo= NULL;
 
774
    if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) {
 
775
        _XkbFree(pSyms->map);
 
776
        pSyms->map= NULL;
 
777
    }
 
778
 
 
779
    if (names->keymap) _XkbFree(names->keymap);
 
780
    names->keymap = NULL;
 
781
    if (names->keycodes) _XkbFree(names->keycodes);
 
782
    names->keycodes = NULL;
 
783
    if (names->types) _XkbFree(names->types);
 
784
    names->types = NULL;
 
785
    if (names->compat) _XkbFree(names->compat);
 
786
    names->compat = NULL;
 
787
    if (names->geometry) _XkbFree(names->geometry);
 
788
    names->geometry = NULL;
 
789
    if (names->symbols) _XkbFree(names->symbols);
 
790
    names->symbols = NULL;
 
791
 
 
792
    return ok;
 
793
}
 
794
 
 
795
/***====================================================================***/
 
796
 
 
797
        /*
 
798
         * InitKeyClassDeviceStruct initializes the key class before it
 
799
         * initializes the keyboard feedback class for a device. 
 
800
         * UpdateActions can't set up the correct autorepeat for keyboard 
 
801
         * initialization because the keyboard feedback isn't created yet.   
 
802
         * Instead, UpdateActions notes the "correct" autorepeat in the 
 
803
         * SrvInfo structure and InitKbdFeedbackClass calls UpdateAutoRepeat 
 
804
         * to apply the computed autorepeat once the feedback class exists.
 
805
         *
 
806
         * DIX will apply the changed autorepeat, so there's no need to
 
807
         * do so here.   This function returns True if both RepeatKeys and
 
808
         * the core protocol autorepeat ctrls are set (i.e. should use 
 
809
         * software autorepeat), false otherwise.
 
810
         *
 
811
         * This function also computes the autorepeat accelerators for the
 
812
         * default indicator feedback.
 
813
         */
 
814
int
 
815
XkbFinishDeviceInit(DeviceIntPtr pXDev)
 
816
{
 
817
XkbSrvInfoPtr           xkbi;
 
818
XkbDescPtr              xkb;
 
819
int                     softRepeat;
 
820
XkbSrvLedInfoPtr        sli;
 
821
 
 
822
    xkbi = NULL;
 
823
    if (pXDev && pXDev->key && pXDev->key->xkbInfo && pXDev->kbdfeed) {
 
824
        xkbi= pXDev->key->xkbInfo;
 
825
        xkb= xkbi->desc;
 
826
        if (pXDev->kbdfeed) {
 
827
            xkbi->kbdProc= pXDev->kbdfeed->CtrlProc;
 
828
            pXDev->kbdfeed->CtrlProc= XkbDDXKeybdCtrlProc;
 
829
        }
 
830
        if (pXDev->kbdfeed->ctrl.autoRepeat)
 
831
            xkb->ctrls->enabled_ctrls|= XkbRepeatKeysMask;
 
832
        softRepeat= (xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0;
 
833
        if (pXDev->kbdfeed) {
 
834
            memcpy(pXDev->kbdfeed->ctrl.autoRepeats,
 
835
                   xkb->ctrls->per_key_repeat,XkbPerKeyBitArraySize);
 
836
            softRepeat= softRepeat&&pXDev->kbdfeed->ctrl.autoRepeat;
 
837
        }
 
838
    }
 
839
    else softRepeat= 0;
 
840
    sli= XkbFindSrvLedInfo(pXDev,XkbDfltXIClass,XkbDfltXIId,0);
 
841
    if (sli && xkbi)
 
842
        XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask);
 
843
#ifdef DEBUG
 
844
    else ErrorF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n");
 
845
#endif
 
846
    return softRepeat;
 
847
}
 
848
 
 
849
        /*
 
850
         * Be very careful about what does and doesn't get freed by this 
 
851
         * function.  To reduce fragmentation, XkbInitDevice allocates a 
 
852
         * single huge block per device and divides it up into most of the 
 
853
         * fixed-size structures for the device.   Don't free anything that
 
854
         * is part of this larger block.
 
855
         */
 
856
void
 
857
XkbFreeInfo(XkbSrvInfoPtr xkbi)
 
858
{
 
859
    if (xkbi->radioGroups) {
 
860
        _XkbFree(xkbi->radioGroups);
 
861
        xkbi->radioGroups= NULL;
 
862
    }
 
863
    if (xkbi->mouseKeyTimer) {
 
864
        TimerFree(xkbi->mouseKeyTimer);
 
865
        xkbi->mouseKeyTimer= NULL;
 
866
    }
 
867
    if (xkbi->slowKeysTimer) {
 
868
        TimerFree(xkbi->slowKeysTimer);
 
869
        xkbi->slowKeysTimer= NULL;
 
870
    }
 
871
    if (xkbi->bounceKeysTimer) {
 
872
        TimerFree(xkbi->bounceKeysTimer);
 
873
        xkbi->bounceKeysTimer= NULL;
 
874
    }
 
875
    if (xkbi->repeatKeyTimer) {
 
876
        TimerFree(xkbi->repeatKeyTimer);
 
877
        xkbi->repeatKeyTimer= NULL;
 
878
    }
 
879
    if (xkbi->krgTimer) {
 
880
        TimerFree(xkbi->krgTimer);
 
881
        xkbi->krgTimer= NULL;
 
882
    }
 
883
    xkbi->beepType= _BEEP_NONE;
 
884
    if (xkbi->beepTimer) {
 
885
        TimerFree(xkbi->beepTimer);
 
886
        xkbi->beepTimer= NULL;
 
887
    }
 
888
    if (xkbi->desc) {
 
889
        XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
 
890
        xkbi->desc= NULL;
 
891
    }
 
892
    _XkbFree(xkbi);
 
893
    return;
 
894
}
 
895
 
 
896
/***====================================================================***/
 
897
 
 
898
extern int      XkbDfltRepeatDelay;
 
899
extern int      XkbDfltRepeatInterval;
 
900
 
 
901
extern unsigned short   XkbDfltAccessXTimeout;
 
902
extern unsigned int     XkbDfltAccessXTimeoutMask;
 
903
extern unsigned int     XkbDfltAccessXFeedback;
 
904
extern unsigned char    XkbDfltAccessXOptions;
 
905
 
 
906
int
 
907
XkbProcessArguments(int argc,char *argv[],int i)
 
908
{
 
909
    if (strcmp(argv[i],"-kb")==0) {
 
910
        noXkbExtension= True;
 
911
        return 1;
 
912
    }
 
913
    else if (strcmp(argv[i],"+kb")==0) {
 
914
        noXkbExtension= False;
 
915
        return 1;
 
916
    }
 
917
    else if (strncmp(argv[i], "-xkbdir", 7) == 0) {
 
918
        if(++i < argc) {
 
919
#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__)
 
920
            if (getuid() != geteuid()) {
 
921
                LogMessage(X_WARNING, "-xkbdir is not available for setuid X servers\n");
 
922
                return -1;
 
923
            } else
 
924
#endif
 
925
            {
 
926
                if (strlen(argv[i]) < PATH_MAX) {
 
927
                    XkbBaseDirectory= argv[i];
 
928
                    return 2;
 
929
                } else {
 
930
                    LogMessage(X_ERROR, "-xkbdir pathname too long\n");
 
931
                    return -1;
 
932
                }
 
933
            }
 
934
        }
 
935
        else {
 
936
            return -1;
 
937
        }
 
938
    }
 
939
    else if (strncmp(argv[i], "-xkbmap", 7) == 0) {
 
940
        if(++i < argc) {
 
941
            if (strlen(argv[i]) < PATH_MAX) {
 
942
                XkbInitialMap= argv[i];
 
943
                return 2;
 
944
            } else {
 
945
                LogMessage(X_ERROR, "-xkbmap pathname too long\n");
 
946
                return -1;
 
947
            }
 
948
        }
 
949
        else {
 
950
            return -1;
 
951
        }
 
952
    }
 
953
    else if ((strncmp(argv[i],"-accessx",8)==0)||
 
954
                 (strncmp(argv[i],"+accessx",8)==0)) {
 
955
        int j=1;            
 
956
        if (argv[i][0]=='-')        
 
957
            XkbWantAccessX= 0;
 
958
        else {
 
959
            XkbWantAccessX= 1;
 
960
            
 
961
            if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
 
962
                XkbDfltAccessXTimeout = atoi(argv[++i]);
 
963
                j++;
 
964
 
 
965
                if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
 
966
                    /*
 
967
                     * presumption that the reasonably useful range of
 
968
                     * values fits in 0..MAXINT since SunOS 4 doesn't
 
969
                     * have strtoul.
 
970
                     */
 
971
                    XkbDfltAccessXTimeoutMask=(unsigned int)
 
972
                                              strtol(argv[++i],NULL,16); 
 
973
                    j++;
 
974
                }
 
975
                if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
 
976
                    if (argv[++i][0] == '1' ) 
 
977
                        XkbDfltAccessXFeedback=XkbAccessXFeedbackMask;
 
978
                    else
 
979
                        XkbDfltAccessXFeedback=0;
 
980
                    j++;
 
981
                }
 
982
                if ( ((i+1)<argc) && (isdigit(argv[i+1][0])) ) {
 
983
                    XkbDfltAccessXOptions=(unsigned char)
 
984
                                           strtol(argv[++i],NULL,16);
 
985
                    j++;
 
986
                }
 
987
            }
 
988
        }
 
989
        return j;
 
990
    }
 
991
    if ((strcmp(argv[i], "-ardelay") == 0) ||
 
992
        (strcmp (argv[i], "-ar1") == 0)) {      /* -ardelay int */
 
993
        if (++i >= argc) UseMsg ();
 
994
        XkbDfltRepeatDelay = (long)atoi(argv[i]);
 
995
        return 2;
 
996
    }
 
997
    if ((strcmp(argv[i], "-arinterval") == 0) ||
 
998
        (strcmp (argv[i], "-ar2") == 0)) {      /* -arinterval int */
 
999
        if (++i >= argc) UseMsg ();
 
1000
        XkbDfltRepeatInterval = (long)atoi(argv[i]);
 
1001
        return 2;
 
1002
    }
 
1003
    return 0;
 
1004
}
 
1005
 
 
1006
void
 
1007
XkbUseMsg(void)
 
1008
{
 
1009
    ErrorF("-kb                    disable the X Keyboard Extension\n");
 
1010
    ErrorF("+kb                    enable the X Keyboard Extension\n");
 
1011
    ErrorF("[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]\n");
 
1012
    ErrorF("                       enable/disable accessx key sequences\n");
 
1013
    ErrorF("-ardelay               set XKB autorepeat delay\n");
 
1014
    ErrorF("-arinterval            set XKB autorepeat interval\n");
 
1015
    ErrorF("-xkbmap                XKB keyboard description to load on startup\n");
 
1016
}