keycodes: save context in Info, not keymap
We don't need the keymap in this case, just makes things more verbose. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
0cc5ae33b5
commit
7bcc5fabbd
|
@ -122,7 +122,7 @@ static inline bool
|
||||||
ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
|
ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
|
||||||
const char *wanted)
|
const char *wanted)
|
||||||
{
|
{
|
||||||
return ReportBadType(info->keymap, "symbol interpretation", field,
|
return ReportBadType(info->keymap->ctx, "symbol interpretation", field,
|
||||||
siText(si, info), wanted);
|
siText(si, info), wanted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ static inline bool
|
||||||
ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
|
ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
|
||||||
const char *field, const char *wanted)
|
const char *field, const char *wanted)
|
||||||
{
|
{
|
||||||
return ReportBadType(info->keymap, "indicator map", field,
|
return ReportBadType(info->keymap->ctx, "indicator map", field,
|
||||||
xkb_atom_text(info->keymap->ctx, led->name),
|
xkb_atom_text(info->keymap->ctx, led->name),
|
||||||
wanted);
|
wanted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ typedef struct _KeyNamesInfo {
|
||||||
int errorCount;
|
int errorCount;
|
||||||
unsigned file_id;
|
unsigned file_id;
|
||||||
enum merge_mode merge;
|
enum merge_mode merge;
|
||||||
|
|
||||||
xkb_keycode_t computedMin; /* lowest keycode stored */
|
xkb_keycode_t computedMin; /* lowest keycode stored */
|
||||||
xkb_keycode_t computedMax; /* highest keycode stored */
|
xkb_keycode_t computedMax; /* highest keycode stored */
|
||||||
xkb_keycode_t explicitMin;
|
xkb_keycode_t explicitMin;
|
||||||
|
@ -149,7 +150,7 @@ typedef struct _KeyNamesInfo {
|
||||||
struct list leds;
|
struct list leds;
|
||||||
struct list aliases;
|
struct list aliases;
|
||||||
|
|
||||||
struct xkb_keymap *keymap;
|
struct xkb_context *ctx;
|
||||||
} KeyNamesInfo;
|
} KeyNamesInfo;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -228,7 +229,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
|
||||||
{
|
{
|
||||||
IndicatorNameInfo *old;
|
IndicatorNameInfo *old;
|
||||||
bool replace;
|
bool replace;
|
||||||
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
int verbosity = xkb_get_log_verbosity(info->ctx);
|
||||||
|
|
||||||
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
|
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
|
||||||
|
|
||||||
|
@ -240,23 +241,23 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
|
||||||
if (old->virtual != new->virtual) {
|
if (old->virtual != new->virtual) {
|
||||||
if (replace)
|
if (replace)
|
||||||
old->virtual = new->virtual;
|
old->virtual = new->virtual;
|
||||||
log_warn(info->keymap->ctx, "Multiple indicators named %s; "
|
log_warn(info->ctx, "Multiple indicators named %s; "
|
||||||
"Using %s instead of %s\n",
|
"Using %s instead of %s\n",
|
||||||
xkb_atom_text(info->keymap->ctx, new->name),
|
xkb_atom_text(info->ctx, new->name),
|
||||||
(old->virtual ? "virtual" : "real"),
|
(old->virtual ? "virtual" : "real"),
|
||||||
(old->virtual ? "real" : "virtual"));
|
(old->virtual ? "real" : "virtual"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_warn(info->keymap->ctx, "Multiple indicators named %s; "
|
log_warn(info->ctx, "Multiple indicators named %s; "
|
||||||
"Identical definitions ignored\n",
|
"Identical definitions ignored\n",
|
||||||
xkb_atom_text(info->keymap->ctx, new->name));
|
xkb_atom_text(info->ctx, new->name));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_warn(info->keymap->ctx, "Multiple indicators named %s; "
|
log_warn(info->ctx, "Multiple indicators named %s; "
|
||||||
"Using %d, ignoring %d\n",
|
"Using %d, ignoring %d\n",
|
||||||
xkb_atom_text(info->keymap->ctx, new->name),
|
xkb_atom_text(info->ctx, new->name),
|
||||||
(replace ? old->ndx : new->ndx),
|
(replace ? old->ndx : new->ndx),
|
||||||
(replace ? new->ndx : old->ndx));
|
(replace ? new->ndx : old->ndx));
|
||||||
}
|
}
|
||||||
|
@ -273,8 +274,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
|
||||||
if ((old->file_id == new->file_id && verbosity > 0) ||
|
if ((old->file_id == new->file_id && verbosity > 0) ||
|
||||||
verbosity > 9) {
|
verbosity > 9) {
|
||||||
if (old->name == new->name && old->virtual == new->virtual) {
|
if (old->name == new->name && old->virtual == new->virtual) {
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple names for indicator %d; "
|
||||||
"Multiple names for indicator %d; "
|
|
||||||
"Identical definitions ignored\n", new->ndx);
|
"Identical definitions ignored\n", new->ndx);
|
||||||
} else {
|
} else {
|
||||||
const char *oldType, *newType;
|
const char *oldType, *newType;
|
||||||
|
@ -295,12 +295,11 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
|
||||||
using = old->name;
|
using = old->name;
|
||||||
ignoring = new->name;
|
ignoring = new->name;
|
||||||
}
|
}
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple names for indicator %d; "
|
||||||
"Multiple names for indicator %d; "
|
|
||||||
"Using %s %s, ignoring %s %s\n",
|
"Using %s %s, ignoring %s %s\n",
|
||||||
new->ndx,
|
new->ndx,
|
||||||
oldType, xkb_atom_text(info->keymap->ctx, using),
|
oldType, xkb_atom_text(info->ctx, using),
|
||||||
newType, xkb_atom_text(info->keymap->ctx, ignoring));
|
newType, xkb_atom_text(info->ctx, ignoring));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (replace) {
|
if (replace) {
|
||||||
|
@ -312,7 +311,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
|
||||||
old = new;
|
old = new;
|
||||||
new = NextIndicatorName(info);
|
new = NextIndicatorName(info);
|
||||||
if (!new) {
|
if (!new) {
|
||||||
log_wsgo(info->keymap->ctx,
|
log_wsgo(info->ctx,
|
||||||
"Couldn't allocate name for indicator %d; Ignored\n",
|
"Couldn't allocate name for indicator %d; Ignored\n",
|
||||||
old->ndx);
|
old->ndx);
|
||||||
return false;
|
return false;
|
||||||
|
@ -345,7 +344,7 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InitKeyNamesInfo(KeyNamesInfo *info, struct xkb_keymap *keymap,
|
InitKeyNamesInfo(KeyNamesInfo *info, struct xkb_context *ctx,
|
||||||
unsigned file_id)
|
unsigned file_id)
|
||||||
{
|
{
|
||||||
info->name = NULL;
|
info->name = NULL;
|
||||||
|
@ -357,7 +356,7 @@ InitKeyNamesInfo(KeyNamesInfo *info, struct xkb_keymap *keymap,
|
||||||
darray_init(info->files);
|
darray_init(info->files);
|
||||||
ClearKeyNamesInfo(info);
|
ClearKeyNamesInfo(info);
|
||||||
info->errorCount = 0;
|
info->errorCount = 0;
|
||||||
info->keymap = keymap;
|
info->ctx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -382,7 +381,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name,
|
||||||
enum merge_mode merge, unsigned file_id, bool reportCollisions)
|
enum merge_mode merge, unsigned file_id, bool reportCollisions)
|
||||||
{
|
{
|
||||||
xkb_keycode_t old;
|
xkb_keycode_t old;
|
||||||
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
int verbosity = xkb_get_log_verbosity(info->ctx);
|
||||||
|
|
||||||
ResizeKeyNameArrays(info, kc);
|
ResizeKeyNameArrays(info, kc);
|
||||||
|
|
||||||
|
@ -401,23 +400,20 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name,
|
||||||
const char *kname = LongKeyNameText(name);
|
const char *kname = LongKeyNameText(name);
|
||||||
|
|
||||||
if (darray_item(info->names, kc) == name && reportCollisions) {
|
if (darray_item(info->names, kc) == name && reportCollisions) {
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple identical key name definitions; "
|
||||||
"Multiple identical key name definitions; "
|
|
||||||
"Later occurences of \"%s = %d\" ignored\n", lname, kc);
|
"Later occurences of \"%s = %d\" ignored\n", lname, kc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (merge == MERGE_AUGMENT) {
|
if (merge == MERGE_AUGMENT) {
|
||||||
if (reportCollisions)
|
if (reportCollisions)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple names for keycode %d; "
|
||||||
"Multiple names for keycode %d; "
|
|
||||||
"Using %s, ignoring %s\n", kc, lname, kname);
|
"Using %s, ignoring %s\n", kc, lname, kname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (reportCollisions)
|
if (reportCollisions)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple names for keycode %d; "
|
||||||
"Multiple names for keycode %d; "
|
|
||||||
"Using %s, ignoring %s\n", kc, kname, lname);
|
"Using %s, ignoring %s\n", kc, kname, lname);
|
||||||
darray_item(info->names, kc) = 0;
|
darray_item(info->names, kc) = 0;
|
||||||
darray_item(info->files, kc) = 0;
|
darray_item(info->files, kc) = 0;
|
||||||
|
@ -432,14 +428,12 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name,
|
||||||
darray_item(info->names, old) = 0;
|
darray_item(info->names, old) = 0;
|
||||||
darray_item(info->files, old) = 0;
|
darray_item(info->files, old) = 0;
|
||||||
if (reportCollisions)
|
if (reportCollisions)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Key name %s assigned to multiple keys; "
|
||||||
"Key name %s assigned to multiple keys; "
|
|
||||||
"Using %d, ignoring %d\n", kname, kc, old);
|
"Using %d, ignoring %d\n", kname, kc, old);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (reportCollisions && verbosity > 3)
|
if (reportCollisions && verbosity > 3)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Key name %s assigned to multiple keys; "
|
||||||
"Key name %s assigned to multiple keys; "
|
|
||||||
"Using %d, ignoring %d\n", kname, old, kc);
|
"Using %d, ignoring %d\n", kname, old, kc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +541,7 @@ HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *stmt)
|
||||||
XkbFile *rtrn;
|
XkbFile *rtrn;
|
||||||
KeyNamesInfo included, next_incl;
|
KeyNamesInfo included, next_incl;
|
||||||
|
|
||||||
InitKeyNamesInfo(&included, info->keymap, info->file_id);
|
InitKeyNamesInfo(&included, info->ctx, info->file_id);
|
||||||
if (stmt->stmt) {
|
if (stmt->stmt) {
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
|
@ -555,14 +549,14 @@ HandleIncludeKeycodes(KeyNamesInfo *info, IncludeStmt *stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; stmt; stmt = stmt->next_incl) {
|
for (; stmt; stmt = stmt->next_incl) {
|
||||||
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_KEYCODES,
|
if (!ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_KEYCODES,
|
||||||
&rtrn, &merge)) {
|
&rtrn, &merge)) {
|
||||||
info->errorCount += 10;
|
info->errorCount += 10;
|
||||||
ClearKeyNamesInfo(&included);
|
ClearKeyNamesInfo(&included);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitKeyNamesInfo(&next_incl, info->keymap, rtrn->id);
|
InitKeyNamesInfo(&next_incl, info->ctx, rtrn->id);
|
||||||
|
|
||||||
HandleKeycodesFile(&next_incl, rtrn, MERGE_OVERRIDE);
|
HandleKeycodesFile(&next_incl, rtrn, MERGE_OVERRIDE);
|
||||||
|
|
||||||
|
@ -587,8 +581,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
|
||||||
{
|
{
|
||||||
if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
|
if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
|
||||||
(info->explicitMax != 0 && stmt->value > info->explicitMax)) {
|
(info->explicitMax != 0 && stmt->value > info->explicitMax)) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx, "Illegal keycode %lu for name %s; "
|
||||||
"Illegal keycode %lu for name %s; "
|
|
||||||
"Must be in the range %d-%d inclusive\n",
|
"Must be in the range %d-%d inclusive\n",
|
||||||
stmt->value, KeyNameText(stmt->name), info->explicitMin,
|
stmt->value, KeyNameText(stmt->name), info->explicitMin,
|
||||||
info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
|
info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
|
||||||
|
@ -609,12 +602,11 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
|
||||||
static void
|
static void
|
||||||
HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
|
HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
|
||||||
{
|
{
|
||||||
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
|
int verbosity = xkb_get_log_verbosity(info->ctx);
|
||||||
|
|
||||||
if (new->real == old->real) {
|
if (new->real == old->real) {
|
||||||
if ((new->file_id == old->file_id && verbosity > 0) || verbosity > 9)
|
if ((new->file_id == old->file_id && verbosity > 0) || verbosity > 9)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Alias of %s for %s declared more than once; "
|
||||||
"Alias of %s for %s declared more than once; "
|
|
||||||
"First definition ignored\n",
|
"First definition ignored\n",
|
||||||
LongKeyNameText(new->alias), LongKeyNameText(new->real));
|
LongKeyNameText(new->alias), LongKeyNameText(new->real));
|
||||||
}
|
}
|
||||||
|
@ -631,8 +623,7 @@ HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((old->file_id == new->file_id && verbosity > 0) || verbosity > 9)
|
if ((old->file_id == new->file_id && verbosity > 0) || verbosity > 9)
|
||||||
log_warn(info->keymap->ctx,
|
log_warn(info->ctx, "Multiple definitions for alias %s; "
|
||||||
"Multiple definitions for alias %s; "
|
|
||||||
"Using %s, ignoring %s\n",
|
"Using %s, ignoring %s\n",
|
||||||
LongKeyNameText(old->alias), LongKeyNameText(use),
|
LongKeyNameText(old->alias), LongKeyNameText(use),
|
||||||
LongKeyNameText(ignore));
|
LongKeyNameText(ignore));
|
||||||
|
@ -662,7 +653,7 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge,
|
||||||
|
|
||||||
alias = calloc(1, sizeof(*alias));
|
alias = calloc(1, sizeof(*alias));
|
||||||
if (!alias) {
|
if (!alias) {
|
||||||
log_wsgo(info->keymap->ctx, "Allocation failure in HandleAliasDef\n");
|
log_wsgo(info->ctx, "Allocation failure in HandleAliasDef\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,13 +683,12 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
ExprDef *arrayNdx;
|
ExprDef *arrayNdx;
|
||||||
int which;
|
int which;
|
||||||
|
|
||||||
if (!ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
|
if (!ExprResolveLhs(info->ctx, stmt->name, &elem, &field,
|
||||||
&arrayNdx))
|
&arrayNdx))
|
||||||
return false; /* internal error, already reported */
|
return false; /* internal error, already reported */
|
||||||
|
|
||||||
if (elem) {
|
if (elem) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx, "Unknown element %s encountered; "
|
||||||
"Unknown element %s encountered; "
|
|
||||||
"Default for field %s ignored\n", elem, field);
|
"Default for field %s ignored\n", elem, field);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -710,28 +700,25 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
which = MAX_KEYCODE_DEF;
|
which = MAX_KEYCODE_DEF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx, "Unknown field encountered; "
|
||||||
"Unknown field encountered; "
|
|
||||||
"Assigment to field %s ignored\n", field);
|
"Assigment to field %s ignored\n", field);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arrayNdx != NULL) {
|
if (arrayNdx != NULL) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx, "The %s setting is not an array; "
|
||||||
"The %s setting is not an array; "
|
|
||||||
"Illegal array reference ignored\n", field);
|
"Illegal array reference ignored\n", field);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ExprResolveKeyCode(info->keymap->ctx, stmt->value, &kc)) {
|
if (!ExprResolveKeyCode(info->ctx, stmt->value, &kc)) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx, "Illegal keycode encountered; "
|
||||||
"Illegal keycode encountered; "
|
|
||||||
"Assignment to field %s ignored\n", field);
|
"Assignment to field %s ignored\n", field);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kc > XKB_KEYCODE_MAX) {
|
if (kc > XKB_KEYCODE_MAX) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Illegal keycode %d (must be in the range %d-%d inclusive); "
|
"Illegal keycode %d (must be in the range %d-%d inclusive); "
|
||||||
"Value of \"%s\" not changed\n",
|
"Value of \"%s\" not changed\n",
|
||||||
kc, 0, XKB_KEYCODE_MAX, field);
|
kc, 0, XKB_KEYCODE_MAX, field);
|
||||||
|
@ -740,7 +727,7 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
|
|
||||||
if (which == MIN_KEYCODE_DEF) {
|
if (which == MIN_KEYCODE_DEF) {
|
||||||
if (info->explicitMax > 0 && info->explicitMax < kc) {
|
if (info->explicitMax > 0 && info->explicitMax < kc) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Minimum key code (%d) must be <= maximum key code (%d); "
|
"Minimum key code (%d) must be <= maximum key code (%d); "
|
||||||
"Minimum key code value not changed\n",
|
"Minimum key code value not changed\n",
|
||||||
kc, info->explicitMax);
|
kc, info->explicitMax);
|
||||||
|
@ -748,7 +735,7 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->computedMax > 0 && info->computedMin < kc) {
|
if (info->computedMax > 0 && info->computedMin < kc) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Minimum key code (%d) must be <= lowest defined key (%d); "
|
"Minimum key code (%d) must be <= lowest defined key (%d); "
|
||||||
"Minimum key code value not changed\n",
|
"Minimum key code value not changed\n",
|
||||||
kc, info->computedMin);
|
kc, info->computedMin);
|
||||||
|
@ -759,7 +746,7 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
}
|
}
|
||||||
else if (which == MAX_KEYCODE_DEF) {
|
else if (which == MAX_KEYCODE_DEF) {
|
||||||
if (info->explicitMin > 0 && info->explicitMin > kc) {
|
if (info->explicitMin > 0 && info->explicitMin > kc) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Maximum code (%d) must be >= minimum key code (%d); "
|
"Maximum code (%d) must be >= minimum key code (%d); "
|
||||||
"Maximum code value not changed\n",
|
"Maximum code value not changed\n",
|
||||||
kc, info->explicitMin);
|
kc, info->explicitMin);
|
||||||
|
@ -767,7 +754,7 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->computedMax > 0 && info->computedMax > kc) {
|
if (info->computedMax > 0 && info->computedMax > kc) {
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Maximum code (%d) must be >= highest defined key (%d); "
|
"Maximum code (%d) must be >= highest defined key (%d); "
|
||||||
"Maximum code value not changed\n",
|
"Maximum code value not changed\n",
|
||||||
kc, info->computedMax);
|
kc, info->computedMax);
|
||||||
|
@ -789,7 +776,7 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
|
||||||
|
|
||||||
if (def->ndx < 1 || def->ndx > XkbNumIndicators) {
|
if (def->ndx < 1 || def->ndx > XkbNumIndicators) {
|
||||||
info->errorCount++;
|
info->errorCount++;
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Name specified for illegal indicator index %d\n; Ignored\n",
|
"Name specified for illegal indicator index %d\n; Ignored\n",
|
||||||
def->ndx);
|
def->ndx);
|
||||||
return false;
|
return false;
|
||||||
|
@ -797,16 +784,16 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
|
||||||
|
|
||||||
InitIndicatorNameInfo(&ii, info);
|
InitIndicatorNameInfo(&ii, info);
|
||||||
|
|
||||||
if (!ExprResolveString(info->keymap->ctx, def->name, &str)) {
|
if (!ExprResolveString(info->ctx, def->name, &str)) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
snprintf(buf, sizeof(buf), "%d", def->ndx);
|
snprintf(buf, sizeof(buf), "%d", def->ndx);
|
||||||
info->errorCount++;
|
info->errorCount++;
|
||||||
return ReportBadType(info->keymap, "indicator", "name", buf,
|
return ReportBadType(info->ctx, "indicator", "name", buf,
|
||||||
"string");
|
"string");
|
||||||
}
|
}
|
||||||
|
|
||||||
ii.ndx = (xkb_led_index_t) def->ndx;
|
ii.ndx = (xkb_led_index_t) def->ndx;
|
||||||
ii.name = xkb_atom_intern(info->keymap->ctx, str);
|
ii.name = xkb_atom_intern(info->ctx, str);
|
||||||
ii.virtual = def->virtual;
|
ii.virtual = def->virtual;
|
||||||
|
|
||||||
return AddIndicatorName(info, merge, &ii);
|
return AddIndicatorName(info, merge, &ii);
|
||||||
|
@ -853,7 +840,7 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
|
||||||
merge);
|
merge);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_err(info->keymap->ctx,
|
log_err(info->ctx,
|
||||||
"Keycode files may define key and indicator names only; "
|
"Keycode files may define key and indicator names only; "
|
||||||
"Ignoring %s\n", StmtTypeToString(stmt->type));
|
"Ignoring %s\n", StmtTypeToString(stmt->type));
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -864,7 +851,7 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
|
||||||
info->errorCount++;
|
info->errorCount++;
|
||||||
|
|
||||||
if (info->errorCount > 10) {
|
if (info->errorCount > 10) {
|
||||||
log_err(info->keymap->ctx, "Abandoning keycodes file \"%s\"\n",
|
log_err(info->ctx, "Abandoning keycodes file \"%s\"\n",
|
||||||
file->topName);
|
file->topName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -872,14 +859,13 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ApplyAliases(KeyNamesInfo *info)
|
ApplyAliases(KeyNamesInfo *info, struct xkb_keymap *keymap)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct xkb_key *key;
|
struct xkb_key *key;
|
||||||
struct xkb_key_alias *old, *a;
|
struct xkb_key_alias *old, *a;
|
||||||
AliasInfo *alias, *next;
|
AliasInfo *alias, *next;
|
||||||
int nNew = 0, nOld;
|
int nNew = 0, nOld;
|
||||||
struct xkb_keymap *keymap = info->keymap;
|
|
||||||
|
|
||||||
nOld = darray_size(keymap->key_aliases);
|
nOld = darray_size(keymap->key_aliases);
|
||||||
old = &darray_item(keymap->key_aliases, 0);
|
old = &darray_item(keymap->key_aliases, 0);
|
||||||
|
@ -887,7 +873,7 @@ ApplyAliases(KeyNamesInfo *info)
|
||||||
list_foreach(alias, &info->aliases, entry) {
|
list_foreach(alias, &info->aliases, entry) {
|
||||||
key = FindNamedKey(keymap, alias->real, false, 0);
|
key = FindNamedKey(keymap, alias->real, false, 0);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
log_lvl(info->keymap->ctx, 5,
|
log_lvl(info->ctx, 5,
|
||||||
"Attempt to alias %s to non-existent key %s; Ignored\n",
|
"Attempt to alias %s to non-existent key %s; Ignored\n",
|
||||||
LongKeyNameText(alias->alias),
|
LongKeyNameText(alias->alias),
|
||||||
LongKeyNameText(alias->real));
|
LongKeyNameText(alias->real));
|
||||||
|
@ -897,7 +883,7 @@ ApplyAliases(KeyNamesInfo *info)
|
||||||
|
|
||||||
key = FindNamedKey(keymap, alias->alias, false, 0);
|
key = FindNamedKey(keymap, alias->alias, false, 0);
|
||||||
if (key) {
|
if (key) {
|
||||||
log_lvl(info->keymap->ctx, 5,
|
log_lvl(info->ctx, 5,
|
||||||
"Attempt to create alias with the name of a real key; "
|
"Attempt to create alias with the name of a real key; "
|
||||||
"Alias \"%s = %s\" ignored\n",
|
"Alias \"%s = %s\" ignored\n",
|
||||||
LongKeyNameText(alias->alias),
|
LongKeyNameText(alias->alias),
|
||||||
|
@ -965,7 +951,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
|
||||||
KeyNamesInfo info; /* contains all the info after parsing */
|
KeyNamesInfo info; /* contains all the info after parsing */
|
||||||
IndicatorNameInfo *ii;
|
IndicatorNameInfo *ii;
|
||||||
|
|
||||||
InitKeyNamesInfo(&info, keymap, file->id);
|
InitKeyNamesInfo(&info, keymap->ctx, file->id);
|
||||||
|
|
||||||
HandleKeycodesFile(&info, file, merge);
|
HandleKeycodesFile(&info, file, merge);
|
||||||
|
|
||||||
|
@ -995,7 +981,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
|
||||||
keymap->indicator_names[ii->ndx - 1] =
|
keymap->indicator_names[ii->ndx - 1] =
|
||||||
xkb_atom_text(keymap->ctx, ii->name);
|
xkb_atom_text(keymap->ctx, ii->name);
|
||||||
|
|
||||||
ApplyAliases(&info);
|
ApplyAliases(&info, keymap);
|
||||||
|
|
||||||
ClearKeyNamesInfo(&info);
|
ClearKeyNamesInfo(&info);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -186,8 +186,8 @@ static inline bool
|
||||||
ReportTypeBadType(KeyTypesInfo *info, KeyTypeInfo *type,
|
ReportTypeBadType(KeyTypesInfo *info, KeyTypeInfo *type,
|
||||||
const char *field, const char *wanted)
|
const char *field, const char *wanted)
|
||||||
{
|
{
|
||||||
return ReportBadType(info->keymap, "key type", field, TypeTxt(info, type),
|
return ReportBadType(info->keymap->ctx, "key type", field,
|
||||||
wanted);
|
TypeTxt(info, type), wanted);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
|
|
|
@ -99,11 +99,10 @@ ReportShouldBeArray(struct xkb_keymap *keymap, const char *type,
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
ReportBadType(struct xkb_keymap *keymap, const char *type, const char *field,
|
ReportBadType(struct xkb_context *ctx, const char *type, const char *field,
|
||||||
const char *name, const char *wanted)
|
const char *name, const char *wanted)
|
||||||
{
|
{
|
||||||
log_err(keymap->ctx,
|
log_err(ctx, "The %s %s field must be a %s; "
|
||||||
"The %s %s field must be a %s; "
|
|
||||||
"Ignoring illegal assignment in %s\n",
|
"Ignoring illegal assignment in %s\n",
|
||||||
type, field, wanted, name);
|
type, field, wanted, name);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue