1 /************************************************************
2 * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
4 * Permission to use, copy, modify, and distribute this
5 * software and its documentation for any purpose and without
6 * fee is hereby granted, provided that the above copyright
7 * notice appear in all copies and that both that copyright
8 * notice and this permission notice appear in supporting
9 * documentation, and that the name of Silicon Graphics not be
10 * used in advertising or publicity pertaining to distribution
11 * of the software without specific prior written permission.
12 * Silicon Graphics makes no representation about the suitability
13 * of this software for any purpose. It is provided "as is"
14 * without any express or implied warranty.
16 * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23 * THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 ********************************************************/
28 * Copyright © 2012 Intel Corporation
29 * Copyright © 2012 Ran Benita <ran234@gmail.com>
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
38 * The above copyright notice and this permission notice (including the next
39 * paragraph) shall be included in all copies or substantial portions of the
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48 * DEALINGS IN THE SOFTWARE.
50 * Author: Daniel Stone <daniel@fooishbar.org>
51 * Ran Benita <ran234@gmail.com>
54 #include "xkbcomp-priv.h"
59 static const ExprDef constTrue = {
60 .common = { .type = STMT_EXPR, .next = NULL },
62 .value_type = EXPR_TYPE_BOOLEAN,
63 .value = { .ival = 1 },
66 static const ExprDef constFalse = {
67 .common = { .type = STMT_EXPR, .next = NULL },
69 .value_type = EXPR_TYPE_BOOLEAN,
70 .value = { .ival = 0 },
74 ACTION_FIELD_CLEAR_LOCKS,
75 ACTION_FIELD_LATCH_TO_LOCK,
76 ACTION_FIELD_GEN_KEY_EVENT,
80 ACTION_FIELD_INCREMENT,
81 ACTION_FIELD_MODIFIERS,
88 ACTION_FIELD_CONTROLS,
96 ACTION_FIELD_MODS_TO_CLEAR,
105 info = calloc(1, sizeof(*info));
109 for (type = 0; type < _ACTION_TYPE_NUM_ENTRIES; type++)
110 info->actions[type].type = type;
112 /* Apply some "factory defaults". */
114 /* Increment default button. */
115 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
116 info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
122 FreeActionsInfo(ActionsInfo *info)
127 static const LookupEntry fieldStrings[] = {
128 { "clearLocks", ACTION_FIELD_CLEAR_LOCKS },
129 { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK },
130 { "genKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
131 { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
132 { "report", ACTION_FIELD_REPORT },
133 { "default", ACTION_FIELD_DEFAULT },
134 { "affect", ACTION_FIELD_AFFECT },
135 { "increment", ACTION_FIELD_INCREMENT },
136 { "modifiers", ACTION_FIELD_MODIFIERS },
137 { "mods", ACTION_FIELD_MODIFIERS },
138 { "group", ACTION_FIELD_GROUP },
139 { "x", ACTION_FIELD_X },
140 { "y", ACTION_FIELD_Y },
141 { "accel", ACTION_FIELD_ACCEL },
142 { "accelerate", ACTION_FIELD_ACCEL },
143 { "repeat", ACTION_FIELD_ACCEL },
144 { "button", ACTION_FIELD_BUTTON },
145 { "value", ACTION_FIELD_VALUE },
146 { "controls", ACTION_FIELD_CONTROLS },
147 { "ctrls", ACTION_FIELD_CONTROLS },
148 { "type", ACTION_FIELD_TYPE },
149 { "count", ACTION_FIELD_COUNT },
150 { "screen", ACTION_FIELD_SCREEN },
151 { "same", ACTION_FIELD_SAME },
152 { "sameServer", ACTION_FIELD_SAME },
153 { "data", ACTION_FIELD_DATA },
154 { "device", ACTION_FIELD_DEVICE },
155 { "dev", ACTION_FIELD_DEVICE },
156 { "key", ACTION_FIELD_KEYCODE },
157 { "keycode", ACTION_FIELD_KEYCODE },
158 { "kc", ACTION_FIELD_KEYCODE },
159 { "clearmods", ACTION_FIELD_MODS_TO_CLEAR },
160 { "clearmodifiers", ACTION_FIELD_MODS_TO_CLEAR },
165 stringToAction(const char *str, unsigned *type_rtrn)
167 return LookupString(actionTypeNames, str, type_rtrn);
171 stringToField(const char *str, enum action_field *field_rtrn)
173 return LookupString(fieldStrings, str, field_rtrn);
177 fieldText(enum action_field field)
179 return LookupValue(fieldStrings, field);
182 /***====================================================================***/
185 ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
186 enum action_field field, const char *type)
189 "Value of %s field must be of type %s; "
190 "Action %s definition ignored\n",
191 fieldText(field), type, ActionTypeText(action));
196 ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
197 enum action_field field)
200 "Field %s is not defined for an action of type %s; "
201 "Action definition ignored\n",
202 fieldText(field), ActionTypeText(action));
207 ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
208 enum action_field field)
211 "The %s field in the %s action is not an array; "
212 "Action definition ignored\n",
213 fieldText(field), ActionTypeText(action));
218 ReportNotFound(struct xkb_keymap *keymap, enum xkb_action_type action,
219 enum action_field field, const char *what, const char *bad)
222 "%s named %s not found; "
223 "Ignoring the %s field of an %s action\n",
224 what, bad, fieldText(field), ActionTypeText(action));
229 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
230 enum action_field field, const ExprDef *array_ndx,
231 const ExprDef *value)
238 CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
239 enum action_field field, const ExprDef *value,
240 enum xkb_action_flags *flags_inout)
242 enum xkb_action_flags tmp;
245 if (field == ACTION_FIELD_CLEAR_LOCKS)
246 tmp = ACTION_LOCK_CLEAR;
247 else if (field == ACTION_FIELD_LATCH_TO_LOCK)
248 tmp = ACTION_LATCH_TO_LOCK;
250 return false; /* WSGO! */
252 if (!ExprResolveBoolean(keymap->ctx, value, &result))
253 return ReportMismatch(keymap, action, field, "boolean");
258 *flags_inout &= ~tmp;
264 CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
265 const ExprDef *value, enum xkb_action_flags *flags_inout,
266 xkb_mod_mask_t *mods_rtrn)
268 if (value->op == EXPR_IDENT) {
270 valStr = xkb_atom_text(keymap->ctx, value->value.str);
271 if (valStr && (istreq(valStr, "usemodmapmods") ||
272 istreq(valStr, "modmapmods"))) {
275 *flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
280 if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
281 return ReportMismatch(keymap, action,
282 ACTION_FIELD_MODIFIERS, "modifier mask");
284 *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
289 HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
290 enum action_field field, const ExprDef *array_ndx,
291 const ExprDef *value)
293 struct xkb_mod_action *act = &action->mods;
294 enum xkb_action_flags rtrn, t1;
297 if (array_ndx != NULL) {
299 case ACTION_FIELD_CLEAR_LOCKS:
300 case ACTION_FIELD_LATCH_TO_LOCK:
301 case ACTION_FIELD_MODIFIERS:
302 return ReportActionNotArray(keymap, action->type, field);
309 case ACTION_FIELD_CLEAR_LOCKS:
310 case ACTION_FIELD_LATCH_TO_LOCK:
312 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
318 case ACTION_FIELD_MODIFIERS:
320 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
331 return ReportIllegal(keymap, action->type, field);
335 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
336 enum action_field field, const ExprDef *array_ndx,
337 const ExprDef *value)
339 struct xkb_mod_action *act = &action->mods;
340 enum xkb_action_flags t1;
343 if (array_ndx && field == ACTION_FIELD_MODIFIERS)
344 return ReportActionNotArray(keymap, action->type, field);
347 case ACTION_FIELD_MODIFIERS:
349 if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
360 return ReportIllegal(keymap, action->type, field);
364 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
365 const ExprDef *value, enum xkb_action_flags *flags_inout,
366 xkb_layout_index_t *grp_rtrn)
370 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
371 *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
372 spec = value->value.child;
375 *flags_inout |= ACTION_ABSOLUTE_SWITCH;
379 if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
380 return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
381 "integer (range 1..8)");
383 if (value->op == EXPR_NEGATE)
384 *grp_rtrn = -*grp_rtrn;
385 else if (value->op != EXPR_UNARY_PLUS)
392 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
393 enum action_field field, const ExprDef *array_ndx,
394 const ExprDef *value)
396 struct xkb_group_action *act = &action->group;
397 enum xkb_action_flags rtrn, t1;
398 xkb_layout_index_t t2;
400 if (array_ndx != NULL) {
402 case ACTION_FIELD_CLEAR_LOCKS:
403 case ACTION_FIELD_LATCH_TO_LOCK:
404 case ACTION_FIELD_GROUP:
405 return ReportActionNotArray(keymap, action->type, field);
413 case ACTION_FIELD_CLEAR_LOCKS:
414 case ACTION_FIELD_LATCH_TO_LOCK:
416 if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
422 case ACTION_FIELD_GROUP:
424 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
435 return ReportIllegal(keymap, action->type, field);
439 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
440 enum action_field field, const ExprDef *array_ndx,
441 const ExprDef *value)
443 struct xkb_group_action *act = &action->group;
444 enum xkb_action_flags t1;
445 xkb_layout_index_t t2;
447 if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
448 return ReportActionNotArray(keymap, action->type, field);
449 if (field == ACTION_FIELD_GROUP) {
451 if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
458 return ReportIllegal(keymap, action->type, field);
462 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
463 enum action_field field, const ExprDef *array_ndx,
464 const ExprDef *value)
466 struct xkb_pointer_action *act = &action->ptr;
469 if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
470 return ReportActionNotArray(keymap, action->type, field);
472 if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
475 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
480 if (!ExprResolveInteger(keymap->ctx, value, &val))
481 return ReportMismatch(keymap, action->type, field, "integer");
483 if (field == ACTION_FIELD_X) {
485 act->flags |= ACTION_ABSOLUTE_X;
490 act->flags |= ACTION_ABSOLUTE_Y;
496 else if (field == ACTION_FIELD_ACCEL) {
499 if (!ExprResolveBoolean(keymap->ctx, value, &set))
500 return ReportMismatch(keymap, action->type, field, "boolean");
503 act->flags &= ~ACTION_NO_ACCEL;
505 act->flags |= ACTION_NO_ACCEL;
508 return ReportIllegal(keymap, action->type, field);
511 static const LookupEntry lockWhich[] = {
513 { "lock", ACTION_LOCK_NO_UNLOCK },
514 { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
515 { "unlock", ACTION_LOCK_NO_LOCK },
520 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
521 enum action_field field, const ExprDef *array_ndx,
522 const ExprDef *value)
524 struct xkb_pointer_button_action *act = &action->btn;
526 if (field == ACTION_FIELD_BUTTON) {
530 return ReportActionNotArray(keymap, action->type, field);
532 if (!ExprResolveButton(keymap->ctx, value, &btn))
533 return ReportMismatch(keymap, action->type, field,
534 "integer (range 1..5)");
536 if (btn < 0 || btn > 5) {
538 "Button must specify default or be in the range 1..5; "
539 "Illegal button value %d ignored\n", btn);
546 else if (action->type == ACTION_TYPE_PTR_LOCK &&
547 field == ACTION_FIELD_AFFECT) {
548 enum xkb_action_flags val;
551 return ReportActionNotArray(keymap, action->type, field);
553 if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
554 return ReportMismatch(keymap, action->type, field,
557 act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
561 else if (field == ACTION_FIELD_COUNT) {
565 return ReportActionNotArray(keymap, action->type, field);
567 /* XXX: Should this actually be ResolveButton? */
568 if (!ExprResolveButton(keymap->ctx, value, &btn))
569 return ReportMismatch(keymap, action->type, field, "integer");
571 if (btn < 0 || btn > 255) {
573 "The count field must have a value in the range 0..255; "
574 "Illegal count %d ignored\n", btn);
581 return ReportIllegal(keymap, action->type, field);
584 static const LookupEntry ptrDflts[] = {
586 { "defaultbutton", 1 },
592 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
593 enum action_field field, const ExprDef *array_ndx,
594 const ExprDef *value)
596 struct xkb_pointer_default_action *act = &action->dflt;
598 if (field == ACTION_FIELD_AFFECT) {
602 return ReportActionNotArray(keymap, action->type, field);
604 if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
605 return ReportMismatch(keymap, action->type, field,
606 "pointer component");
609 else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
610 const ExprDef *button;
614 return ReportActionNotArray(keymap, action->type, field);
616 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
617 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
618 button = value->value.child;
621 act->flags |= ACTION_ABSOLUTE_SWITCH;
625 if (!ExprResolveButton(keymap->ctx, button, &btn))
626 return ReportMismatch(keymap, action->type, field,
627 "integer (range 1..5)");
629 if (btn < 0 || btn > 5) {
631 "New default button value must be in the range 1..5; "
632 "Illegal default button value %d ignored\n", btn);
637 "Cannot set default pointer button to \"default\"; "
638 "Illegal default button setting ignored\n");
642 act->value = (value->op == EXPR_NEGATE ? -btn: btn);
646 return ReportIllegal(keymap, action->type, field);
650 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
651 enum action_field field, const ExprDef *array_ndx,
652 const ExprDef *value)
654 struct xkb_switch_screen_action *act = &action->screen;
656 if (field == ACTION_FIELD_SCREEN) {
661 return ReportActionNotArray(keymap, action->type, field);
663 if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
664 act->flags &= ~ACTION_ABSOLUTE_SWITCH;
665 scrn = value->value.child;
668 act->flags |= ACTION_ABSOLUTE_SWITCH;
672 if (!ExprResolveInteger(keymap->ctx, scrn, &val))
673 return ReportMismatch(keymap, action->type, field,
676 if (val < 0 || val > 255) {
678 "Screen index must be in the range 1..255; "
679 "Illegal screen value %d ignored\n", val);
683 act->screen = (value->op == EXPR_NEGATE ? -val : val);
686 else if (field == ACTION_FIELD_SAME) {
690 return ReportActionNotArray(keymap, action->type, field);
692 if (!ExprResolveBoolean(keymap->ctx, value, &set))
693 return ReportMismatch(keymap, action->type, field, "boolean");
696 act->flags &= ~ACTION_SAME_SCREEN;
698 act->flags |= ACTION_SAME_SCREEN;
703 return ReportIllegal(keymap, action->type, field);
707 HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
708 enum action_field field, const ExprDef *array_ndx,
709 const ExprDef *value)
711 struct xkb_controls_action *act = &action->ctrls;
713 if (field == ACTION_FIELD_CONTROLS) {
717 return ReportActionNotArray(keymap, action->type, field);
719 if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
720 return ReportMismatch(keymap, action->type, field,
727 return ReportIllegal(keymap, action->type, field);
731 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
732 enum action_field field, const ExprDef *array_ndx,
733 const ExprDef *value)
735 struct xkb_private_action *act = &action->priv;
737 if (field == ACTION_FIELD_TYPE) {
740 if (!ExprResolveInteger(keymap->ctx, value, &type))
741 return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
743 if (type < 0 || type > 255) {
745 "Private action type must be in the range 0..255; "
746 "Illegal type %d ignored\n", type);
751 * It's possible for someone to write something like this:
752 * actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
753 * where the type refers to some existing action type, e.g. LockMods.
754 * This assumes that this action's struct is laid out in memory
755 * exactly as described in the XKB specification and libraries.
756 * We, however, have changed these structs in various ways, so this
757 * assumption is no longer true. Since this is a lousy "feature", we
758 * make actions like these no-ops for now.
760 if (type < ACTION_TYPE_PRIVATE) {
761 log_info(keymap->ctx,
762 "Private actions of type %s are not supported; Ignored\n",
763 ActionTypeText(type));
764 act->type = ACTION_TYPE_NONE;
767 act->type = (enum xkb_action_type) type;
772 else if (field == ACTION_FIELD_DATA) {
773 if (array_ndx == NULL) {
778 if (!ExprResolveString(keymap->ctx, value, &val))
779 return ReportMismatch(keymap, action->type, field, "string");
781 str = xkb_atom_text(keymap->ctx, val);
783 if (len < 1 || len > 7) {
784 log_warn(keymap->ctx,
785 "A private action has 7 data bytes; "
786 "Extra %d bytes ignored\n", len - 6);
790 strncpy((char *) act->data, str, sizeof(act->data));
796 if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
798 "Array subscript must be integer; "
799 "Illegal subscript ignored\n");
803 if (ndx < 0 || ndx >= sizeof(act->data)) {
805 "The data for a private action is %lu bytes long; "
806 "Attempt to use data[%d] ignored\n",
807 (unsigned long) sizeof(act->data), ndx);
811 if (!ExprResolveInteger(keymap->ctx, value, &datum))
812 return ReportMismatch(keymap, act->type, field, "integer");
814 if (datum < 0 || datum > 255) {
816 "All data for a private action must be 0..255; "
817 "Illegal datum %d ignored\n", datum);
821 act->data[ndx] = (uint8_t) datum;
826 return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
829 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
830 union xkb_action *action,
831 enum action_field field,
832 const ExprDef *array_ndx,
833 const ExprDef *value);
835 static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = {
836 [ACTION_TYPE_NONE] = HandleNoAction,
837 [ACTION_TYPE_MOD_SET] = HandleSetLatchMods,
838 [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods,
839 [ACTION_TYPE_MOD_LOCK] = HandleLockMods,
840 [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup,
841 [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup,
842 [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup,
843 [ACTION_TYPE_PTR_MOVE] = HandleMovePtr,
844 [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn,
845 [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn,
846 [ACTION_TYPE_PTR_DEFAULT] = HandleSetPtrDflt,
847 [ACTION_TYPE_TERMINATE] = HandleNoAction,
848 [ACTION_TYPE_SWITCH_VT] = HandleSwitchScreen,
849 [ACTION_TYPE_CTRL_SET] = HandleSetLockControls,
850 [ACTION_TYPE_CTRL_LOCK] = HandleSetLockControls,
851 [ACTION_TYPE_PRIVATE] = HandlePrivate,
854 /***====================================================================***/
857 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
858 union xkb_action *action, ActionsInfo *info)
862 unsigned handler_type;
864 if (def->op != EXPR_ACTION_DECL) {
865 log_err(keymap->ctx, "Expected an action definition, found %s\n",
866 expr_op_type_to_string(def->op));
870 str = xkb_atom_text(keymap->ctx, def->value.action.name);
871 if (!stringToAction(str, &handler_type)) {
872 log_err(keymap->ctx, "Unknown action %s\n", str);
877 * Get the default values for this action type, as modified by
878 * statements such as:
879 * latchMods.clearLocks = True;
881 *action = info->actions[handler_type];
884 * Now change the action properties as specified for this
885 * particular instance, e.g. "modifiers" and "clearLocks" in:
886 * SetMods(modifiers=Alt,clearLocks);
888 for (arg = def->value.action.args; arg != NULL;
889 arg = (ExprDef *) arg->common.next) {
890 const ExprDef *value;
891 ExprDef *field, *arrayRtrn;
892 const char *elemRtrn, *fieldRtrn;
893 enum action_field fieldNdx;
895 if (arg->op == EXPR_ASSIGN) {
896 field = arg->value.binary.left;
897 value = arg->value.binary.right;
899 else if (arg->op == EXPR_NOT || arg->op == EXPR_INVERT) {
900 field = arg->value.child;
908 if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
914 "Cannot change defaults in an action definition; "
915 "Ignoring attempt to change %s.%s\n",
916 elemRtrn, fieldRtrn);
920 if (!stringToField(fieldRtrn, &fieldNdx)) {
921 log_err(keymap->ctx, "Unknown field name %s\n", fieldRtrn);
925 if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn,
935 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
936 ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)
939 enum action_field action_field;
941 if (!stringToAction(elem, &action))
944 if (!stringToField(field, &action_field)) {
945 log_err(keymap->ctx, "\"%s\" is not a legal field name\n", field);
949 return handleAction[action](keymap, &info->actions[action],
950 action_field, array_ndx, value);