vmod: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-07-21 15:27:09 +03:00
parent 3bb3e9c3a9
commit 544a83e6d7
2 changed files with 46 additions and 39 deletions

View File

@ -43,7 +43,6 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
for (i = 0; i < XkbNumVirtualMods; i++) for (i = 0; i < XkbNumVirtualMods; i++)
keymap->vmods[i] = XkbNoModifierMask; keymap->vmods[i] = XkbNoModifierMask;
info->keymap = keymap;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
if (keymap->vmod_names[i]) if (keymap->vmod_names[i])
info->defined |= bit; info->defined |= bit;
@ -69,45 +68,53 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<= for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
1) { 1) {
if (info->defined & bit) { if (!(info->defined & bit)) {
if (keymap->vmod_names[i] && if (nextFree < 0)
strcmp(keymap->vmod_names[i], nextFree = i;
xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */ continue;
info->available |= bit; }
if (stmt->value == NULL)
return true;
else {
const char *str1;
const char *str2 = "";
if (!ExprResolveModMask(keymap->ctx, stmt->value,
&mod)) {
str1 = xkb_atom_text(keymap->ctx, stmt->name);
ACTION("Declaration of %s ignored\n", str1);
return false;
}
if (mod.uval == keymap->vmods[i])
return true;
str1 = xkb_atom_text(keymap->ctx, stmt->name); if (keymap->vmod_names[i] &&
WARN("Virtual modifier %s multiply defined\n", str1); strcmp(keymap->vmod_names[i],
str1 = XkbcModMaskText(keymap->vmods[i], true); xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
if (mergeMode == MERGE_OVERRIDE) { info->available |= bit;
str2 = str1; if (stmt->value == NULL)
str1 = XkbcModMaskText(mod.uval, true); return true;
} else {
ACTION("Using %s, ignoring %s\n", str1, str2); const char *str1;
if (mergeMode == MERGE_OVERRIDE) const char *str2 = "";
keymap->vmods[i] = mod.uval;
return true; if (!ExprResolveModMask(keymap->ctx, stmt->value,
&mod)) {
log_err(keymap->ctx, "Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name));
return false;
} }
if (mod.uval == keymap->vmods[i])
return true;
str1 = XkbcModMaskText(keymap->vmods[i], true);
if (mergeMode == MERGE_OVERRIDE) {
str2 = str1;
str1 = XkbcModMaskText(mod.uval, true);
}
log_warn(keymap->ctx,
"Virtual modifier %s multiply defined; "
"Using %s, ignoring %s\n",
xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
if (mergeMode == MERGE_OVERRIDE)
keymap->vmods[i] = mod.uval;
return true;
} }
} }
else if (nextFree < 0)
nextFree = i;
} }
if (nextFree < 0) { if (nextFree < 0) {
ERROR("Too many virtual modifiers defined (maximum %d)\n", log_err(keymap->ctx,
XkbNumVirtualMods); "Too many virtual modifiers defined (maximum %d)\n",
XkbNumVirtualMods);
return false; return false;
} }
info->defined |= (1 << nextFree); info->defined |= (1 << nextFree);
@ -120,8 +127,8 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
keymap->vmods[nextFree] = mod.uval; keymap->vmods[nextFree] = mod.uval;
return true; return true;
} }
ACTION("Declaration of %s ignored\n", log_err(keymap->ctx, "Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name)); xkb_atom_text(keymap->ctx, stmt->name));
return false; return false;
} }
@ -217,8 +224,9 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
if (ExprResolveInteger(keymap->ctx, def, val_rtrn)) { if (ExprResolveInteger(keymap->ctx, def, val_rtrn)) {
if (val_rtrn->uval < XkbNumVirtualMods) if (val_rtrn->uval < XkbNumVirtualMods)
return true; return true;
ERROR("Illegal virtual modifier %d (must be 0..%d inclusive)\n", log_err(keymap->ctx,
val_rtrn->uval, XkbNumVirtualMods - 1); "Illegal virtual modifier %d (must be 0..%d inclusive)\n",
val_rtrn->uval, XkbNumVirtualMods - 1);
} }
return false; return false;
} }

View File

@ -31,7 +31,6 @@
#include "expr.h" #include "expr.h"
typedef struct _VModInfo { typedef struct _VModInfo {
struct xkb_keymap *keymap;
unsigned defined; unsigned defined;
unsigned available; unsigned available;
unsigned newlyDefined; unsigned newlyDefined;