keymap-dump: add missing support for NoLock and NoUnlock flags

Based on a libxkbfile patch by Andreas Wettstein.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-02-15 23:50:21 +02:00
parent 11a9f76bf2
commit 8d3db622b8
1 changed files with 23 additions and 16 deletions

View File

@ -273,6 +273,20 @@ write_led_map(struct xkb_keymap *keymap, struct buf *buf,
return true; return true;
} }
static const char *
affect_lock_text(enum xkb_action_flags flags)
{
switch (flags & (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) {
case ACTION_LOCK_NO_UNLOCK:
return ",affect=lock";
case ACTION_LOCK_NO_LOCK:
return ",affect=unlock";
case ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK:
return ",affect=neither";
}
return "";
}
static bool static bool
write_action(struct xkb_keymap *keymap, struct buf *buf, write_action(struct xkb_keymap *keymap, struct buf *buf,
const union xkb_action *action, const union xkb_action *action,
@ -289,16 +303,17 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
type = ActionTypeText(action->type); type = ActionTypeText(action->type);
switch (action->type) { switch (action->type) {
case ACTION_TYPE_MOD_LOCK:
case ACTION_TYPE_MOD_SET: case ACTION_TYPE_MOD_SET:
case ACTION_TYPE_MOD_LATCH: case ACTION_TYPE_MOD_LATCH:
case ACTION_TYPE_MOD_LOCK:
if (action->mods.flags & ACTION_MODS_LOOKUP_MODMAP) if (action->mods.flags & ACTION_MODS_LOOKUP_MODMAP)
args = "modMapMods"; args = "modMapMods";
else else
args = ModMaskText(keymap, action->mods.mods.mods); args = ModMaskText(keymap, action->mods.mods.mods);
write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args, write_buf(buf, "%s%s(modifiers=%s%s%s%s)%s", prefix, type, args,
(action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "", (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "",
(action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "", (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "",
(action->type == ACTION_TYPE_MOD_LOCK) ? affect_lock_text(action->mods.flags) : "",
suffix); suffix);
break; break;
@ -330,18 +345,8 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
break; break;
case ACTION_TYPE_PTR_LOCK: case ACTION_TYPE_PTR_LOCK:
switch (action->btn.flags & args = affect_lock_text(action->btn.flags);
(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) { /* fallthrough */
case ACTION_LOCK_NO_UNLOCK:
args = ",affect=lock";
break;
case ACTION_LOCK_NO_LOCK:
args = ",affect=unlock";
break;
case ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK:
args = ",affect=neither";
break;
}
case ACTION_TYPE_PTR_BUTTON: case ACTION_TYPE_PTR_BUTTON:
write_buf(buf, "%s%s(button=", prefix, type); write_buf(buf, "%s%s(button=", prefix, type);
if (action->btn.button > 0 && action->btn.button <= 5) if (action->btn.button > 0 && action->btn.button <= 5)
@ -373,8 +378,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
case ACTION_TYPE_CTRL_SET: case ACTION_TYPE_CTRL_SET:
case ACTION_TYPE_CTRL_LOCK: case ACTION_TYPE_CTRL_LOCK:
write_buf(buf, "%s%s(controls=%s)%s", prefix, type, write_buf(buf, "%s%s(controls=%s%s)%s", prefix, type,
ControlMaskText(keymap->ctx, action->ctrls.ctrls), suffix); ControlMaskText(keymap->ctx, action->ctrls.ctrls),
(action->type == ACTION_TYPE_CTRL_LOCK) ? affect_lock_text(action->ctrls.flags) : "",
suffix);
break; break;
case ACTION_TYPE_NONE: case ACTION_TYPE_NONE: