keymap-dump: use ActionTypeText Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index ad82ba6..2186066 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -453,7 +453,7 @@ static bool
write_action(struct xkb_keymap *keymap, struct buf *buf,
union xkb_action *action, const char *prefix, const char *suffix)
{
- const char *type = NULL;
+ const char *type;
const char *args = NULL;
if (!prefix)
@@ -461,23 +461,18 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
if (!suffix)
suffix = "";
+ type = ActionTypeText(action->any.type);
+
switch (action->any.type) {
case XkbSA_SetMods:
- if (!type)
- type = "SetMods";
case XkbSA_LatchMods:
- if (!type)
- type = "LatchMods";
case XkbSA_LockMods:
- if (!type)
- type = "LockMods";
if (action->mods.flags & XkbSA_UseModMapMods)
args = "modMapMods";
else
args = get_mod_mask_text(keymap, action->mods.real_mods,
action->mods.vmods);
- write_buf(buf, "%s%s(modifiers=%s%s%s)%s",
- prefix, type, args,
+ write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args,
(action->any.type != XkbSA_LockGroup &&
(action->mods.flags & XkbSA_ClearLocks)) ?
",clearLocks" : "",
@@ -488,16 +483,9 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
break;
case XkbSA_SetGroup:
- if (!type)
- type = "SetGroup";
case XkbSA_LatchGroup:
- if (!type)
- type = "LatchGroup";
case XkbSA_LockGroup:
- if (!type)
- type = "LockGroup";
- write_buf(buf, "%s%s(group=%s%d%s%s)%s",
- prefix, type,
+ write_buf(buf, "%s%s(group=%s%d%s%s)%s", prefix, type,
(!(action->group.flags & XkbSA_GroupAbsolute) &&
action->group.group > 0) ? "+" : "",
(action->group.flags & XkbSA_GroupAbsolute) ?
@@ -512,13 +500,11 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
break;
case XkbSA_Terminate:
- write_buf(buf, "%sTerminate()%s", prefix,
- suffix);
+ write_buf(buf, "%s%s()%s", prefix, type, suffix);
break;
case XkbSA_MovePtr:
- write_buf(buf, "%sMovePtr(x=%s%d,y=%s%d%s)%s",
- prefix,
+ write_buf(buf, "%s%s(x=%s%d,y=%s%d%s)%s", prefix, type,
(!(action->ptr.flags & XkbSA_MoveAbsoluteX) &&
action->ptr.x >= 0) ? "+" : "",
action->ptr.x,
@@ -529,34 +515,25 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
suffix);
break;
- case XkbSA_PtrBtn:
- if (!type)
- type = "PtrBtn";
case XkbSA_LockPtrBtn:
- if (!type) {
- type = "LockPtrBtn";
- switch (action->btn.flags &
- (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
- case XkbSA_LockNoUnlock:
- args = ",affect=lock";
- break;
-
- case XkbSA_LockNoLock:
- args = ",affect=unlock";
- break;
-
- case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
- args = ",affect=neither";
- break;
-
- default:
- args = ",affect=both";
- break;
- }
- }
- else {
- args = NULL;
+ switch (action->btn.flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
+ case XkbSA_LockNoUnlock:
+ args = ",affect=lock";
+ break;
+
+ case XkbSA_LockNoLock:
+ args = ",affect=unlock";
+ break;
+
+ case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
+ args = ",affect=neither";
+ break;
+
+ default:
+ args = ",affect=both";
+ break;
}
+ case XkbSA_PtrBtn:
write_buf(buf, "%s%s(button=", prefix, type);
if (action->btn.button > 0 && action->btn.button <= 5)
write_buf(buf, "%d", action->btn.button);
@@ -570,7 +547,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
break;
case XkbSA_SetPtrDflt:
- write_buf(buf, "%sSetPtrDflt(", prefix);
+ write_buf(buf, "%s%s(", prefix, type);
if (action->dflt.affect == XkbSA_AffectDfltBtn)
write_buf(buf, "affect=button,button=%s%d",
(!(action->dflt.flags & XkbSA_DfltBtnAbsolute) &&
@@ -580,7 +557,7 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
break;
case XkbSA_SwitchScreen:
- write_buf(buf, "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix,
+ write_buf(buf, "%s%s(screen=%s%d,%ssame)%s", prefix, type,
(!(action->screen.flags & XkbSA_SwitchAbsolute) &&
action->screen.screen >= 0) ? "+" : "",
action->screen.screen,
@@ -590,14 +567,9 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
/* Deprecated actions below here */
case XkbSA_SetControls:
- if (!type)
- type = "SetControls";
case XkbSA_LockControls:
- if (!type)
- type = "LockControls";
- write_buf(buf, "%s%s(controls=%s)%s",
- prefix, type, get_control_mask_text(action->ctrls.ctrls),
- suffix);
+ write_buf(buf, "%s%s(controls=%s)%s", prefix, type,
+ get_control_mask_text(action->ctrls.ctrls), suffix);
break;
case XkbSA_ISOLock:
@@ -613,8 +585,8 @@ write_action(struct xkb_keymap *keymap, struct buf *buf,
case XkbSA_XFree86Private:
default:
write_buf(buf,
- "%sPrivate(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s",
- prefix, action->any.type, action->any.data[0],
+ "%s%s(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s",
+ prefix, type, action->any.type, action->any.data[0],
action->any.data[1], action->any.data[2],
action->any.data[3], action->any.data[4],
action->any.data[5], action->any.data[6],
diff --git a/src/text.c b/src/text.c
index ff19838..022d284 100644
--- a/src/text.c
+++ b/src/text.c
@@ -211,27 +211,27 @@ FileTypeText(enum xkb_file_type type)
}
static const char *actionTypeNames[XkbSA_NumActions] = {
- "NoAction", /* XkbSA_NoAction */
- "SetMods", /* XkbSA_SetMods */
- "LatchMods", /* XkbSA_LatchMods */
- "LockMods", /* XkbSA_LockMods */
- "SetGroup", /* XkbSA_SetGroup */
- "LatchGroup", /* XkbSA_LatchGroup */
- "LockGroup", /* XkbSA_LockGroup */
- "MovePtr", /* XkbSA_MovePtr */
- "PtrBtn", /* XkbSA_PtrBtn */
- "LockPtrBtn", /* XkbSA_LockPtrBtn */
- "SetPtrDflt", /* XkbSA_SetPtrDflt */
- "ISOLock", /* XkbSA_ISOLock */
- "Terminate", /* XkbSA_Terminate */
- "SwitchScreen", /* XkbSA_SwitchScreen */
- "SetControls", /* XkbSA_SetControls */
- "LockControls", /* XkbSA_LockControls */
- "ActionMessage", /* XkbSA_ActionMessage */
- "RedirectKey", /* XkbSA_RedirectKey */
- "DeviceBtn", /* XkbSA_DeviceBtn */
- "LockDeviceBtn", /* XkbSA_LockDeviceBtn */
- "DeviceValuator" /* XkbSA_DeviceValuator */
+ [XkbSA_NoAction] = "NoAction",
+ [XkbSA_SetMods] = "SetMods",
+ [XkbSA_LatchMods] = "LatchMods",
+ [XkbSA_LockMods] = "LockMods",
+ [XkbSA_SetGroup] = "SetGroup",
+ [XkbSA_LatchGroup] = "LatchGroup",
+ [XkbSA_LockGroup] = "LockGroup",
+ [XkbSA_MovePtr] = "MovePtr",
+ [XkbSA_PtrBtn] = "PtrBtn",
+ [XkbSA_LockPtrBtn] = "LockPtrBtn",
+ [XkbSA_SetPtrDflt] = "SetPtrDflt",
+ [XkbSA_ISOLock] = "ISOLock",
+ [XkbSA_Terminate] = "Terminate",
+ [XkbSA_SwitchScreen] = "SwitchScreen",
+ [XkbSA_SetControls] = "SetControls",
+ [XkbSA_LockControls] = "LockControls",
+ [XkbSA_ActionMessage] = "ActionMessage",
+ [XkbSA_RedirectKey] = "RedirectKey",
+ [XkbSA_DeviceBtn] = "DeviceBtn",
+ [XkbSA_LockDeviceBtn] = "LockDeviceBtn",
+ [XkbSA_DeviceValuator] = "DeviceValuator"
};
const char *