aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkb
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkb')
-rw-r--r--xorg-server/xkb/XKBAlloc.c4
-rw-r--r--xorg-server/xkb/XKBGAlloc.c24
-rw-r--r--xorg-server/xkb/XKBMAlloc.c49
-rw-r--r--xorg-server/xkb/XKBMisc.c4
-rw-r--r--xorg-server/xkb/maprules.c50
-rw-r--r--xorg-server/xkb/xkb.c55
-rw-r--r--xorg-server/xkb/xkbAccessX.c1552
-rw-r--r--xorg-server/xkb/xkbActions.c10
-rw-r--r--xorg-server/xkb/xkbInit.c33
-rw-r--r--xorg-server/xkb/xkbLEDs.c30
-rw-r--r--xorg-server/xkb/xkbUtils.c248
-rw-r--r--xorg-server/xkb/xkbfmisc.c882
-rw-r--r--xorg-server/xkb/xkmread.c6
13 files changed, 1422 insertions, 1525 deletions
diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c
index 4d342a0fa..9dab41c5e 100644
--- a/xorg-server/xkb/XKBAlloc.c
+++ b/xorg-server/xkb/XKBAlloc.c
@@ -82,7 +82,7 @@ XkbSymInterpretRec *prev_interpret;
}
compat->size_si= nSI;
compat->num_si= 0;
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ memset((char *)&compat->groups[0], 0, XkbNumKbdGroups*sizeof(XkbModsRec));
xkb->compat= compat;
return Success;
}
@@ -99,7 +99,7 @@ register XkbCompatMapPtr compat;
if (freeMap)
which= XkbAllCompatMask;
if (which&XkbGroupCompatMask)
- bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ memset((char *)&compat->groups[0], 0, XkbNumKbdGroups*sizeof(XkbModsRec));
if (which&XkbSymInterpMask) {
if ((compat->sym_interpret)&&(compat->size_si>0))
free(compat->sym_interpret);
diff --git a/xorg-server/xkb/XKBGAlloc.c b/xorg-server/xkb/XKBGAlloc.c
index 4dc3e7017..b5c9b8446 100644
--- a/xorg-server/xkb/XKBGAlloc.c
+++ b/xorg-server/xkb/XKBGAlloc.c
@@ -183,8 +183,7 @@ _XkbClearColor(char *color_in)
{
XkbColorPtr color= (XkbColorPtr)color_in;
- if (color->spec)
- free(color->spec);
+ free(color->spec);
return;
}
@@ -478,7 +477,7 @@ _XkbGeomAlloc( void ** old,
if (*num>0) {
char *tmp= (char *)(*old);
- bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
+ memset(&tmp[sz_elem*(*num)], 0, (num_new*sz_elem));
}
return Success;
}
@@ -663,8 +662,7 @@ register XkbPropertyPtr prop;
return NULL;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
- if (prop->value)
- free(prop->value);
+ free(prop->value);
prop->value= malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);
@@ -701,7 +699,7 @@ register XkbKeyAliasPtr alias;
return NULL;
for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
- bzero(alias->real,XkbKeyNameLength);
+ memset(alias->real, 0, XkbKeyNameLength);
strncpy(alias->real,realStr,XkbKeyNameLength);
return alias;
}
@@ -711,7 +709,7 @@ register XkbKeyAliasPtr alias;
return NULL;
}
alias= &geom->key_aliases[geom->num_key_aliases];
- bzero(alias,sizeof(XkbKeyAliasRec));
+ memset(alias, 0, sizeof(XkbKeyAliasRec));
strncpy(alias->alias,aliasStr,XkbKeyNameLength);
strncpy(alias->real,realStr,XkbKeyNameLength);
geom->num_key_aliases++;
@@ -758,7 +756,7 @@ XkbOutlinePtr outline;
return NULL;
}
outline= &shape->outlines[shape->num_outlines];
- bzero(outline,sizeof(XkbOutlineRec));
+ memset(outline, 0, sizeof(XkbOutlineRec));
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
return NULL;
shape->num_outlines++;
@@ -783,7 +781,7 @@ register int i;
(_XkbAllocShapes(geom,1)!=Success))
return NULL;
shape= &geom->shapes[geom->num_shapes];
- bzero(shape,sizeof(XkbShapeRec));
+ memset(shape, 0, sizeof(XkbShapeRec));
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
return NULL;
shape->name= name;
@@ -801,7 +799,7 @@ XkbKeyPtr key;
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
return NULL;
key= &row->keys[row->num_keys++];
- bzero(key,sizeof(XkbKeyRec));
+ memset(key, 0, sizeof(XkbKeyRec));
return key;
}
@@ -816,7 +814,7 @@ XkbRowPtr row;
(_XkbAllocRows(section,1)!=Success))
return NULL;
row= &section->rows[section->num_rows];
- bzero(row,sizeof(XkbRowRec));
+ memset(row, 0, sizeof(XkbRowRec));
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
return NULL;
section->num_rows++;
@@ -896,7 +894,7 @@ register int i,nDoodads;
return NULL;
doodad= &geom->doodads[geom->num_doodads++];
}
- bzero(doodad,sizeof(XkbDoodadRec));
+ memset(doodad, 0, sizeof(XkbDoodadRec));
doodad->any.name= name;
return doodad;
}
@@ -960,7 +958,7 @@ XkbOverlayRowPtr row;
(_XkbAllocOverlayRows(overlay,1)!=Success))
return NULL;
row= &overlay->rows[overlay->num_rows];
- bzero(row,sizeof(XkbOverlayRowRec));
+ memset(row, 0, sizeof(XkbOverlayRowRec));
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
return NULL;
row->row_under= row_under;
diff --git a/xorg-server/xkb/XKBMAlloc.c b/xorg-server/xkb/XKBMAlloc.c
index 34e52835d..0bd7b5e01 100644
--- a/xorg-server/xkb/XKBMAlloc.c
+++ b/xorg-server/xkb/XKBMAlloc.c
@@ -84,7 +84,7 @@ XkbClientMapPtr map;
return BadAlloc;
}
map->size_types= nTotalTypes;
- bzero(&map->types[map->num_types],
+ memset(&map->types[map->num_types], 0,
((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
}
}
@@ -177,7 +177,7 @@ XkbServerMapPtr map;
return BadAlloc;
}
map->size_acts= need;
- bzero(&map->acts[map->num_acts],
+ memset(&map->acts[map->num_acts], 0,
((map->size_acts-map->num_acts)*sizeof(XkbAction)));
}
if (map->key_acts==NULL) {
@@ -312,8 +312,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
if ((map_count>type->map_count)||(type->map==NULL))
type->map = realloc(type->map,map_count * sizeof(XkbKTMapEntryRec));
if (!type->map) {
- if (prev_map)
- free(prev_map);
+ free(prev_map);
return BadAlloc;
}
if (want_preserve) {
@@ -324,8 +323,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
map_count * sizeof(XkbModsRec));
}
if (!type->preserve) {
- if (prev_preserve)
- free(prev_preserve);
+ free(prev_preserve);
return BadAlloc;
}
}
@@ -342,8 +340,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
type->level_names = realloc(type->level_names,
new_num_lvls * sizeof(Atom));
if (!type->level_names) {
- if (prev_level_names)
- free(prev_level_names);
+ free(prev_level_names);
return BadAlloc;
}
}
@@ -368,7 +365,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
* The possibilities marked with '+' require us to examine the key types
* associated with each group for the key.
*/
- bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ memset(matchingKeys, 0, XkbMaxKeyCount*sizeof(KeyCode));
nMatchingKeys= 0;
if (new_num_lvls>type->num_levels) {
int nTotal;
@@ -461,7 +458,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
if (nClear>0)
- bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ memset(&pSyms[g*width+firstClear], 0, nClear*sizeof(KeySym));
}
}
}
@@ -491,8 +488,8 @@ KeySym *newSyms;
nOldSyms*sizeof(KeySym));
}
if ((needed-nOldSyms)>0) {
- bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
- (needed-nOldSyms)*sizeof(KeySym));
+ memset(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb, key)],
+ 0, (needed-nOldSyms)*sizeof(KeySym));
}
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
xkb->map->num_syms+= needed;
@@ -515,7 +512,7 @@ KeySym *newSyms;
if (nCopy!=0)
memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
if (nKeySyms>nCopy)
- bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ memset(&newSyms[nSyms+nCopy], 0, (nKeySyms-nCopy)*sizeof(KeySym));
xkb->map->key_sym_map[i].offset = nSyms;
nSyms+= nKeySyms;
}
@@ -568,7 +565,7 @@ int tmp;
tmp= xkb->min_key_code-minKC;
if (xkb->map) {
if (xkb->map->key_sym_map) {
- bzero((char *)&xkb->map->key_sym_map[minKC],
+ memset((char *)&xkb->map->key_sym_map[minKC], 0,
tmp*sizeof(XkbSymMapRec));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -578,7 +575,7 @@ int tmp;
}
}
if (xkb->map->modmap) {
- bzero((char *)&xkb->map->modmap[minKC],tmp);
+ memset((char *)&xkb->map->modmap[minKC], 0, tmp);
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
XkbModifierMapMask,minKC,
@@ -589,7 +586,7 @@ int tmp;
}
if (xkb->server) {
if (xkb->server->behaviors) {
- bzero((char *)&xkb->server->behaviors[minKC],
+ memset((char *)&xkb->server->behaviors[minKC], 0,
tmp*sizeof(XkbBehavior));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -599,7 +596,7 @@ int tmp;
}
}
if (xkb->server->key_acts) {
- bzero((char *)&xkb->server->key_acts[minKC],
+ memset((char *)&xkb->server->key_acts[minKC], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -609,7 +606,7 @@ int tmp;
}
}
if (xkb->server->vmodmap) {
- bzero((char *)&xkb->server->vmodmap[minKC],
+ memset((char *)&xkb->server->vmodmap[minKC], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -620,7 +617,7 @@ int tmp;
}
}
if ((xkb->names)&&(xkb->names->keys)) {
- bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ memset((char *)&xkb->names->keys[minKC], 0, tmp*sizeof(XkbKeyNameRec));
if (changes) {
changes->names.changed= _ExtendRange(changes->names.changed,
XkbKeyNamesMask,minKC,
@@ -644,7 +641,7 @@ int tmp;
free(prev_key_sym_map);
return BadAlloc;
}
- bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ memset((char *)&xkb->map->key_sym_map[xkb->max_key_code], 0,
tmp*sizeof(XkbSymMapRec));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -662,7 +659,7 @@ int tmp;
free(prev_modmap);
return BadAlloc;
}
- bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+ memset((char *)&xkb->map->modmap[xkb->max_key_code], 0, tmp);
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
XkbModifierMapMask,maxKC,
@@ -681,7 +678,7 @@ int tmp;
free(prev_behaviors);
return BadAlloc;
}
- bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ memset((char *)&xkb->server->behaviors[xkb->max_key_code], 0,
tmp*sizeof(XkbBehavior));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -699,7 +696,7 @@ int tmp;
free(prev_key_acts);
return BadAlloc;
}
- bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ memset((char *)&xkb->server->key_acts[xkb->max_key_code], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -717,7 +714,7 @@ int tmp;
free(prev_vmodmap);
return BadAlloc;
}
- bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ memset((char *)&xkb->server->vmodmap[xkb->max_key_code], 0,
tmp*sizeof(unsigned short));
if (changes) {
changes->map.changed= _ExtendRange(changes->map.changed,
@@ -736,7 +733,7 @@ int tmp;
free(prev_keys);
return BadAlloc;
}
- bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ memset((char *)&xkb->names->keys[xkb->max_key_code], 0,
tmp*sizeof(XkbKeyNameRec));
if (changes) {
changes->names.changed= _ExtendRange(changes->names.changed,
@@ -790,7 +787,7 @@ XkbAction *newActs;
memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
nCopy*sizeof(XkbAction));
if (nCopy<nKeyActs)
- bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ memset(&newActs[nActs+nCopy], 0, (nKeyActs-nCopy)*sizeof(XkbAction));
xkb->server->key_acts[i]= nActs;
nActs+= nKeyActs;
}
diff --git a/xorg-server/xkb/XKBMisc.c b/xorg-server/xkb/XKBMisc.c
index 758638f4b..f983466ea 100644
--- a/xorg-server/xkb/XKBMisc.c
+++ b/xorg-server/xkb/XKBMisc.c
@@ -580,7 +580,7 @@ int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
if (pSyms==NULL)
return BadAlloc;
- bzero(pSyms,width*nGroups*sizeof(KeySym));
+ memset(pSyms, 0, width*nGroups*sizeof(KeySym));
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
pOldType= XkbKeyKeyType(xkb,key,i);
pNewType= &xkb->map->types[newTypes[i]];
@@ -596,7 +596,7 @@ int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
if (pActs==NULL)
return BadAlloc;
- bzero(pActs,width*nGroups*sizeof(XkbAction));
+ memset(pActs, 0, width*nGroups*sizeof(XkbAction));
for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
pOldType= XkbKeyKeyType(xkb,key,i);
pNewType= &xkb->map->types[newTypes[i]];
diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c
index a717aa456..2a118ae6a 100644
--- a/xorg-server/xkb/maprules.c
+++ b/xorg-server/xkb/maprules.c
@@ -270,7 +270,7 @@ Bool found;
l_ndx_present = v_ndx_present = present= 0;
str= &line->line[1];
len = remap->number;
- bzero((char *)remap,sizeof(RemapSpec));
+ memset((char *)remap, 0, sizeof(RemapSpec));
remap->number = len;
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
found= FALSE;
@@ -412,7 +412,7 @@ Bool append = FALSE;
DebugF("Illegal line of data ignored\n");
return FALSE;
}
- bzero((char *)&tmp,sizeof(FileSpec));
+ memset((char *)&tmp, 0, sizeof(FileSpec));
str= line->line;
for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
str= NULL;
@@ -495,7 +495,7 @@ static Bool
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
{
- bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
+ memset((char *)mdefs, 0, sizeof(XkbRF_MultiDefsRec));
mdefs->model = defs->model;
mdefs->options = _XkbDupString(defs->options);
if (mdefs->options) squeeze_spaces(mdefs->options);
@@ -553,9 +553,9 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- if (defs->options) free(defs->options);
- if (defs->layout[1]) free(defs->layout[1]);
- if (defs->variant[1]) free(defs->variant[1]);
+ free(defs->options);
+ free(defs->layout[1]);
+ free(defs->variant[1]);
}
static void
@@ -834,7 +834,7 @@ XkbRF_GetComponents( XkbRF_RulesPtr rules,
MakeMultiDefs(&mdefs, defs);
- bzero((char *)names,sizeof(XkbComponentNamesRec));
+ memset((char *)names, 0, sizeof(XkbComponentNamesRec));
XkbRF_ClearPartialMatches(rules);
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
XkbRF_ApplyPartialMatches(rules, names);
@@ -876,7 +876,7 @@ XkbRF_AddRule(XkbRF_RulesPtr rules)
DebugF("Allocation failure in XkbRF_AddRule\n");
return NULL;
}
- bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec));
+ memset((char *)&rules->rules[rules->num_rules], 0, sizeof(XkbRF_RuleRec));
return &rules->rules[rules->num_rules++];
}
@@ -898,7 +898,7 @@ XkbRF_AddGroup(XkbRF_RulesPtr rules)
return NULL;
}
- bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec));
+ memset((char *)&rules->groups[rules->num_groups], 0, sizeof(XkbRF_GroupRec));
return &rules->groups[rules->num_groups++];
}
@@ -912,20 +912,20 @@ XkbRF_GroupRec tgroup,*group;
if (!(rules && file))
return FALSE;
- bzero((char *)&remap,sizeof(RemapSpec));
- bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ memset((char *)&remap, 0, sizeof(RemapSpec));
+ memset((char *)&tgroup, 0, sizeof(XkbRF_GroupRec));
InitInputLine(&line);
while (GetInputLine(file,&line,TRUE)) {
if (CheckLine(&line,&remap,&trule,&tgroup)) {
if (tgroup.number) {
if ((group= XkbRF_AddGroup(rules))!=NULL) {
*group= tgroup;
- bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
+ memset((char *)&tgroup, 0, sizeof(XkbRF_GroupRec));
}
} else {
if ((rule= XkbRF_AddRule(rules))!=NULL) {
*rule= trule;
- bzero((char *)&trule,sizeof(XkbRF_RuleRec));
+ memset((char *)&trule, 0, sizeof(XkbRF_RuleRec));
}
}
}
@@ -988,16 +988,16 @@ XkbRF_GroupPtr group;
return;
if (rules->rules) {
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
- if (rule->model) free(rule->model);
- if (rule->layout) free(rule->layout);
- if (rule->variant) free(rule->variant);
- if (rule->option) free(rule->option);
- if (rule->keycodes) free(rule->keycodes);
- if (rule->symbols) free(rule->symbols);
- if (rule->types) free(rule->types);
- if (rule->compat) free(rule->compat);
- if (rule->geometry) free(rule->geometry);
- bzero((char *)rule,sizeof(XkbRF_RuleRec));
+ free(rule->model);
+ free(rule->layout);
+ free(rule->variant);
+ free(rule->option);
+ free(rule->keycodes);
+ free(rule->symbols);
+ free(rule->types);
+ free(rule->compat);
+ free(rule->geometry);
+ memset((char *)rule, 0, sizeof(XkbRF_RuleRec));
}
free(rules->rules);
rules->num_rules= rules->sz_rules= 0;
@@ -1006,8 +1006,8 @@ XkbRF_GroupPtr group;
if (rules->groups) {
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
- if (group->name) free(group->name);
- if (group->words) free(group->words);
+ free(group->name);
+ free(group->words);
}
free(rules->groups);
rules->num_groups= 0;
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c
index 3c337b63e..cd48515d7 100644
--- a/xorg-server/xkb/xkb.c
+++ b/xorg-server/xkb/xkb.c
@@ -557,7 +557,7 @@ ProcXkbGetState(ClientPtr client)
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);
xkb= &dev->key->xkbInfo->state;
- bzero(&rep,sizeof(xkbGetStateReply));
+ memset(&rep, 0, sizeof(xkbGetStateReply));
rep.type= X_Reply;
rep.sequenceNumber= client->sequence;
rep.length = 0;
@@ -1429,7 +1429,7 @@ ProcXkbGetMap(ClientPtr client)
CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask);
xkb= dev->key->xkbInfo->desc;
- bzero(&rep,sizeof(xkbGetMapReply));
+ memset(&rep, 0, sizeof(xkbGetMapReply));
rep.type= X_Reply;
rep.sequenceNumber= client->sequence;
rep.length = (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2;
@@ -2172,7 +2172,7 @@ unsigned first,last;
first= req->firstKeyBehavior;
last= req->firstKeyBehavior+req->nKeyBehaviors-1;
- bzero(&server->behaviors[first],req->nKeyBehaviors*sizeof(XkbBehavior));
+ memset(&server->behaviors[first], 0, req->nKeyBehaviors*sizeof(XkbBehavior));
for (i=0;i<req->totalKeyBehaviors;i++) {
if ((server->behaviors[wire->key].type&XkbKB_Permanent)==0) {
server->behaviors[wire->key].type= wire->type;
@@ -2190,7 +2190,7 @@ unsigned first,last;
else xkbi->radioGroups= calloc(1, sz);
if (xkbi->radioGroups) {
if (xkbi->nRadioGroups)
- bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
+ memset(&xkbi->radioGroups[xkbi->nRadioGroups], 0,
(maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));
xkbi->nRadioGroups= maxRG;
}
@@ -2245,7 +2245,7 @@ CARD8 * start;
start= wire;
first= req->firstKeyExplicit;
last= req->firstKeyExplicit+req->nKeyExplicit-1;
- bzero(&xkb->explicit[first],req->nKeyExplicit);
+ memset(&xkb->explicit[first], 0, req->nKeyExplicit);
for (i=0;i<req->totalKeyExplicit;i++,wire+= 2) {
xkb->explicit[wire[0]]= wire[1];
}
@@ -2279,7 +2279,7 @@ CARD8 * start;
start= wire;
first= req->firstModMapKey;
last= req->firstModMapKey+req->nModMapKeys-1;
- bzero(&xkb->modmap[first],req->nModMapKeys);
+ memset(&xkb->modmap[first], 0, req->nModMapKeys);
for (i=0;i<req->totalModMapKeys;i++,wire+= 2) {
xkb->modmap[wire[0]]= wire[1];
}
@@ -2311,7 +2311,7 @@ XkbServerMapPtr srv = xkbi->desc->server;
first= req->firstVModMapKey;
last= req->firstVModMapKey+req->nVModMapKeys-1;
- bzero(&srv->vmodmap[first],req->nVModMapKeys*sizeof(unsigned short));
+ memset(&srv->vmodmap[first], 0, req->nVModMapKeys*sizeof(unsigned short));
for (i=0;i<req->totalVModMapKeys;i++,wire++) {
srv->vmodmap[wire->key]= wire->vmods;
}
@@ -2438,7 +2438,7 @@ _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char *values)
xkb = xkbi->desc;
XkbSetCauseXkbReq(&cause,X_kbSetMap,client);
- bzero(&change, sizeof(change));
+ memset(&change, 0, sizeof(change));
sentNKN = FALSE;
if ((xkb->min_key_code!=req->minKeyCode)||
(xkb->max_key_code!=req->maxKeyCode)) {
@@ -2851,7 +2851,7 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
XkbEventCauseRec cause;
XkbSetCauseXkbReq(&cause,X_kbSetCompatMap,client);
- bzero(&change,sizeof(XkbChangesRec));
+ memset(&change, 0, sizeof(XkbChangesRec));
XkbUpdateActions(dev,xkb->min_key_code,XkbNumKeys(xkb),&change,&check,
&cause);
if (check)
@@ -3384,8 +3384,8 @@ _XkbSetNamedIndicator(ClientPtr client, DeviceIntPtr dev,
statec |= ((sli->effectiveState ^ sli->explicitState) & (1 << led));
}
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
- bzero((char *)&changes,sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
XkbSetCauseXkbReq(&cause,X_kbSetNamedIndicator,client);
if (namec)
XkbApplyLedNameChanges(dev,sli,namec,&ed,&changes,&cause);
@@ -4038,7 +4038,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff)
return BadAlloc;
}
- bzero(&nn,sizeof(xkbNamesNotify));
+ memset(&nn, 0, sizeof(xkbNamesNotify));
nn.changed= stuff->which;
tmp = (CARD32 *)&stuff[1];
if (stuff->which&XkbKeycodesNameMask)
@@ -4160,7 +4160,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff)
if (names->indicators[i]!=None)
sli->namesPresent|= bit;
}
- bzero(&edev,sizeof(xkbExtensionDeviceNotify));
+ memset(&edev, 0, sizeof(xkbExtensionDeviceNotify));
edev.reason= XkbXI_IndicatorNamesMask;
edev.ledClass= KbdFeedbackClass;
edev.ledID= dev->kbdfeed->ctrl.id;
@@ -4478,7 +4478,7 @@ xkbDoodadWireDesc * doodadWire;
for (i=0;i<num_doodads;i++,doodad++) {
doodadWire= (xkbDoodadWireDesc *)wire;
wire= (char *)&doodadWire[1];
- bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
+ memset(doodadWire, 0, SIZEOF(xkbDoodadWireDesc));
doodadWire->any.name= doodad->any.name;
doodadWire->any.type= doodad->any.type;
doodadWire->any.priority= doodad->any.priority;
@@ -5290,7 +5290,7 @@ _XkbSetGeometry(ClientPtr client, DeviceIntPtr dev, xkbSetGeometryReq *stuff)
XkbFreeGeometry(old,XkbGeomAllMask,TRUE);
if (new_name) {
xkbNamesNotify nn;
- bzero(&nn,sizeof(xkbNamesNotify));
+ memset(&nn, 0, sizeof(xkbNamesNotify));
nn.changed= XkbGeometryNameMask;
XkbSendNamesNotify(dev,&nn);
}
@@ -5497,7 +5497,7 @@ ProcXkbListComponents(ClientPtr client)
status= Success;
str= (unsigned char *)&stuff[1];
- bzero(&list,sizeof(XkbSrvListInfoRec));
+ memset(&list, 0, sizeof(XkbSrvListInfoRec));
list.maxRtrn= stuff->maxNames;
list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,FALSE,&status);
list.pattern[_XkbListTypes]= GetComponentSpec(&str,FALSE,&status);
@@ -5516,7 +5516,7 @@ ProcXkbListComponents(ClientPtr client)
}
return status;
}
- bzero(&rep,sizeof(xkbListComponentsReply));
+ memset(&rep, 0, sizeof(xkbListComponentsReply));
rep.type= X_Reply;
rep.deviceID = dev->id;
rep.sequenceNumber = client->sequence;
@@ -5624,7 +5624,7 @@ ProcXkbGetKbdByName(ClientPtr client)
geom_changed= FALSE;
}
- bzero(mapFile,PATH_MAX);
+ memset(mapFile, 0, PATH_MAX);
rep.type= X_Reply;
rep.deviceID = dev->id;
rep.sequenceNumber = client->sequence;
@@ -5659,7 +5659,7 @@ ProcXkbGetKbdByName(ClientPtr client)
if (stuff->load ||
((rep.reported&XkbGBN_SymbolsMask) && (new->compat))) {
XkbChangesRec changes;
- bzero(&changes,sizeof(changes));
+ memset(&changes, 0, sizeof(changes));
XkbUpdateDescActions(new,
new->min_key_code,XkbNumKeys(new),
&changes);
@@ -6123,7 +6123,7 @@ char * str;
wanted&= ~XkbXI_IndicatorsMask;
nameLen= XkbSizeCountedString(dev->name);
- bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply));
+ memset((char *)&rep, 0, SIZEOF(xkbGetDeviceInfoReply));
rep.type = X_Reply;
rep.deviceID= dev->id;
rep.sequenceNumber = client->sequence;
@@ -6331,8 +6331,8 @@ xkbExtensionDeviceNotify ed;
XkbChangesRec changes;
DeviceIntPtr kbd;
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
- bzero((char *)&changes,sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
XkbSetCauseXkbReq(&cause,X_kbSetDeviceInfo,client);
ledWire= (xkbDeviceLedsWireDesc *)wire;
for (i=0;i<num;i++) {
@@ -6353,11 +6353,11 @@ DeviceIntPtr kbd;
atomWire= (CARD32 *)&ledWire[1];
if (changed&XkbXI_IndicatorNamesMask) {
namec= sli->namesPresent|ledWire->namesPresent;
- bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ memset((char *)sli->names, 0, XkbNumIndicators*sizeof(Atom));
}
if (ledWire->namesPresent) {
sli->namesPresent= ledWire->namesPresent;
- bzero((char *)sli->names,XkbNumIndicators*sizeof(Atom));
+ memset((char *)sli->names, 0, XkbNumIndicators*sizeof(Atom));
for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
if (ledWire->namesPresent&bit) {
sli->names[n]= (Atom)*atomWire;
@@ -6371,7 +6371,7 @@ DeviceIntPtr kbd;
if (changed&XkbXI_IndicatorMapsMask) {
mapc= sli->mapsPresent|ledWire->mapsPresent;
sli->mapsPresent= ledWire->mapsPresent;
- bzero((char*)sli->maps,XkbNumIndicators*sizeof(XkbIndicatorMapRec));
+ memset((char*)sli->maps, 0, XkbNumIndicators*sizeof(XkbIndicatorMapRec));
}
if (ledWire->mapsPresent) {
for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
@@ -6450,7 +6450,7 @@ _XkbSetDeviceInfoCheck(ClientPtr client, DeviceIntPtr dev,
char *wire;
xkbExtensionDeviceNotify ed;
- bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
+ memset((char *)&ed, 0, SIZEOF(xkbExtensionDeviceNotify));
ed.deviceID= dev->id;
wire= (char *)&stuff[1];
if (stuff->change&XkbXI_ButtonActionsMask) {
@@ -6709,6 +6709,9 @@ XkbExtensionInit(void)
if (!RT_XKBCLIENT)
return;
+ if (!XkbInitPrivates())
+ return;
+
if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors,
ProcXkbDispatch, SProcXkbDispatch,
NULL, StandardMinorOpcode))) {
diff --git a/xorg-server/xkb/xkbAccessX.c b/xorg-server/xkb/xkbAccessX.c
index be1dceea3..be12e5d83 100644
--- a/xorg-server/xkb/xkbAccessX.c
+++ b/xorg-server/xkb/xkbAccessX.c
@@ -1,776 +1,776 @@
-/************************************************************
-Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
-
-Permission to use, copy, modify, and distribute this
-software and its documentation for any purpose and without
-fee is hereby granted, provided that the above copyright
-notice appear in all copies and that both that copyright
-notice and this permission notice appear in supporting
-documentation, and that the name of Silicon Graphics not be
-used in advertising or publicity pertaining to distribution
-of the software without specific prior written permission.
-Silicon Graphics makes no representation about the suitability
-of this software for any purpose. It is provided "as is"
-without any express or implied warranty.
-
-SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
-GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
-THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <math.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
-#include "exglobals.h"
-#include <X11/extensions/XIproto.h>
-#include "inputstr.h"
-#include "eventstr.h"
-#include <xkbsrv.h>
-#if !defined(WIN32)
-#include <sys/time.h>
-#endif
-
-int XkbDfltRepeatDelay= 660;
-int XkbDfltRepeatInterval= 40;
-
-#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
-#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
-
-unsigned short XkbDfltAccessXTimeout= 120;
-unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
-static unsigned int XkbDfltAccessXTimeoutValues= 0;
-static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
-static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
-unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
-unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
-
-void
-AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls)
-{
- xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001);
- xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/
- pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve));
- return;
-}
-
-void
-AccessXInit(DeviceIntPtr keybd)
-{
-XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-
- xkbi->shiftKeyCount= 0;
- xkbi->mouseKeysCounter= 0;
- xkbi->inactiveKey= 0;
- xkbi->slowKey= 0;
- xkbi->repeatKey= 0;
- xkbi->krgTimerActive= _OFF_TIMER;
- xkbi->beepType= _BEEP_NONE;
- xkbi->beepCount= 0;
- xkbi->mouseKeyTimer= NULL;
- xkbi->slowKeysTimer= NULL;
- xkbi->bounceKeysTimer= NULL;
- xkbi->repeatKeyTimer= NULL;
- xkbi->krgTimer= NULL;
- xkbi->beepTimer= NULL;
- ctrls->repeat_delay = XkbDfltRepeatDelay;
- ctrls->repeat_interval = XkbDfltRepeatInterval;
- ctrls->debounce_delay = 300;
- ctrls->slow_keys_delay = 300;
- ctrls->mk_delay = 160;
- ctrls->mk_interval = 40;
- ctrls->mk_time_to_max = 30;
- ctrls->mk_max_speed = 30;
- ctrls->mk_curve = 500;
- ctrls->mk_dflt_btn = 1;
- ctrls->ax_timeout = XkbDfltAccessXTimeout;
- ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask;
- ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues;
- ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask;
- ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues;
- if (XkbDfltAccessXTimeout)
- ctrls->enabled_ctrls |= XkbAccessXTimeoutMask;
- else
- ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask;
- ctrls->enabled_ctrls |= XkbDfltAccessXFeedback;
- ctrls->ax_options = XkbDfltAccessXOptions;
- AccessXComputeCurveFactor(xkbi,ctrls);
- return;
-}
-
-/************************************************************************/
-/* */
-/* AccessXKeyboardEvent */
-/* */
-/* Generate a synthetic keyboard event. */
-/* */
-/************************************************************************/
-static void
-AccessXKeyboardEvent(DeviceIntPtr keybd,
- int type,
- BYTE keyCode,
- Bool isRepeat)
-{
- DeviceEvent event;
- memset(&event, 0, sizeof(DeviceEvent));
- event.header = ET_Internal;
- event.type = type;
- event.detail.key = keyCode;
- event.time = GetTimeInMillis();
- event.length = sizeof(DeviceEvent);
- event.key_repeat = isRepeat;
- event.sourceid = keybd->id;
- event.deviceid = keybd->id;
-
- if (xkbDebugFlags&0x8) {
- DebugF("[xkb] AXKE: Key %d %s\n", keyCode,
- (event.type == ET_KeyPress ? "down" : "up"));
- }
-
- XkbProcessKeyboardEvent(&event, keybd);
- return;
-} /* AccessXKeyboardEvent */
-
-/************************************************************************/
-/* */
-/* AccessXKRGTurnOn */
-/* */
-/* Turn the keyboard response group on. */
-/* */
-/************************************************************************/
-static void
-AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN)
-{
-XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-XkbControlsRec old;
-XkbEventCauseRec cause;
-XkbSrvLedInfoPtr sli;
-
- old= *ctrls;
- ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask);
- if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
- XkbSendControlsNotify(dev,pCN);
- cause.kc= pCN->keycode;
- cause.event= pCN->eventType;
- cause.mjr= pCN->requestMajor;
- cause.mnr= pCN->requestMinor;
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
- XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl);
- return;
-
-} /* AccessXKRGTurnOn */
-
-/************************************************************************/
-/* */
-/* AccessXKRGTurnOff */
-/* */
-/* Turn the keyboard response group off. */
-/* */
-/************************************************************************/
-static void
-AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
-{
-XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-XkbControlsRec old;
-XkbEventCauseRec cause;
-XkbSrvLedInfoPtr sli;
-
- old = *ctrls;
- ctrls->enabled_ctrls &= ~XkbAX_KRGMask;
- if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
- XkbSendControlsNotify(dev,pCN);
- cause.kc= pCN->keycode;
- cause.event= pCN->eventType;
- cause.mjr= pCN->requestMajor;
- cause.mnr= pCN->requestMinor;
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
- unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls;
- XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes);
- }
- return;
-
-} /* AccessXKRGTurnOff */
-
-/************************************************************************/
-/* */
-/* AccessXStickyKeysTurnOn */
-/* */
-/* Turn StickyKeys on. */
-/* */
-/************************************************************************/
-static void
-AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN)
-{
-XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-XkbControlsRec old;
-XkbEventCauseRec cause;
-XkbSrvLedInfoPtr sli;
-
- old = *ctrls;
- ctrls->enabled_ctrls |= XkbStickyKeysMask;
- xkbi->shiftKeyCount = 0;
- if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
- XkbSendControlsNotify(dev,pCN);
- cause.kc= pCN->keycode;
- cause.event= pCN->eventType;
- cause.mjr= pCN->requestMajor;
- cause.mnr= pCN->requestMinor;
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
- XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask);
- }
- return;
-
-} /* AccessXStickyKeysTurnOn */
-
-/************************************************************************/
-/* */
-/* AccessXStickyKeysTurnOff */
-/* */
-/* Turn StickyKeys off. */
-/* */
-/************************************************************************/
-static void
-AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
-{
-XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-XkbControlsRec old;
-XkbEventCauseRec cause;
-XkbSrvLedInfoPtr sli;
-
- old = *ctrls;
- ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
- xkbi->shiftKeyCount = 0;
- if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
- XkbSendControlsNotify(dev,pCN);
-
- cause.kc= pCN->keycode;
- cause.event= pCN->eventType;
- cause.mjr= pCN->requestMajor;
- cause.mnr= pCN->requestMinor;
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
- XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask);
- }
-#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
- XkbClearAllLatchesAndLocks(dev,xkbi,FALSE,&cause);
-#endif
- return;
-} /* AccessXStickyKeysTurnOff */
-
-static CARD32
-AccessXKRGExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
-xkbControlsNotify cn;
-
- if (xkbi->krgTimerActive==_KRG_WARN_TIMER) {
- XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask);
- xkbi->krgTimerActive= _KRG_TIMER;
- return 4000;
- }
- xkbi->krgTimerActive= _OFF_TIMER;
- cn.keycode = 0;
- cn.eventType = 0;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask)
- AccessXKRGTurnOff((DeviceIntPtr)arg,&cn);
- else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn);
- return 0;
-}
-
-static CARD32
-AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-DeviceIntPtr dev = (DeviceIntPtr) arg;
-XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
-
- if (xkbi->repeatKey == 0)
- return 0;
-
- AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, TRUE);
-
- return xkbi->desc->ctrls->repeat_interval;
-}
-
-void
-AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key)
-{
- if (xkbi->repeatKey==key)
- xkbi->repeatKey= 0;
- return;
-}
-
-static CARD32
-AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-DeviceIntPtr keybd;
-XkbSrvInfoPtr xkbi;
-XkbDescPtr xkb;
-XkbControlsPtr ctrls;
-
- keybd= (DeviceIntPtr)arg;
- xkbi= keybd->key->xkbInfo;
- xkb= xkbi->desc;
- ctrls= xkb->ctrls;
- if (xkbi->slowKey!=0) {
- xkbAccessXNotify ev;
- KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey);
- ev.detail= XkbAXN_SKAccept;
- ev.keycode= xkbi->slowKey;
- ev.slowKeysDelay= ctrls->slow_keys_delay;
- ev.debounceDelay= ctrls->debounce_delay;
- XkbSendAccessXNotify(keybd,&ev);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask))
- XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask);
- AccessXKeyboardEvent(keybd, ET_KeyPress,xkbi->slowKey,FALSE);
- /* check for magic sequences */
- if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) &&
- ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)))
- xkbi->shiftKeyCount++;
-
- /* Start repeating if necessary. Stop autorepeating if the user
- * presses a non-modifier key that doesn't autorepeat.
- */
- if (keybd->kbdfeed->ctrl.autoRepeat &&
- ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
- (ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
- if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) {
- xkbi->repeatKey = xkbi->slowKey;
- xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
- 0, ctrls->repeat_delay,
- AccessXRepeatKeyExpire, (pointer)keybd);
- }
- }
- }
- return 0;
-}
-
-static CARD32
-AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
-
- xkbi->inactiveKey= 0;
- return 0;
-}
-
-static CARD32
-AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
-{
-DeviceIntPtr dev = (DeviceIntPtr)arg;
-XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
-XkbControlsPtr ctrls= xkbi->desc->ctrls;
-XkbControlsRec old;
-xkbControlsNotify cn;
-XkbEventCauseRec cause;
-XkbSrvLedInfoPtr sli;
-
- if (xkbi->lastPtrEventTime) {
- unsigned timeToWait = (ctrls->ax_timeout*1000);
- unsigned timeElapsed = (now-xkbi->lastPtrEventTime);
-
- if (timeToWait > timeElapsed)
- return (timeToWait - timeElapsed);
- }
- old= *ctrls;
- xkbi->shiftKeyCount= 0;
- ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask;
- ctrls->enabled_ctrls|=
- (ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask);
- if (ctrls->axt_opts_mask) {
- ctrls->ax_options&= ~ctrls->axt_opts_mask;
- ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask);
- }
- if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,FALSE)) {
- cn.keycode = 0;
- cn.eventType = 0;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- XkbSendControlsNotify(dev,&cn);
- }
- XkbSetCauseUnknown(&cause);
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
- if (ctrls->ax_options!=old.ax_options) {
- unsigned set,cleared,bell;
- set= ctrls->ax_options&(~old.ax_options);
- cleared= (~ctrls->ax_options)&old.ax_options;
- if (set && cleared) bell= _BEEP_FEATURE_CHANGE;
- else if (set) bell= _BEEP_FEATURE_ON;
- else bell= _BEEP_FEATURE_OFF;
- XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask);
- }
- xkbi->krgTimerActive= _OFF_TIMER;
- return 0;
-}
-
-
-/************************************************************************/
-/* */
-/* AccessXFilterPressEvent */
-/* */
-/* Filter events before they get any further if SlowKeys is turned on. */
-/* In addition, this routine handles the ever so popular magic key */
-/* acts for turning various accessibility features on/off. */
-/* */
-/* Returns TRUE if this routine has discarded the event. */
-/* Returns FALSE if the event needs further processing. */
-/* */
-/************************************************************************/
-Bool
-AccessXFilterPressEvent( DeviceEvent* event,
- DeviceIntPtr keybd)
-{
-XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-Bool ignoreKeyEvent = FALSE;
-KeyCode key = event->detail.key;
-KeySym * sym = XkbKeySymsPtr(xkbi->desc,key);
-
- if (ctrls->enabled_ctrls&XkbAccessXKeysMask) {
- /* check for magic sequences */
- if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) {
- if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) {
- xkbi->krgTimerActive = _KRG_WARN_TIMER;
- xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000,
- AccessXKRGExpire, (pointer)keybd);
- }
- else {
- xkbi->krgTimerActive = _KRG_TIMER;
- xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000,
- AccessXKRGExpire, (pointer)keybd);
- }
- if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
- CARD32 now= GetTimeInMillis();
- if ((now-xkbi->lastShiftEventTime)>15000)
- xkbi->shiftKeyCount= 1;
- else xkbi->shiftKeyCount++;
- xkbi->lastShiftEventTime= now;
- }
- }
- else {
- if (xkbi->krgTimerActive) {
- xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL);
- xkbi->krgTimerActive= _OFF_TIMER;
- }
- }
- }
-
- /* Don't transmit the KeyPress if SlowKeys is turned on;
- * The wakeup handler will synthesize one for us if the user
- * has held the key long enough.
- */
- if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
- xkbAccessXNotify ev;
- /* If key was already pressed, ignore subsequent press events
- * from the server's autorepeat
- */
- if(xkbi->slowKey == key)
- return TRUE;
- ev.detail= XkbAXN_SKPress;
- ev.keycode= key;
- ev.slowKeysDelay= ctrls->slow_keys_delay;
- ev.debounceDelay= ctrls->debounce_delay;
- XkbSendAccessXNotify(keybd,&ev);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask))
- XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask);
- xkbi->slowKey= key;
- xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
- 0, ctrls->slow_keys_delay,
- AccessXSlowKeyExpire, (pointer)keybd);
- ignoreKeyEvent = TRUE;
- }
-
- /* Don't transmit the KeyPress if BounceKeys is turned on
- * and the user pressed the same key within a given time period
- * from the last release.
- */
- else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) &&
- (key == xkbi->inactiveKey)) {
- if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
- XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
- ignoreKeyEvent = TRUE;
- }
-
- /* Start repeating if necessary. Stop autorepeating if the user
- * presses a non-modifier key that doesn't autorepeat.
- */
- if (XkbDDXUsesSoftRepeat(keybd)) {
- if ((keybd->kbdfeed->ctrl.autoRepeat) &&
- ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
- XkbRepeatKeysMask)) {
- if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) {
- if (xkbDebugFlags&0x10)
- DebugF("Starting software autorepeat...\n");
- if (xkbi->repeatKey == key)
- ignoreKeyEvent = TRUE;
- else {
- xkbi->repeatKey = key;
- xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
- 0, ctrls->repeat_delay,
- AccessXRepeatKeyExpire, (pointer)keybd);
- }
- }
- }
- }
-
- /* Check for two keys being pressed at the same time. This section
- * essentially says the following:
- *
- * If StickyKeys is on, and a modifier is currently being held down,
- * and one of the following is true: the current key is not a modifier
- * or the currentKey is a modifier, but not the only modifier being
- * held down, turn StickyKeys off if the TwoKeys off ctrl is set.
- */
- if ((ctrls->enabled_ctrls & XkbStickyKeysMask) &&
- (xkbi->state.base_mods!=0) &&
- (XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) {
- xkbControlsNotify cn;
- cn.keycode = key;
- cn.eventType = KeyPress;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- AccessXStickyKeysTurnOff(keybd,&cn);
- }
-
- if (!ignoreKeyEvent)
- XkbProcessKeyboardEvent(event, keybd);
- return ignoreKeyEvent;
-} /* AccessXFilterPressEvent */
-
-/************************************************************************/
-/* */
-/* AccessXFilterReleaseEvent */
-/* */
-/* Filter events before they get any further if SlowKeys is turned on. */
-/* In addition, this routine handles the ever so popular magic key */
-/* acts for turning various accessibility features on/off. */
-/* */
-/* Returns TRUE if this routine has discarded the event. */
-/* Returns FALSE if the event needs further processing. */
-/* */
-/************************************************************************/
-Bool
-AccessXFilterReleaseEvent( DeviceEvent* event,
- DeviceIntPtr keybd)
-{
-XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
-XkbControlsPtr ctrls = xkbi->desc->ctrls;
-KeyCode key = event->detail.key;
-Bool ignoreKeyEvent = FALSE;
-
- /* Don't transmit the KeyRelease if BounceKeys is on and
- * this is the release of a key that was ignored due to
- * BounceKeys.
- */
- if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
- if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key)))
- ignoreKeyEvent = TRUE;
- xkbi->inactiveKey= key;
- xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0,
- ctrls->debounce_delay,
- AccessXBounceKeyExpire, (pointer)keybd);
- }
-
- /* Don't transmit the KeyRelease if SlowKeys is turned on and
- * the user didn't hold the key long enough. We know we passed
- * the key if the down bit was set by CoreProcessKeyboadEvent.
- */
- if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
- xkbAccessXNotify ev;
- unsigned beep_type;
- ev.keycode= key;
- ev.slowKeysDelay= ctrls->slow_keys_delay;
- ev.debounceDelay= ctrls->debounce_delay;
- if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) {
- ev.detail= XkbAXN_SKRelease;
- beep_type= _BEEP_SLOW_RELEASE;
- }
- else {
- ev.detail= XkbAXN_SKReject;
- beep_type= _BEEP_SLOW_REJECT;
- ignoreKeyEvent = TRUE;
- }
- XkbSendAccessXNotify(keybd,&ev);
- if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) {
- XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask);
- }
- if (xkbi->slowKey==key)
- xkbi->slowKey= 0;
- }
-
- /* Stop Repeating if the user releases the key that is currently
- * repeating.
- */
- if (xkbi->repeatKey==key) {
- xkbi->repeatKey= 0;
- }
-
- if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) {
- xkbi->lastPtrEventTime= 0;
- xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0,
- ctrls->ax_timeout*1000,
- AccessXTimeoutExpire, (pointer)keybd);
- xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER;
- }
- else if (xkbi->krgTimerActive!=_OFF_TIMER) {
- xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL);
- xkbi->krgTimerActive= _OFF_TIMER;
- }
-
- /* Keep track of how many times the Shift key has been pressed.
- * If it has been pressed and released 5 times in a row, toggle
- * the state of StickyKeys.
- */
- if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) {
- KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key);
- if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) {
- xkbi->shiftKeyCount= 0;
- }
- else if (xkbi->shiftKeyCount>=5) {
- xkbControlsNotify cn;
- cn.keycode = key;
- cn.eventType = KeyPress;
- cn.requestMajor = 0;
- cn.requestMinor = 0;
- if (ctrls->enabled_ctrls & XkbStickyKeysMask)
- AccessXStickyKeysTurnOff(keybd,&cn);
- else
- AccessXStickyKeysTurnOn(keybd,&cn);
- xkbi->shiftKeyCount= 0;
- }
- }
-
- if (!ignoreKeyEvent)
- XkbProcessKeyboardEvent(event, keybd);
- return ignoreKeyEvent;
-
-} /* AccessXFilterReleaseEvent */
-
-/************************************************************************/
-/* */
-/* ProcessPointerEvent */
-/* */
-/* This routine merely sets the shiftKeyCount and clears the keyboard */
-/* response group timer (if necessary) on a mouse event. This is so */
-/* multiple shifts with just the mouse and shift-drags with the mouse */
-/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
-/* */
-/************************************************************************/
-extern int xkbDevicePrivateIndex;
-extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
-void
-ProcessPointerEvent( InternalEvent *ev,
- DeviceIntPtr mouse)
-{
-DeviceIntPtr dev;
-XkbSrvInfoPtr xkbi = NULL;
-unsigned changed = 0;
-ProcessInputProc backupproc;
-xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
-DeviceEvent *event = &ev->device_event;
-
- dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse;
-
- if (dev && dev->key)
- {
- xkbi = dev->key->xkbInfo;
- xkbi->shiftKeyCount = 0;
- xkbi->lastPtrEventTime= event->time;
- }
-
- if (event->type == ET_ButtonPress) {
- changed |= XkbPointerButtonMask;
- }
- else if (event->type == ET_ButtonRelease) {
- if (xkbi)
- xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7));
- changed |= XkbPointerButtonMask;
- }
-
- /* Guesswork. mostly.
- * xkb actuall goes through some effort to transparently wrap the
- * processInputProcs (see XkbSetExtension). But we all love fun, so the
- * previous XKB implementation just hardcoded the CPPE call here instead
- * of unwrapping like anybody with any sense of decency would do.
- * I got no clue what the correct thing to do is, but my guess is that
- * it's not hardcoding. I may be wrong. whatever it is, don't come whining
- * to me. I just work here.
- *
- * Anyway. here's the old call, if you don't like the wrapping, revert it.
- *
- * CoreProcessPointerEvent(xE,mouse,count);
- *
- * see. it's still steaming. told you. (whot)
- */
-
- UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc);
- mouse->public.processInputProc(ev, mouse);
- COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr,
- backupproc, xkbUnwrapProc);
-
- if (!xkbi)
- return;
-
- xkbi->state.ptr_buttons = (mouse->button) ? mouse->button->state : 0;
-
- /* clear any latched modifiers */
- if ( xkbi->state.latched_mods && (event->type == ET_ButtonRelease) ) {
- unsigned changed_leds;
- XkbStateRec oldState;
- XkbSrvLedInfoPtr sli;
-
- sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
- oldState= xkbi->state;
- XkbLatchModifiers(dev,0xFF,0x00);
-
- XkbComputeDerivedState(xkbi);
- changed |= XkbStateChangedFlags(&oldState,&xkbi->state);
- if (changed&sli->usedComponents) {
- changed_leds= XkbIndicatorsToUpdate(dev,changed,FALSE);
- if (changed_leds) {
- XkbEventCauseRec cause;
- XkbSetCauseKey(&cause,(event->detail.key & 0x7), event->type);
- XkbUpdateIndicators(dev,changed_leds,TRUE,NULL,&cause);
- }
- }
- }
-
- if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
- xkbStateNotify sn;
- sn.keycode= event->detail.key;
- sn.eventType= event->type;
- sn.requestMajor = sn.requestMinor = 0;
- sn.changed= changed;
- XkbSendStateNotify(dev,&sn);
- }
-
-} /* ProcessPointerEvent */
-
-
-
-
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright
+notice appear in all copies and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be
+used in advertising or publicity pertaining to distribution
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <math.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "exglobals.h"
+#include <X11/extensions/XIproto.h>
+#include "inputstr.h"
+#include "eventstr.h"
+#include <xkbsrv.h>
+#if !defined(WIN32)
+#include <sys/time.h>
+#endif
+
+int XkbDfltRepeatDelay= 660;
+int XkbDfltRepeatInterval= 40;
+
+#define DFLT_TIMEOUT_CTRLS (XkbAX_KRGMask|XkbStickyKeysMask|XkbMouseKeysMask)
+#define DFLT_TIMEOUT_OPTS (XkbAX_IndicatorFBMask)
+
+unsigned short XkbDfltAccessXTimeout= 120;
+unsigned int XkbDfltAccessXTimeoutMask= DFLT_TIMEOUT_CTRLS;
+static unsigned int XkbDfltAccessXTimeoutValues= 0;
+static unsigned int XkbDfltAccessXTimeoutOptionsMask= DFLT_TIMEOUT_OPTS;
+static unsigned int XkbDfltAccessXTimeoutOptionsValues= 0;
+unsigned int XkbDfltAccessXFeedback= XkbAccessXFeedbackMask;
+unsigned short XkbDfltAccessXOptions= XkbAX_AllOptionsMask & ~(XkbAX_IndicatorFBMask|XkbAX_SKReleaseFBMask|XkbAX_SKRejectFBMask);
+
+void
+AccessXComputeCurveFactor(XkbSrvInfoPtr xkbi,XkbControlsPtr ctrls)
+{
+ xkbi->mouseKeysCurve= 1.0+(((double)ctrls->mk_curve)*0.001);
+ xkbi->mouseKeysCurveFactor= ( ((double)ctrls->mk_max_speed)/
+ pow((double)ctrls->mk_time_to_max,xkbi->mouseKeysCurve));
+ return;
+}
+
+void
+AccessXInit(DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+
+ xkbi->shiftKeyCount= 0;
+ xkbi->mouseKeysCounter= 0;
+ xkbi->inactiveKey= 0;
+ xkbi->slowKey= 0;
+ xkbi->repeatKey= 0;
+ xkbi->krgTimerActive= _OFF_TIMER;
+ xkbi->beepType= _BEEP_NONE;
+ xkbi->beepCount= 0;
+ xkbi->mouseKeyTimer= NULL;
+ xkbi->slowKeysTimer= NULL;
+ xkbi->bounceKeysTimer= NULL;
+ xkbi->repeatKeyTimer= NULL;
+ xkbi->krgTimer= NULL;
+ xkbi->beepTimer= NULL;
+ ctrls->repeat_delay = XkbDfltRepeatDelay;
+ ctrls->repeat_interval = XkbDfltRepeatInterval;
+ ctrls->debounce_delay = 300;
+ ctrls->slow_keys_delay = 300;
+ ctrls->mk_delay = 160;
+ ctrls->mk_interval = 40;
+ ctrls->mk_time_to_max = 30;
+ ctrls->mk_max_speed = 30;
+ ctrls->mk_curve = 500;
+ ctrls->mk_dflt_btn = 1;
+ ctrls->ax_timeout = XkbDfltAccessXTimeout;
+ ctrls->axt_ctrls_mask = XkbDfltAccessXTimeoutMask;
+ ctrls->axt_ctrls_values = XkbDfltAccessXTimeoutValues;
+ ctrls->axt_opts_mask = XkbDfltAccessXTimeoutOptionsMask;
+ ctrls->axt_opts_values = XkbDfltAccessXTimeoutOptionsValues;
+ if (XkbDfltAccessXTimeout)
+ ctrls->enabled_ctrls |= XkbAccessXTimeoutMask;
+ else
+ ctrls->enabled_ctrls &= ~XkbAccessXTimeoutMask;
+ ctrls->enabled_ctrls |= XkbDfltAccessXFeedback;
+ ctrls->ax_options = XkbDfltAccessXOptions;
+ AccessXComputeCurveFactor(xkbi,ctrls);
+ return;
+}
+
+/************************************************************************/
+/* */
+/* AccessXKeyboardEvent */
+/* */
+/* Generate a synthetic keyboard event. */
+/* */
+/************************************************************************/
+static void
+AccessXKeyboardEvent(DeviceIntPtr keybd,
+ int type,
+ BYTE keyCode,
+ Bool isRepeat)
+{
+ DeviceEvent event;
+ memset(&event, 0, sizeof(DeviceEvent));
+ event.header = ET_Internal;
+ event.type = type;
+ event.detail.key = keyCode;
+ event.time = GetTimeInMillis();
+ event.length = sizeof(DeviceEvent);
+ event.key_repeat = isRepeat;
+ event.sourceid = keybd->id;
+ event.deviceid = keybd->id;
+
+ if (xkbDebugFlags&0x8) {
+ DebugF("[xkb] AXKE: Key %d %s\n", keyCode,
+ (event.type == ET_KeyPress ? "down" : "up"));
+ }
+
+ XkbProcessKeyboardEvent(&event, keybd);
+ return;
+} /* AccessXKeyboardEvent */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOn */
+/* */
+/* Turn the keyboard response group on. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOn(DeviceIntPtr dev,CARD16 KRGControl,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old= *ctrls;
+ ctrls->enabled_ctrls |= (KRGControl&XkbAX_KRGMask);
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask))
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,KRGControl);
+ return;
+
+} /* AccessXKRGTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXKRGTurnOff */
+/* */
+/* Turn the keyboard response group off. */
+/* */
+/************************************************************************/
+static void
+AccessXKRGTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbAX_KRGMask;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ unsigned changes= old.enabled_ctrls^ctrls->enabled_ctrls;
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,changes);
+ }
+ return;
+
+} /* AccessXKRGTurnOff */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOn */
+/* */
+/* Turn StickyKeys on. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOn(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls |= XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_ON,XkbStickyKeysMask);
+ }
+ return;
+
+} /* AccessXStickyKeysTurnOn */
+
+/************************************************************************/
+/* */
+/* AccessXStickyKeysTurnOff */
+/* */
+/* Turn StickyKeys off. */
+/* */
+/************************************************************************/
+static void
+AccessXStickyKeysTurnOff(DeviceIntPtr dev,xkbControlsNotify *pCN)
+{
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+XkbControlsRec old;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ old = *ctrls;
+ ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
+ xkbi->shiftKeyCount = 0;
+ if (XkbComputeControlsNotify(dev,&old,ctrls,pCN,FALSE))
+ XkbSendControlsNotify(dev,pCN);
+
+ cause.kc= pCN->keycode;
+ cause.event= pCN->eventType;
+ cause.mjr= pCN->requestMajor;
+ cause.mnr= pCN->requestMinor;
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_FeatureFBMask)) {
+ XkbDDXAccessXBeep(dev,_BEEP_FEATURE_OFF,XkbStickyKeysMask);
+ }
+#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
+ XkbClearAllLatchesAndLocks(dev,xkbi,FALSE,&cause);
+#endif
+ return;
+} /* AccessXStickyKeysTurnOff */
+
+static CARD32
+AccessXKRGExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+xkbControlsNotify cn;
+
+ if (xkbi->krgTimerActive==_KRG_WARN_TIMER) {
+ XkbDDXAccessXBeep((DeviceIntPtr)arg,_BEEP_SLOW_WARN,XkbStickyKeysMask);
+ xkbi->krgTimerActive= _KRG_TIMER;
+ return 4000;
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (xkbi->desc->ctrls->enabled_ctrls&XkbSlowKeysMask)
+ AccessXKRGTurnOff((DeviceIntPtr)arg,&cn);
+ else AccessXKRGTurnOn((DeviceIntPtr)arg,XkbSlowKeysMask,&cn);
+ return 0;
+}
+
+static CARD32
+AccessXRepeatKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev = (DeviceIntPtr) arg;
+XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
+
+ if (xkbi->repeatKey == 0)
+ return 0;
+
+ AccessXKeyboardEvent(dev, ET_KeyPress, xkbi->repeatKey, TRUE);
+
+ return xkbi->desc->ctrls->repeat_interval;
+}
+
+void
+AccessXCancelRepeatKey(XkbSrvInfoPtr xkbi,KeyCode key)
+{
+ if (xkbi->repeatKey==key)
+ xkbi->repeatKey= 0;
+ return;
+}
+
+static CARD32
+AccessXSlowKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr keybd;
+XkbSrvInfoPtr xkbi;
+XkbDescPtr xkb;
+XkbControlsPtr ctrls;
+
+ keybd= (DeviceIntPtr)arg;
+ xkbi= keybd->key->xkbInfo;
+ xkb= xkbi->desc;
+ ctrls= xkb->ctrls;
+ if (xkbi->slowKey!=0) {
+ xkbAccessXNotify ev;
+ KeySym *sym= XkbKeySymsPtr(xkb,xkbi->slowKey);
+ ev.detail= XkbAXN_SKAccept;
+ ev.keycode= xkbi->slowKey;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKAcceptFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_ACCEPT,XkbSlowKeysMask);
+ AccessXKeyboardEvent(keybd, ET_KeyPress,xkbi->slowKey,FALSE);
+ /* check for magic sequences */
+ if ((ctrls->enabled_ctrls&XkbAccessXKeysMask) &&
+ ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)))
+ xkbi->shiftKeyCount++;
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (keybd->kbdfeed->ctrl.autoRepeat &&
+ ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
+ (ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) {
+ xkbi->repeatKey = xkbi->slowKey;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+ return 0;
+}
+
+static CARD32
+AccessXBounceKeyExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+XkbSrvInfoPtr xkbi= ((DeviceIntPtr)arg)->key->xkbInfo;
+
+ xkbi->inactiveKey= 0;
+ return 0;
+}
+
+static CARD32
+AccessXTimeoutExpire(OsTimerPtr timer,CARD32 now,pointer arg)
+{
+DeviceIntPtr dev = (DeviceIntPtr)arg;
+XkbSrvInfoPtr xkbi= dev->key->xkbInfo;
+XkbControlsPtr ctrls= xkbi->desc->ctrls;
+XkbControlsRec old;
+xkbControlsNotify cn;
+XkbEventCauseRec cause;
+XkbSrvLedInfoPtr sli;
+
+ if (xkbi->lastPtrEventTime) {
+ unsigned timeToWait = (ctrls->ax_timeout*1000);
+ unsigned timeElapsed = (now-xkbi->lastPtrEventTime);
+
+ if (timeToWait > timeElapsed)
+ return timeToWait - timeElapsed;
+ }
+ old= *ctrls;
+ xkbi->shiftKeyCount= 0;
+ ctrls->enabled_ctrls&= ~ctrls->axt_ctrls_mask;
+ ctrls->enabled_ctrls|=
+ (ctrls->axt_ctrls_values&ctrls->axt_ctrls_mask);
+ if (ctrls->axt_opts_mask) {
+ ctrls->ax_options&= ~ctrls->axt_opts_mask;
+ ctrls->ax_options|= (ctrls->axt_opts_values&ctrls->axt_opts_mask);
+ }
+ if (XkbComputeControlsNotify(dev,&old,ctrls,&cn,FALSE)) {
+ cn.keycode = 0;
+ cn.eventType = 0;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ XkbSendControlsNotify(dev,&cn);
+ }
+ XkbSetCauseUnknown(&cause);
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ XkbUpdateIndicators(dev,sli->usesControls,TRUE,NULL,&cause);
+ if (ctrls->ax_options!=old.ax_options) {
+ unsigned set,cleared,bell;
+ set= ctrls->ax_options&(~old.ax_options);
+ cleared= (~ctrls->ax_options)&old.ax_options;
+ if (set && cleared) bell= _BEEP_FEATURE_CHANGE;
+ else if (set) bell= _BEEP_FEATURE_ON;
+ else bell= _BEEP_FEATURE_OFF;
+ XkbDDXAccessXBeep(dev,bell,XkbAccessXTimeoutMask);
+ }
+ xkbi->krgTimerActive= _OFF_TIMER;
+ return 0;
+}
+
+
+/************************************************************************/
+/* */
+/* AccessXFilterPressEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterPressEvent( DeviceEvent* event,
+ DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+Bool ignoreKeyEvent = FALSE;
+KeyCode key = event->detail.key;
+KeySym * sym = XkbKeySymsPtr(xkbi->desc,key);
+
+ if (ctrls->enabled_ctrls&XkbAccessXKeysMask) {
+ /* check for magic sequences */
+ if ((sym[0]==XK_Shift_R)||(sym[0]==XK_Shift_L)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SlowWarnFBMask)) {
+ xkbi->krgTimerActive = _KRG_WARN_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 4000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ else {
+ xkbi->krgTimerActive = _KRG_TIMER;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 8000,
+ AccessXKRGExpire, (pointer)keybd);
+ }
+ if (!(ctrls->enabled_ctrls & XkbSlowKeysMask)) {
+ CARD32 now= GetTimeInMillis();
+ if ((now-xkbi->lastShiftEventTime)>15000)
+ xkbi->shiftKeyCount= 1;
+ else xkbi->shiftKeyCount++;
+ xkbi->lastShiftEventTime= now;
+ }
+ }
+ else {
+ if (xkbi->krgTimerActive) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer,0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+ }
+ }
+
+ /* Don't transmit the KeyPress if SlowKeys is turned on;
+ * The wakeup handler will synthesize one for us if the user
+ * has held the key long enough.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ /* If key was already pressed, ignore subsequent press events
+ * from the server's autorepeat
+ */
+ if(xkbi->slowKey == key)
+ return TRUE;
+ ev.detail= XkbAXN_SKPress;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKPressFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_SLOW_PRESS,XkbSlowKeysMask);
+ xkbi->slowKey= key;
+ xkbi->slowKeysTimer = TimerSet(xkbi->slowKeysTimer,
+ 0, ctrls->slow_keys_delay,
+ AccessXSlowKeyExpire, (pointer)keybd);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Don't transmit the KeyPress if BounceKeys is turned on
+ * and the user pressed the same key within a given time period
+ * from the last release.
+ */
+ else if ((ctrls->enabled_ctrls & XkbBounceKeysMask) &&
+ (key == xkbi->inactiveKey)) {
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_BKRejectFBMask))
+ XkbDDXAccessXBeep(keybd,_BEEP_BOUNCE_REJECT,XkbBounceKeysMask);
+ ignoreKeyEvent = TRUE;
+ }
+
+ /* Start repeating if necessary. Stop autorepeating if the user
+ * presses a non-modifier key that doesn't autorepeat.
+ */
+ if (XkbDDXUsesSoftRepeat(keybd)) {
+ if ((keybd->kbdfeed->ctrl.autoRepeat) &&
+ ((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
+ XkbRepeatKeysMask)) {
+ if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) {
+ if (xkbDebugFlags&0x10)
+ DebugF("Starting software autorepeat...\n");
+ if (xkbi->repeatKey == key)
+ ignoreKeyEvent = TRUE;
+ else {
+ xkbi->repeatKey = key;
+ xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
+ 0, ctrls->repeat_delay,
+ AccessXRepeatKeyExpire, (pointer)keybd);
+ }
+ }
+ }
+ }
+
+ /* Check for two keys being pressed at the same time. This section
+ * essentially says the following:
+ *
+ * If StickyKeys is on, and a modifier is currently being held down,
+ * and one of the following is true: the current key is not a modifier
+ * or the currentKey is a modifier, but not the only modifier being
+ * held down, turn StickyKeys off if the TwoKeys off ctrl is set.
+ */
+ if ((ctrls->enabled_ctrls & XkbStickyKeysMask) &&
+ (xkbi->state.base_mods!=0) &&
+ (XkbAX_NeedOption(ctrls,XkbAX_TwoKeysMask))) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(event, keybd);
+ return ignoreKeyEvent;
+} /* AccessXFilterPressEvent */
+
+/************************************************************************/
+/* */
+/* AccessXFilterReleaseEvent */
+/* */
+/* Filter events before they get any further if SlowKeys is turned on. */
+/* In addition, this routine handles the ever so popular magic key */
+/* acts for turning various accessibility features on/off. */
+/* */
+/* Returns TRUE if this routine has discarded the event. */
+/* Returns FALSE if the event needs further processing. */
+/* */
+/************************************************************************/
+Bool
+AccessXFilterReleaseEvent( DeviceEvent* event,
+ DeviceIntPtr keybd)
+{
+XkbSrvInfoPtr xkbi = keybd->key->xkbInfo;
+XkbControlsPtr ctrls = xkbi->desc->ctrls;
+KeyCode key = event->detail.key;
+Bool ignoreKeyEvent = FALSE;
+
+ /* Don't transmit the KeyRelease if BounceKeys is on and
+ * this is the release of a key that was ignored due to
+ * BounceKeys.
+ */
+ if (ctrls->enabled_ctrls & XkbBounceKeysMask) {
+ if ((key!=xkbi->mouseKey)&&(!BitIsOn(keybd->key->down,key)))
+ ignoreKeyEvent = TRUE;
+ xkbi->inactiveKey= key;
+ xkbi->bounceKeysTimer= TimerSet(xkbi->bounceKeysTimer, 0,
+ ctrls->debounce_delay,
+ AccessXBounceKeyExpire, (pointer)keybd);
+ }
+
+ /* Don't transmit the KeyRelease if SlowKeys is turned on and
+ * the user didn't hold the key long enough. We know we passed
+ * the key if the down bit was set by CoreProcessKeyboadEvent.
+ */
+ if (ctrls->enabled_ctrls & XkbSlowKeysMask) {
+ xkbAccessXNotify ev;
+ unsigned beep_type;
+ ev.keycode= key;
+ ev.slowKeysDelay= ctrls->slow_keys_delay;
+ ev.debounceDelay= ctrls->debounce_delay;
+ if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) {
+ ev.detail= XkbAXN_SKRelease;
+ beep_type= _BEEP_SLOW_RELEASE;
+ }
+ else {
+ ev.detail= XkbAXN_SKReject;
+ beep_type= _BEEP_SLOW_REJECT;
+ ignoreKeyEvent = TRUE;
+ }
+ XkbSendAccessXNotify(keybd,&ev);
+ if (XkbAX_NeedFeedback(ctrls,XkbAX_SKRejectFBMask)) {
+ XkbDDXAccessXBeep(keybd,beep_type,XkbSlowKeysMask);
+ }
+ if (xkbi->slowKey==key)
+ xkbi->slowKey= 0;
+ }
+
+ /* Stop Repeating if the user releases the key that is currently
+ * repeating.
+ */
+ if (xkbi->repeatKey==key) {
+ xkbi->repeatKey= 0;
+ }
+
+ if ((ctrls->enabled_ctrls&XkbAccessXTimeoutMask)&&(ctrls->ax_timeout>0)) {
+ xkbi->lastPtrEventTime= 0;
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0,
+ ctrls->ax_timeout*1000,
+ AccessXTimeoutExpire, (pointer)keybd);
+ xkbi->krgTimerActive= _ALL_TIMEOUT_TIMER;
+ }
+ else if (xkbi->krgTimerActive!=_OFF_TIMER) {
+ xkbi->krgTimer= TimerSet(xkbi->krgTimer, 0, 0, NULL, NULL);
+ xkbi->krgTimerActive= _OFF_TIMER;
+ }
+
+ /* Keep track of how many times the Shift key has been pressed.
+ * If it has been pressed and released 5 times in a row, toggle
+ * the state of StickyKeys.
+ */
+ if ((!ignoreKeyEvent)&&(xkbi->shiftKeyCount)) {
+ KeySym *pSym= XkbKeySymsPtr(xkbi->desc,key);
+ if ((pSym[0]!=XK_Shift_L)&&(pSym[0]!=XK_Shift_R)) {
+ xkbi->shiftKeyCount= 0;
+ }
+ else if (xkbi->shiftKeyCount>=5) {
+ xkbControlsNotify cn;
+ cn.keycode = key;
+ cn.eventType = KeyPress;
+ cn.requestMajor = 0;
+ cn.requestMinor = 0;
+ if (ctrls->enabled_ctrls & XkbStickyKeysMask)
+ AccessXStickyKeysTurnOff(keybd,&cn);
+ else
+ AccessXStickyKeysTurnOn(keybd,&cn);
+ xkbi->shiftKeyCount= 0;
+ }
+ }
+
+ if (!ignoreKeyEvent)
+ XkbProcessKeyboardEvent(event, keybd);
+ return ignoreKeyEvent;
+
+} /* AccessXFilterReleaseEvent */
+
+/************************************************************************/
+/* */
+/* ProcessPointerEvent */
+/* */
+/* This routine merely sets the shiftKeyCount and clears the keyboard */
+/* response group timer (if necessary) on a mouse event. This is so */
+/* multiple shifts with just the mouse and shift-drags with the mouse */
+/* don't accidentally turn on StickyKeys or the Keyboard Response Group.*/
+/* */
+/************************************************************************/
+extern int xkbDevicePrivateIndex;
+extern void xkbUnwrapProc(DeviceIntPtr, DeviceHandleProc, pointer);
+void
+ProcessPointerEvent( InternalEvent *ev,
+ DeviceIntPtr mouse)
+{
+DeviceIntPtr dev;
+XkbSrvInfoPtr xkbi = NULL;
+unsigned changed = 0;
+ProcessInputProc backupproc;
+xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(mouse);
+DeviceEvent *event = &ev->device_event;
+
+ dev = (IsMaster(mouse) || mouse->u.master) ? GetMaster(mouse, MASTER_KEYBOARD) : mouse;
+
+ if (dev && dev->key)
+ {
+ xkbi = dev->key->xkbInfo;
+ xkbi->shiftKeyCount = 0;
+ xkbi->lastPtrEventTime= event->time;
+ }
+
+ if (event->type == ET_ButtonPress) {
+ changed |= XkbPointerButtonMask;
+ }
+ else if (event->type == ET_ButtonRelease) {
+ if (xkbi)
+ xkbi->lockedPtrButtons&= ~(1 << (event->detail.key & 0x7));
+ changed |= XkbPointerButtonMask;
+ }
+
+ /* Guesswork. mostly.
+ * xkb actuall goes through some effort to transparently wrap the
+ * processInputProcs (see XkbSetExtension). But we all love fun, so the
+ * previous XKB implementation just hardcoded the CPPE call here instead
+ * of unwrapping like anybody with any sense of decency would do.
+ * I got no clue what the correct thing to do is, but my guess is that
+ * it's not hardcoding. I may be wrong. whatever it is, don't come whining
+ * to me. I just work here.
+ *
+ * Anyway. here's the old call, if you don't like the wrapping, revert it.
+ *
+ * CoreProcessPointerEvent(xE,mouse,count);
+ *
+ * see. it's still steaming. told you. (whot)
+ */
+
+ UNWRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr, backupproc);
+ mouse->public.processInputProc(ev, mouse);
+ COND_WRAP_PROCESS_INPUT_PROC(mouse, xkbPrivPtr,
+ backupproc, xkbUnwrapProc);
+
+ if (!xkbi)
+ return;
+
+ xkbi->state.ptr_buttons = (mouse->button) ? mouse->button->state : 0;
+
+ /* clear any latched modifiers */
+ if ( xkbi->state.latched_mods && (event->type == ET_ButtonRelease) ) {
+ unsigned changed_leds;
+ XkbStateRec oldState;
+ XkbSrvLedInfoPtr sli;
+
+ sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
+ oldState= xkbi->state;
+ XkbLatchModifiers(dev,0xFF,0x00);
+
+ XkbComputeDerivedState(xkbi);
+ changed |= XkbStateChangedFlags(&oldState,&xkbi->state);
+ if (changed&sli->usedComponents) {
+ changed_leds= XkbIndicatorsToUpdate(dev,changed,FALSE);
+ if (changed_leds) {
+ XkbEventCauseRec cause;
+ XkbSetCauseKey(&cause,(event->detail.key & 0x7), event->type);
+ XkbUpdateIndicators(dev,changed_leds,TRUE,NULL,&cause);
+ }
+ }
+ }
+
+ if (((xkbi->flags&_XkbStateNotifyInProgress)==0)&&(changed!=0)) {
+ xkbStateNotify sn;
+ sn.keycode= event->detail.key;
+ sn.eventType= event->type;
+ sn.requestMajor = sn.requestMinor = 0;
+ sn.changed= changed;
+ XkbSendStateNotify(dev,&sn);
+ }
+
+} /* ProcessPointerEvent */
+
+
+
+
diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c
index 03f23a777..44675c9fe 100644
--- a/xorg-server/xkb/xkbActions.c
+++ b/xorg-server/xkb/xkbActions.c
@@ -43,8 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "mi.h"
#define EXTENSION_EVENT_BASE 64
-static int xkbDevicePrivateKeyIndex;
-DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKeyIndex;
+DevPrivateKeyRec xkbDevicePrivateKeyRec;
static void XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button);
static void XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y);
@@ -64,6 +63,11 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
backupproc,xkbUnwrapProc);
}
+Bool
+XkbInitPrivates(void)
+{
+ return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, 0);
+}
void
XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
@@ -1033,7 +1037,7 @@ register int i;
xkbi->filters= realloc(xkbi->filters,
xkbi->szFilters * sizeof(XkbFilterRec));
/* 6/21/93 (ef) -- XXX! deal with allocation failure */
- bzero(&xkbi->filters[xkbi->szFilters/2],
+ memset(&xkbi->filters[xkbi->szFilters/2], 0,
(xkbi->szFilters/2)*sizeof(XkbFilterRec));
return &xkbi->filters[xkbi->szFilters/2];
}
diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c
index 3da625a5b..eb3e04d64 100644
--- a/xorg-server/xkb/xkbInit.c
+++ b/xorg-server/xkb/xkbInit.c
@@ -43,6 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "inputstr.h"
#include "opaque.h"
#include "property.h"
+#include "scrnintstr.h"
#define XKBSRV_NEED_FILE_FUNCS
#include <xkbsrv.h>
#include "xkbgeom.h"
@@ -210,7 +211,7 @@ char * pval;
ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
out,len);
}
- dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8,
+ dixChangeWindowProperty(serverClient, screenInfo.screens[0]->root, name, XA_STRING, 8,
PropModeReplace, len, pval, TRUE);
free(pval);
return TRUE;
@@ -219,20 +220,15 @@ char * pval;
static void
XkbSetRulesUsed(XkbRMLVOSet *rmlvo)
{
- if (XkbRulesUsed)
- free(XkbRulesUsed);
+ free(XkbRulesUsed);
XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL);
- if (XkbModelUsed)
- free(XkbModelUsed);
+ free(XkbModelUsed);
XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL);
- if (XkbLayoutUsed)
- free(XkbLayoutUsed);
+ free(XkbLayoutUsed);
XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL);
- if (XkbVariantUsed)
- free(XkbVariantUsed);
+ free(XkbVariantUsed);
XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL);
- if (XkbOptionsUsed)
- free(XkbOptionsUsed);
+ free(XkbOptionsUsed);
XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL);
if (XkbWantRulesProp)
QueueWorkProc(XkbWriteRulesProp,NULL,NULL);
@@ -243,28 +239,23 @@ void
XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
{
if (rmlvo->rules) {
- if (XkbRulesDflt)
- free(XkbRulesDflt);
+ free(XkbRulesDflt);
XkbRulesDflt= _XkbDupString(rmlvo->rules);
}
if (rmlvo->model) {
- if (XkbModelDflt)
- free(XkbModelDflt);
+ free(XkbModelDflt);
XkbModelDflt= _XkbDupString(rmlvo->model);
}
if (rmlvo->layout) {
- if (XkbLayoutDflt)
- free(XkbLayoutDflt);
+ free(XkbLayoutDflt);
XkbLayoutDflt= _XkbDupString(rmlvo->layout);
}
if (rmlvo->variant) {
- if (XkbVariantDflt)
- free(XkbVariantDflt);
+ free(XkbVariantDflt);
XkbVariantDflt= _XkbDupString(rmlvo->variant);
}
if (rmlvo->options) {
- if (XkbOptionsDflt)
- free(XkbOptionsDflt);
+ free(XkbOptionsDflt);
XkbOptionsDflt= _XkbDupString(rmlvo->options);
}
return;
diff --git a/xorg-server/xkb/xkbLEDs.c b/xorg-server/xkb/xkbLEDs.c
index a0a037fd7..65d8739be 100644
--- a/xorg-server/xkb/xkbLEDs.c
+++ b/xorg-server/xkb/xkbLEDs.c
@@ -166,7 +166,7 @@ XkbStatePtr state;
}
}
}
- return (stateChange || ctrlChange);
+ return stateChange || ctrlChange;
}
/*
@@ -263,7 +263,7 @@ unsigned oldState;
if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -273,7 +273,7 @@ unsigned oldState;
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->indicators.state_changes|= affected;
}
@@ -362,8 +362,8 @@ XkbChangesRec changes;
xkbExtensionDeviceNotify ed;
unsigned side_affected;
- bzero((char *)&changes,sizeof(XkbChangesRec));
- bzero((char *)&ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)&changes, 0, sizeof(XkbChangesRec));
+ memset((char *)&ed, 0, sizeof(xkbExtensionDeviceNotify));
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0);
sli->explicitState&= ~affect;
sli->explicitState|= (affect&values);
@@ -605,8 +605,8 @@ void
XkbFreeSrvLedInfo(XkbSrvLedInfoPtr sli)
{
if ((sli->flags&XkbSLI_IsDefault)==0) {
- if (sli->maps) free(sli->maps);
- if (sli->names) free(sli->names);
+ free(sli->maps);
+ free(sli->names);
}
sli->maps= NULL;
sli->names= NULL;
@@ -735,7 +735,7 @@ XkbFlushLedEvents( DeviceIntPtr dev,
if (changes->indicators.state_changes)
XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
XkbSendNotification(kbd,changes,cause);
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
if (XkbAX_NeedFeedback(kbd->key->xkbInfo->desc->ctrls, XkbAX_IndicatorFBMask)) {
if (sli->effectiveState)
@@ -751,7 +751,7 @@ XkbFlushLedEvents( DeviceIntPtr dev,
XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState);
XkbSendExtensionDeviceNotify(dev,cause->client,ed);
}
- bzero((char *)ed,sizeof(XkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(XkbExtensionDeviceNotify));
}
return;
}
@@ -778,7 +778,7 @@ xkbExtensionDeviceNotify my_ed;
if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -788,7 +788,7 @@ xkbExtensionDeviceNotify my_ed;
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->names.changed|= XkbIndicatorNamesMask;
changes->names.changed_indicators|= changed_names;
@@ -855,7 +855,7 @@ xkbExtensionDeviceNotify my_ed;
if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if ((ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
@@ -865,7 +865,7 @@ xkbExtensionDeviceNotify my_ed;
if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) {
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
changes->indicators.map_changes|= changed_maps;
}
@@ -917,7 +917,7 @@ Bool kb_changed;
if (changes==NULL) {
changes= &my_changes;
- bzero((char *)changes,sizeof(XkbChangesRec));
+ memset((char *)changes, 0, sizeof(XkbChangesRec));
}
kb_changed= FALSE;
@@ -943,7 +943,7 @@ Bool kb_changed;
if (ed==NULL) {
ed= &my_ed;
- bzero((char *)ed,sizeof(xkbExtensionDeviceNotify));
+ memset((char *)ed, 0, sizeof(xkbExtensionDeviceNotify));
}
else if (affected&&(ed->reason&XkbXI_IndicatorsMask)&&
((ed->ledClass!=sli->class)||(ed->ledID!=sli->id))) {
diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c
index ab433a800..6b6e6d379 100644
--- a/xorg-server/xkb/xkbUtils.c
+++ b/xorg-server/xkb/xkbUtils.c
@@ -282,7 +282,7 @@ register unsigned key;
register unsigned bit,i;
unsigned present;
- bzero(newVMods,XkbNumVirtualMods);
+ memset(newVMods, 0, XkbNumVirtualMods);
present= 0;
for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
if (xkb->server->vmodmap[key]==0)
@@ -588,7 +588,7 @@ XkbSrvInfoPtr xkbi = dev->key->xkbInfo;
xkbMapNotify mn;
xkbi->desc->server->explicit[key]|= XkbExplicitAutoRepeatMask;
- bzero(&mn,sizeof(mn));
+ memset(&mn, 0, sizeof(mn));
mn.changed= XkbExplicitComponentsMask;
mn.firstKeyExplicit= key;
mn.nKeyExplicit= 1;
@@ -919,11 +919,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (src->map->syms) {
if (src->map->size_syms != dst->map->size_syms) {
- if (dst->map->syms)
- tmp = realloc(dst->map->syms,
- src->map->size_syms * sizeof(KeySym));
- else
- tmp = malloc(src->map->size_syms * sizeof(KeySym));
+ tmp = realloc(dst->map->syms,
+ src->map->size_syms * sizeof(KeySym));
if (!tmp)
return FALSE;
dst->map->syms = tmp;
@@ -933,23 +930,16 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
src->map->size_syms * sizeof(KeySym));
}
else {
- if (dst->map->syms) {
- free(dst->map->syms);
- dst->map->syms = NULL;
- }
+ free(dst->map->syms);
+ dst->map->syms = NULL;
}
dst->map->num_syms = src->map->num_syms;
dst->map->size_syms = src->map->size_syms;
if (src->map->key_sym_map) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->map->key_sym_map)
- tmp = realloc(dst->map->key_sym_map,
- (src->max_key_code + 1) *
- sizeof(XkbSymMapRec));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbSymMapRec));
+ tmp = realloc(dst->map->key_sym_map,
+ (src->max_key_code + 1) * sizeof(XkbSymMapRec));
if (!tmp)
return FALSE;
dst->map->key_sym_map = tmp;
@@ -958,10 +948,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
(src->max_key_code + 1) * sizeof(XkbSymMapRec));
}
else {
- if (dst->map->key_sym_map) {
- free(dst->map->key_sym_map);
- dst->map->key_sym_map = NULL;
- }
+ free(dst->map->key_sym_map);
+ dst->map->key_sym_map = NULL;
}
if (src->map->types && src->map->num_types) {
@@ -973,7 +961,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (!tmp)
return FALSE;
dst->map->types = tmp;
- bzero(dst->map->types + dst->map->num_types,
+ memset(dst->map->types + dst->map->num_types, 0,
(src->map->num_types - dst->map->num_types) *
sizeof(XkbKeyTypeRec));
}
@@ -988,15 +976,12 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
dst->map->types) {
for (i = src->map->num_types, dtype = (dst->map->types + i);
i < dst->map->num_types; i++, dtype++) {
- if (dtype->level_names)
- free(dtype->level_names);
+ free(dtype->level_names);
dtype->level_names = NULL;
dtype->num_levels = 0;
if (dtype->map_count) {
- if (dtype->map)
- free(dtype->map);
- if (dtype->preserve)
- free(dtype->preserve);
+ free(dtype->map);
+ free(dtype->preserve);
}
}
}
@@ -1099,10 +1084,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
}
else {
if (dtype->map_count && i < dst->map->num_types) {
- if (dtype->map)
- free(dtype->map);
- if (dtype->preserve)
- free(dtype->preserve);
+ free(dtype->map);
+ free(dtype->preserve);
}
dtype->map_count = 0;
dtype->map = NULL;
@@ -1117,26 +1100,22 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (dst->map->types) {
for (i = 0, dtype = dst->map->types; i < dst->map->num_types;
i++, dtype++) {
- if (dtype->level_names)
- free(dtype->level_names);
+ free(dtype->level_names);
if (dtype->map && dtype->map_count)
free(dtype->map);
if (dtype->preserve && dtype->map_count)
free(dtype->preserve);
}
- free(dst->map->types);
- dst->map->types = NULL;
}
+ free(dst->map->types);
+ dst->map->types = NULL;
dst->map->num_types = 0;
dst->map->size_types = 0;
}
if (src->map->modmap) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->map->modmap)
- tmp = realloc(dst->map->modmap, src->max_key_code + 1);
- else
- tmp = malloc(src->max_key_code + 1);
+ tmp = realloc(dst->map->modmap, src->max_key_code + 1);
if (!tmp)
return FALSE;
dst->map->modmap = tmp;
@@ -1144,10 +1123,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1);
}
else {
- if (dst->map->modmap) {
- free(dst->map->modmap);
- dst->map->modmap = NULL;
- }
+ free(dst->map->modmap);
+ dst->map->modmap = NULL;
}
}
else {
@@ -1174,10 +1151,7 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
if (src->server->explicit) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->explicit)
- tmp = realloc(dst->server->explicit, src->max_key_code + 1);
- else
- tmp = malloc(src->max_key_code + 1);
+ tmp = realloc(dst->server->explicit, src->max_key_code + 1);
if (!tmp)
return FALSE;
dst->server->explicit = tmp;
@@ -1186,19 +1160,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
src->max_key_code + 1);
}
else {
- if (dst->server->explicit) {
- free(dst->server->explicit);
- dst->server->explicit = NULL;
- }
+ free(dst->server->explicit);
+ dst->server->explicit = NULL;
}
if (src->server->acts) {
if (src->server->size_acts != dst->server->size_acts) {
- if (dst->server->acts)
- tmp = realloc(dst->server->acts,
- src->server->size_acts * sizeof(XkbAction));
- else
- tmp = malloc(src->server->size_acts * sizeof(XkbAction));
+ tmp = realloc(dst->server->acts,
+ src->server->size_acts * sizeof(XkbAction));
if (!tmp)
return FALSE;
dst->server->acts = tmp;
@@ -1207,23 +1176,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
src->server->size_acts * sizeof(XkbAction));
}
else {
- if (dst->server->acts) {
- free(dst->server->acts);
- dst->server->acts = NULL;
- }
+ free(dst->server->acts);
+ dst->server->acts = NULL;
}
dst->server->size_acts = src->server->size_acts;
dst->server->num_acts = src->server->num_acts;
if (src->server->key_acts) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->key_acts)
- tmp = realloc(dst->server->key_acts,
- (src->max_key_code + 1) *
- sizeof(unsigned short));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(unsigned short));
+ tmp = realloc(dst->server->key_acts,
+ (src->max_key_code + 1) * sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->key_acts = tmp;
@@ -1232,21 +1194,14 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
(src->max_key_code + 1) * sizeof(unsigned short));
}
else {
- if (dst->server->key_acts) {
- free(dst->server->key_acts);
- dst->server->key_acts = NULL;
- }
+ free(dst->server->key_acts);
+ dst->server->key_acts = NULL;
}
if (src->server->behaviors) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->behaviors)
- tmp = realloc(dst->server->behaviors,
- (src->max_key_code + 1) *
- sizeof(XkbBehavior));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbBehavior));
+ tmp = realloc(dst->server->behaviors,
+ (src->max_key_code + 1) * sizeof(XkbBehavior));
if (!tmp)
return FALSE;
dst->server->behaviors = tmp;
@@ -1255,23 +1210,16 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
(src->max_key_code + 1) * sizeof(XkbBehavior));
}
else {
- if (dst->server->behaviors) {
- free(dst->server->behaviors);
- dst->server->behaviors = NULL;
- }
+ free(dst->server->behaviors);
+ dst->server->behaviors = NULL;
}
memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods);
if (src->server->vmodmap) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->server->vmodmap)
- tmp = realloc(dst->server->vmodmap,
- (src->max_key_code + 1) *
- sizeof(unsigned short));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(unsigned short));
+ tmp = realloc(dst->server->vmodmap,
+ (src->max_key_code + 1) * sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->vmodmap = tmp;
@@ -1280,10 +1228,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
(src->max_key_code + 1) * sizeof(unsigned short));
}
else {
- if (dst->server->vmodmap) {
- free(dst->server->vmodmap);
- dst->server->vmodmap = NULL;
- }
+ free(dst->server->vmodmap);
+ dst->server->vmodmap = NULL;
}
}
else {
@@ -1309,12 +1255,8 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
if (src->names->keys) {
if (src->max_key_code != dst->max_key_code) {
- if (dst->names->keys)
- tmp = realloc(dst->names->keys, (src->max_key_code + 1) *
- sizeof(XkbKeyNameRec));
- else
- tmp = malloc((src->max_key_code + 1) *
- sizeof(XkbKeyNameRec));
+ tmp = realloc(dst->names->keys,
+ (src->max_key_code + 1) * sizeof(XkbKeyNameRec));
if (!tmp)
return FALSE;
dst->names->keys = tmp;
@@ -1323,21 +1265,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
(src->max_key_code + 1) * sizeof(XkbKeyNameRec));
}
else {
- if (dst->names->keys) {
- free(dst->names->keys);
- dst->names->keys = NULL;
- }
+ free(dst->names->keys);
+ dst->names->keys = NULL;
}
if (src->names->num_key_aliases) {
if (src->names->num_key_aliases != dst->names->num_key_aliases) {
- if (dst->names->key_aliases)
- tmp = realloc(dst->names->key_aliases,
- src->names->num_key_aliases *
- sizeof(XkbKeyAliasRec));
- else
- tmp = malloc(src->names->num_key_aliases *
- sizeof(XkbKeyAliasRec));
+ tmp = realloc(dst->names->key_aliases,
+ src->names->num_key_aliases *
+ sizeof(XkbKeyAliasRec));
if (!tmp)
return FALSE;
dst->names->key_aliases = tmp;
@@ -1346,20 +1282,15 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
src->names->num_key_aliases * sizeof(XkbKeyAliasRec));
}
else {
- if (dst->names->key_aliases) {
- free(dst->names->key_aliases);
- dst->names->key_aliases = NULL;
- }
+ free(dst->names->key_aliases);
+ dst->names->key_aliases = NULL;
}
dst->names->num_key_aliases = src->names->num_key_aliases;
if (src->names->num_rg) {
if (src->names->num_rg != dst->names->num_rg) {
- if (dst->names->radio_groups)
- tmp = realloc(dst->names->radio_groups,
- src->names->num_rg * sizeof(Atom));
- else
- tmp = malloc(src->names->num_rg * sizeof(Atom));
+ tmp = realloc(dst->names->radio_groups,
+ src->names->num_rg * sizeof(Atom));
if (!tmp)
return FALSE;
dst->names->radio_groups = tmp;
@@ -1368,8 +1299,7 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
src->names->num_rg * sizeof(Atom));
}
else {
- if (dst->names->radio_groups)
- free(dst->names->radio_groups);
+ free(dst->names->radio_groups);
}
dst->names->num_rg = src->names->num_rg;
@@ -1410,13 +1340,8 @@ _XkbCopyCompat(XkbDescPtr src, XkbDescPtr dst)
if (src->compat->sym_interpret && src->compat->num_si) {
if (src->compat->num_si != dst->compat->size_si) {
- if (dst->compat->sym_interpret)
- tmp = realloc(dst->compat->sym_interpret,
- src->compat->num_si *
- sizeof(XkbSymInterpretRec));
- else
- tmp = malloc(src->compat->num_si *
- sizeof(XkbSymInterpretRec));
+ tmp = realloc(dst->compat->sym_interpret,
+ src->compat->num_si * sizeof(XkbSymInterpretRec));
if (!tmp)
return FALSE;
dst->compat->sym_interpret = tmp;
@@ -1501,7 +1426,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
dst->geom->sz_properties = src->geom->num_properties;
if (dst->geom->sz_properties > dst->geom->num_properties) {
- bzero(dst->geom->properties + dst->geom->num_properties,
+ memset(dst->geom->properties + dst->geom->num_properties, 0,
(dst->geom->sz_properties - dst->geom->num_properties) *
sizeof(XkbPropertyRec));
}
@@ -1579,7 +1504,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
dst->geom->sz_colors = src->geom->num_colors;
if (dst->geom->sz_colors > dst->geom->num_colors) {
- bzero(dst->geom->colors + dst->geom->num_colors,
+ memset(dst->geom->colors + dst->geom->num_colors, 0,
(dst->geom->sz_colors - dst->geom->num_colors) *
sizeof(XkbColorRec));
}
@@ -1750,25 +1675,18 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
j < dsection->num_doodads;
j++, ddoodad++) {
if (ddoodad->any.type == XkbTextDoodad) {
- if (ddoodad->text.text) {
- free(ddoodad->text.text);
- ddoodad->text.text = NULL;
- }
- if (ddoodad->text.font) {
- free(ddoodad->text.font);
- ddoodad->text.font = NULL;
- }
+ free(ddoodad->text.text);
+ ddoodad->text.text = NULL;
+ free(ddoodad->text.font);
+ ddoodad->text.font = NULL;
}
else if (ddoodad->any.type == XkbLogoDoodad) {
- if (ddoodad->logo.logo_name) {
- free(ddoodad->logo.logo_name);
- ddoodad->logo.logo_name = NULL;
- }
+ free(ddoodad->logo.logo_name);
+ ddoodad->logo.logo_name = NULL;
}
}
- if (dsection->num_doodads)
- free(dsection->doodads);
+ free(dsection->doodads);
}
dst->geom->num_sections = 0;
@@ -1877,20 +1795,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
i < dst->geom->num_doodads;
i++, ddoodad++) {
if (ddoodad->any.type == XkbTextDoodad) {
- if (ddoodad->text.text) {
- free(ddoodad->text.text);
- ddoodad->text.text = NULL;
- }
- if (ddoodad->text.font) {
- free(ddoodad->text.font);
- ddoodad->text.font = NULL;
- }
+ free(ddoodad->text.text);
+ ddoodad->text.text = NULL;
+ free(ddoodad->text.font);
+ ddoodad->text.font = NULL;
}
else if (ddoodad->any.type == XkbLogoDoodad) {
- if (ddoodad->logo.logo_name) {
- free(ddoodad->logo.logo_name);
- ddoodad->logo.logo_name = NULL;
- }
+ free(ddoodad->logo.logo_name);
+ ddoodad->logo.logo_name = NULL;
}
}
dst->geom->num_doodads = 0;
@@ -1966,9 +1878,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
dst->geom->num_key_aliases = dst->geom->sz_key_aliases;
}
else {
- if (dst->geom->key_aliases) {
- free(dst->geom->key_aliases);
- }
+ free(dst->geom->key_aliases);
dst->geom->key_aliases = NULL;
dst->geom->num_key_aliases = 0;
dst->geom->sz_key_aliases = 0;
@@ -1998,9 +1908,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
dst->geom->base_color = &(dst->geom->colors[i]);
}
else {
- if (dst->geom->label_font) {
- free(dst->geom->label_font);
- }
+ free(dst->geom->label_font);
dst->geom->label_font = NULL;
dst->geom->label_color = NULL;
dst->geom->base_color = NULL;
@@ -2035,10 +1943,8 @@ _XkbCopyIndicators(XkbDescPtr src, XkbDescPtr dst)
memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec));
}
else {
- if (dst->indicators) {
- free(dst->indicators);
- dst->indicators = NULL;
- }
+ free(dst->indicators);
+ dst->indicators = NULL;
}
return TRUE;
}
@@ -2056,10 +1962,8 @@ _XkbCopyControls(XkbDescPtr src, XkbDescPtr dst)
memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec));
}
else {
- if (dst->ctrls) {
- free(dst->ctrls);
- dst->ctrls = NULL;
- }
+ free(dst->ctrls);
+ dst->ctrls = NULL;
}
return TRUE;
}
diff --git a/xorg-server/xkb/xkbfmisc.c b/xorg-server/xkb/xkbfmisc.c
index 103e609a9..382b6ebba 100644
--- a/xorg-server/xkb/xkbfmisc.c
+++ b/xorg-server/xkb/xkbfmisc.c
@@ -1,441 +1,441 @@
-/************************************************************
- Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
- ********************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-#include <X11/Xos.h>
-#include <X11/Xfuncs.h>
-#include <X11/extensions/XKMformat.h>
-
-#include <X11/X.h>
-#include <X11/keysym.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "inputstr.h"
-#include "dix.h"
-#include "xkbstr.h"
-#define XKBSRV_NEED_FILE_FUNCS 1
-#include <xkbsrv.h>
-#include "xkbgeom.h"
-#include "xkb.h"
-
-unsigned
-_XkbKSCheckCase(KeySym ks)
-{
-unsigned set,rtrn;
-
- set= (ks & (~0xff)) >> 8;
- rtrn= 0;
- switch (set) {
- case 0: /* latin 1 */
- if (((ks>=XK_A)&&(ks<=XK_Z))||
- ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
- rtrn|= _XkbKSUpper;
- }
- if (((ks>=XK_a)&&(ks<=XK_z))||
- ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
- rtrn|= _XkbKSLower;
- }
- break;
- case 1: /* latin 2 */
- if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
- ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
- rtrn|= _XkbKSUpper;
- }
- if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
- ((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
- rtrn|= _XkbKSLower;
- }
- break;
- case 2: /* latin 3 */
- if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
- ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
- rtrn|= _XkbKSUpper;
- }
- if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
- ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
- rtrn|= _XkbKSLower;
- }
- break;
- case 3: /* latin 4 */
- if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
- (ks==XK_ENG)||
- ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
- rtrn|= _XkbKSUpper;
- }
- if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
- (ks==XK_eng)||
- ((ks>=XK_amacron)&&(ks<=XK_umacron))) {
- rtrn|= _XkbKSLower;
- }
- break;
- case 18: /* latin 8 */
- if ((ks==XK_Babovedot)||
- ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
- ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
- (ks==XK_Mabovedot)||
- (ks==XK_Pabovedot)||
- (ks==XK_Sabovedot)||
- (ks==XK_Wdiaeresis)||
- ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
- rtrn|= _XkbKSUpper;
- }
- if ((ks==XK_babovedot)||
- (ks==XK_dabovedot)||
- (ks==XK_fabovedot)||
- (ks==XK_mabovedot)||
- ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
- (ks==XK_ygrave)||
- ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
- rtrn|= _XkbKSLower;
- }
- break;
- case 19: /* latin 9 */
- if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
- rtrn|= _XkbKSUpper;
- }
- if (ks==XK_oe) {
- rtrn|= _XkbKSLower;
- }
- break;
- }
- return rtrn;
-}
-
-/***===================================================================***/
-
-static Bool
-XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
-{
- fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
- return TRUE;
-}
-
-#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
-#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
-
-/* ARGSUSED */
-static void
-_AddIncl( FILE * file,
- XkbDescPtr xkb,
- Bool topLevel,
- Bool showImplicit,
- int index,
- void * priv)
-{
- if ((priv)&&(strcmp((char *)priv,"%")!=0))
- fprintf(file," include \"%s\"\n",(char *)priv);
- return;
-}
-
-Bool
-XkbWriteXKBKeymapForNames( FILE * file,
- XkbComponentNamesPtr names,
- XkbDescPtr xkb,
- unsigned want,
- unsigned need)
-{
-const char * tmp;
-unsigned complete;
-XkbNamesPtr old_names;
-int multi_section;
-unsigned wantNames,wantConfig,wantDflts;
-
- complete= 0;
- if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
- if (COMPLETE(names->types)) complete|= XkmTypesMask;
- if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
- if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
- if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
- want|= (complete|need);
- if (want&XkmSymbolsMask)
- want|= XkmKeyNamesMask|XkmTypesMask;
-
- if (want==0)
- return FALSE;
-
- if (xkb) {
- old_names = xkb->names;
-
- xkb->defined = 0;
- /* Wow would it ever be neat if we didn't need this noise. */
- if (xkb->names && xkb->names->keys)
- xkb->defined |= XkmKeyNamesMask;
- if (xkb->map && xkb->map->types)
- xkb->defined |= XkmTypesMask;
- if (xkb->compat)
- xkb->defined |= XkmCompatMapMask;
- if (xkb->map && xkb->map->num_syms)
- xkb->defined |= XkmSymbolsMask;
- if (xkb->indicators)
- xkb->defined |= XkmIndicatorsMask;
- if (xkb->geom)
- xkb->defined |= XkmGeometryMask;
- }
- else {
- old_names= NULL;
- }
-
- wantConfig= want&(~complete);
- if (xkb!=NULL) {
- if (wantConfig&XkmTypesMask) {
- if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
- wantConfig&= ~XkmTypesMask;
- }
- if (wantConfig&XkmCompatMapMask) {
- if ((!xkb->compat) || (xkb->compat->num_si<1))
- wantConfig&= ~XkmCompatMapMask;
- }
- if (wantConfig&XkmSymbolsMask) {
- if ((!xkb->map) || (!xkb->map->key_sym_map))
- wantConfig&= ~XkmSymbolsMask;
- }
- if (wantConfig&XkmIndicatorsMask) {
- if (!xkb->indicators)
- wantConfig&= ~XkmIndicatorsMask;
- }
- if (wantConfig&XkmKeyNamesMask) {
- if ((!xkb->names)||(!xkb->names->keys))
- wantConfig&= ~XkmKeyNamesMask;
- }
- if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
- wantConfig&= ~XkmGeometryMask;
- }
- else {
- wantConfig= 0;
- }
- complete|= wantConfig;
-
- wantDflts= 0;
- wantNames= want&(~complete);
- if ((xkb!=NULL) && (old_names!=NULL)) {
- if (wantNames&XkmTypesMask) {
- if (old_names->types!=None) {
- tmp= NameForAtom(old_names->types);
- names->types= _XkbDupString(tmp);
- }
- else {
- wantDflts|= XkmTypesMask;
- }
- complete|= XkmTypesMask;
- }
- if (wantNames&XkmCompatMapMask) {
- if (old_names->compat!=None) {
- tmp= NameForAtom(old_names->compat);
- names->compat= _XkbDupString(tmp);
- }
- else wantDflts|= XkmCompatMapMask;
- complete|= XkmCompatMapMask;
- }
- if (wantNames&XkmSymbolsMask) {
- if (old_names->symbols==None)
- return FALSE;
- tmp= NameForAtom(old_names->symbols);
- names->symbols= _XkbDupString(tmp);
- complete|= XkmSymbolsMask;
- }
- if (wantNames&XkmKeyNamesMask) {
- if (old_names->keycodes!=None) {
- tmp= NameForAtom(old_names->keycodes);
- names->keycodes= _XkbDupString(tmp);
- }
- else wantDflts|= XkmKeyNamesMask;
- complete|= XkmKeyNamesMask;
- }
- if (wantNames&XkmGeometryMask) {
- if (old_names->geometry==None)
- return FALSE;
- tmp= NameForAtom(old_names->geometry);
- names->geometry= _XkbDupString(tmp);
- complete|= XkmGeometryMask;
- wantNames&= ~XkmGeometryMask;
- }
- }
- if (complete&XkmCompatMapMask)
- complete|= XkmIndicatorsMask|XkmVirtualModsMask;
- else if (complete&(XkmSymbolsMask|XkmTypesMask))
- complete|= XkmVirtualModsMask;
- if (need & (~complete))
- return FALSE;
- if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
- return FALSE;
-
- multi_section= 1;
- if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
- ((complete&(~XkmKeymapLegal))==0)) {
- fprintf(file,"xkb_keymap \"default\" {\n");
- }
- else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
- ((complete&(~XkmSemanticsLegal))==0)) {
- fprintf(file,"xkb_semantics \"default\" {\n");
- }
- else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
- ((complete&(~XkmLayoutLegal))==0)) {
- fprintf(file,"xkb_layout \"default\" {\n");
- }
- else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
- multi_section= 0;
- }
- else {
- return FALSE;
- }
-
- wantNames= complete&(~(wantConfig|wantDflts));
- if (wantConfig&XkmKeyNamesMask)
- XkbWriteXKBKeycodes(file,xkb,FALSE,FALSE,_AddIncl,names->keycodes);
- else if (wantDflts&XkmKeyNamesMask)
- fprintf(stderr,"Default symbols not implemented yet!\n");
- else if (wantNames&XkmKeyNamesMask)
- XkbWriteSectionFromName(file,"keycodes",names->keycodes);
-
- if (wantConfig&XkmTypesMask)
- XkbWriteXKBKeyTypes(file,xkb,FALSE,FALSE,_AddIncl,names->types);
- else if (wantDflts&XkmTypesMask)
- fprintf(stderr,"Default types not implemented yet!\n");
- else if (wantNames&XkmTypesMask)
- XkbWriteSectionFromName(file,"types",names->types);
-
- if (wantConfig&XkmCompatMapMask)
- XkbWriteXKBCompatMap(file,xkb,FALSE,FALSE,_AddIncl,names->compat);
- else if (wantDflts&XkmCompatMapMask)
- fprintf(stderr,"Default interps not implemented yet!\n");
- else if (wantNames&XkmCompatMapMask)
- XkbWriteSectionFromName(file,"compatibility",names->compat);
-
- if (wantConfig&XkmSymbolsMask)
- XkbWriteXKBSymbols(file,xkb,FALSE,FALSE,_AddIncl,names->symbols);
- else if (wantNames&XkmSymbolsMask)
- XkbWriteSectionFromName(file,"symbols",names->symbols);
-
- if (wantConfig&XkmGeometryMask)
- XkbWriteXKBGeometry(file,xkb,FALSE,FALSE,_AddIncl,names->geometry);
- else if (wantNames&XkmGeometryMask)
- XkbWriteSectionFromName(file,"geometry",names->geometry);
-
- if (multi_section)
- fprintf(file,"};\n");
- return TRUE;
-}
-
-/***====================================================================***/
-
-int
-XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
-{
-register int i;
-
- if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
- return 0;
- for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
- if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
- return i;
- }
- if (!use_aliases)
- return 0;
- if (xkb->geom && xkb->geom->key_aliases) {
- XkbKeyAliasPtr a;
- a= xkb->geom->key_aliases;
- for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
- if (strncmp(name,a->alias,XkbKeyNameLength)==0)
- return XkbFindKeycodeByName(xkb,a->real,FALSE);
- }
- }
- if (xkb->names && xkb->names->key_aliases) {
- XkbKeyAliasPtr a;
- a= xkb->names->key_aliases;
- for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
- if (strncmp(name,a->alias,XkbKeyNameLength)==0)
- return XkbFindKeycodeByName(xkb,a->real,FALSE);
- }
- }
- return 0;
-}
-
-
-unsigned
-XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
-{
-unsigned rtrn;
-
- rtrn= 0;
- if (toXkm) {
- if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
- if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
- if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
- if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
- if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
- if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
- }
- else {
- if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
- if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
- if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
- if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
- if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
- if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
- if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
- }
- return rtrn;
-}
-
-/***====================================================================***/
-
-#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
-
-Bool
-XkbNameMatchesPattern(char *name,char *ptrn)
-{
- while (ptrn[0]!='\0') {
- if (name[0]=='\0') {
- if (ptrn[0]=='*') {
- ptrn++;
- continue;
- }
- return FALSE;
- }
- if (ptrn[0]=='?') {
- if (UNMATCHABLE(name[0]))
- return FALSE;
- }
- else if (ptrn[0]=='*') {
- if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
- return TRUE;
- return XkbNameMatchesPattern(name,ptrn+1);
- }
- else if (ptrn[0]!=name[0])
- return FALSE;
- name++;
- ptrn++;
- }
- /* if we get here, the pattern is exhausted (-:just like me:-) */
- return (name[0]=='\0');
-}
+/************************************************************
+ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+
+ Permission to use, copy, modify, and distribute this
+ software and its documentation for any purpose and without
+ fee is hereby granted, provided that the above copyright
+ notice appear in all copies and that both that copyright
+ notice and this permission notice appear in supporting
+ documentation, and that the name of Silicon Graphics not be
+ used in advertising or publicity pertaining to distribution
+ of the software without specific prior written permission.
+ Silicon Graphics makes no representation about the suitability
+ of this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+
+ SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ ********************************************************/
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
+#include <X11/extensions/XKMformat.h>
+
+#include <X11/X.h>
+#include <X11/keysym.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "inputstr.h"
+#include "dix.h"
+#include "xkbstr.h"
+#define XKBSRV_NEED_FILE_FUNCS 1
+#include <xkbsrv.h>
+#include "xkbgeom.h"
+#include "xkb.h"
+
+unsigned
+_XkbKSCheckCase(KeySym ks)
+{
+unsigned set,rtrn;
+
+ set= (ks & (~0xff)) >> 8;
+ rtrn= 0;
+ switch (set) {
+ case 0: /* latin 1 */
+ if (((ks>=XK_A)&&(ks<=XK_Z))||
+ ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_a)&&(ks<=XK_z))||
+ ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 1: /* latin 2 */
+ if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))||
+ ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))||
+ ((ks>=XK_racute)&&(ks<=XK_tcedilla))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 2: /* latin 3 */
+ if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))||
+ ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))||
+ ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 3: /* latin 4 */
+ if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))||
+ (ks==XK_ENG)||
+ ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))||
+ (ks==XK_eng)||
+ ((ks>=XK_amacron)&&(ks<=XK_umacron))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 18: /* latin 8 */
+ if ((ks==XK_Babovedot)||
+ ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))||
+ ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))||
+ (ks==XK_Mabovedot)||
+ (ks==XK_Pabovedot)||
+ (ks==XK_Sabovedot)||
+ (ks==XK_Wdiaeresis)||
+ ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) {
+ rtrn|= _XkbKSUpper;
+ }
+ if ((ks==XK_babovedot)||
+ (ks==XK_dabovedot)||
+ (ks==XK_fabovedot)||
+ (ks==XK_mabovedot)||
+ ((ks>=XK_wgrave)&&(ks<=XK_wacute))||
+ (ks==XK_ygrave)||
+ ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ case 19: /* latin 9 */
+ if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) {
+ rtrn|= _XkbKSUpper;
+ }
+ if (ks==XK_oe) {
+ rtrn|= _XkbKSLower;
+ }
+ break;
+ }
+ return rtrn;
+}
+
+/***===================================================================***/
+
+static Bool
+XkbWriteSectionFromName(FILE *file,char *sectionName,char *name)
+{
+ fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name);
+ return TRUE;
+}
+
+#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%')))
+#define COMPLETE(n) ((n)&&(!NEED_DESC(n)))
+
+/* ARGSUSED */
+static void
+_AddIncl( FILE * file,
+ XkbDescPtr xkb,
+ Bool topLevel,
+ Bool showImplicit,
+ int index,
+ void * priv)
+{
+ if ((priv)&&(strcmp((char *)priv,"%")!=0))
+ fprintf(file," include \"%s\"\n",(char *)priv);
+ return;
+}
+
+Bool
+XkbWriteXKBKeymapForNames( FILE * file,
+ XkbComponentNamesPtr names,
+ XkbDescPtr xkb,
+ unsigned want,
+ unsigned need)
+{
+const char * tmp;
+unsigned complete;
+XkbNamesPtr old_names;
+int multi_section;
+unsigned wantNames,wantConfig,wantDflts;
+
+ complete= 0;
+ if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask;
+ if (COMPLETE(names->types)) complete|= XkmTypesMask;
+ if (COMPLETE(names->compat)) complete|= XkmCompatMapMask;
+ if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask;
+ if (COMPLETE(names->geometry)) complete|= XkmGeometryMask;
+ want|= (complete|need);
+ if (want&XkmSymbolsMask)
+ want|= XkmKeyNamesMask|XkmTypesMask;
+
+ if (want==0)
+ return FALSE;
+
+ if (xkb) {
+ old_names = xkb->names;
+
+ xkb->defined = 0;
+ /* Wow would it ever be neat if we didn't need this noise. */
+ if (xkb->names && xkb->names->keys)
+ xkb->defined |= XkmKeyNamesMask;
+ if (xkb->map && xkb->map->types)
+ xkb->defined |= XkmTypesMask;
+ if (xkb->compat)
+ xkb->defined |= XkmCompatMapMask;
+ if (xkb->map && xkb->map->num_syms)
+ xkb->defined |= XkmSymbolsMask;
+ if (xkb->indicators)
+ xkb->defined |= XkmIndicatorsMask;
+ if (xkb->geom)
+ xkb->defined |= XkmGeometryMask;
+ }
+ else {
+ old_names= NULL;
+ }
+
+ wantConfig= want&(~complete);
+ if (xkb!=NULL) {
+ if (wantConfig&XkmTypesMask) {
+ if ((!xkb->map) || (xkb->map->num_types<XkbNumRequiredTypes))
+ wantConfig&= ~XkmTypesMask;
+ }
+ if (wantConfig&XkmCompatMapMask) {
+ if ((!xkb->compat) || (xkb->compat->num_si<1))
+ wantConfig&= ~XkmCompatMapMask;
+ }
+ if (wantConfig&XkmSymbolsMask) {
+ if ((!xkb->map) || (!xkb->map->key_sym_map))
+ wantConfig&= ~XkmSymbolsMask;
+ }
+ if (wantConfig&XkmIndicatorsMask) {
+ if (!xkb->indicators)
+ wantConfig&= ~XkmIndicatorsMask;
+ }
+ if (wantConfig&XkmKeyNamesMask) {
+ if ((!xkb->names)||(!xkb->names->keys))
+ wantConfig&= ~XkmKeyNamesMask;
+ }
+ if ((wantConfig&XkmGeometryMask)&&(!xkb->geom))
+ wantConfig&= ~XkmGeometryMask;
+ }
+ else {
+ wantConfig= 0;
+ }
+ complete|= wantConfig;
+
+ wantDflts= 0;
+ wantNames= want&(~complete);
+ if ((xkb!=NULL) && (old_names!=NULL)) {
+ if (wantNames&XkmTypesMask) {
+ if (old_names->types!=None) {
+ tmp= NameForAtom(old_names->types);
+ names->types= _XkbDupString(tmp);
+ }
+ else {
+ wantDflts|= XkmTypesMask;
+ }
+ complete|= XkmTypesMask;
+ }
+ if (wantNames&XkmCompatMapMask) {
+ if (old_names->compat!=None) {
+ tmp= NameForAtom(old_names->compat);
+ names->compat= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmCompatMapMask;
+ complete|= XkmCompatMapMask;
+ }
+ if (wantNames&XkmSymbolsMask) {
+ if (old_names->symbols==None)
+ return FALSE;
+ tmp= NameForAtom(old_names->symbols);
+ names->symbols= _XkbDupString(tmp);
+ complete|= XkmSymbolsMask;
+ }
+ if (wantNames&XkmKeyNamesMask) {
+ if (old_names->keycodes!=None) {
+ tmp= NameForAtom(old_names->keycodes);
+ names->keycodes= _XkbDupString(tmp);
+ }
+ else wantDflts|= XkmKeyNamesMask;
+ complete|= XkmKeyNamesMask;
+ }
+ if (wantNames&XkmGeometryMask) {
+ if (old_names->geometry==None)
+ return FALSE;
+ tmp= NameForAtom(old_names->geometry);
+ names->geometry= _XkbDupString(tmp);
+ complete|= XkmGeometryMask;
+ wantNames&= ~XkmGeometryMask;
+ }
+ }
+ if (complete&XkmCompatMapMask)
+ complete|= XkmIndicatorsMask|XkmVirtualModsMask;
+ else if (complete&(XkmSymbolsMask|XkmTypesMask))
+ complete|= XkmVirtualModsMask;
+ if (need & (~complete))
+ return FALSE;
+ if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete)))
+ return FALSE;
+
+ multi_section= 1;
+ if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&&
+ ((complete&(~XkmKeymapLegal))==0)) {
+ fprintf(file,"xkb_keymap \"default\" {\n");
+ }
+ else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&&
+ ((complete&(~XkmSemanticsLegal))==0)) {
+ fprintf(file,"xkb_semantics \"default\" {\n");
+ }
+ else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&&
+ ((complete&(~XkmLayoutLegal))==0)) {
+ fprintf(file,"xkb_layout \"default\" {\n");
+ }
+ else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) {
+ multi_section= 0;
+ }
+ else {
+ return FALSE;
+ }
+
+ wantNames= complete&(~(wantConfig|wantDflts));
+ if (wantConfig&XkmKeyNamesMask)
+ XkbWriteXKBKeycodes(file,xkb,FALSE,FALSE,_AddIncl,names->keycodes);
+ else if (wantDflts&XkmKeyNamesMask)
+ fprintf(stderr,"Default symbols not implemented yet!\n");
+ else if (wantNames&XkmKeyNamesMask)
+ XkbWriteSectionFromName(file,"keycodes",names->keycodes);
+
+ if (wantConfig&XkmTypesMask)
+ XkbWriteXKBKeyTypes(file,xkb,FALSE,FALSE,_AddIncl,names->types);
+ else if (wantDflts&XkmTypesMask)
+ fprintf(stderr,"Default types not implemented yet!\n");
+ else if (wantNames&XkmTypesMask)
+ XkbWriteSectionFromName(file,"types",names->types);
+
+ if (wantConfig&XkmCompatMapMask)
+ XkbWriteXKBCompatMap(file,xkb,FALSE,FALSE,_AddIncl,names->compat);
+ else if (wantDflts&XkmCompatMapMask)
+ fprintf(stderr,"Default interps not implemented yet!\n");
+ else if (wantNames&XkmCompatMapMask)
+ XkbWriteSectionFromName(file,"compatibility",names->compat);
+
+ if (wantConfig&XkmSymbolsMask)
+ XkbWriteXKBSymbols(file,xkb,FALSE,FALSE,_AddIncl,names->symbols);
+ else if (wantNames&XkmSymbolsMask)
+ XkbWriteSectionFromName(file,"symbols",names->symbols);
+
+ if (wantConfig&XkmGeometryMask)
+ XkbWriteXKBGeometry(file,xkb,FALSE,FALSE,_AddIncl,names->geometry);
+ else if (wantNames&XkmGeometryMask)
+ XkbWriteSectionFromName(file,"geometry",names->geometry);
+
+ if (multi_section)
+ fprintf(file,"};\n");
+ return TRUE;
+}
+
+/***====================================================================***/
+
+int
+XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases)
+{
+register int i;
+
+ if ((!xkb)||(!xkb->names)||(!xkb->names->keys))
+ return 0;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0)
+ return i;
+ }
+ if (!use_aliases)
+ return 0;
+ if (xkb->geom && xkb->geom->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->geom->key_aliases;
+ for (i=0;i<xkb->geom->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,FALSE);
+ }
+ }
+ if (xkb->names && xkb->names->key_aliases) {
+ XkbKeyAliasPtr a;
+ a= xkb->names->key_aliases;
+ for (i=0;i<xkb->names->num_key_aliases;i++,a++) {
+ if (strncmp(name,a->alias,XkbKeyNameLength)==0)
+ return XkbFindKeycodeByName(xkb,a->real,FALSE);
+ }
+ }
+ return 0;
+}
+
+
+unsigned
+XkbConvertGetByNameComponents(Bool toXkm,unsigned orig)
+{
+unsigned rtrn;
+
+ rtrn= 0;
+ if (toXkm) {
+ if (orig&XkbGBN_TypesMask) rtrn|= XkmTypesMask;
+ if (orig&XkbGBN_CompatMapMask) rtrn|= XkmCompatMapMask;
+ if (orig&XkbGBN_SymbolsMask) rtrn|= XkmSymbolsMask;
+ if (orig&XkbGBN_IndicatorMapMask) rtrn|= XkmIndicatorsMask;
+ if (orig&XkbGBN_KeyNamesMask) rtrn|= XkmKeyNamesMask;
+ if (orig&XkbGBN_GeometryMask) rtrn|= XkmGeometryMask;
+ }
+ else {
+ if (orig&XkmTypesMask) rtrn|= XkbGBN_TypesMask;
+ if (orig&XkmCompatMapMask) rtrn|= XkbGBN_CompatMapMask;
+ if (orig&XkmSymbolsMask) rtrn|= XkbGBN_SymbolsMask;
+ if (orig&XkmIndicatorsMask) rtrn|= XkbGBN_IndicatorMapMask;
+ if (orig&XkmKeyNamesMask) rtrn|= XkbGBN_KeyNamesMask;
+ if (orig&XkmGeometryMask) rtrn|= XkbGBN_GeometryMask;
+ if (orig!=0) rtrn|= XkbGBN_OtherNamesMask;
+ }
+ return rtrn;
+}
+
+/***====================================================================***/
+
+#define UNMATCHABLE(c) (((c)=='(')||((c)==')')||((c)=='/'))
+
+Bool
+XkbNameMatchesPattern(char *name,char *ptrn)
+{
+ while (ptrn[0]!='\0') {
+ if (name[0]=='\0') {
+ if (ptrn[0]=='*') {
+ ptrn++;
+ continue;
+ }
+ return FALSE;
+ }
+ if (ptrn[0]=='?') {
+ if (UNMATCHABLE(name[0]))
+ return FALSE;
+ }
+ else if (ptrn[0]=='*') {
+ if ((!UNMATCHABLE(name[0]))&&XkbNameMatchesPattern(name+1,ptrn))
+ return TRUE;
+ return XkbNameMatchesPattern(name,ptrn+1);
+ }
+ else if (ptrn[0]!=name[0])
+ return FALSE;
+ name++;
+ ptrn++;
+ }
+ /* if we get here, the pattern is exhausted (-:just like me:-) */
+ return name[0]=='\0';
+}
diff --git a/xorg-server/xkb/xkmread.c b/xorg-server/xkb/xkmread.c
index 660884a7f..4b2043667 100644
--- a/xorg-server/xkb/xkmread.c
+++ b/xorg-server/xkb/xkmread.c
@@ -80,7 +80,7 @@ int newCount= *newCountRtrn;
oldPtr= realloc(oldPtr,newCount*elemSize);
if (oldPtr!=NULL) {
char *tmp= (char *)oldPtr;
- bzero(&tmp[oldCount*elemSize],(newCount-oldCount)*elemSize);
+ memset(&tmp[oldCount*elemSize], 0, (newCount-oldCount)*elemSize);
}
}
else if (newCount<oldCount) {
@@ -725,8 +725,8 @@ int nRead=0;
return -1;
}
nRead+= tmp*SIZEOF(xkmKeySymMapDesc);
- bzero((char *)typeName,XkbNumKbdGroups*sizeof(Atom));
- bzero((char *)type,XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
+ memset((char *)typeName, 0, XkbNumKbdGroups*sizeof(Atom));
+ memset((char *)type, 0, XkbNumKbdGroups*sizeof(XkbKeyTypePtr));
if (wireMap.flags&XkmKeyHasTypes) {
register int g;
for (g=0;g<XkbNumKbdGroups;g++) {