compat: ignore "group" (compatibility) statements

Group compatibility statements are like the following:
    group 3 = AltGr;
This currently results in:
    keymap->groups[2].mask = <real mod mapped from AltGr vmod>
And we don't do any thing with this value later. The reason it exists in
XKB is to support non-XKB clients (i.e. XKB support disabled entirely in
the server), which do not know the concept of "group", and use some
modifier to distinguish between the first and second keyboard layouts
(usually with the AltGr key). We don't care about all of that, so we can
forget about it.

One artifact of this removal is that xkb_map_num_groups no longer
works, because it counted through keymap->groups (this wasn't entirely
correct BTW). Instead we add a new num_groups member to the keymap,
which just hold the maximum among the xkb_key's num_groups. This also
means we don't have to compute anything just to get the number of
groups.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-08-27 21:31:18 +03:00
parent 7f75502f18
commit 9de067aad4
6 changed files with 14 additions and 109 deletions

View File

@ -577,16 +577,6 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
write_buf(buf, "\t\t};\n");
}
for (i = 0; i < XkbNumKbdGroups; i++) {
struct xkb_mods *gc;
gc = &keymap->groups[i];
if (gc->mods == 0)
continue;
write_buf(buf, "\t\tgroup %d = %s;\n", i + 1,
VModMaskText(keymap, gc->mods));
}
for (i = 0; i < XkbNumIndicators; i++) {
struct xkb_indicator_map *map = &keymap->indicators[i];
if (map->flags == 0 && map->which_groups == 0 &&

View File

@ -168,14 +168,7 @@ xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
XKB_EXPORT xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *keymap)
{
xkb_group_index_t ret = 0;
xkb_group_index_t i;
for (i = 0; i < XkbNumKbdGroups; i++)
if (keymap->groups[i].mask)
ret++;
return ret;
return keymap->num_groups;
}
/**

View File

@ -67,6 +67,9 @@ isempty(const char *s)
return s == NULL || s[0] == '\0';
}
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* Compiler Attributes */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)

View File

@ -365,7 +365,8 @@ struct xkb_keymap {
xkb_mod_mask_t vmods[XkbNumVirtualMods];
const char *vmod_names[XkbNumVirtualMods];
struct xkb_mods groups[XkbNumKbdGroups];
/* Number of groups in the key with the most groups. */
xkb_group_index_t num_groups;
const char *group_names[XkbNumKbdGroups];
struct xkb_indicator_map indicators[XkbNumIndicators];

View File

@ -173,13 +173,6 @@ typedef struct _LEDInfo {
unsigned int ctrls;
} LEDInfo;
typedef struct _GroupCompatInfo {
unsigned file_id;
enum merge_mode merge;
bool defined;
xkb_mod_mask_t mods;
} GroupCompatInfo;
typedef struct _CompatInfo {
char *name;
unsigned file_id;
@ -188,7 +181,6 @@ typedef struct _CompatInfo {
struct list interps;
SymInterpInfo dflt;
LEDInfo ledDflt;
GroupCompatInfo groupCompat[XkbNumKbdGroups];
darray(LEDInfo) leds;
VModInfo vmods;
ActionInfo *act;
@ -274,8 +266,6 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id)
info->ledDflt.file_id = file_id;
info->ledDflt.defined = 0;
info->ledDflt.merge = MERGE_OVERRIDE;
memset(&info->groupCompat[0], 0,
XkbNumKbdGroups * sizeof(GroupCompatInfo));
darray_init(info->leds);
InitVModInfo(&info->vmods, keymap);
}
@ -298,8 +288,6 @@ ClearCompatInfo(CompatInfo *info)
info->nInterps = 0;
list_foreach_safe(si, next_si, &info->interps, entry)
free(si);
memset(&info->groupCompat[0], 0,
XkbNumKbdGroups * sizeof(GroupCompatInfo));
darray_free(info->leds);
FreeActionInfo(info->act);
info->act = NULL;
@ -422,27 +410,6 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
return true;
}
static bool
AddGroupCompat(CompatInfo *info, xkb_group_index_t group, GroupCompatInfo *new)
{
GroupCompatInfo *gc;
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
gc = &info->groupCompat[group];
if (gc->mods == new->mods)
return true;
if ((gc->file_id == new->file_id && verbosity > 0) || verbosity > 9)
log_warn(info->keymap->ctx,
"Compat map for group %u redefined; "
"Using %s definition\n",
group + 1, (new->merge == MERGE_AUGMENT ? "old" : "new"));
if (new->defined && (new->merge != MERGE_AUGMENT || !gc->defined))
*gc = *new;
return true;
}
/***====================================================================***/
@ -594,8 +561,6 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
{
SymInterpInfo *si, *next_si;
LEDInfo *led;
GroupCompatInfo *gcm;
xkb_group_index_t i;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
@ -613,13 +578,6 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
into->errorCount++;
}
for (i = 0; i < XkbNumKbdGroups; i++) {
gcm = &from->groupCompat[i];
gcm->merge = (merge == MERGE_DEFAULT ? gcm->merge : merge);
if (!AddGroupCompat(into, i, gcm))
into->errorCount++;
}
darray_foreach(led, from->leds) {
led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
if (!AddIndicatorMap(into, led))
@ -999,37 +957,6 @@ HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
return true;
}
static bool
HandleGroupCompatDef(CompatInfo *info, GroupCompatDef *def,
enum merge_mode merge)
{
GroupCompatInfo tmp;
merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
if (def->group < 1 || def->group > XkbNumKbdGroups) {
log_err(info->keymap->ctx,
"Keyboard group must be in the range 1..%u; "
"Compatibility map for illegal group %u ignored\n",
XkbNumKbdGroups, def->group);
return false;
}
tmp.file_id = info->file_id;
tmp.merge = merge;
if (!ExprResolveVModMask(info->keymap, def->def, &tmp.mods)) {
log_err(info->keymap->ctx,
"Expected a modifier mask in group compatibility definition; "
"Ignoring illegal compatibility map for group %u\n",
def->group);
return false;
}
tmp.defined = true;
return AddGroupCompat(info, def->group - 1, &tmp);
}
static bool
HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
enum merge_mode merge)
@ -1093,7 +1020,10 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
ok = HandleInterpDef(info, (InterpDef *) stmt, merge);
break;
case STMT_GROUP_COMPAT:
ok = HandleGroupCompatDef(info, (GroupCompatDef *) stmt, merge);
log_dbg(info->keymap->ctx,
"The \"group\" statement in compat is unsupported; "
"Ignored\n");
ok = true;
break;
case STMT_INDICATOR_MAP:
ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
@ -1208,9 +1138,7 @@ bool
CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{
xkb_group_index_t i;
CompatInfo info;
GroupCompatInfo *gcm;
InitCompatInfo(&info, keymap, file->id);
info.dflt.merge = merge;
@ -1237,12 +1165,6 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
CopyInterps(&info, false, XkbSI_AnyOfOrNone);
}
for (i = 0; i < XkbNumKbdGroups; i++) {
gcm = &info.groupCompat[i];
if (gcm->file_id != 0 || gcm->mods != 0)
keymap->groups[i].mods = gcm->mods;
}
if (!CopyIndicatorMapDefs(&info))
info.errorCount++;
@ -1445,7 +1367,6 @@ bool
UpdateModifiersFromCompat(struct xkb_keymap *keymap)
{
xkb_mod_index_t vmod;
xkb_group_index_t grp;
xkb_led_index_t led;
unsigned int i, j;
struct xkb_key *key;
@ -1490,13 +1411,13 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
UpdateActionMods(keymap, &key->actions[i], key->modmap);
}
/* Update group modifiers. */
for (grp = 0; grp < XkbNumKbdGroups; grp++)
ComputeEffectiveMask(keymap, &keymap->groups[grp]);
/* Update vmod -> indicator maps. */
for (led = 0; led < XkbNumIndicators; led++)
ComputeEffectiveMask(keymap, &keymap->indicators[led].mods);
/* Find maximum number of groups out of all keys in the keymap. */
xkb_foreach_key(key, keymap)
keymap->num_groups = MAX(keymap->num_groups, key->num_groups);
return true;
}

View File

@ -1050,9 +1050,6 @@ xkb_keymap {
interpret Any+AnyOf(all) {
action= SetMods(modifiers=modMapMods,clearLocks);
};
group 2 = AltGr;
group 3 = AltGr;
group 4 = AltGr;
indicator "Caps Lock" {
whichModState= locked;
modifiers= Lock;