Remove MERGE_ALT_FORM merge mode
The mode comes from the "alternate" keyword, which is unused in xkeyboard-config and mostly undocumented. Its purpose is to allow to assign the same key name to multiple key codes, which is not allowed otherwise (and doesn't make much sense). The xkblib specification implies that this was part of the overlay functionality, which we also no longer support. If we do encounter this keyword, we just treat it as MERGE_DEFAULT. The keycodes.c code will detect a collision and will ignore all but the first key code (and the error count is not incremented). Some peripheral code is also removed as a result. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
dd85790c73
commit
0765064b35
|
@ -323,15 +323,10 @@ write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
|
||||||
keymap->max_key_code);
|
keymap->max_key_code);
|
||||||
|
|
||||||
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
|
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
|
||||||
const char *alternate = "";
|
|
||||||
|
|
||||||
if (darray_item(keymap->names->keys, key).name[0] == '\0')
|
if (darray_item(keymap->names->keys, key).name[0] == '\0')
|
||||||
continue;
|
continue;
|
||||||
if (XkbcFindKeycodeByName(keymap,
|
|
||||||
darray_item(keymap->names->keys, key).name,
|
write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
|
||||||
true) != key)
|
|
||||||
alternate = "alternate ";
|
|
||||||
write_buf(keymap, buf, size, offset, "\t\t%s%6s = %d;\n", alternate,
|
|
||||||
XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
|
XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
|
||||||
key);
|
key);
|
||||||
}
|
}
|
||||||
|
@ -780,10 +775,6 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
|
||||||
|
|
||||||
if (xkb_key_num_groups(keymap, key) == 0)
|
if (xkb_key_num_groups(keymap, key) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (XkbcFindKeycodeByName(keymap,
|
|
||||||
darray_item(keymap->names->keys, key).name,
|
|
||||||
true) != key)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
|
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
|
||||||
XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
|
XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
|
||||||
|
|
24
src/misc.c
24
src/misc.c
|
@ -122,27 +122,3 @@ _XkbcKSCheckCase(xkb_keysym_t ks)
|
||||||
|
|
||||||
return rtrn;
|
return rtrn;
|
||||||
}
|
}
|
||||||
|
|
||||||
xkb_keycode_t
|
|
||||||
XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name,
|
|
||||||
bool use_aliases)
|
|
||||||
{
|
|
||||||
struct xkb_key_alias *alias;
|
|
||||||
xkb_keycode_t i;
|
|
||||||
|
|
||||||
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
|
|
||||||
if (strncmp(darray_item(keymap->names->keys, i).name, name,
|
|
||||||
XkbKeyNameLength) == 0)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!use_aliases)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
darray_foreach(alias, keymap->names->key_aliases)
|
|
||||||
if (strncmp(name, alias->alias, XkbKeyNameLength) == 0)
|
|
||||||
return XkbcFindKeycodeByName(keymap, alias->real, false);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
|
@ -459,10 +459,6 @@ xkb_context_take_file_id(struct xkb_context *ctx);
|
||||||
extern unsigned
|
extern unsigned
|
||||||
_XkbcKSCheckCase(xkb_keysym_t sym);
|
_XkbcKSCheckCase(xkb_keysym_t sym);
|
||||||
|
|
||||||
extern xkb_keycode_t
|
|
||||||
XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name,
|
|
||||||
bool use_aliases);
|
|
||||||
|
|
||||||
#define _XkbKSLower (1 << 0)
|
#define _XkbKSLower (1 << 0)
|
||||||
#define _XkbKSUpper (1 << 1)
|
#define _XkbKSUpper (1 << 1)
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ typedef struct _KeyNamesInfo
|
||||||
xkb_keycode_t explicitMax;
|
xkb_keycode_t explicitMax;
|
||||||
darray(unsigned long) names;
|
darray(unsigned long) names;
|
||||||
darray(unsigned int) files;
|
darray(unsigned int) files;
|
||||||
darray(unsigned char) has_alt_forms;
|
|
||||||
IndicatorNameInfo *leds;
|
IndicatorNameInfo *leds;
|
||||||
AliasInfo *aliases;
|
AliasInfo *aliases;
|
||||||
} KeyNamesInfo;
|
} KeyNamesInfo;
|
||||||
|
@ -87,7 +86,6 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
|
||||||
|
|
||||||
darray_resize0(info->names, newMax + 1);
|
darray_resize0(info->names, newMax + 1);
|
||||||
darray_resize0(info->files, newMax + 1);
|
darray_resize0(info->files, newMax + 1);
|
||||||
darray_resize0(info->has_alt_forms, newMax + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -281,7 +279,6 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||||
info->computedMin = XKB_KEYCODE_MAX;
|
info->computedMin = XKB_KEYCODE_MAX;
|
||||||
darray_free(info->names);
|
darray_free(info->names);
|
||||||
darray_free(info->files);
|
darray_free(info->files);
|
||||||
darray_free(info->has_alt_forms);
|
|
||||||
if (info->leds)
|
if (info->leds)
|
||||||
ClearIndicatorNameInfo(info->leds, info);
|
ClearIndicatorNameInfo(info->leds, info);
|
||||||
if (info->aliases)
|
if (info->aliases)
|
||||||
|
@ -296,7 +293,6 @@ InitKeyNamesInfo(KeyNamesInfo * info)
|
||||||
info->aliases = NULL;
|
info->aliases = NULL;
|
||||||
darray_init(info->names);
|
darray_init(info->names);
|
||||||
darray_init(info->files);
|
darray_init(info->files);
|
||||||
darray_init(info->has_alt_forms);
|
|
||||||
ClearKeyNamesInfo(info);
|
ClearKeyNamesInfo(info);
|
||||||
info->errorCount = 0;
|
info->errorCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -347,16 +343,11 @@ AddKeyName(KeyNamesInfo * info,
|
||||||
|
|
||||||
LongToKeyName(darray_item(info->names, kc), buf);
|
LongToKeyName(darray_item(info->names, kc), buf);
|
||||||
buf[4] = '\0';
|
buf[4] = '\0';
|
||||||
if (darray_item(info->names, kc) == lval)
|
if (darray_item(info->names, kc) == lval && reportCollisions)
|
||||||
{
|
{
|
||||||
if (darray_item(info->has_alt_forms, kc) || (merge == MERGE_ALT_FORM)) {
|
|
||||||
darray_item(info->has_alt_forms, kc) = true;
|
|
||||||
}
|
|
||||||
else if (reportCollisions) {
|
|
||||||
WARN("Multiple identical key name definitions\n");
|
WARN("Multiple identical key name definitions\n");
|
||||||
ACTION("Later occurences of \"<%s> = %d\" ignored\n",
|
ACTION("Later occurences of \"<%s> = %d\" ignored\n",
|
||||||
buf, kc);
|
buf, kc);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (merge == MERGE_AUGMENT)
|
if (merge == MERGE_AUGMENT)
|
||||||
|
@ -386,32 +377,24 @@ AddKeyName(KeyNamesInfo * info,
|
||||||
{
|
{
|
||||||
darray_item(info->names, old) = 0;
|
darray_item(info->names, old) = 0;
|
||||||
darray_item(info->files, old) = 0;
|
darray_item(info->files, old) = 0;
|
||||||
darray_item(info->has_alt_forms, old) = true;
|
|
||||||
if (reportCollisions)
|
if (reportCollisions)
|
||||||
{
|
{
|
||||||
WARN("Key name <%s> assigned to multiple keys\n", name);
|
WARN("Key name <%s> assigned to multiple keys\n", name);
|
||||||
ACTION("Using %d, ignoring %d\n", kc, old);
|
ACTION("Using %d, ignoring %d\n", kc, old);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (merge != MERGE_ALT_FORM)
|
else
|
||||||
{
|
{
|
||||||
if ((reportCollisions) && (warningLevel > 3))
|
if ((reportCollisions) && (warningLevel > 3))
|
||||||
{
|
{
|
||||||
WARN("Key name <%s> assigned to multiple keys\n", name);
|
WARN("Key name <%s> assigned to multiple keys\n", name);
|
||||||
ACTION("Using %d, ignoring %d\n", old, kc);
|
ACTION("Using %d, ignoring %d\n", old, kc);
|
||||||
ACTION
|
|
||||||
("Use 'alternate' keyword to assign the same name to multiple keys\n");
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
darray_item(info->has_alt_forms, old) = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
darray_item(info->names, kc) = lval;
|
darray_item(info->names, kc) = lval;
|
||||||
darray_item(info->files, kc) = fileID;
|
darray_item(info->files, kc) = fileID;
|
||||||
darray_item(info->has_alt_forms, kc) = (merge == MERGE_ALT_FORM);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,16 +422,11 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
|
||||||
|
|
||||||
for (i = from->computedMin; i <= from->computedMax; i++)
|
for (i = from->computedMin; i <= from->computedMax; i++)
|
||||||
{
|
{
|
||||||
unsigned thisMerge;
|
|
||||||
if (darray_item(from->names, i) == 0)
|
if (darray_item(from->names, i) == 0)
|
||||||
continue;
|
continue;
|
||||||
LongToKeyName(darray_item(from->names, i), buf);
|
LongToKeyName(darray_item(from->names, i), buf);
|
||||||
buf[4] = '\0';
|
buf[4] = '\0';
|
||||||
if (darray_item(from->has_alt_forms, i))
|
if (!AddKeyName(into, i, buf, merge, from->fileID, false))
|
||||||
thisMerge = MERGE_ALT_FORM;
|
|
||||||
else
|
|
||||||
thisMerge = merge;
|
|
||||||
if (!AddKeyName(into, i, buf, thisMerge, from->fileID, false))
|
|
||||||
into->errorCount++;
|
into->errorCount++;
|
||||||
}
|
}
|
||||||
if (from->leds)
|
if (from->leds)
|
||||||
|
|
|
@ -264,57 +264,57 @@ DeclList : DeclList Decl
|
||||||
|
|
||||||
Decl : OptMergeMode VarDecl
|
Decl : OptMergeMode VarDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode VModDecl
|
| OptMergeMode VModDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode InterpretDecl
|
| OptMergeMode InterpretDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode KeyNameDecl
|
| OptMergeMode KeyNameDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode KeyAliasDecl
|
| OptMergeMode KeyAliasDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode KeyTypeDecl
|
| OptMergeMode KeyTypeDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode SymbolsDecl
|
| OptMergeMode SymbolsDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode ModMapDecl
|
| OptMergeMode ModMapDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode GroupCompatDecl
|
| OptMergeMode GroupCompatDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode IndicatorMapDecl
|
| OptMergeMode IndicatorMapDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode IndicatorNameDecl
|
| OptMergeMode IndicatorNameDecl
|
||||||
{
|
{
|
||||||
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
|
$2->merge= $1;
|
||||||
$$= &$2->common;
|
$$= &$2->common;
|
||||||
}
|
}
|
||||||
| OptMergeMode ShapeDecl
|
| OptMergeMode ShapeDecl
|
||||||
|
@ -328,14 +328,7 @@ Decl : OptMergeMode VarDecl
|
||||||
}
|
}
|
||||||
| MergeMode STRING
|
| MergeMode STRING
|
||||||
{
|
{
|
||||||
if ($1==MERGE_ALT_FORM) {
|
|
||||||
yyerror(&@1, scanner,
|
|
||||||
"cannot use 'alternate' to include other maps");
|
|
||||||
$$= &IncludeCreate($2,MERGE_DEFAULT)->common;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$$= &IncludeCreate($2,$1)->common;
|
$$= &IncludeCreate($2,$1)->common;
|
||||||
}
|
|
||||||
free($2);
|
free($2);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -596,7 +589,14 @@ MergeMode : INCLUDE { $$= MERGE_DEFAULT; }
|
||||||
| AUGMENT { $$= MERGE_AUGMENT; }
|
| AUGMENT { $$= MERGE_AUGMENT; }
|
||||||
| OVERRIDE { $$= MERGE_OVERRIDE; }
|
| OVERRIDE { $$= MERGE_OVERRIDE; }
|
||||||
| REPLACE { $$= MERGE_REPLACE; }
|
| REPLACE { $$= MERGE_REPLACE; }
|
||||||
| ALTERNATE { $$= MERGE_ALT_FORM; }
|
| ALTERNATE
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This used to be MERGE_ALT_FORM. This functionality was
|
||||||
|
* unused and has been removed.
|
||||||
|
*/
|
||||||
|
$$ = MERGE_DEFAULT;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
OptExprList : ExprList { $$= $1; }
|
OptExprList : ExprList { $$= $1; }
|
||||||
|
|
|
@ -626,17 +626,6 @@ CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
|
||||||
StmtSetMerge(ParseCommon * stmt, enum merge_mode merge, struct YYLTYPE *loc, void *scanner)
|
|
||||||
{
|
|
||||||
if ((merge == MERGE_ALT_FORM) && (stmt->stmtType != StmtKeycodeDef))
|
|
||||||
{
|
|
||||||
yyerror(loc, scanner, "illegal use of 'alternate' merge mode");
|
|
||||||
merge = MERGE_DEFAULT;
|
|
||||||
}
|
|
||||||
return merge;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FreeExpr(ExprDef *expr)
|
FreeExpr(ExprDef *expr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,9 +113,6 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn);
|
||||||
extern IncludeStmt *
|
extern IncludeStmt *
|
||||||
IncludeCreate(char *str, enum merge_mode merge);
|
IncludeCreate(char *str, enum merge_mode merge);
|
||||||
|
|
||||||
extern unsigned
|
|
||||||
StmtSetMerge(ParseCommon *stmt, enum merge_mode merge, struct YYLTYPE *loc, void *scanner);
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
CheckDefaultMap(XkbFile *maps, const char *fileName);
|
CheckDefaultMap(XkbFile *maps, const char *fileName);
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@ enum merge_mode {
|
||||||
MERGE_AUGMENT,
|
MERGE_AUGMENT,
|
||||||
MERGE_OVERRIDE,
|
MERGE_OVERRIDE,
|
||||||
MERGE_REPLACE,
|
MERGE_REPLACE,
|
||||||
MERGE_ALT_FORM,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AutoKeyNames (1L << 0)
|
#define AutoKeyNames (1L << 0)
|
||||||
|
|
Loading…
Reference in New Issue